import"./color-convert-d47c3cb3.js";import"./vanilla-colorful-3f59310b.js";import{i as Oe,a as eo,b as Ce,c as bs,d as qt,e as to,f as $a,u as Od,g as On,m as qa,s as Dd,h as ja,j as Dn,k as Nd,l as vt,n as mn,o as no,t as Jn,p as Bd,q as Gt,r as Fd}from"./lodash-es-9851428c.js";/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ld(){try{return navigator.userAgent.toLowerCase()}catch{return""}}const ct=Ld(),zd={isMac:Ka(ct),isWindows:Hd(ct),isGecko:Wd(ct),isSafari:Ud(ct),isiOS:$d(ct),isAndroid:qd(ct),isBlink:jd(ct),features:{isRegExpUnicodePropertySupported:Kd()}},P=zd;function Ka(s){return s.indexOf("macintosh")>-1}function Hd(s){return s.indexOf("windows")>-1}function Wd(s){return!!s.match(/gecko\/\d+/)}function Ud(s){return s.indexOf(" applewebkit/")>-1&&s.indexOf("chrome")===-1}function $d(s){return!!s.match(/iphone|ipad/i)||Ka(s)&&navigator.maxTouchPoints>0}function qd(s){return s.indexOf("android")>-1}function jd(s){return s.indexOf("chrome/")>-1&&s.indexOf("edge/")<0}function Kd(){let s=!1;try{s="ć".search(new RegExp("[\\p{L}]","u"))===0}catch{}return s}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ga(s,e,t,n){t=t||function(l,c){return l===c};const i=Array.isArray(s)?s:Array.prototype.slice.call(s),o=Array.isArray(e)?e:Array.prototype.slice.call(e),r=Gd(i,o,t);return n?Qd(r,o.length):Jd(o,r)}function Gd(s,e,t){const n=io(s,e,t);if(n===-1)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const i=so(s,n),o=so(e,n),r=io(i,o,t),a=s.length-r,l=e.length-r;return{firstIndex:n,lastIndexOld:a,lastIndexNew:l}}function io(s,e,t){for(let n=0;n<Math.max(s.length,e.length);n++)if(s[n]===void 0||e[n]===void 0||!t(s[n],e[n]))return n;return-1}function so(s,e){return s.slice(e).reverse()}function Jd(s,e){const t=[],{firstIndex:n,lastIndexOld:i,lastIndexNew:o}=e;return o-n>0&&t.push({index:n,type:"insert",values:s.slice(n,o)}),i-n>0&&t.push({index:n+(o-n),type:"delete",howMany:i-n}),t}function Qd(s,e){const{firstIndex:t,lastIndexOld:n,lastIndexNew:i}=s;if(t===-1)return Array(e).fill("equal");let o=[];return t>0&&(o=o.concat(Array(t).fill("equal"))),i-t>0&&(o=o.concat(Array(i-t).fill("insert"))),n-t>0&&(o=o.concat(Array(n-t).fill("delete"))),i<e&&(o=o.concat(Array(e-i).fill("equal"))),o}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function en(s,e,t){t=t||function(w,v){return w===v};const n=s.length,i=e.length;if(n>200||i>200||n+i>300)return en.fastDiff(s,e,t,!0);let o,r;if(i<n){const w=s;s=e,e=w,o="delete",r="insert"}else o="insert",r="delete";const a=s.length,l=e.length,c=l-a,d={},u={};function h(w){const v=(u[w-1]!==void 0?u[w-1]:-1)+1,C=u[w+1]!==void 0?u[w+1]:-1,k=v>C?-1:1;d[w+k]&&(d[w]=d[w+k].slice(0)),d[w]||(d[w]=[]),d[w].push(v>C?o:r);let N=Math.max(v,C),X=N-w;for(;X<a&&N<l&&t(s[X],e[N]);)X++,N++,d[w].push("equal");return N}let f=0,g;do{for(g=-f;g<c;g++)u[g]=h(g);for(g=c+f;g>c;g--)u[g]=h(g);u[c]=h(c),f++}while(u[c]!==l);return d[c].slice(1)}en.fastDiff=Ga;/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function oo(){return function s(){s.called=!0}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ke{constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=oo(),this.off=oo()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const ae=new Array(256).fill("").map((s,e)=>("0"+e.toString(16)).slice(-2));function De(){const s=Math.random()*4294967296>>>0,e=Math.random()*4294967296>>>0,t=Math.random()*4294967296>>>0,n=Math.random()*4294967296>>>0;return"e"+ae[s>>0&255]+ae[s>>8&255]+ae[s>>16&255]+ae[s>>24&255]+ae[e>>0&255]+ae[e>>8&255]+ae[e>>16&255]+ae[e>>24&255]+ae[t>>0&255]+ae[t>>8&255]+ae[t>>16&255]+ae[t>>24&255]+ae[n>>0&255]+ae[n>>8&255]+ae[n>>16&255]+ae[n>>24&255]}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Yd={get(s="normal"){return typeof s!="number"?this[s]||this.normal:s},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5},tt=Yd;/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ja(s,e){const t=tt.get(e.priority);for(let n=0;n<s.length;n++)if(tt.get(s[n].priority)<t){s.splice(n,0,e);return}s.push(e)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Zd="https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html";class m extends Error{constructor(e,t,n){super(Xd(e,n)),this.name="CKEditorError",this.context=t,this.data=n}is(e){return e==="CKEditorError"}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const n=new m(e.message,t);throw n.stack=e.stack,n}}function K(s,e){console.warn(...eu(s,e))}function Qa(s){return`
Read more: ${Zd}#error-${s}`}function Xd(s,e){const t=new WeakSet,i=e?` ${JSON.stringify(e,(r,a)=>{if(typeof a=="object"&&a!==null){if(t.has(a))return`[object ${a.constructor.name}]`;t.add(a)}return a})}`:"",o=Qa(s);return s+i+o}function eu(s,e){const t=Qa(s);return e?[s,e,t]:[s,t]}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const tu="38.0.1",nu=new Date(2023,4,23);/* istanbul ignore next -- @preserve */const ro=typeof window=="object"?window:global;/* istanbul ignore next -- @preserve */if(ro.CKEDITOR_VERSION)throw new m("ckeditor-duplicated-modules",null);ro.CKEDITOR_VERSION=tu;/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Vt=Symbol("listeningTo"),Bi=Symbol("emitterId"),ze=Symbol("delegations"),Ya=H(Object);function H(s){if(!s)return Ya;class e extends s{on(n,i,o){this.listenTo(this,n,i,o)}once(n,i,o){let r=!1;const a=(l,...c)=>{r||(r=!0,l.off(),i.call(this,l,...c))};this.listenTo(this,n,a,o)}off(n,i){this.stopListening(this,n,i)}listenTo(n,i,o,r={}){let a,l;this[Vt]||(this[Vt]={});const c=this[Vt];ai(n)||Za(n);const d=ai(n);(a=c[d])||(a=c[d]={emitter:n,callbacks:{}}),(l=a.callbacks[i])||(l=a.callbacks[i]=[]),l.push(o),ru(this,n,i,o,r)}stopListening(n,i,o){const r=this[Vt];let a=n&&ai(n);const l=r&&a?r[a]:void 0,c=l&&i?l.callbacks[i]:void 0;if(!(!r||n&&!l||i&&!c))if(o)li(this,n,i,o),c.indexOf(o)!==-1&&(c.length===1?delete l.callbacks[i]:li(this,n,i,o));else if(c){for(;o=c.pop();)li(this,n,i,o);delete l.callbacks[i]}else if(l){for(i in l.callbacks)this.stopListening(n,i);delete r[a]}else{for(a in r)this.stopListening(r[a].emitter);delete this[Vt]}}fire(n,...i){try{const o=n instanceof Ke?n:new Ke(this,n),r=o.name;let a=el(this,r);if(o.path.push(this),a){const c=[o,...i];a=Array.from(a);for(let d=0;d<a.length&&(a[d].callback.apply(this,c),o.off.called&&(delete o.off.called,this._removeEventListener(r,a[d].callback)),!o.stop.called);d++);}const l=this[ze];if(l){const c=l.get(r),d=l.get("*");c&&ao(c,o,i),d&&ao(d,o,i)}return o.return}catch(o){/* istanbul ignore next -- @preserve */m.rethrowUnexpectedError(o,this)}}delegate(...n){return{to:(i,o)=>{this[ze]||(this[ze]=new Map),n.forEach(r=>{const a=this[ze].get(r);a?a.set(i,o):this[ze].set(r,new Map([[i,o]]))})}}}stopDelegating(n,i){if(this[ze])if(!n)this[ze].clear();else if(!i)this[ze].delete(n);else{const o=this[ze].get(n);o&&o.delete(i)}}_addEventListener(n,i,o){ou(this,n);const r=Fi(this,n),a=tt.get(o.priority),l={callback:i,priority:a};for(const c of r)Ja(c,l)}_removeEventListener(n,i){const o=Fi(this,n);for(const r of o)for(let a=0;a<r.length;a++)r[a].callback==i&&(r.splice(a,1),a--)}}return e}["on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(s=>{H[s]=Ya.prototype[s]});function iu(s,e){const t=s[Vt];return t&&t[e]?t[e].emitter:null}function Za(s,e){s[Bi]||(s[Bi]=e||De())}function ai(s){return s[Bi]}function Xa(s){return s._events||Object.defineProperty(s,"_events",{value:{}}),s._events}function su(){return{callbacks:[],childEvents:[]}}function ou(s,e){const t=Xa(s);if(t[e])return;let n=e,i=null;const o=[];for(;n!==""&&!t[n];)t[n]=su(),o.push(t[n]),i&&t[n].childEvents.push(i),i=n,n=n.substr(0,n.lastIndexOf(":"));if(n!==""){for(const r of o)r.callbacks=t[n].callbacks.slice();t[n].childEvents.push(i)}}function Fi(s,e){const t=Xa(s)[e];if(!t)return[];let n=[t.callbacks];for(let i=0;i<t.childEvents.length;i++){const o=Fi(s,t.childEvents[i]);n=n.concat(o)}return n}function el(s,e){let t;return!s._events||!(t=s._events[e])||!t.callbacks.length?e.indexOf(":")>-1?el(s,e.substr(0,e.lastIndexOf(":"))):null:t.callbacks}function ao(s,e,t){for(let[n,i]of s){i?typeof i=="function"&&(i=i(e.name)):i=e.name;const o=new Ke(e.source,i);o.path=[...e.path],n.fire(o,...t)}}function ru(s,e,t,n,i){e._addEventListener?e._addEventListener(t,n,i):s._addEventListener.call(e,t,n,i)}function li(s,e,t,n){e._removeEventListener?e._removeEventListener(t,n):s._removeEventListener.call(e,t,n)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Nn=Symbol("observableProperties"),Qn=Symbol("boundObservables"),Bn=Symbol("boundProperties"),At=Symbol("decoratedMethods"),lo=Symbol("decoratedOriginal"),tl=D(H());function D(s){if(!s)return tl;class e extends s{set(n,i){if(Oe(n)){Object.keys(n).forEach(r=>{this.set(r,n[r])},this);return}ci(this);const o=this[Nn];if(n in this&&!o.has(n))throw new m("observable-set-cannot-override",this);Object.defineProperty(this,n,{enumerable:!0,configurable:!0,get(){return o.get(n)},set(r){const a=o.get(n);let l=this.fire(`set:${n}`,n,r,a);l===void 0&&(l=r),(a!==l||!o.has(n))&&(o.set(n,l),this.fire(`change:${n}`,n,l,a))}}),this[n]=i}bind(...n){if(!n.length||!co(n))throw new m("observable-bind-wrong-properties",this);if(new Set(n).size!==n.length)throw new m("observable-bind-duplicate-properties",this);ci(this);const i=this[Bn];n.forEach(r=>{if(i.has(r))throw new m("observable-bind-rebind",this)});const o=new Map;return n.forEach(r=>{const a={property:r,to:[]};i.set(r,a),o.set(r,a)}),{to:au,toMany:lu,_observable:this,_bindProperties:n,_to:[],_bindings:o}}unbind(...n){if(!this[Nn])return;const i=this[Bn],o=this[Qn];if(n.length){if(!co(n))throw new m("observable-unbind-wrong-properties",this);n.forEach(r=>{const a=i.get(r);a&&(a.to.forEach(([l,c])=>{const d=o.get(l),u=d[c];u.delete(a),u.size||delete d[c],Object.keys(d).length||(o.delete(l),this.stopListening(l,"change"))}),i.delete(r))})}else o.forEach((r,a)=>{this.stopListening(a,"change")}),o.clear(),i.clear()}decorate(n){ci(this);const i=this[n];if(!i)throw new m("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:n});this.on(n,(o,r)=>{o.return=i.apply(this,r)}),this[n]=function(...o){return this.fire(n,o)},this[n][lo]=i,this[At]||(this[At]=[]),this[At].push(n)}stopListening(n,i,o){if(!n&&this[At]){for(const r of this[At])this[r]=this[r][lo];delete this[At]}super.stopListening(n,i,o)}}return e}["set","bind","unbind","decorate","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(s=>{D[s]=tl.prototype[s]});function ci(s){s[Nn]||(Object.defineProperty(s,Nn,{value:new Map}),Object.defineProperty(s,Qn,{value:new Map}),Object.defineProperty(s,Bn,{value:new Map}))}function au(...s){const e=du(...s),t=Array.from(this._bindings.keys()),n=t.length;if(!e.callback&&e.to.length>1)throw new m("observable-bind-to-no-callback",this);if(n>1&&e.callback)throw new m("observable-bind-to-extra-callback",this);e.to.forEach(i=>{if(i.properties.length&&i.properties.length!==n)throw new m("observable-bind-to-properties-length",this);i.properties.length||(i.properties=this._bindProperties)}),this._to=e.to,e.callback&&(this._bindings.get(t[0]).callback=e.callback),fu(this._observable,this._to),hu(this),this._bindProperties.forEach(i=>{nl(this._observable,i)})}function lu(s,e,t){if(this._bindings.size>1)throw new m("observable-bind-to-many-not-one-binding",this);this.to(...cu(s,e),t)}function cu(s,e){const t=s.map(n=>[n,e]);return Array.prototype.concat.apply([],t)}function co(s){return s.every(e=>typeof e=="string")}function du(...s){if(!s.length)throw new m("observable-bind-to-parse-error",null);const e={to:[]};let t;return typeof s[s.length-1]=="function"&&(e.callback=s.pop()),s.forEach(n=>{if(typeof n=="string")t.properties.push(n);else if(typeof n=="object")t={observable:n,properties:[]},e.to.push(t);else throw new m("observable-bind-to-parse-error",null)}),e}function uu(s,e,t,n){const i=s[Qn],o=i.get(t),r=o||{};r[n]||(r[n]=new Set),r[n].add(e),o||i.set(t,r)}function hu(s){let e;s._bindings.forEach((t,n)=>{s._to.forEach(i=>{e=i.properties[t.callback?0:s._bindProperties.indexOf(n)],t.to.push([i.observable,e]),uu(s._observable,t,i.observable,e)})})}function nl(s,e){const n=s[Bn].get(e);let i;n.callback?i=n.callback.apply(s,n.to.map(o=>o[0][o[1]])):(i=n.to[0],i=i[0][i[1]]),Object.prototype.hasOwnProperty.call(s,e)?s[e]=i:s.set(e,i)}function fu(s,e){e.forEach(t=>{const n=s[Qn];let i;n.get(t.observable)||s.listenTo(t.observable,"change",(o,r)=>{i=n.get(t.observable)[r],i&&i.forEach(a=>{nl(s,a.property)})})})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class mu{constructor(){this._replacedElements=[]}replace(e,t){this._replacedElements.push({element:e,newElement:t}),e.style.display="none",t&&e.parentNode.insertBefore(t,e.nextSibling)}restore(){this._replacedElements.forEach(({element:e,newElement:t})=>{e.style.display="",t&&t.remove()}),this._replacedElements=[]}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Li(s){let e=0;for(const t of s)e++;return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function le(s,e){const t=Math.min(s.length,e.length);for(let n=0;n<t;n++)if(s[n]!=e[n])return n;return s.length==e.length?"same":s.length<e.length?"prefix":"extension"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function pe(s){return!!(s&&s[Symbol.iterator])}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function zi(s,e,t={},n=[]){const i=t&&t.xmlns,o=i?s.createElementNS(i,e):s.createElement(e);for(const r in t)o.setAttribute(r,t[r]);(eo(n)||!pe(n))&&(n=[n]);for(let r of n)eo(r)&&(r=s.createTextNode(r)),o.appendChild(r);return o}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class il{constructor(e,t){this._config={},t&&this.define(uo(t)),e&&this._setObjectToTarget(this._config,e)}set(e,t){this._setToTarget(this._config,e,t)}define(e,t){this._setToTarget(this._config,e,t,!0)}get(e){return this._getFromSource(this._config,e)}*names(){for(const e of Object.keys(this._config))yield e}_setToTarget(e,t,n,i=!1){if(Ce(t)){this._setObjectToTarget(e,t,i);return}const o=t.split(".");t=o.pop();for(const r of o)Ce(e[r])||(e[r]={}),e=e[r];if(Ce(n)){Ce(e[t])||(e[t]={}),e=e[t],this._setObjectToTarget(e,n,i);return}i&&typeof e[t]<"u"||(e[t]=n)}_getFromSource(e,t){const n=t.split(".");t=n.pop();for(const i of n){if(!Ce(e[i])){e=null;break}e=e[i]}return e?uo(e[t]):void 0}_setObjectToTarget(e,t,n){Object.keys(t).forEach(i=>{this._setToTarget(e,i,t[i],n)})}}function uo(s){return bs(s,gu)}function gu(s){return qt(s)?s:void 0}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function nt(s){if(s){if(s.defaultView)return s instanceof s.defaultView.Document;if(s.ownerDocument&&s.ownerDocument.defaultView)return s instanceof s.ownerDocument.defaultView.Node}return!1}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Fn(s){const e=Object.prototype.toString.apply(s);return e=="[object Window]"||e=="[object global]"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const sl=Qe(H());function Qe(s){if(!s)return sl;class e extends s{listenTo(n,i,o,r={}){if(nt(n)||Fn(n)){const a={capture:!!r.useCapture,passive:!!r.usePassive},l=this._getProxyEmitter(n,a)||new pu(n,a);this.listenTo(l,i,o,r)}else super.listenTo(n,i,o,r)}stopListening(n,i,o){if(nt(n)||Fn(n)){const r=this._getAllProxyEmitters(n);for(const a of r)this.stopListening(a,i,o)}else super.stopListening(n,i,o)}_getProxyEmitter(n,i){return iu(this,ol(n,i))}_getAllProxyEmitters(n){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map(i=>this._getProxyEmitter(n,i)).filter(i=>!!i)}}return e}["_getProxyEmitter","_getAllProxyEmitters","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(s=>{Qe[s]=sl.prototype[s]});class pu extends H(){constructor(e,t){super(),Za(this,ol(e,t)),this._domNode=e,this._options=t}attach(e){if(this._domListeners&&this._domListeners[e])return;const t=this._createDomListener(e);this._domNode.addEventListener(e,t,this._options),this._domListeners||(this._domListeners={}),this._domListeners[e]=t}detach(e){let t;this._domListeners[e]&&(!(t=this._events[e])||!t.callbacks.length)&&this._domListeners[e].removeListener()}_addEventListener(e,t,n){this.attach(e),H().prototype._addEventListener.call(this,e,t,n)}_removeEventListener(e,t){H().prototype._removeEventListener.call(this,e,t),this.detach(e)}_createDomListener(e){const t=n=>{this.fire(e,n)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}}function wu(s){return s["data-ck-expando"]||(s["data-ck-expando"]=De())}function ol(s,e){let t=wu(s);for(const n of Object.keys(e).sort())e[n]&&(t+="-"+n);return t}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let Hi;try{Hi={window,document}}catch{/* istanbul ignore next -- @preserve */Hi={window:{},document:{}}}const S=Hi;/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function bu(s){let e=s.parentElement;if(!e)return null;for(;e.tagName!="BODY";){const t=e.style.overflowY||S.window.getComputedStyle(e).overflowY;if(t==="auto"||t==="scroll")break;if(e=e.parentElement,!e)return null}return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function rl(s){const e=[];let t=s;for(;t&&t.nodeType!=Node.DOCUMENT_NODE;)e.unshift(t),t=t.parentNode;return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function _u(s){return s instanceof HTMLTextAreaElement?s.value:s.innerHTML}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function J(s){return Object.prototype.toString.call(s)=="[object Text]"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Yn(s){return Object.prototype.toString.apply(s)=="[object Range]"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function al(s){const e=s.ownerDocument.defaultView.getComputedStyle(s);return{top:parseInt(e.borderTopWidth,10),right:parseInt(e.borderRightWidth,10),bottom:parseInt(e.borderBottomWidth,10),left:parseInt(e.borderLeftWidth,10)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const ll=["top","right","bottom","left","width","height"];class L{constructor(e){const t=Yn(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),cl(e)||t)if(t){const n=L.getDomRangeRects(e);gn(this,L.getBoundingRect(n))}else gn(this,e.getBoundingClientRect());else if(Fn(e)){const{innerWidth:n,innerHeight:i}=e;gn(this,{top:0,right:n,bottom:i,left:0,width:n,height:i})}else gn(this,e)}clone(){return new L(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left),width:0,height:0};return t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0?null:new L(t)}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(!ho(e)){let n=e.parentNode||e.commonAncestorContainer;for(;n&&!ho(n);){const i=new L(n),o=t.getIntersection(i);if(o)o.getArea()<t.getArea()&&(t=o);else return null;n=n.parentNode}}return t}isEqual(e){for(const t of ll)if(this[t]!==e[t])return!1;return!0}contains(e){const t=this.getIntersection(e);return!!(t&&t.isEqual(e))}excludeScrollbarsAndBorders(){const e=this._source;let t,n,i;if(Fn(e))t=e.innerWidth-e.document.documentElement.clientWidth,n=e.innerHeight-e.document.documentElement.clientHeight,i=e.getComputedStyle(e.document.documentElement).direction;else{const o=al(e);t=e.offsetWidth-e.clientWidth-o.left-o.right,n=e.offsetHeight-e.clientHeight-o.top-o.bottom,i=e.ownerDocument.defaultView.getComputedStyle(e).direction,this.left+=o.left,this.top+=o.top,this.right-=o.right,this.bottom-=o.bottom,this.width=this.right-this.left,this.height=this.bottom-this.top}return this.width-=t,i==="ltr"?this.right-=t:this.left+=t,this.height-=n,this.bottom-=n,this}static getDomRangeRects(e){const t=[],n=Array.from(e.getClientRects());if(n.length)for(const i of n)t.push(new L(i));else{let i=e.startContainer;J(i)&&(i=i.parentNode);const o=new L(i.getBoundingClientRect());o.right=o.left,o.width=0,t.push(o)}return t}static getBoundingRect(e){const t={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:0,height:0};let n=0;for(const i of e)n++,t.left=Math.min(t.left,i.left),t.top=Math.min(t.top,i.top),t.right=Math.max(t.right,i.right),t.bottom=Math.max(t.bottom,i.bottom);return n==0?null:(t.width=t.right-t.left,t.height=t.bottom-t.top,new L(t))}}function gn(s,e){for(const t of ll)s[t]=e[t]}function ho(s){return cl(s)?s===s.ownerDocument.body:!1}function cl(s){return s!==null&&typeof s=="object"&&s.nodeType===1&&typeof s.getBoundingClientRect=="function"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class U{constructor(e,t){U._observerInstance||U._createObserver(),this._element=e,this._callback=t,U._addElementCallback(e,t),U._observerInstance.observe(e)}destroy(){U._deleteElementCallback(this._element,this._callback)}static _addElementCallback(e,t){U._elementCallbacks||(U._elementCallbacks=new Map);let n=U._elementCallbacks.get(e);n||(n=new Set,U._elementCallbacks.set(e,n)),n.add(t)}static _deleteElementCallback(e,t){const n=U._getElementCallbacks(e);n&&(n.delete(t),n.size||(U._elementCallbacks.delete(e),U._observerInstance.unobserve(e))),U._elementCallbacks&&!U._elementCallbacks.size&&(U._observerInstance=null,U._elementCallbacks=null)}static _getElementCallbacks(e){return U._elementCallbacks?U._elementCallbacks.get(e):null}static _createObserver(){U._observerInstance=new S.window.ResizeObserver(e=>{for(const t of e){const n=U._getElementCallbacks(t.target);if(n)for(const i of n)i(t)}})}}U._observerInstance=null;U._elementCallbacks=null;/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function fo(s,e){s instanceof HTMLTextAreaElement&&(s.value=e),s.innerHTML=e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function dl(s){return e=>e+s}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function pn(s){let e=0;for(;s.previousSibling;)s=s.previousSibling,e++;return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ul(s,e,t){s.insertBefore(t,s.childNodes[e]||null)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Bt(s){return s&&s.nodeType===Node.COMMENT_NODE}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function vu(s){try{S.document.createAttribute(s)}catch{return!1}return!0}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function _t(s){return!!(s&&s.getClientRects&&s.getClientRects().length)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function yu(s){return!s||!s.parentNode||s.offsetParent===S.document.body?null:s.offsetParent}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function hl({element:s,target:e,positions:t,limiter:n,fitInViewport:i,viewportOffsetConfig:o}){to(e)&&(e=e()),to(n)&&(n=n());const r=yu(s),a=new L(s),l=new L(e);let c;const d=i&&Cu(o)||null,u={targetRect:l,elementRect:a,positionedElementAncestor:r,viewportRect:d};if(!n&&!i)c=new Wi(t[0],u);else{const h=n&&new L(n).getVisible();Object.assign(u,{limiterRect:h,viewportRect:d}),c=ku(t,u)||new Wi(t[0],u)}return c}function Cu(s){s=Object.assign({top:0,bottom:0,left:0,right:0},s);const e=new L(S.window);return e.top+=s.top,e.height-=s.top,e.bottom-=s.bottom,e.height-=s.bottom,e}function ku(s,e){const{elementRect:t}=e,n=t.getArea(),i=s.map(a=>new Wi(a,e)).filter(a=>!!a.name);let o=0,r=null;for(const a of i){const{limiterIntersectionArea:l,viewportIntersectionArea:c}=a;if(l===n)return a;const d=c**2+l**2;d>o&&(o=d,r=a)}return r}function Eu(s,e){const t=fl(new L(e)),n=al(e);let i=0,o=0;i-=t.left,o-=t.top,i+=e.scrollLeft,o+=e.scrollTop,i-=n.left,o-=n.top,s.moveBy(i,o)}function fl(s){const{scrollX:e,scrollY:t}=S.window;return s.clone().moveBy(e,t)}class Wi{constructor(e,t){const n=e(t.targetRect,t.elementRect,t.viewportRect);if(!n)return;const{left:i,top:o,name:r,config:a}=n;this.name=r,this.config=a,this._positioningFunctionCorrdinates={left:i,top:o},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;if(e){const t=this._options.viewportRect;if(t){const n=e.getIntersection(t);if(n)return n.getIntersectionArea(this._rect)}else return e.getIntersectionArea(this._rect)}return 0}get viewportIntersectionArea(){const e=this._options.viewportRect;return e?e.getIntersectionArea(this._rect):0}get _rect(){return this._cachedRect?this._cachedRect:(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCorrdinates.left,this._positioningFunctionCorrdinates.top),this._cachedRect)}get _absoluteRect(){return this._cachedAbsoluteRect?this._cachedAbsoluteRect:(this._cachedAbsoluteRect=fl(this._rect),this._options.positionedElementAncestor&&Eu(this._cachedAbsoluteRect,this._options.positionedElementAncestor),this._cachedAbsoluteRect)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function mo(s){const e=s.parentNode;e&&e.removeChild(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Tu({target:s,viewportOffset:e=0,ancestorOffset:t=0,alignToTop:n,forceScroll:i}){const o=_s(s);let r=o,a=null;for(;r;){let l;r==o?l=go(s):l=go(a),Su({parent:l,getRect:()=>po(s,r),alignToTop:n,ancestorOffset:t,forceScroll:i});const c=po(s,r);if(Au({window:r,rect:c,viewportOffset:e,alignToTop:n,forceScroll:i}),r.parent!=r){if(a=r.frameElement,r=r.parent,!a)return}else r=null}}function Au({window:s,rect:e,alignToTop:t,forceScroll:n,viewportOffset:i}){const o=e.clone().moveBy(0,i),r=e.clone().moveBy(0,-i),a=new L(s).excludeScrollbarsAndBorders(),l=[r,o],c=t&&n,d=l.every(w=>a.contains(w));let{scrollX:u,scrollY:h}=s;const f=u,g=h;c?h-=a.top-e.top+i:d||(gl(r,a)?h-=a.top-e.top+i:ml(o,a)&&(t?h+=e.top-a.top-i:h+=e.bottom-a.bottom+i)),d||(pl(e,a)?u-=a.left-e.left+i:wl(e,a)&&(u+=e.right-a.right+i)),(u!=f||h!==g)&&s.scrollTo(u,h)}function Su({parent:s,getRect:e,alignToTop:t,forceScroll:n,ancestorOffset:i=0}){const o=_s(s),r=t&&n;let a,l,c;for(;s!=o.document.body;)l=e(),a=new L(s).excludeScrollbarsAndBorders(),c=a.contains(l),r?s.scrollTop-=a.top-l.top+i:c||(gl(l,a)?s.scrollTop-=a.top-l.top+i:ml(l,a)&&(t?s.scrollTop+=l.top-a.top-i:s.scrollTop+=l.bottom-a.bottom+i)),c||(pl(l,a)?s.scrollLeft-=a.left-l.left+i:wl(l,a)&&(s.scrollLeft+=l.right-a.right+i)),s=s.parentNode}function ml(s,e){return s.bottom>e.bottom}function gl(s,e){return s.top<e.top}function pl(s,e){return s.left<e.left}function wl(s,e){return s.right>e.right}function _s(s){return Yn(s)?s.startContainer.ownerDocument.defaultView:s.ownerDocument.defaultView}function go(s){if(Yn(s)){let e=s.commonAncestorContainer;return J(e)&&(e=e.parentNode),e}else return s.parentNode}function po(s,e){const t=_s(s),n=new L(s);if(t===e)return n;{let i=t;for(;i!=e;){const o=i.frameElement,r=new L(o).excludeScrollbarsAndBorders();n.moveBy(r.left,r.top),i=i.parent}}return n}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Pu={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},xu={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},M=Ou(),Iu=Object.fromEntries(Object.entries(M).map(([s,e])=>[e,s.charAt(0).toUpperCase()+s.slice(1)]));function Lt(s){let e;if(typeof s=="string"){if(e=M[s.toLowerCase()],!e)throw new m("keyboard-unknown-key",null,{key:s})}else e=s.keyCode+(s.altKey?M.alt:0)+(s.ctrlKey?M.ctrl:0)+(s.shiftKey?M.shift:0)+(s.metaKey?M.cmd:0);return e}function vs(s){return typeof s=="string"&&(s=Du(s)),s.map(e=>typeof e=="string"?Mu(e):e).reduce((e,t)=>t+e,0)}function wo(s){let e=vs(s);return Object.entries(P.isMac?Pu:xu).reduce((i,[o,r])=>(e&M[o]&&(e&=~M[o],i+=r),i),"")+(e?Iu[e]:"")}function Ru(s){return s==M.arrowright||s==M.arrowleft||s==M.arrowup||s==M.arrowdown}function ys(s,e){const t=e==="ltr";switch(s){case M.arrowleft:return t?"left":"right";case M.arrowright:return t?"right":"left";case M.arrowup:return"up";case M.arrowdown:return"down"}}function Mu(s){if(s.endsWith("!"))return Lt(s.slice(0,-1));const e=Lt(s);return P.isMac&&e==M.ctrl?M.cmd:e}function Vu(s,e){const t=ys(s,e);return t==="down"||t==="right"}function Ou(){const s={arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let e=65;e<=90;e++){const t=String.fromCharCode(e);s[t.toLowerCase()]=e}for(let e=48;e<=57;e++)s[e-48]=e;for(let e=112;e<=123;e++)s["f"+(e-111)]=e;for(const e of"`-=[];',./\\")s[e]=e.charCodeAt(0);return s}function Du(s){return s.split("+").map(e=>e.trim())}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Nu=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function bo(s){return Nu.includes(s)?"rtl":"ltr"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function se(s){return Array.isArray(s)?s:[s]}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 *//* istanbul ignore else -- @preserve */S.window.CKEDITOR_TRANSLATIONS||(S.window.CKEDITOR_TRANSLATIONS={});function Bu(s,e,t=1){if(typeof t!="number")throw new m("translation-service-quantity-not-a-number",null,{quantity:t});const n=Lu();n===1&&(s=Object.keys(S.window.CKEDITOR_TRANSLATIONS)[0]);const i=e.id||e.string;if(n===0||!Fu(s,i))return t!==1?e.plural:e.string;const o=S.window.CKEDITOR_TRANSLATIONS[s].dictionary,r=S.window.CKEDITOR_TRANSLATIONS[s].getPluralForm||(c=>c===1?0:1),a=o[i];if(typeof a=="string")return a;const l=Number(r(t));return a[l]}function Fu(s,e){return!!S.window.CKEDITOR_TRANSLATIONS[s]&&!!S.window.CKEDITOR_TRANSLATIONS[s].dictionary[e]}function Lu(){return Object.keys(S.window.CKEDITOR_TRANSLATIONS).length}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zu{constructor({uiLanguage:e="en",contentLanguage:t}={}){this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=bo(this.uiLanguage),this.contentLanguageDirection=bo(this.contentLanguage),this.t=(n,i)=>this._t(n,i)}get language(){return console.warn("locale-deprecated-language-property: The Locale#language property has been deprecated and will be removed in the near future. Please use #uiLanguage and #contentLanguage properties instead."),this.uiLanguage}_t(e,t=[]){t=se(t),typeof e=="string"&&(e={string:e});const i=!!e.plural?t[0]:1,o=Bu(this.uiLanguage,e,i);return Hu(o,t)}}function Hu(s,e){return s.replace(/%(\d+)/g,(t,n)=>n<e.length?e[n]:t)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _e extends H(){constructor(e={},t={}){super();const n=pe(e);if(n||(t=e),this._items=[],this._itemMap=new Map,this._idProperty=t.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],n)for(const i of e)this._items.push(i),this._itemMap.set(this._getItemIdBeforeAdding(i),i)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(e,t){return this.addMany([e],t)}addMany(e,t){if(t===void 0)t=this._items.length;else if(t>this._items.length||t<0)throw new m("collection-add-item-invalid-index",this);let n=0;for(const i of e){const o=this._getItemIdBeforeAdding(i),r=t+n;this._items.splice(r,0,i),this._itemMap.set(o,i),this.fire("add",i,r),n++}return this.fire("change",{added:e,removed:[],index:t}),this}get(e){let t;if(typeof e=="string")t=this._itemMap.get(e);else if(typeof e=="number")t=this._items[e];else throw new m("collection-get-invalid-arg",this);return t||null}has(e){if(typeof e=="string")return this._itemMap.has(e);{const t=this._idProperty,n=e[t];return n&&this._itemMap.has(n)}}getIndex(e){let t;return typeof e=="string"?t=this._itemMap.get(e):t=e,t?this._items.indexOf(t):-1}remove(e){const[t,n]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:n}),t}map(e,t){return this._items.map(e,t)}find(e,t){return this._items.find(e,t)}filter(e,t){return this._items.filter(e,t)}clear(){this._bindToCollection&&(this.stopListening(this._bindToCollection),this._bindToCollection=null);const e=Array.from(this._items);for(;this.length;)this._remove(0);this.fire("change",{added:[],removed:e,index:0})}bindTo(e){if(this._bindToCollection)throw new m("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:t=>{this._setUpBindToBinding(n=>new t(n))},using:t=>{typeof t=="function"?this._setUpBindToBinding(t):this._setUpBindToBinding(n=>n[t])}}}_setUpBindToBinding(e){const t=this._bindToCollection,n=(i,o,r)=>{const a=t._bindToCollection==this,l=t._bindToInternalToExternalMap.get(o);if(a&&l)this._bindToExternalToInternalMap.set(o,l),this._bindToInternalToExternalMap.set(l,o);else{const c=e(o);if(!c){this._skippedIndexesFromExternal.push(r);return}let d=r;for(const u of this._skippedIndexesFromExternal)r>u&&d--;for(const u of t._skippedIndexesFromExternal)d>=u&&d++;this._bindToExternalToInternalMap.set(o,c),this._bindToInternalToExternalMap.set(c,o),this.add(c,d);for(let u=0;u<t._skippedIndexesFromExternal.length;u++)d<=t._skippedIndexesFromExternal[u]&&t._skippedIndexesFromExternal[u]++}};for(const i of t)n(null,i,t.getIndex(i));this.listenTo(t,"add",n),this.listenTo(t,"remove",(i,o,r)=>{const a=this._bindToExternalToInternalMap.get(o);a&&this.remove(a),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce((l,c)=>(r<c&&l.push(c-1),r>c&&l.push(c),l),[])})}_getItemIdBeforeAdding(e){const t=this._idProperty;let n;if(t in e){if(n=e[t],typeof n!="string")throw new m("collection-add-invalid-id",this);if(this.get(n))throw new m("collection-add-item-already-exists",this)}else e[t]=n=De();return n}_remove(e){let t,n,i,o=!1;const r=this._idProperty;if(typeof e=="string"?(n=e,i=this._itemMap.get(n),o=!i,i&&(t=this._items.indexOf(i))):typeof e=="number"?(t=e,i=this._items[t],o=!i,i&&(n=i[r])):(i=e,n=i[r],t=this._items.indexOf(i),o=t==-1||!this._itemMap.get(n)),o)throw new m("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(n);const a=this._bindToInternalToExternalMap.get(i);return this._bindToInternalToExternalMap.delete(i),this._bindToExternalToInternalMap.delete(a),this.fire("remove",i,t),[i,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ne(s){const e=s.next();return e.done?null:e.value}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ve extends Qe(D()){constructor(){super(),this._elements=new Set,this._nextEventLoopTimeout=null,this.set("isFocused",!1),this.set("focusedElement",null)}add(e){if(this._elements.has(e))throw new m("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",()=>this._focus(e),{useCapture:!0}),this.listenTo(e,"blur",()=>this._blur(),{useCapture:!0}),this._elements.add(e)}remove(e){e===this.focusedElement&&this._blur(),this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e))}destroy(){this.stopListening()}_focus(e){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=e,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout(()=>{this.focusedElement=null,this.isFocused=!1},0)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Be{constructor(){this._listener=new(Qe())}listenTo(e){this._listener.listenTo(e,"keydown",(t,n)=>{this._listener.fire("_keydown:"+Lt(n),n)})}set(e,t,n={}){const i=vs(e),o=n.priority;this._listener.listenTo(this._listener,"_keydown:"+i,(r,a)=>{t(a,()=>{a.preventDefault(),a.stopPropagation(),r.stop()}),r.return=!0},{priority:o})}press(e){return!!this._listener.fire("_keydown:"+Lt(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Wu(s){const e=new Map;for(const t in s)e.set(t,s[t]);return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ge(s){return pe(s)?new Map(s):Wu(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Uu=1e4;function $u(s,e,t,n){if(Math.max(e.length,s.length)>Uu)return s.slice(0,t).concat(e).concat(s.slice(t+n,s.length));{const i=Array.from(s);return i.splice(t,n,...e),i}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ui(s,e){let t;function n(...i){n.cancel(),t=setTimeout(()=>s(...i),e)}return n.cancel=()=>{clearTimeout(t)},n}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function qu(s){function e(u){return u.match(/^[a-zA-Z0-9+/=$]+$/g)&&u.length>=40&&u.length<=255?"VALID":"INVALID"}let t="",n="";if(!s)return"INVALID";try{t=atob(s)}catch{return"INVALID"}const i=t.split("-"),o=i[0],r=i[1];if(!r)return e(s);try{atob(r)}catch{try{if(atob(o),!atob(o).length)return e(s)}catch{return e(s)}}if(o.length<40||o.length>255)return"INVALID";try{atob(o)}catch{return"INVALID"}try{n=atob(r)}catch{return"INVALID"}if(n.length!==8)return"INVALID";const a=Number(n.substring(0,4)),l=Number(n.substring(4,6))-1,c=Number(n.substring(6,8)),d=new Date(a,l,c);return d<nu||isNaN(Number(d))?"INVALID":"VALID"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ju(s){return!!s&&s.length==1&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(s)}function Ku(s){return!!s&&s.length==1&&/[\ud800-\udbff]/.test(s)}function Gu(s){return!!s&&s.length==1&&/[\udc00-\udfff]/.test(s)}function Cs(s,e){return Ku(s.charAt(e-1))&&Gu(s.charAt(e))}function ks(s,e){return ju(s.charAt(e))}const Ju=Qu();function bl(s,e){const t=String(s).matchAll(Ju);return Array.from(t).some(n=>n.index<e&&e<n.index+n[0].length)}function Qu(){const s=[/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,/\p{Emoji}\u{FE0F}?\u{20E3}/u,/\p{Emoji}\u{FE0F}/u,/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u],e=/\p{Regional_Indicator}{2}/u.source,t="(?:"+s.map(i=>i.source).join("|")+")",n=`${e}|${t}(?:‍${t})*`;return new RegExp(n,"ug")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _ extends D(){constructor(e){super(),this._disableStack=new Set,this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on("set:isEnabled",_o,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",_o),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function _o(s){s.return=!1,s.stop()}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class x extends D(){constructor(e){super(),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.listenTo(e,"change:isReadOnly",()=>{this.refresh()}),this.on("set:isEnabled",t=>{this.affectsData&&(e.isReadOnly||this._isEnabledBasedOnSelection&&!e.model.canEditAt(e.model.document.selection))&&(t.return=!1,t.stop())},{priority:"highest"}),this.on("execute",t=>{this.isEnabled||t.stop()},{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on("set:isEnabled",vo,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",vo),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function vo(s){s.return=!1,s.stop()}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yo extends x{constructor(){super(...arguments),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){Ja(this._childCommandsDefinitions,{command:e,priority:t.priority||"normal"}),e.on("change:isEnabled",()=>this._checkEnabled()),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){const e=this._childCommandsDefinitions.find(({command:t})=>t.isEnabled);return e&&e.command}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _l extends H(){constructor(e,t=[],n=[]){super(),this._plugins=new Map,this._context=e,this._availablePlugins=new Map;for(const i of t)i.pluginName&&this._availablePlugins.set(i.pluginName,i);this._contextPlugins=new Map;for(const[i,o]of n)this._contextPlugins.set(i,o),this._contextPlugins.set(o,i),i.pluginName&&this._availablePlugins.set(i.pluginName,i)}*[Symbol.iterator](){for(const e of this._plugins)typeof e[0]=="function"&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let n=e;throw typeof e=="function"&&(n=e.pluginName||e.name),new m("plugincollection-plugin-not-loaded",this._context,{plugin:n})}return t}has(e){return this._plugins.has(e)}init(e,t=[],n=[]){const i=this,o=this._context;f(e),w(e);const r=e.filter(T=>!u(T,t)),a=[...g(r)];ue(a,n);const l=N(a);return X(l,"init").then(()=>X(l,"afterInit")).then(()=>l);function c(T){return typeof T=="function"}function d(T){return c(T)&&!!T.isContextPlugin}function u(T,R){return R.some(E=>E===T||h(T)===E||h(E)===T)}function h(T){return c(T)?T.pluginName||T.name:T}function f(T,R=new Set){T.forEach(E=>{c(E)&&(R.has(E)||(R.add(E),E.pluginName&&!i._availablePlugins.has(E.pluginName)&&i._availablePlugins.set(E.pluginName,E),E.requires&&f(E.requires,R)))})}function g(T,R=new Set){return T.map(E=>c(E)?E:i._availablePlugins.get(E)).reduce((E,ee)=>R.has(ee)?E:(R.add(ee),ee.requires&&(w(ee.requires,ee),g(ee.requires,R).forEach(lt=>E.add(lt))),E.add(ee)),new Set)}function w(T,R=null){T.map(E=>c(E)?E:i._availablePlugins.get(E)||E).forEach(E=>{v(E,R),C(E,R),k(E,R)})}function v(T,R){if(!c(T))throw R?new m("plugincollection-soft-required",o,{missingPlugin:T,requiredBy:h(R)}):new m("plugincollection-plugin-not-found",o,{plugin:T})}function C(T,R){if(d(R)&&!d(T))throw new m("plugincollection-context-required",o,{plugin:h(T),requiredBy:h(R)})}function k(T,R){if(R&&u(T,t))throw new m("plugincollection-required",o,{plugin:h(T),requiredBy:h(R)})}function N(T){return T.map(R=>{let E=i._contextPlugins.get(R);return E=E||new R(o),i._add(R,E),E})}function X(T,R){return T.reduce((E,ee)=>!ee[R]||i._contextPlugins.has(ee)?E:E.then(ee[R].bind(ee)),Promise.resolve())}function ue(T,R){for(const E of R){if(typeof E!="function")throw new m("plugincollection-replace-plugin-invalid-type",null,{pluginItem:E});const ee=E.pluginName;if(!ee)throw new m("plugincollection-replace-plugin-missing-name",null,{pluginItem:E});if(E.requires&&E.requires.length)throw new m("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:ee});const lt=i._availablePlugins.get(ee);if(!lt)throw new m("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:ee});const Xs=T.indexOf(lt);if(Xs===-1){if(i._contextPlugins.has(lt))return;throw new m("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:ee})}if(lt.requires&&lt.requires.length)throw new m("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:ee});T.splice(Xs,1,E),i._availablePlugins.set(ee,E)}}}destroy(){const e=[];for(const[,t]of this)typeof t.destroy=="function"&&!this._contextPlugins.has(t)&&e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const n=e.pluginName;if(n){if(this._plugins.has(n))throw new m("plugincollection-plugin-name-conflict",null,{pluginName:n,plugin1:this._plugins.get(n).constructor,plugin2:e});this._plugins.set(n,t)}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vl{constructor(e){this._contextOwner=null,this.config=new il(e,this.constructor.defaultConfig);const t=this.constructor.builtinPlugins;this.config.define("plugins",t),this.plugins=new _l(this,t);const n=this.config.get("language")||{};this.locale=new zu({uiLanguage:typeof n=="string"?n:n.ui,contentLanguage:this.config.get("language.content")}),this.t=this.locale.t,this.editors=new _e}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const n of e.concat(t)){if(typeof n!="function")throw new m("context-initplugins-constructor-only",null,{Plugin:n});if(n.isContextPlugin!==!0)throw new m("context-initplugins-invalid-plugin",null,{Plugin:n})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,e=>e.destroy())).then(()=>this.plugins.destroy())}_addEditor(e,t){if(this._contextOwner)throw new m("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise(t=>{const n=new this(e);t(n.initPlugins().then(()=>n))})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zn extends D(){constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Pn=new WeakMap;function yl({view:s,element:e,text:t,isDirectHost:n=!0,keepOnFocus:i=!1}){const o=s.document;Pn.has(o)||(Pn.set(o,new Map),o.registerPostFixer(r=>di(o,r)),o.on("change:isComposing",()=>{s.change(r=>di(o,r))},{priority:"high"})),Pn.get(o).set(e,{text:t,isDirectHost:n,keepOnFocus:i,hostElement:n?e:null}),s.change(r=>di(o,r))}function Yu(s,e){return e.hasClass("ck-placeholder")?!1:(s.addClass("ck-placeholder",e),!0)}function Zu(s,e){return e.hasClass("ck-placeholder")?(s.removeClass("ck-placeholder",e),!0):!1}function Xu(s,e){if(!s.isAttached()||Array.from(s.getChildren()).some(r=>!r.is("uiElement")))return!1;const n=s.document,o=n.selection.anchor;return n.isComposing&&o&&o.parent===s?!1:e||!n.isFocused?!0:!!o&&o.parent!==s}function di(s,e){const t=Pn.get(s),n=[];let i=!1;for(const[o,r]of t)r.isDirectHost&&(n.push(o),Co(e,o,r)&&(i=!0));for(const[o,r]of t){if(r.isDirectHost)continue;const a=eh(o);a&&(n.includes(a)||(r.hostElement=a,Co(e,o,r)&&(i=!0)))}return i}function Co(s,e,t){const{text:n,isDirectHost:i,hostElement:o}=t;let r=!1;return o.getAttribute("data-placeholder")!==n&&(s.setAttribute("data-placeholder",n,o),r=!0),(i||e.childCount==1)&&Xu(o,t.keepOnFocus)?Yu(s,o)&&(r=!0):Zu(s,o)&&(r=!0),r}function eh(s){if(s.childCount){const e=s.getChild(0);if(e.is("element")&&!e.is("uiElement")&&!e.is("attributeElement"))return e}return null}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let yt=class{is(){throw new Error("is() method is abstract")}};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let Ct=class extends H(yt){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 m("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),i=e.getAncestors(t);let o=0;for(;n[o]==i[o]&&n[o];)o++;return o===0?null:n[o-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),i=le(t,n);switch(i){case"prefix":return!0;case"extension":return!1;default:return t[i]<n[i]}}isAfter(e){return this==e||this.root!==e.root?!1:!this.isBefore(e)}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,t){this.fire(`change:${e}`,t),this.parent&&this.parent._fireChange(e,t)}toJSON(){const e=$a(this);return delete e.parent,e}};Ct.prototype.is=function(s){return s==="node"||s==="view:node"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let j=class $i extends Ct{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 $i?this===e||this.data===e.data:!1}_clone(){return new $i(this.document,this.data)}};j.prototype.is=function(s){return s==="$text"||s==="view:$text"||s==="text"||s==="view:text"||s==="node"||s==="view:node"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let xe=class extends yt{constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.data.length)throw new m("view-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.data.length)throw new m("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}};xe.prototype.is=function(s){return s==="$textProxy"||s==="view:$textProxy"||s==="textProxy"||s==="view:textProxy"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Fe{constructor(...e){this._patterns=[],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 i=ko(t,n);if(i)return{element:t,pattern:n,match:i}}return null}matchAll(...e){const t=[];for(const n of e)for(const i of this._patterns){const o=ko(n,i);o&&t.push({element:n,pattern:i,match:o})}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}}function ko(s,e){if(typeof e=="function")return e(s);const t={};return e.name&&(t.name=th(e.name,s.name),!t.name)||e.attributes&&(t.attributes=oh(e.attributes,s),!t.attributes)||e.classes&&(t.classes=rh(e.classes,s),!t.classes)||e.styles&&(t.styles=ah(e.styles,s),!t.styles)?null:t}function th(s,e){return s instanceof RegExp?!!e.match(s):s===e}function Es(s,e,t){const n=nh(s),i=Array.from(e),o=[];if(n.forEach(([r,a])=>{i.forEach(l=>{ih(r,l)&&sh(a,l,t)&&o.push(l)})}),!(!n.length||o.length<n.length))return o}function nh(s){return Array.isArray(s)?s.map(e=>Ce(e)?((e.key===void 0||e.value===void 0)&&K("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0]):Ce(s)?Object.entries(s):[[s,!0]]}function ih(s,e){return s===!0||s===e||s instanceof RegExp&&e.match(s)}function sh(s,e,t){if(s===!0)return!0;const n=t(e);return s===n||s instanceof RegExp&&!!String(n).match(s)}function oh(s,e){const t=new Set(e.getAttributeKeys());return Ce(s)?(s.style!==void 0&&K("matcher-pattern-deprecated-attributes-style-key",s),s.class!==void 0&&K("matcher-pattern-deprecated-attributes-class-key",s)):(t.delete("style"),t.delete("class")),Es(s,t,n=>e.getAttribute(n))}function rh(s,e){return Es(s,e.getClassNames(),()=>{})}function ah(s,e){return Es(s,e.getStyleNames(!0),t=>e.getStyle(t))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lh{constructor(e){this._styles={},this._styleProcessor=e}get isEmpty(){const e=Object.entries(this._styles);return!Array.from(e).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=Array.from(dh(e).entries());for(const[n,i]of t)this._styleProcessor.toNormalizedForm(n,i,this._styles)}has(e){if(this.isEmpty)return!1;const n=this._styleProcessor.getReducedForm(e,this._styles).find(([i])=>i===e);return Array.isArray(n)}set(e,t){if(Oe(e))for(const[n,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(n,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=qi(e);Od(this._styles,t),delete this._styles[e],this._cleanEmptyObjectsOnPath(t)}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this._getStylesEntries().map(e=>e.join(":")).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!Oe(this._styles[e]))return this._styles[e];const n=this._styleProcessor.getReducedForm(e,this._styles).find(([i])=>i===e);if(Array.isArray(n))return n[1]}getStyleNames(e=!1){return this.isEmpty?[]:e?this._styleProcessor.getStyleNames(this._styles):this._getStylesEntries().map(([n])=>n)}clear(){this._styles={}}_getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const n of t)e.push(...this._styleProcessor.getReducedForm(n,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),o=On(this._styles,i);if(!o)return;!Array.from(Object.keys(o)).length&&this.remove(i)}}class ch{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(Oe(t)){ui(n,qi(e),t);return}if(this._normalizers.has(e)){const i=this._normalizers.get(e),{path:o,value:r}=i(t);ui(n,o,r)}else ui(n,e,t)}getNormalized(e,t){if(!e)return qa({},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 On(t,n);const i=n(e,t);if(i)return i}return On(t,qi(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=Array.from(this._consumables.keys()).filter(i=>{const o=this.getNormalized(i,e);return o&&typeof o=="object"?Object.keys(o).length:o}),n=new Set([...t,...Object.keys(e)]);return Array.from(n.values())}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const n of t)this._mapStyleNames(n,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function dh(s){let e=null,t=0,n=0,i=null;const o=new Map;if(s==="")return o;s.charAt(s.length-1)!=";"&&(s=s+";");for(let r=0;r<s.length;r++){const a=s.charAt(r);if(e===null)switch(a){case":":i||(i=s.substr(t,r-t),n=r+1);break;case'"':case"'":e=a;break;case";":{const l=s.substr(n,r-n);i&&o.set(i.trim(),l.trim()),i=null,t=r+1;break}}else a===e&&(e=null)}return o}function qi(s){return s.replace("-",".")}function ui(s,e,t){let n=t;Oe(t)&&(n=qa({},On(s,e),t)),Dd(s,e,n)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let Ee=class Cl extends Ct{constructor(e,t,n,i){if(super(e),this._unsafeAttributesToRender=[],this._customProperties=new Map,this.name=t,this._attrs=uh(n),this._children=[],i&&this._insertChild(0,i),this._classes=new Set,this._attrs.has("class")){const o=this._attrs.get("class");Eo(this._classes,o),this._attrs.delete("class")}this._styles=new lh(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style"))}get childCount(){return this._children.length}get isEmpty(){return 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.size>0&&(yield"class"),this._styles.isEmpty||(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.isEmpty||(yield["style",this.getAttribute("style")])}getAttribute(e){if(e=="class")return this._classes.size>0?[...this._classes].join(" "):void 0;if(e=="style"){const t=this._styles.toString();return t==""?void 0:t}return this._attrs.get(e)}hasAttribute(e){return e=="class"?this._classes.size>0:e=="style"?!this._styles.isEmpty:this._attrs.has(e)}isSimilar(e){if(!(e instanceof Cl))return!1;if(this===e)return!0;if(this.name!=e.name||this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,n]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==n)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(e){return this._styles.getStyleNames(e)}hasStyle(...e){for(const t of e)if(!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new Fe(...e);let n=this.parent;for(;n&&!n.is("documentFragment");){if(t.match(n))return n;n=n.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),n=Array.from(this._attrs).map(i=>`${i[0]}="${i[1]}"`).sort().join(" ");return this.name+(e==""?"":` class="${e}"`)+(t?` style="${t}"`:"")+(n==""?"":` ${n}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._clone(e));const n=new this.constructor(this.document,this.name,this._attrs,t);return n._classes=new Set(this._classes),n._styles.set(this._styles.getNormalized()),n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._unsafeAttributesToRender=this._unsafeAttributesToRender,n}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let n=0;const i=hh(this.document,t);for(const o of i)o.parent!==null&&o._remove(),o.parent=this,o.document=this.document,this._children.splice(e,0,o),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this);for(let n=e;n<e+t;n++)this._children[n].parent=null;return this._children.splice(e,t)}_setAttribute(e,t){const n=String(t);this._fireChange("attributes",this),e=="class"?Eo(this._classes,n):e=="style"?this._styles.setTo(n):this._attrs.set(e,n)}_removeAttribute(e){return this._fireChange("attributes",this),e=="class"?this._classes.size>0?(this._classes.clear(),!0):!1:e=="style"?this._styles.isEmpty?!1:(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of se(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of se(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),typeof e!="string"?this._styles.set(e):this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of se(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}};Ee.prototype.is=function(s,e){return e?e===this.name&&(s==="element"||s==="view:element"):s==="element"||s==="view:element"||s==="node"||s==="view:node"};function uh(s){const e=Ge(s);for(const[t,n]of e)n===null?e.delete(t):typeof n!="string"&&e.set(t,String(n));return e}function Eo(s,e){const t=e.split(/\s+/);s.clear(),t.forEach(n=>s.add(n))}function hh(s,e){return typeof e=="string"?[new j(s,e)]:(pe(e)||(e=[e]),Array.from(e).map(t=>typeof t=="string"?new j(s,t):t instanceof xe?new j(s,t.data):t))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rn extends Ee{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=kl}}rn.prototype.is=function(s,e){return e?e===this.name&&(s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function kl(){const s=[...this.getChildren()],e=s[this.childCount-1];if(e&&e.is("element","br"))return this.childCount;for(const t of s)if(!t.is("uiElement"))return null;return this.childCount}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xn extends D(rn){constructor(e,t,n,i){super(e,t,n,i),this.set("isReadOnly",!1),this.set("isFocused",!1),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",o=>o&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}}Xn.prototype.is=function(s,e){return e?e===this.name&&(s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const To=Symbol("rootName");class El extends Xn{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(To)}set rootName(e){this._setCustomProperty(To,e)}set _name(e){this.name=e}}El.prototype.is=function(s,e){return e?e===this.name&&(s==="rootElement"||s==="view:rootElement"||s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="rootElement"||s==="view:rootElement"||s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let mt=class{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new m("view-tree-walker-no-start-position",null);if(e.direction&&e.direction!="forward"&&e.direction!="backward")throw new m("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=y._createAt(e.startPosition):this._position=y._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)}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 i;if(n instanceof j){if(e.isAtEnd)return this._position=y._createAfter(n),this._next();i=n.data[e.offset]}else i=n.getChild(e.offset);if(i instanceof Ee)return this.shallow?e.offset++:e=new y(i,0),this._position=e,this._formatReturnValue("elementStart",i,t,e,1);if(i instanceof j){if(this.singleCharacters)return e=new y(i,0),this._position=e,this._next();{let o=i.data.length,r;return i==this._boundaryEndParent?(o=this.boundaries.end.offset,r=new xe(i,0,o),e=y._createAfter(r)):(r=new xe(i,0,i.data.length),e.offset++),this._position=e,this._formatReturnValue("text",r,t,e,o)}}else if(typeof i=="string"){let o;this.singleCharacters?o=1:o=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-e.offset;const r=new xe(n,e.offset,o);return e.offset+=o,this._position=e,this._formatReturnValue("text",r,t,e,o)}else return e=y._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 i;if(n instanceof j){if(e.isAtStart)return this._position=y._createBefore(n),this._previous();i=n.data[e.offset-1]}else i=n.getChild(e.offset-1);if(i instanceof Ee)return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",i,t,e,1)):(e=new y(i,i.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",i,t,e));if(i instanceof j){if(this.singleCharacters)return e=new y(i,i.data.length),this._position=e,this._previous();{let o=i.data.length,r;if(i==this._boundaryStartParent){const a=this.boundaries.start.offset;r=new xe(i,a,i.data.length-a),o=r.data.length,e=y._createBefore(r)}else r=new xe(i,0,i.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",r,t,e,o)}}else if(typeof i=="string"){let o;if(this.singleCharacters)o=1;else{const a=n===this._boundaryStartParent?this.boundaries.start.offset:0;o=e.offset-a}e.offset-=o;const r=new xe(n,e.offset,o);return this._position=e,this._formatReturnValue("text",r,t,e,o)}else return e=y._createBefore(n),this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}_formatReturnValue(e,t,n,i,o){return t instanceof xe&&(t.offsetInText+t.data.length==t.textNode.data.length&&(this.direction=="forward"&&!(this.boundaries&&this.boundaries.end.isEqual(this.position))?(i=y._createAfter(t.textNode),this._position=i):n=y._createAfter(t.textNode)),t.offsetInText===0&&(this.direction=="backward"&&!(this.boundaries&&this.boundaries.start.isEqual(this.position))?(i=y._createBefore(t.textNode),this._position=i):n=y._createBefore(t.textNode))),{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:i,length:o}}}};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let y=class He extends yt{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 Xn);)if(e.parent)e=e.parent;else return null;return e}getShiftedBy(e){const t=He._createAt(this),n=t.offset+e;return t.offset=n<0?0:n,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new mt(t);return n.skip(e),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let i=0;for(;t[i]==n[i]&&t[i];)i++;return i===0?null:t[i-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 i=le(t,n);switch(i){case"prefix":return"before";case"extension":return"after";default:return t[i]<n[i]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new mt(e)}clone(){return new He(this.parent,this.offset)}static _createAt(e,t){if(e instanceof He)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 m("view-createpositionat-offset-required",n)}return new He(n,t)}}static _createAfter(e){if(e.is("$textProxy"))return new He(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new m("view-position-after-root",e,{root:e});return new He(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new He(e.textNode,e.offsetInText);if(!e.parent)throw new m("view-position-before-root",e,{root:e});return new He(e.parent,e.index)}};y.prototype.is=function(s){return s==="position"||s==="view:position"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let A=class Ze extends yt{constructor(e,t=null){super(),this.start=e.clone(),this.end=t?t.clone():e.clone()}*[Symbol.iterator](){yield*new mt({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(wn,{direction:"backward"}),t=this.end.getLastMatchingPosition(wn);return e.parent.is("$text")&&e.isAtStart&&(e=y._createBefore(e.parent)),t.parent.is("$text")&&t.isAtEnd&&(t=y._createAfter(t.parent)),new Ze(e,t)}getTrimmed(){let e=this.start.getLastMatchingPosition(wn);if(e.isAfter(this.end)||e.isEqual(this.end))return new Ze(e,e);let t=this.end.getLastMatchingPosition(wn,{direction:"backward"});const n=e.nodeAfter,i=t.nodeBefore;return n&&n.is("$text")&&(e=new y(n,0)),i&&i.is("$text")&&(t=new y(i,i.data.length)),new Ze(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),i=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&i}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new Ze(this.start,e.start)),this.containsPosition(e.end)&&t.push(new Ze(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 Ze(t,n)}return null}getWalker(e={}){return e.boundaries=this,new mt(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 Ze(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new mt(e);for(const n of t)yield n.item}*getPositions(e={}){e.boundaries=this;const t=new mt(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)}static _createFromParentsAndOffsets(e,t,n,i){return new this(new y(e,t),new y(n,i))}static _createFromPositionAndShift(e,t){const n=e,i=e.getShiftedBy(t);return t>0?new this(n,i):new this(i,n)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(y._createBefore(e),t)}};A.prototype.is=function(s){return s==="range"||s==="view:range"};function wn(s){return!!(s.item.is("attributeElement")||s.item.is("uiElement"))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let it=class Tl extends H(yt){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 i of e._ranges)if(t.isEqual(i)){n=!0;break}if(!n)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Li(this.getRanges()),n=Li(e.getRanges());if(t!=n)return!1;if(t==0)return!0;for(let i of this.getRanges()){i=i.getTrimmed();let o=!1;for(let r of e.getRanges())if(r=r.getTrimmed(),i.start.isEqual(r.start)&&i.end.isEqual(r.end)){o=!0;break}if(!o)return!1}return!0}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,n,i]=e;if(typeof n=="object"&&(i=n,n=void 0),t===null)this._setRanges([]),this._setFakeOptions(i);else if(t instanceof Tl||t instanceof Ts)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof A)this._setRanges([t],i&&i.backward),this._setFakeOptions(i);else if(t instanceof y)this._setRanges([new A(t)]),this._setFakeOptions(i);else if(t instanceof Ct){const o=!!i&&!!i.backward;let r;if(n===void 0)throw new m("view-selection-setto-required-second-parameter",this);n=="in"?r=A._createIn(t):n=="on"?r=A._createOn(t):r=new A(y._createAt(t,n)),this._setRanges([r],o),this._setFakeOptions(i)}else if(pe(t))this._setRanges(t,i&&i.backward),this._setFakeOptions(i);else throw new m("view-selection-setto-not-selectable",this);this.fire("change")}setFocus(e,t){if(this.anchor===null)throw new m("view-selection-setfocus-no-ranges",this);const n=y._createAt(e,t);if(n.compareWith(this.focus)=="same")return;const i=this.anchor;this._ranges.pop(),n.compareWith(i)=="before"?this._addRange(new A(n,i),!0):this._addRange(new A(i,n)),this.fire("change")}_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 A))throw new m("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 m("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new A(e.start,e.end))}};it.prototype.is=function(s){return s==="selection"||s==="view:selection"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let Ts=class extends H(yt){constructor(...e){super(),this._selection=new it,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}};Ts.prototype.is=function(s){return s==="selection"||s=="documentSelection"||s=="view:selection"||s=="view:documentSelection"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jt extends Ke{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-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const hi=Symbol("bubbling contexts");function ji(s){class e extends s{fire(n,...i){try{const o=n instanceof Ke?n:new Ke(this,n),r=fi(this);if(!r.size)return;if(Jt(o,"capturing",this),St(r,"$capture",o,...i))return o.return;const a=o.startRange||this.selection.getFirstRange(),l=a?a.getContainedElement():null,c=l?!!Al(r,l):!1;let d=l||fh(a);if(Jt(o,"atTarget",d),!c){if(St(r,"$text",o,...i))return o.return;Jt(o,"bubbling",d)}for(;d;){if(d.is("rootElement")){if(St(r,"$root",o,...i))return o.return}else if(d.is("element")&&St(r,d.name,o,...i))return o.return;if(St(r,d,o,...i))return o.return;d=d.parent,Jt(o,"bubbling",d)}return Jt(o,"bubbling",this),St(r,"$document",o,...i),o.return}catch(o){/* istanbul ignore next -- @preserve */m.rethrowUnexpectedError(o,this)}}_addEventListener(n,i,o){const r=se(o.context||"$document"),a=fi(this);for(const l of r){let c=a.get(l);c||(c=new(H()),a.set(l,c)),this.listenTo(c,n,i,o)}}_removeEventListener(n,i){const o=fi(this);for(const r of o.values())this.stopListening(r,n,i)}}return e}{const s=ji(Object);["fire","_addEventListener","_removeEventListener"].forEach(e=>{ji[e]=s.prototype[e]})}function Jt(s,e,t){s instanceof jt&&(s._eventPhase=e,s._currentTarget=t)}function St(s,e,t,...n){const i=typeof e=="string"?s.get(e):Al(s,e);return i?(i.fire(t,...n),t.stop.called):!1}function Al(s,e){for(const[t,n]of s)if(typeof t=="function"&&t(e))return n;return null}function fi(s){return s[hi]||(s[hi]=new Map),s[hi]}function fh(s){if(!s)return null;const e=s.start.parent,t=s.end.parent,n=e.getPath(),i=t.getPath();return n.length>i.length?e:t}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let ei=class extends ji(D()){constructor(e){super(),this._postFixers=new Set,this.selection=new Ts,this.roots=new _e({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.map(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let t=!1;do for(const n of this._postFixers)if(t=n(e),t)break;while(t)}};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Sl=10;class gt extends Ee{constructor(e,t,n,i){super(e,t,n,i),this._priority=Sl,this._id=null,this._clonesGroup=null,this.getFillerOffset=mh}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(this.id===null)throw new m("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}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}}gt.DEFAULT_PRIORITY=Sl;gt.prototype.is=function(s,e){return e?e===this.name&&(s==="attributeElement"||s==="view:attributeElement"||s==="element"||s==="view:element"):s==="attributeElement"||s==="view:attributeElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function mh(){if(mi(this))return null;let s=this.parent;for(;s&&s.is("attributeElement");){if(mi(s)>1)return null;s=s.parent}return!s||mi(s)>1?null:this.childCount}function mi(s){return Array.from(s.getChildren()).filter(e=>!e.is("uiElement")).length}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class As extends Ee{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=gh}_insertChild(e,t){if(t&&(t instanceof Ct||Array.from(t).length>0))throw new m("view-emptyelement-cannot-add",[this,t]);return 0}}As.prototype.is=function(s,e){return e?e===this.name&&(s==="emptyElement"||s==="view:emptyElement"||s==="element"||s==="view:element"):s==="emptyElement"||s==="view:emptyElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function gh(){return null}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ti extends Ee{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=wh}_insertChild(e,t){if(t&&(t instanceof Ct||Array.from(t).length>0))throw new m("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}}ti.prototype.is=function(s,e){return e?e===this.name&&(s==="uiElement"||s==="view:uiElement"||s==="element"||s==="view:element"):s==="uiElement"||s==="view:uiElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function ph(s){s.document.on("arrowKey",(e,t)=>bh(e,t,s.domConverter),{priority:"low"})}function wh(){return null}function bh(s,e,t){if(e.keyCode==M.arrowright){const n=e.domTarget.ownerDocument.defaultView.getSelection(),i=n.rangeCount==1&&n.getRangeAt(0).collapsed;if(i||e.shiftKey){const o=n.focusNode,r=n.focusOffset,a=t.domPositionToView(o,r);if(a===null)return;let l=!1;const c=a.getLastMatchingPosition(d=>(d.item.is("uiElement")&&(l=!0),!!(d.item.is("uiElement")||d.item.is("attributeElement"))));if(l){const d=t.viewPositionToDom(c);i?n.collapse(d.parent,d.offset):n.extend(d.parent,d.offset)}}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ss extends Ee{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=_h}_insertChild(e,t){if(t&&(t instanceof Ct||Array.from(t).length>0))throw new m("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}Ss.prototype.is=function(s,e){return e?e===this.name&&(s==="rawElement"||s==="view:rawElement"||s==="element"||s==="view:element"):s==="rawElement"||s==="view:rawElement"||s===this.name||s==="view:"+this.name||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function _h(){return null}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let pt=class extends H(yt){constructor(e,t){super(),this._children=[],this._customProperties=new Map,this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return this.childCount===0}get root(){return this}get parent(){return null}get name(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this);let n=0;const i=vh(this.document,t);for(const o of i)o.parent!==null&&o._remove(),o.parent=this,this._children.splice(e,0,o),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this);for(let n=e;n<e+t;n++)this._children[n].parent=null;return this._children.splice(e,t)}_fireChange(e,t){this.fire("change:"+e,t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}};pt.prototype.is=function(s){return s==="documentFragment"||s==="view:documentFragment"};function vh(s,e){return typeof e=="string"?[new j(s,e)]:(pe(e)||(e=[e]),Array.from(e).map(t=>typeof t=="string"?new j(s,t):t instanceof xe?new j(s,t.data):t))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pl{constructor(e){this._cloneGroups=new Map,this._slotFactory=null,this.document=e}setSelection(...e){this.document.selection._setTo(...e)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new pt(this.document,e)}createText(e){return new j(this.document,e)}createAttributeElement(e,t,n={}){const i=new gt(this.document,e,t);return typeof n.priority=="number"&&(i._priority=n.priority),n.id&&(i._id=n.id),n.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),i}createContainerElement(e,t,n={},i={}){let o=null;Ce(n)?i=n:o=n;const r=new rn(this.document,e,t,o);return i.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),r}createEditableElement(e,t,n={}){const i=new Xn(this.document,e,t);return n.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),i}createEmptyElement(e,t,n={}){const i=new As(this.document,e,t);return n.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),i}createUIElement(e,t,n){const i=new ti(this.document,e,t);return n&&(i.render=n),i}createRawElement(e,t,n,i={}){const o=new Ss(this.document,e,t);return n&&(o.render=n),i.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),o}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){Ce(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 y?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new m("view-writer-break-non-container-element",this.document);if(!t.parent)throw new m("view-writer-break-root",this.document);if(e.isAtStart)return y._createBefore(t);if(!e.isAtEnd){const n=t._clone(!1);this.insert(y._createAfter(t),n);const i=new A(e,y._createAt(t,"end")),o=new y(n,0);this.move(i,o)}return y._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 r=n.parent,a=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new y(r,a))}const i=n.getChild(t-1),o=n.getChild(t);if(!i||!o)return e;if(i.is("$text")&&o.is("$text"))return So(i,o);if(i.is("attributeElement")&&o.is("attributeElement")&&i.isSimilar(o)){const r=i.childCount;return i._appendChild(o.getChildren()),o._remove(),this._removeFromClonedElementsGroup(o),this.mergeAttributes(new y(i,r))}return e}mergeContainers(e){const t=e.nodeBefore,n=e.nodeAfter;if(!t||!n||!t.is("containerElement")||!n.is("containerElement"))throw new m("view-writer-merge-containers-invalid-position",this.document);const i=t.getChild(t.childCount-1),o=i instanceof j?y._createAt(i,"end"):y._createAt(t,"end");return this.move(A._createIn(n),y._createAt(t,"end")),this.remove(A._createOn(n)),o}insert(e,t){t=pe(t)?[...t]:[t],xl(t,this.document);const n=t.reduce((r,a)=>{const l=r[r.length-1],c=!a.is("uiElement");return!l||l.breakAttributes!=c?r.push({breakAttributes:c,nodes:[a]}):l.nodes.push(a),r},[]);let i=null,o=e;for(const{nodes:r,breakAttributes:a}of n){const l=this._insertNodes(o,r,a);i||(i=l.start),o=l.end}return i?new A(i,o):new A(e)}remove(e){const t=e instanceof A?e:A._createOn(e);if(Qt(t,this.document),t.isCollapsed)return new pt(this.document);const{start:n,end:i}=this._breakAttributesRange(t,!0),o=n.parent,r=i.offset-n.offset,a=o._removeChildren(n.offset,r);for(const c of a)this._removeFromClonedElementsGroup(c);const l=this.mergeAttributes(n);return t.start=l,t.end=l.clone(),new pt(this.document,a)}clear(e,t){Qt(e,this.document);const n=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const i of n){const o=i.item;let r;if(o.is("element")&&t.isSimilar(o))r=A._createOn(o);else if(!i.nextPosition.isAfter(e.start)&&o.is("$textProxy")){const a=o.getAncestors().find(l=>l.is("element")&&t.isSimilar(l));a&&(r=A._createIn(a))}r&&(r.end.isAfter(e.end)&&(r.end=e.end),r.start.isBefore(e.start)&&(r.start=e.start),this.remove(r))}}move(e,t){let n;if(t.isAfter(e.end)){t=this._breakAttributes(t,!0);const i=t.parent,o=i.childCount;e=this._breakAttributesRange(e,!0),n=this.remove(e),t.offset+=i.childCount-o}else n=this.remove(e);return this.insert(t,n)}wrap(e,t){if(!(t instanceof gt))throw new m("view-writer-wrap-invalid-attribute",this.document);if(Qt(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&!yh(n.parent)&&(n=n.getLastMatchingPosition(o=>o.item.is("uiElement"))),n=this._wrapPosition(n,t);const i=this.document.selection;return i.isCollapsed&&i.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new A(n)}else return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof gt))throw new m("view-writer-unwrap-invalid-attribute",this.document);if(Qt(e,this.document),e.isCollapsed)return e;const{start:n,end:i}=this._breakAttributesRange(e,!0),o=n.parent,r=this._unwrapChildren(o,n.offset,i.offset,t),a=this.mergeAttributes(r.start);a.isEqual(r.start)||r.end.offset--;const l=this.mergeAttributes(r.end);return new A(a,l)}rename(e,t){const n=new rn(this.document,e,t.getAttributes());return this.insert(y._createAfter(t),n),this.move(A._createIn(t),y._createAt(n,0)),this.remove(A._createOn(t)),n}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return y._createAt(e,t)}createPositionAfter(e){return y._createAfter(e)}createPositionBefore(e){return y._createBefore(e)}createRange(e,t){return new A(e,t)}createRangeOn(e){return A._createOn(e)}createRangeIn(e){return A._createIn(e)}createSelection(...e){return new it(...e)}createSlot(e="children"){if(!this._slotFactory)throw new m("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,n){let i;if(n?i=Ki(e):i=e.parent.is("$text")?e.parent.parent:e.parent,!i)throw new m("view-writer-invalid-position-container",this.document);let o;n?o=this._breakAttributes(e,!0):o=e.parent.is("$text")?gi(e):e;const r=i._insertChild(o.offset,t);for(const d of t)this._addToClonedElementsGroup(d);const a=o.getShiftedBy(r),l=this.mergeAttributes(o);l.isEqual(o)||a.offset--;const c=this.mergeAttributes(a);return new A(l,c)}_wrapChildren(e,t,n,i){let o=t;const r=[];for(;o<n;){const l=e.getChild(o),c=l.is("$text"),d=l.is("attributeElement");if(d&&this._wrapAttributeElement(i,l))r.push(new y(e,o));else if(c||!d||Ch(i,l)){const u=i._clone();l._remove(),u._appendChild(l),e._insertChild(o,u),this._addToClonedElementsGroup(u),r.push(new y(e,o))}else this._wrapChildren(l,0,l.childCount,i);o++}let a=0;for(const l of r){if(l.offset-=a,l.offset==t)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return A._createFromParentsAndOffsets(e,t,e,n)}_unwrapChildren(e,t,n,i){let o=t;const r=[];for(;o<n;){const l=e.getChild(o);if(!l.is("attributeElement")){o++;continue}if(l.isSimilar(i)){const c=l.getChildren(),d=l.childCount;l._remove(),e._insertChild(o,c),this._removeFromClonedElementsGroup(l),r.push(new y(e,o),new y(e,o+d)),o+=d,n+=d-1;continue}if(this._unwrapAttributeElement(i,l)){r.push(new y(e,o),new y(e,o+1)),o++;continue}this._unwrapChildren(l,0,l.childCount,i),o++}let a=0;for(const l of r){if(l.offset-=a,l.offset==t||l.offset==n)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return A._createFromParentsAndOffsets(e,t,e,n)}_wrapRange(e,t){const{start:n,end:i}=this._breakAttributesRange(e,!0),o=n.parent,r=this._wrapChildren(o,n.offset,i.offset,t),a=this.mergeAttributes(r.start);a.isEqual(r.start)||r.end.offset--;const l=this.mergeAttributes(r.end);return new A(a,l)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return Ao(e.clone());e.parent.is("$text")&&(e=gi(e));const n=this.createAttributeElement("_wrapPosition-fake-element");n._priority=Number.POSITIVE_INFINITY,n.isSimilar=()=>!1,e.parent._insertChild(e.offset,n);const i=new A(e,e.getShiftedBy(1));this.wrap(i,t);const o=new y(n.parent,n.index);n._remove();const r=o.nodeBefore,a=o.nodeAfter;return r instanceof j&&a instanceof j?So(r,a):Ao(o)}_wrapAttributeElement(e,t){if(!Po(e,t)||e.name!==t.name||e.priority!==t.priority)return!1;for(const n of e.getAttributeKeys())if(!(n==="class"||n==="style")&&t.hasAttribute(n)&&t.getAttribute(n)!==e.getAttribute(n))return!1;for(const n of e.getStyleNames())if(t.hasStyle(n)&&t.getStyle(n)!==e.getStyle(n))return!1;for(const n of e.getAttributeKeys())n==="class"||n==="style"||t.hasAttribute(n)||this.setAttribute(n,e.getAttribute(n),t);for(const n of e.getStyleNames())t.hasStyle(n)||this.setStyle(n,e.getStyle(n),t);for(const n of e.getClassNames())t.hasClass(n)||this.addClass(n,t);return!0}_unwrapAttributeElement(e,t){if(!Po(e,t)||e.name!==t.name||e.priority!==t.priority)return!1;for(const n of e.getAttributeKeys())if(!(n==="class"||n==="style")&&(!t.hasAttribute(n)||t.getAttribute(n)!==e.getAttribute(n)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const n of e.getStyleNames())if(!t.hasStyle(n)||t.getStyle(n)!==e.getStyle(n))return!1;for(const n of e.getAttributeKeys())n==="class"||n==="style"||this.removeAttribute(n,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const n=e.start,i=e.end;if(Qt(e,this.document),e.isCollapsed){const l=this._breakAttributes(e.start,t);return new A(l,l)}const o=this._breakAttributes(i,t),r=o.parent.childCount,a=this._breakAttributes(n,t);return o.offset+=o.parent.childCount-r,new A(a,o)}_breakAttributes(e,t=!1){const n=e.offset,i=e.parent;if(e.parent.is("emptyElement"))throw new m("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new m("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new m("view-writer-cannot-break-raw-element",this.document);if(!t&&i.is("$text")&&Gi(i.parent)||Gi(i))return e.clone();if(i.is("$text"))return this._breakAttributes(gi(e),t);const o=i.childCount;if(n==o){const r=new y(i.parent,i.index+1);return this._breakAttributes(r,t)}else if(n===0){const r=new y(i.parent,i.index);return this._breakAttributes(r,t)}else{const r=i.index+1,a=i._clone();i.parent._insertChild(r,a),this._addToClonedElementsGroup(a);const l=i.childCount-n,c=i._removeChildren(n,l);a._appendChild(c);const d=new y(i.parent,r);return this._breakAttributes(d,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const i of e.getChildren())this._addToClonedElementsGroup(i);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 i of e.getChildren())this._removeFromClonedElementsGroup(i);const t=e.id;if(!t)return;const n=this._cloneGroups.get(t);n&&n.delete(e)}}function yh(s){return Array.from(s.getChildren()).some(e=>!e.is("uiElement"))}function Ki(s){let e=s.parent;for(;!Gi(e);){if(!e)return;e=e.parent}return e}function Ch(s,e){return s.priority<e.priority?!0:s.priority>e.priority?!1:s.getIdentity()<e.getIdentity()}function Ao(s){const e=s.nodeBefore;if(e&&e.is("$text"))return new y(e,e.data.length);const t=s.nodeAfter;return t&&t.is("$text")?new y(t,0):s}function gi(s){if(s.offset==s.parent.data.length)return new y(s.parent.parent,s.parent.index+1);if(s.offset===0)return new y(s.parent.parent,s.parent.index);const e=s.parent.data.slice(s.offset);return s.parent._data=s.parent.data.slice(0,s.offset),s.parent.parent._insertChild(s.parent.index+1,new j(s.root.document,e)),new y(s.parent.parent,s.parent.index+1)}function So(s,e){const t=s.data.length;return s._data+=e.data,e._remove(),new y(s,t)}const kh=[j,gt,rn,As,Ss,ti];function xl(s,e){for(const t of s){if(!kh.some(n=>t instanceof n))throw new m("view-writer-insert-invalid-node-type",e);t.is("$text")||xl(t.getChildren(),e)}}function Gi(s){return s&&(s.is("containerElement")||s.is("documentFragment"))}function Qt(s,e){const t=Ki(s.start),n=Ki(s.end);if(!t||!n||t!==n)throw new m("view-writer-invalid-range-container",e)}function Po(s,e){return s.id===null&&e.id===null}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Il=s=>s.createTextNode(" "),Rl=s=>{const e=s.createElement("span");return e.dataset.ckeFiller="true",e.innerText=" ",e},Ml=s=>{const e=s.createElement("br");return e.dataset.ckeFiller="true",e},Ie=7,Ln="⁠".repeat(Ie);function me(s){return J(s)&&s.data.substr(0,Ie)===Ln}function Zt(s){return s.data.length==Ie&&me(s)}function xo(s){return me(s)?s.data.slice(Ie):s.data}function Eh(s){s.document.on("arrowKey",Th,{priority:"low"})}function Th(s,e){if(e.keyCode==M.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(t.rangeCount==1&&t.getRangeAt(0).collapsed){const n=t.getRangeAt(0).startContainer,i=t.getRangeAt(0).startOffset;me(n)&&i<=Ie&&t.collapse(n,0)}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ah extends D(){constructor(e,t){super(),this.domDocuments=new Set,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this._inlineFiller=null,this._fakeSelectionContainer=null,this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),P.isBlink&&!P.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()}),this.set("isComposing",!1),this.on("change:isComposing",()=>{this.isComposing||this.render()})}markToSync(e,t){if(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 m("view-renderer-unknown-type",this)}}render(){if(this.isComposing&&!P.isAndroid)return;let e=null;const t=P.isBlink&&!P.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=y._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),i=n.parent.ownerDocument;me(n.parent)?this._inlineFiller=n.parent:this._inlineFiller=Io(i,n.parent,n.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){if(!this.domConverter.mapViewToDom(e))return;const n=Array.from(this.domConverter.mapViewToDom(e).childNodes),i=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),o=this._diffNodeLists(n,i),r=this._findUpdateActions(o,n,i,Ph);if(r.indexOf("update")!==-1){const a={equal:0,insert:0,delete:0};for(const l of r)if(l==="update"){const c=a.equal+a.insert,d=a.equal+a.delete,u=e.getChild(c);u&&!(u.is("uiElement")||u.is("rawElement"))&&this._updateElementMappings(u,n[d]),mo(i[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")?y._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&&J(t.parent)&&me(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!me(e))throw new m("view-renderer-filler-was-lost",this);Zt(e)?e.remove():e.data=e.data.substr(Ie),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")||!Sh(t)||n===t.getFillerOffset())return!1;const i=e.nodeBefore,o=e.nodeAfter;return!(i instanceof j||o instanceof j||P.isAndroid&&(i||o))}_updateText(e,t){const n=this.domConverter.findCorrespondingDomText(e);let o=this.domConverter.viewToDom(e).data;const r=t.inlineFillerPosition;r&&r.parent==e.parent&&r.offset==e.index&&(o=Ln+o),Ro(n,o)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const n=Array.from(t.attributes).map(o=>o.name),i=e.getAttributeKeys();for(const o of i)this.domConverter.setDomElementAttribute(t,o,e.getAttribute(o),e);for(const o of n)e.hasAttribute(o)||this.domConverter.removeDomElementAttribute(t,o)}_updateChildren(e,t){const n=this.domConverter.mapViewToDom(e);if(!n)return;if(P.isAndroid){let u=null;for(const h of Array.from(n.childNodes)){if(u&&J(u)&&J(h)){n.normalize();break}u=h}}const i=t.inlineFillerPosition,o=n.childNodes,r=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));i&&i.parent===e&&Io(n.ownerDocument,r,i.offset);const a=this._diffNodeLists(o,r),l=this._findUpdateActions(a,o,r,xh);let c=0;const d=new Set;for(const u of l)u==="delete"?(d.add(o[c]),mo(o[c])):(u==="equal"||u==="update")&&c++;c=0;for(const u of l)u==="insert"?(ul(n,c,r[c]),c++):u==="update"?(Ro(o[c],r[c].data),c++):u==="equal"&&(this._markDescendantTextToSync(this.domConverter.domToView(r[c])),c++);for(const u of d)u.parentNode||this.domConverter.unbindDomElement(u)}_diffNodeLists(e,t){return e=Mh(e,this._fakeSelectionContainer),en(e,t,Ih.bind(null,this.domConverter))}_findUpdateActions(e,t,n,i){if(e.indexOf("insert")===-1||e.indexOf("delete")===-1)return e;let o=[],r=[],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"?r.push(t[l.equal+l.delete]):(o=o.concat(en(r,a,i).map(d=>d==="equal"?"update":d)),o.push("equal"),r=[],a=[]),l[c]++;return o.concat(en(r,a,i).map(c=>c==="equal"?"update":c))}_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(P.isBlink&&!P.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);!this.isFocused||!e||(this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&P.isAndroid||this._updateDomSelection(e))}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=Vh(t));const n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(e))return;(!n.parentElement||n.parentElement!=e)&&e.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||" ";const i=t.getSelection(),o=t.createRange();i.removeAllRanges(),o.selectNodeContents(n),i.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),i=this.domConverter.viewPositionToDom(this.selection.focus);t.collapse(n.parent,n.offset),t.extend(i.parent,i.offset),P.isGecko&&Rh(i,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,n=e.ownerDocument.getSelection();return!t||t.parentElement!==e||n.anchorNode!==t&&!t.contains(n.anchorNode)?!0:t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const n=e.activeElement,i=this.domConverter.mapDomToView(n);n&&i&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Sh(s){if(s.getAttribute("contenteditable")=="false")return!1;const e=s.findAncestor(t=>t.hasAttribute("contenteditable"));return!e||e.getAttribute("contenteditable")=="true"}function Io(s,e,t){const n=e instanceof Array?e:e.childNodes,i=n[t];if(J(i))return i.data=Ln+i.data,i;{const o=s.createTextNode(Ln);return Array.isArray(e)?n.splice(t,0,o):ul(e,t,o),o}}function Ph(s,e){return nt(s)&&nt(e)&&!J(s)&&!J(e)&&!Bt(s)&&!Bt(e)&&s.tagName.toLowerCase()===e.tagName.toLowerCase()}function xh(s,e){return nt(s)&&nt(e)&&J(s)&&J(e)}function Ih(s,e,t){return e===t?!0:J(e)&&J(t)?e.data===t.data:!!(s.isBlockFiller(e)&&s.isBlockFiller(t))}function Rh(s,e){const t=s.parent;if(t.nodeType!=Node.ELEMENT_NODE||s.offset!=t.childNodes.length-1)return;const n=t.childNodes[s.offset];n&&n.tagName=="BR"&&e.addRange(e.getRangeAt(0))}function Mh(s,e){const t=Array.from(s);return t.length==0||!e||t[t.length-1]==e&&t.pop(),t}function Vh(s){const e=s.createElement("div");return e.className="ck-fake-selection-container",Object.assign(e.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),e.textContent=" ",e}function Ro(s,e){const t=s.data;if(t==e)return;const n=Ga(t,e);for(const i of n)i.type==="insert"?s.insertData(i.index,i.values.join("")):s.deleteData(i.index,i.howMany)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Oh=Ml(S.document),Dh=Il(S.document),Nh=Rl(S.document),bn="data-ck-unsafe-attribute-",Mo="data-ck-unsafe-element";class ni{constructor(e,{blockFillerMode:t,renderingMode:n="editing"}={}){this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new Fe,this._encounteredRawContentDomNodes=new WeakSet,this.document=e,this.renderingMode=n,this.blockFillerMode=t||(n==="editing"?"br":"nbsp"),this.preElements=["pre"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument=this.renderingMode==="editing"?S.document:S.document.implementation.createHTMLDocument("")}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new it(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 Array.from(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"&&t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i)?!1:n==="img"&&(e==="src"||e==="srcset")||n==="source"&&e==="srcset"?!0:!t.match(/^\s*(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"),i=n.createDocumentFragment(),o=n.body.childNodes;for(;o.length>0;)i.appendChild(o[0]);const r=n.createTreeWalker(i,NodeFilter.SHOW_ELEMENT),a=[];let l;for(;l=r.nextNode();)a.push(l);for(const c of a){for(const u of c.getAttributeNames())this.setDomElementAttribute(c,u,c.getAttribute(u));const d=c.tagName.toLowerCase();this._shouldRenameElement(d)&&(Oo(d),c.replaceWith(this._createReplacementDomElement(d,c)))}for(;e.firstChild;)e.firstChild.remove();e.append(i)}viewToDom(e,t={}){if(e.is("$text")){const n=this._processDataFromViewText(e);return this._domDocument.createTextNode(n)}else{if(this.mapViewToDom(e))return this.mapViewToDom(e);let n;if(e.is("documentFragment"))n=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(n,e);else{if(e.is("uiElement"))return e.name==="$comment"?n=this._domDocument.createComment(e.getCustomProperty("$rawContent")):n=e.render(this._domDocument,this),t.bind&&this.bindElements(n,e),n;this._shouldRenameElement(e.name)?(Oo(e.name),n=this._createReplacementDomElement(e.name)):e.hasAttribute("xmlns")?n=this._domDocument.createElementNS(e.getAttribute("xmlns"),e.name):n=this._domDocument.createElement(e.name),e.is("rawElement")&&e.render(n,this),t.bind&&this.bindElements(n,e);for(const i of e.getAttributeKeys())this.setDomElementAttribute(n,i,e.getAttribute(i),e)}if(t.withChildren!==!1)for(const i of this.viewChildrenToDom(e,t))n.appendChild(i);return n}}setDomElementAttribute(e,t,n,i){const o=this.shouldRenderAttribute(t,n,e.tagName.toLowerCase())||i&&i.shouldRenderUnsafeAttribute(t);if(o||K("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:n}),!vu(t)){K("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:n});return}e.hasAttribute(t)&&!o?e.removeAttribute(t):e.hasAttribute(bn+t)&&o&&e.removeAttribute(bn+t),e.setAttribute(o?t:bn+t,n)}removeDomElementAttribute(e,t){t!=Mo&&(e.removeAttribute(t),e.removeAttribute(bn+t))}*viewChildrenToDom(e,t={}){const n=e.getFillerOffset&&e.getFillerOffset();let i=0;for(const o of e.getChildren()){n===i&&(yield this._getBlockFiller());const r=o.is("element")&&!!o.getCustomProperty("dataPipeline:transparentRendering")&&!ne(o.getAttributes());r&&this.renderingMode=="data"?yield*this.viewChildrenToDom(o,t):(r&&K("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:o}),yield this.viewToDom(o,t)),i++}n===i&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),n=this.viewPositionToDom(e.end),i=this._domDocument.createRange();return i.setStart(t.parent,t.offset),i.setEnd(n.parent,n.offset),i}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const n=this.findCorrespondingDomText(t);if(!n)return null;let i=e.offset;return me(n)&&(i+=Ie),{parent:n,offset:i}}else{let n,i,o;if(e.offset===0){if(n=this.mapViewToDom(t),!n)return null;o=n.childNodes[0]}else{const a=e.nodeBefore;if(i=a.is("$text")?this.findCorrespondingDomText(a):this.mapViewToDom(a),!i)return null;n=i.parentNode,o=i.nextSibling}if(J(o)&&me(o))return{parent:o,offset:Ie};const r=i?pn(i)+1:0;return{parent:n,offset:r}}}domToView(e,t={}){if(this.isBlockFiller(e))return null;const n=this.getHostViewElement(e);if(n)return n;if(Bt(e)&&t.skipComments)return null;if(J(e)){if(Zt(e))return null;{const i=this._processDataFromDomText(e);return i===""?null:new j(this.document,i)}}else{if(this.mapDomToView(e))return this.mapDomToView(e);let i;if(this.isDocumentFragment(e))i=new pt(this.document),t.bind&&this.bindDocumentFragments(e,i);else{i=this._createViewElement(e,t),t.bind&&this.bindElements(e,i);const o=e.attributes;if(o)for(let r=o.length,a=0;a<r;a++)i._setAttribute(o[a].name,o[a].value);if(this._isViewElementWithRawContent(i,t)||Bt(e)){const r=Bt(e)?e.data:e.innerHTML;return i._setCustomProperty("$rawContent",r),this._encounteredRawContentDomNodes.add(e),i}}if(t.withChildren!==!1)for(const o of this.domChildrenToView(e,t))i._appendChild(o);return i}}*domChildrenToView(e,t){for(let n=0;n<e.childNodes.length;n++){const i=e.childNodes[n],o=this.domToView(i,t);o!==null&&(yield o)}}domSelectionToView(e){if(e.rangeCount===1){let i=e.getRangeAt(0).startContainer;J(i)&&(i=i.parentNode);const o=this.fakeSelectionToView(i);if(o)return o}const t=this.isDomSelectionBackward(e),n=[];for(let i=0;i<e.rangeCount;i++){const o=e.getRangeAt(i),r=this.domRangeToView(o);r&&n.push(r)}return new it(n,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),n=this.domPositionToView(e.endContainer,e.endOffset);return t&&n?new A(t,n):null}domPositionToView(e,t=0){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,pn(e));const n=this.mapDomToView(e);if(n&&(n.is("uiElement")||n.is("rawElement")))return y._createBefore(n);if(J(e)){if(Zt(e))return this.domPositionToView(e.parentNode,pn(e));const i=this.findCorrespondingViewText(e);let o=t;return i?(me(e)&&(o-=Ie,o=o<0?0:o),new y(i,o)):null}else{if(t===0){const i=this.mapDomToView(e);if(i)return new y(i,0)}else{const i=e.childNodes[t-1];if(J(i)&&Zt(i)||i&&this.isBlockFiller(i))return this.domPositionToView(i.parentNode,pn(i));const o=J(i)?this.findCorrespondingViewText(i):this.mapDomToView(i);if(o&&o.parent)return new y(o.parent,o.index+1)}return null}}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(Zt(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 i=this.mapDomToView(n);if(i){const o=i.nextSibling;return o instanceof j?o:null}}else{const i=this.mapDomToView(e.parentNode);if(i){const o=i.getChild(0);return o instanceof j?o: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){const{scrollX:n,scrollY:i}=S.window,o=[];Vo(t,r=>{const{scrollLeft:a,scrollTop:l}=r;o.push([a,l])}),t.focus(),Vo(t,r=>{const[a,l]=o.shift();r.scrollLeft=a,r.scrollTop=l}),S.window.scrollTo(n,i)}}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(Oh):e.tagName==="BR"&&Vl(e,this.blockElements)&&e.parentNode.childNodes.length===1?!0:e.isEqualNode(Nh)||Fh(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=rl(e);for(t.pop();t.length;){const n=t.pop(),i=this._domToViewMapping.get(n);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return Il(this._domDocument);case"markedNbsp":return Rl(this._domDocument);case"br":return Ml(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(J(e)&&me(e)&&t<Ie||this.isElement(e)&&me(e.childNodes[t]))return!1;const n=this.mapDomToView(e);return!(n&&(n.is("uiElement")||n.is("rawElement")))}_processDataFromViewText(e){let t=e.data;if(e.getAncestors().some(n=>this.preElements.includes(n.name)))return t;if(t.charAt(0)==" "){const n=this._getTouchingInlineViewNode(e,!1);(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n)||!n)&&(t=" "+t.substr(1))}if(t.charAt(t.length-1)==" "){const n=this._getTouchingInlineViewNode(e,!0),i=n&&n.is("$textProxy")&&n.data.charAt(0)==" ";(t.charAt(t.length-2)==" "||!n||i)&&(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(e.getAncestors().some(n=>this.preElements.includes(n.name)))return!1;const t=this._processDataFromViewText(e);return t.charAt(t.length-1)==" "}_processDataFromDomText(e){let t=e.data;if(Bh(e,this.preElements))return xo(e);t=t.replace(/[ \n\t\r]{1,}/g," ");const n=this._getTouchingInlineDomNode(e,!1),i=this._getTouchingInlineDomNode(e,!0),o=this._checkShouldLeftTrimDomText(e,n),r=this._checkShouldRightTrimDomText(e,i);o&&(t=t.replace(/^ /,"")),r&&(t=t.replace(/ $/,"")),t=xo(new Text(t)),t=t.replace(/ \u00A0/g,"  ");const a=i&&this.isElement(i)&&i.tagName!="BR",l=i&&J(i)&&i.data.charAt(0)==" ";return(/( |\u00A0)\u00A0$/.test(t)||!i||a||l)&&(t=t.replace(/\u00A0$/," ")),(o||n&&this.isElement(n)&&n.tagName!="BR")&&(t=t.replace(/^\u00A0/," ")),t}_checkShouldLeftTrimDomText(e,t){return t?this.isElement(t)?t.tagName==="BR":this._encounteredRawContentDomNodes.has(e.previousSibling)?!1:/[^\S\u00A0]/.test(t.data.charAt(t.data.length-1)):!0}_checkShouldRightTrimDomText(e,t){return t?!1:!me(e)}_getTouchingInlineViewNode(e,t){const n=new mt({startPosition:t?y._createAfter(e):y._createBefore(e),direction:t?"forward":"backward"});for(const i of n){if(i.item.is("element")&&this.inlineObjectElements.includes(i.item.name))return i.item;if(i.item.is("containerElement"))return null;if(i.item.is("element","br"))return null;if(i.item.is("$textProxy"))return i.item}return null}_getTouchingInlineDomNode(e,t){if(!e.parentNode)return null;const n=t?"firstChild":"lastChild",i=t?"nextSibling":"previousSibling";let o=!0,r=e;do if(!o&&r[n]?r=r[n]:r[i]?(r=r[i],o=!1):(r=r.parentNode,o=!0),!r||this._isBlockElement(r))return null;while(!(J(r)||r.tagName=="BR"||this._isInlineObjectElement(r)));return r}_isBlockElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isInlineObjectElement(e){return this.isElement(e)&&this.inlineObjectElements.includes(e.tagName.toLowerCase())}_createViewElement(e,t){if(Bt(e))return new ti(this.document,"$comment");const n=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Ee(this.document,n)}_isViewElementWithRawContent(e,t){return t.withChildren!==!1&&!!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(Mo,e),t){for(;t.firstChild;)n.appendChild(t.firstChild);for(const i of t.getAttributeNames())n.setAttribute(i,t.getAttribute(i))}return n}}function Bh(s,e){return rl(s).some(n=>n.tagName&&e.includes(n.tagName.toLowerCase()))}function Vo(s,e){let t=s;for(;t;)e(t),t=t.parentElement}function Fh(s,e){return s.isEqualNode(Dh)&&Vl(s,e)&&s.parentNode.childNodes.length===1}function Vl(s,e){const t=s.parentNode;return!!t&&!!t.tagName&&e.includes(t.tagName.toLowerCase())}function Oo(s){s==="script"&&K("domconverter-unsafe-script-element-detected"),s==="style"&&K("domconverter-unsafe-style-element-detected")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Le extends Qe(){constructor(e){super(),this._isEnabled=!1,this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&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-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zt{constructor(e,t,n){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,ja(this,n)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class st extends Le{constructor(){super(...arguments),this.useCapture=!1}observe(e){(typeof this.domEventType=="string"?[this.domEventType]:this.domEventType).forEach(n=>{this.listenTo(e,n,(i,o)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(o.target)&&this.onDomEvent(o)},{useCapture:this.useCapture})})}stopObserving(e){this.stopListening(e)}fire(e,t,n){this.isEnabled&&this.document.fire(e,new zt(this.view,t,n))}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Lh extends st{constructor(){super(...arguments),this.domEventType=["keydown","keyup"]}onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return Lt(this)}};this.fire(e.type,e,t)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zh extends Le{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Dn(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 it(t.getRanges(),{backward:t.isBackward,fake:!1});(e==M.arrowleft||e==M.arrowup)&&n.setTo(n.getFirstPosition()),(e==M.arrowright||e==M.arrowdown)&&n.setTo(n.getLastPosition());const i={oldSelection:t,newSelection:n,domSelection:null};this.document.fire("selectionChange",i),this._fireSelectionChangeDoneDebounced(i)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ol extends Le{constructor(e){super(e),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this.renderer=e._renderer,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const 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,i=new Set;for(const r of e){const a=t.mapDomToView(r.target);a&&(a.is("uiElement")||a.is("rawElement")||r.type==="childList"&&!this._isBogusBrMutation(r)&&i.add(a))}for(const r of e){const a=t.mapDomToView(r.target);if(!(a&&(a.is("uiElement")||a.is("rawElement")))&&r.type==="characterData"){const l=t.findCorrespondingViewText(r.target);l&&!i.has(l.parent)?n.add(l):!l&&me(r.target)&&i.add(t.mapDomToView(r.target.parentNode))}}let o=!1;for(const r of n)o=!0,this.renderer.markToSync("text",r);for(const r of i){const a=t.mapViewToDom(r),l=Array.from(r.getChildren()),c=Array.from(t.domChildrenToView(a,{withChildren:!1}));Nd(l,c,Hh)||(o=!0,this.renderer.markToSync("children",r))}o&&this.view.forceRender()}_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 Hh(s,e){if(!Array.isArray(s))return s===e?!0:s.is("$text")&&e.is("$text")?s.data===e.data:!1}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ji extends st{constructor(e){super(e),this._isFocusChanging=!1,this.domEventType=["focus","blur"],this.useCapture=!0;const t=this.document;t.on("focus",()=>{this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this.flush(),e.change(()=>{})},50)}),t.on("blur",(n,i)=>{const o=t.selection.editableElement;(o===null||o===i.target)&&(t.isFocused=!1,this._isFocusChanging=!1,e.change(()=>{}))})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wh extends Le{constructor(e){super(e),this.mutationObserver=e.getObserver(Ol),this.focusObserver=e.getObserver(Ji),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=Dn(t=>{this.document.fire("selectionChangeDone",t)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Dn(()=>this.document.isSelecting=!1,5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,n=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},i=()=>{this.document.isSelecting&&(this._handleSelectionChange(null,t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",n,{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),!this._documents.has(t)&&(this.listenTo(t,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",(o,r)=>{this.document.isComposing&&!P.isAndroid||(this._handleSelectionChange(r,t),this._documentIsSelectingInactivityTimeoutDebounced())}),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e,t){if(!this.isEnabled)return;const n=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(n.anchorNode))return;this.mutationObserver.flush();const i=this.domConverter.domSelectionToView(n);if(i.rangeCount==0){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,!(this.selection.isEqual(i)&&this.domConverter.isDomSelectionCorrect(n))){if(++this._loopbackCounter>60){this._reportInfiniteLoop();return}if(this.focusObserver.flush(),this.selection.isSimilar(i))this.view.forceRender();else{const o={oldSelection:this.selection,newSelection:i,domSelection:n};this.document.fire("selectionChange",o),this._fireSelectionChangeDoneDebounced(o)}}}_clearInfiniteLoop(){this._loopbackCounter=0}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Uh extends st{constructor(e){super(e),this.domEventType=["compositionstart","compositionupdate","compositionend"];const t=this.document;t.on("compositionstart",()=>{t.isComposing=!0},{priority:"low"}),t.on("compositionend",()=>{t.isComposing=!1},{priority:"low"})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Dl{constructor(e,t={}){this._files=t.cacheFiles?Do(e):null,this._native=e}get files(){return this._files||(this._files=Do(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 Do(s){const e=Array.from(s.files||[]),t=Array.from(s.items||[]);return e.length?e:t.filter(n=>n.kind==="file").map(n=>n.getAsFile())}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $h extends st{constructor(){super(...arguments),this.domEventType="beforeinput"}onDomEvent(e){const t=e.getTargetRanges(),n=this.view,i=n.document;let o=null,r=null,a=[];if(e.dataTransfer&&(o=new Dl(e.dataTransfer)),e.data!==null?r=e.data:o&&(r=o.getData("text/plain")),i.selection.isFake)a=Array.from(i.selection.getRanges());else if(t.length)a=t.map(l=>n.domConverter.domRangeToView(l));else if(P.isAndroid){const l=e.target.ownerDocument.defaultView.getSelection();a=Array.from(n.domConverter.domSelectionToView(l).getRanges())}if(P.isAndroid&&e.inputType=="insertCompositionText"&&r&&r.endsWith(`
`)){this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[n.createRange(a[0].end)]});return}if(e.inputType=="insertText"&&r&&r.includes(`
`)){const l=r.split(/\n{1,2}/g);let c=a;for(let d=0;d<l.length;d++){const u=l[d];u!=""&&(this.fire(e.type,e,{data:u,dataTransfer:o,targetRanges:c,inputType:e.inputType,isComposing:e.isComposing}),c=[i.selection.getFirstRange()]),d+1<l.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:c}),c=[i.selection.getFirstRange()])}return}this.fire(e.type,e,{data:r,dataTransfer:o,targetRanges:a,inputType:e.inputType,isComposing:e.isComposing})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qh extends Le{constructor(e){super(e),this.document.on("keydown",(t,n)=>{if(this.isEnabled&&Ru(n.keyCode)){const i=new jt(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,n),i.stop.called&&t.stop()}})}observe(){}stopObserving(){}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jh extends Le{constructor(e){super(e);const t=this.document;t.on("keydown",(n,i)=>{if(!this.isEnabled||i.keyCode!=M.tab||i.ctrlKey)return;const o=new jt(t,"tab",t.selection.getFirstRange());t.fire(o,i),o.stop.called&&n.stop()})}observe(){}stopObserving(){}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let Kh=class extends D(){constructor(e){super(),this.domRoots=new Map,this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this.document=new ei(e),this.domConverter=new ni(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Ah(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new Pl(this.document),this.addObserver(Ol),this.addObserver(Ji),this.addObserver(Wh),this.addObserver(Lh),this.addObserver(zh),this.addObserver(Uh),this.addObserver(qh),this.addObserver($h),this.addObserver(jh),Eh(this),ph(this),this.on("render",()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1}),this.listenTo(this.document.selection,"change",()=>{this._hasChangedSinceTheLastRendering=!0}),this.listenTo(this.document,"change:isFocused",()=>{this._hasChangedSinceTheLastRendering=!0})}attachDomRoot(e,t="main"){const n=this.document.getRoot(t);n._name=e.tagName.toLowerCase();const i={};for(const{name:r,value:a}of Array.from(e.attributes))i[r]=a,r==="class"?this._writer.addClass(a.split(" "),n):this._writer.setAttribute(r,a,n);this._initialDomRootAttributes.set(e,i);const o=()=>{this._writer.setAttribute("contenteditable",(!n.isReadOnly).toString(),n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};o(),this.domRoots.set(t,e),this.domConverter.bindElements(e,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(e.ownerDocument),n.on("change:children",(r,a)=>this._renderer.markToSync("children",a)),n.on("change:attributes",(r,a)=>this._renderer.markToSync("attributes",a)),n.on("change:text",(r,a)=>this._renderer.markToSync("text",a)),n.on("change:isReadOnly",()=>this.change(o)),n.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const r of this._observers.values())r.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach(({name:i})=>t.removeAttribute(i));const n=this._initialDomRootAttributes.get(t);for(const i in n)t.setAttribute(i,n[i]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const i of this._observers.values())i.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[n,i]of this.domRoots)t.observe(i,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:i=20}={}){const o=this.document.selection.getFirstRange();o&&Tu({target:this.domConverter.viewRangeToDom(o),viewportOffset:n,ancestorOffset:i,alignToTop:e,forceScroll:t})}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 m("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 */m.rethrowUnexpectedError(t,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Ji).flush(),this.change(()=>{})}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return y._createAt(e,t)}createPositionAfter(e){return y._createAfter(e)}createPositionBefore(e){return y._createBefore(e)}createRange(e,t){return new A(e,t)}createRangeOn(e){return A._createOn(e)}createRangeIn(e){return A._createIn(e)}createSelection(...e){return new it(...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-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ot{is(){throw new Error("is() method is abstract")}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let kt=class extends ot{constructor(e){super(),this.parent=null,this._attrs=Ge(e)}get document(){return null}get index(){let e;if(!this.parent)return null;if((e=this.parent.getChildIndex(this))===null)throw new m("model-node-not-found-in-parent",this);return e}get startOffset(){let e;if(!this.parent)return null;if((e=this.parent.getChildStartOffset(this))===null)throw new m("model-node-not-found-in-parent",this);return e}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const e=this.index;return 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),i=e.getAncestors(t);let o=0;for(;n[o]==i[o]&&n[o];)o++;return o===0?null:n[o-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),i=le(t,n);switch(i){case"prefix":return!0;case"extension":return!1;default:return t[i]<n[i]}}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=Ge(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}};kt.prototype.is=function(s){return s==="node"||s==="model:node"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tn{constructor(e){this._nodes=[],e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._nodes.reduce((e,t)=>e+t.offsetSize,0)}getNode(e){return this._nodes[e]||null}getNodeIndex(e){const t=this._nodes.indexOf(e);return t==-1?null:t}getNodeStartOffset(e){const t=this.getNodeIndex(e);return t===null?null:this._nodes.slice(0,t).reduce((n,i)=>n+i.offsetSize,0)}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new m("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const n of this._nodes){if(e>=t&&e<t+n.offsetSize)return this.getNodeIndex(n);t+=n.offsetSize}if(t!=e)throw new m("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.length}_insertNodes(e,t){for(const n of t)if(!(n instanceof kt))throw new m("model-nodelist-insertnodes-not-node",this);this._nodes=$u(this._nodes,Array.from(t),e,0)}_removeNodes(e,t=1){return this._nodes.splice(e,t)}toJSON(){return this._nodes.map(e=>e.toJSON())}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let q=class Qi extends kt{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 Qi(this.data,this.getAttributes())}static fromJSON(e){return new Qi(e.data,e.attributes)}};q.prototype.is=function(s){return s==="$text"||s==="model:$text"||s==="text"||s==="model:text"||s==="node"||s==="model:node"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ke extends ot{constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new m("model-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.offsetSize)throw new m("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()}}ke.prototype.is=function(s){return s==="$textProxy"||s==="model:$textProxy"||s==="textProxy"||s==="model:textProxy"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class B extends kt{constructor(e,t,n){super(t),this._children=new tn,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)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const n of e)t=t.getChild(t.offsetToIndex(n));return t}findAncestor(e,t={}){let n=t.includeSelf?this:this.parent;for(;n;){if(n.name===e)return n;n=n.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map(n=>n._clone(!0)):void 0;return new B(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=Gh(t);for(const i of n)i.parent!==null&&i._remove(),i.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const i of n)i.parent=null;return n}static fromJSON(e){let t;if(e.children){t=[];for(const n of e.children)n.name?t.push(B.fromJSON(n)):t.push(q.fromJSON(n))}return new B(e.name,e.attributes,t)}}B.prototype.is=function(s,e){return e?e===this.name&&(s==="element"||s==="model:element"):s==="element"||s==="model:element"||s==="node"||s==="model:node"};function Gh(s){return typeof s=="string"?[new q(s)]:(pe(s)||(s=[s]),Array.from(s).map(e=>typeof e=="string"?new q(e):e instanceof ke?new q(e.data,e.getAttributes()):e))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Re{constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new m("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if(t!="forward"&&t!="backward")throw new m("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=b._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,i,o;do i=this.position,o=this._visitedParent,{done:t,value:n}=this.next();while(!t&&e(n));t||(this._position=i,this._visitedParent=o)}next(){return 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 i=nn(t,n),o=i||Nl(t,n,i);if(o instanceof B)return this.shallow?t.offset++:(t.path.push(0),this._visitedParent=o),this._position=t,dt("elementStart",o,e,t,1);if(o instanceof q){let r;if(this.singleCharacters)r=1;else{let c=o.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offset<c&&(c=this.boundaries.end.offset),r=c-t.offset}const a=t.offset-o.startOffset,l=new ke(o,a,r);return t.offset+=r,this._position=t,dt("text",l,e,t,r)}else return t.path.pop(),t.offset++,this._position=t,this._visitedParent=n.parent,this.ignoreElementEnd?this._next():dt("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 i=t.parent,o=nn(t,i),r=o||Bl(t,i,o);if(r instanceof B)return t.offset--,this.shallow?(this._position=t,dt("elementStart",r,e,t,1)):(t.path.push(r.maxOffset),this._position=t,this._visitedParent=r,this.ignoreElementEnd?this._previous():dt("elementEnd",r,e,t));if(r instanceof q){let a;if(this.singleCharacters)a=1;else{let d=r.startOffset;this._boundaryStartParent==n&&this.boundaries.start.offset>d&&(d=this.boundaries.start.offset),a=t.offset-d}const l=t.offset-r.startOffset,c=new ke(r,l-a,a);return t.offset-=a,this._position=t,dt("text",c,e,t,a)}else return t.path.pop(),this._position=t,this._visitedParent=n.parent,dt("elementStart",n,e,t,1)}}function dt(s,e,t,n,i){return{done:!1,value:{type:s,item:e,previousPosition:t,nextPosition:n,length:i}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class b extends ot{constructor(e,t,n="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new m("model-position-root-invalid",e);if(!(t instanceof Array)||t.length===0)throw new m("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.getChild(e.offsetToIndex(this.path[t])),!e)throw new m("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new m("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return nn(this,this.parent)}get nodeAfter(){const e=this.parent;return Nl(this,e,nn(this,e))}get nodeBefore(){const e=this.parent;return Bl(this,e,nn(this,e))}get isAtStart(){return this.offset===0}get isAtEnd(){return this.offset==this.parent.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=le(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 Re(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=le(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 i=0;for(;t[i]==n[i]&&t[i];)i++;return i===0?null:t[i-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 i=this.path[n]-e.path[n];if(i<-1||i>1)return!1;if(i===1)return No(e,this,n);if(i===-1)return No(this,e,n)}return this.path.length===e.path.length?!0:this.path.length>e.path.length?Yi(this.path,t):Yi(e.path,t)}hasSameParentAs(e){if(this.root!==e.root)return!1;const t=this.getParentPath(),n=e.getParentPath();return le(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=b._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 i;return n?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):this.isEqual(e.deletionPosition)?i=b._createAt(e.deletionPosition):i=this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const n=b._createAt(this);if(this.root!=e.root)return n;if(le(e.getParentPath(),this.getParentPath())=="same"){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;n.offset-=t}}else if(le(e.getParentPath(),this.getParentPath())=="prefix"){const i=e.path.length-1;if(e.offset<=this.path[i]){if(e.offset+t>this.path[i])return null;n.path[i]-=t}}return n}_getTransformedByInsertion(e,t){const n=b._createAt(this);if(this.root!=e.root)return n;if(le(e.getParentPath(),this.getParentPath())=="same")(e.offset<this.offset||e.offset==this.offset&&this.stickiness!="toPrevious")&&(n.offset+=t);else if(le(e.getParentPath(),this.getParentPath())=="prefix"){const i=e.path.length-1;e.offset<=this.path[i]&&(n.path[i]+=t)}return n}_getTransformedByMove(e,t,n){if(t=t._getTransformedByDeletion(e,n),e.isEqual(t))return b._createAt(this);const i=this._getTransformedByDeletion(e,n);return i===null||e.isEqual(this)&&this.stickiness=="toNext"||e.getShiftedBy(n).isEqual(this)&&this.stickiness=="toPrevious"?this._getCombined(e,t):i._getTransformedByInsertion(t,n)}_getCombined(e,t){const n=e.path.length-1,i=b._createAt(t);return i.stickiness=this.stickiness,i.offset=i.offset+this.path[n]-e.offset,i.path=[...i.path,...this.path.slice(n+1)],i}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 instanceof b)return new b(e.root,e.path,e.stickiness);{const i=e;if(t=="end")t=i.maxOffset;else{if(t=="before")return this._createBefore(i,n);if(t=="after")return this._createAfter(i,n);if(t!==0&&!t)throw new m("model-createpositionat-offset-required",[this,e])}if(!i.is("element")&&!i.is("documentFragment"))throw new m("model-position-parent-incorrect",[this,e]);const o=i.getPath();return o.push(t),new this(i.root,o,n)}}static _createAfter(e,t){if(!e.parent)throw new m("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 m("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 b(t.graveyard,e.path);return n.stickiness=e.stickiness,n}if(!t.getRoot(e.root))throw new m("model-position-fromjson-no-root",t,{rootName:e.root});return new b(t.getRoot(e.root),e.path,e.stickiness)}}b.prototype.is=function(s){return s==="position"||s==="model:position"};function nn(s,e){const t=e.getChild(e.offsetToIndex(s.offset));return t&&t.is("$text")&&t.startOffset<s.offset?t:null}function Nl(s,e,t){return t!==null?null:e.getChild(e.offsetToIndex(s.offset))}function Bl(s,e,t){return t!==null?null:e.getChild(e.offsetToIndex(s.offset)-1)}function No(s,e,t){return!(t+1===s.path.length||!Yi(e.path,t+1)||!Jh(s,t+1))}function Yi(s,e){for(;e<s.length;){if(s[e]!==0)return!1;e++}return!0}function Jh(s,e){let t=s.parent,n=s.path.length-1,i=0;for(;n>=e;){if(s.path[n]+i!==t.maxOffset)return!1;i=1,n--,t=t.parent}return!0}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class p extends ot{constructor(e,t){super(),this.start=b._createAt(e),this.end=t?b._createAt(t):b._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new Re({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){const e=this.start.getParentPath(),t=this.end.getParentPath();return le(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),i=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&i}containsItem(e){const t=b._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 p(this.start,e.start)),this.containsPosition(e.end)&&t.push(new p(e.end,this.end))):t.push(new p(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 p(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 i=this.start,o=this.end;return e.start.isBefore(i)&&(i=e.start),e.end.isAfter(o)&&(o=e.end),new p(i,o)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,n=b._createAt(this.start);let i=n.parent;for(;n.path.length>t+1;){const o=i.maxOffset-n.offset;o!==0&&e.push(new p(n,n.getShiftedBy(o))),n.path=n.path.slice(0,-1),n.offset++,i=i.parent}for(;n.path.length<=this.end.path.length;){const o=this.end.path[n.path.length-1],r=o-n.offset;r!==0&&e.push(new p(n,n.getShiftedBy(r))),n.offset=o,n.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new Re(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new Re(e);for(const n of t)yield n.item}*getPositions(e={}){e.boundaries=this;const t=new Re(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 p(this.start,this.end)]}getTransformedByOperations(e){const t=[new p(this.start,this.end)];for(const n of e)for(let i=0;i<t.length;i++){const o=t[i].getTransformedByOperation(n);t.splice(i,1,...o),i+=o.length-1}for(let n=0;n<t.length;n++){const i=t[n];for(let o=n+1;o<t.length;o++){const r=t[o];(i.containsRange(r)||r.containsRange(i)||i.isEqual(r))&&t.splice(o,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,i=e.howMany,o=e.targetPosition;return this._getTransformedByMove(n,o,i,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 p(t,n)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new p(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=b._createAt(n),t.offset=0):(e.deletionPosition.isEqual(t)||(n=e.deletionPosition),t=e.targetPosition),new p(t,n)):new p(t,n)}_getTransformedByInsertion(e,t,n=!1){if(n&&this.containsPosition(e))return[new p(this.start,e),new p(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const i=new p(this.start,this.end);return i.start=i.start._getTransformedByInsertion(e,t),i.end=i.end._getTransformedByInsertion(e,t),[i]}}_getTransformedByMove(e,t,n,i=!1){if(this.isCollapsed){const u=this.start._getTransformedByMove(e,t,n);return[new p(u)]}const o=p._createFromPositionAndShift(e,n),r=t._getTransformedByDeletion(e,n);if(this.containsPosition(t)&&!i&&(o.containsPosition(this.start)||o.containsPosition(this.end))){const u=this.start._getTransformedByMove(e,t,n),h=this.end._getTransformedByMove(e,t,n);return[new p(u,h)]}let a;const l=this.getDifference(o);let c=null;const d=this.getIntersection(o);if(l.length==1?c=new p(l[0].start._getTransformedByDeletion(e,n),l[0].end._getTransformedByDeletion(e,n)):l.length==2&&(c=new p(this.start,this.end._getTransformedByDeletion(e,n))),c?a=c._getTransformedByInsertion(r,n,d!==null||i):a=[],d){const u=new p(d.start._getCombined(o.start,r),d.end._getCombined(o.start,r));a.length==2?a.splice(1,0,u):a.push(u)}return a}_getTransformedByDeletion(e,t){let n=this.start._getTransformedByDeletion(e,t),i=this.end._getTransformedByDeletion(e,t);return n==null&&i==null?null:(n==null&&(n=e),i==null&&(i=e),new p(n,i))}static _createFromPositionAndShift(e,t){const n=e,i=e.getShiftedBy(t);return t>0?new this(n,i):new this(i,n)}static _createIn(e){return new this(b._createAt(e,0),b._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(b._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(e.length===0)throw new m("range-create-from-ranges-empty-array",null);if(e.length==1)return e[0].clone();const t=e[0];e.sort((o,r)=>o.start.isAfter(r.start)?1:-1);const n=e.indexOf(t),i=new this(t.start,t.end);if(n>0)for(let o=n-1;e[o].end.isEqual(i.start);o++)i.start=b._createAt(e[o].start);for(let o=n+1;o<e.length&&e[o].start.isEqual(i.end);o++)i.end=b._createAt(e[o].end);return i}static fromJSON(e,t){return new this(b.fromJSON(e.start,t),b.fromJSON(e.end,t))}}p.prototype.is=function(s){return s==="range"||s==="model:range"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Fl extends H(){constructor(){super(),this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._viewToModelLengthCallbacks=new Map,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._deferredBindingRemovals=new Map,this._unboundMarkerNames=new Set,this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;const n=this._modelToViewMapping.get(t.modelPosition.parent);if(!n)throw new m("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(n,t.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,t)=>{if(t.modelPosition)return;const n=this.findMappedViewAncestor(t.viewPosition),i=this._viewToModelMapping.get(n),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,n);t.modelPosition=b._createAt(i,o)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const n=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const i of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(i);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e),this._modelToViewMapping.get(n)==e&&this._modelToViewMapping.delete(n))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const n=this._markerNameToElements.get(t)||new Set;n.add(e);const i=this._elementToMarkerNames.get(e)||new Set;i.add(t),this._markerNameToElements.set(t,n),this._elementToMarkerNames.set(e,i)}unbindElementFromMarkerName(e,t){const n=this._markerNameToElements.get(t);n&&(n.delete(e),n.size==0&&this._markerNameToElements.delete(t));const i=this._elementToMarkerNames.get(e);i&&(i.delete(t),i.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 p(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new A(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 i of t)if(i.is("attributeElement"))for(const o of i.getElementsWithSameId())n.add(o);else n.add(i);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 o=this._toModelOffset(e.parent,e.index,n),r=this._toModelOffset(e,t,e);return o+r}if(e.is("$text"))return t;let i=0;for(let o=0;o<t;o++)i+=this.getModelLength(e.getChild(o));return i}getModelLength(e){if(this._viewToModelLengthCallbacks.get(e.name))return this._viewToModelLengthCallbacks.get(e.name)(e);if(this._viewToModelMapping.has(e))return 1;if(e.is("$text"))return e.data.length;if(e.is("uiElement"))return 0;{let t=0;for(const n of e.getChildren())t+=this.getModelLength(n);return t}}findPositionIn(e,t){let n,i=0,o=0,r=0;if(e.is("$text"))return new y(e,t);for(;o<t;)n=e.getChild(r),i=this.getModelLength(n),o+=i,r++;return o==t?this._moveViewPositionToTextNode(new y(e,r)):this.findPositionIn(n,t-(o-i))}_moveViewPositionToTextNode(e){const t=e.nodeBefore,n=e.nodeAfter;return t instanceof j?new y(t,t.data.length):n instanceof j?new y(n,0):e}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Qh{constructor(){this._consumable=new Map,this._textProxyRegistry=new Map}add(e,t){t=_n(t),e instanceof ke&&(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=_n(t),e instanceof ke&&(e=this._getSymbolForTextProxy(e)),this.test(e,t)?(this._consumable.get(e).set(t,!1),!0):!1}test(e,t){t=_n(t),e instanceof ke&&(e=this._getSymbolForTextProxy(e));const n=this._consumable.get(e);if(n===void 0)return null;const i=n.get(t);return i===void 0?null:i}revert(e,t){t=_n(t),e instanceof ke&&(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,i]of this._consumable)for(const[o,r]of i){const a=o.split(":")[0];r&&e==a&&t.push({event:o,item:n.name||n.description})}if(t.length)throw new m("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const n=this._textProxyRegistry.get(e.startOffset);if(n){const i=n.get(e.endOffset);i&&(t=i.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,n=e.endOffset,i=e.parent,o=Symbol("$textProxy:"+e.data);let r,a;return r=this._textProxyRegistry.get(t),r||(r=new Map,this._textProxyRegistry.set(t,r)),a=r.get(n),a||(a=new Map,r.set(n,a)),a.set(i,o),o}}function _n(s){const e=s.split(":");return e[0]=="insert"?e[0]:e[0]=="addMarker"||e[0]=="removeMarker"?s:e.length>1?e[0]+":"+e[1]:e[0]}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ll extends H(){constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,n){const i=this._createConversionApi(n,e.getRefreshedItems());for(const r of e.getMarkersToRemove())this._convertMarkerRemove(r.name,r.range,i);const o=this._reduceChanges(e.getChanges());for(const r of o)r.type==="insert"?this._convertInsert(p._createFromPositionAndShift(r.position,r.length),i):r.type==="reinsert"?this._convertReinsert(p._createFromPositionAndShift(r.position,r.length),i):r.type==="remove"?this._convertRemove(r.position,r.length,r.name,i):this._convertAttribute(r.range,r.attributeKey,r.attributeOldValue,r.attributeNewValue,i);for(const r of i.mapper.flushUnboundMarkerNames()){const a=t.get(r).getRange();this._convertMarkerRemove(r,a,i),this._convertMarkerAdd(r,a,i)}for(const r of e.getMarkersToAdd())this._convertMarkerAdd(r.name,r.range,i);i.mapper.flushDeferredBindings(),i.consumable.verifyAllConsumed("insert")}convert(e,t,n,i={}){const o=this._createConversionApi(n,void 0,i);this._convertInsert(e,o);for(const[r,a]of t)this._convertMarkerAdd(r,a,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,n){const i=Array.from(t.getMarkersAtPosition(e.getFirstPosition())),o=this._createConversionApi(n);if(this._addConsumablesForSelection(o.consumable,e,i),this.fire("selection",{selection:e},o),!!e.isCollapsed){for(const r of i){const a=r.getRange();if(!Yh(e.getFirstPosition(),r,o.mapper))continue;const l={item:e,markerName:r.name,markerRange:a};o.consumable.test(e,"addMarker:"+r.name)&&this.fire(`addMarker:${r.name}`,l,o)}for(const r of e.getAttributeKeys()){const a={item:e,range:e.getFirstRange(),attributeKey:r,attributeOldValue:null,attributeNewValue:e.getAttribute(r)};o.consumable.test(e,"attribute:"+a.attributeKey)&&this.fire(`attribute:${a.attributeKey}:$text`,a,o)}}}_convertInsert(e,t,n={}){n.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,Array.from(e));for(const i of Array.from(e.getWalker({shallow:!0})).map(Bo))this._testAndFire("insert",i,t)}_convertRemove(e,t,n,i){this.fire(`remove:${n}`,{position:e,length:t},i)}_convertAttribute(e,t,n,i,o){this._addConsumablesForRange(o.consumable,e,`attribute:${t}`);for(const r of e){const a={item:r.item,range:p._createFromPositionAndShift(r.previousPosition,r.length),attributeKey:t,attributeOldValue:n,attributeNewValue:i};this._testAndFire(`attribute:${t}`,a,o)}}_convertReinsert(e,t){const n=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,n);for(const i of n.map(Bo))this._testAndFire("insert",{...i,reconversion:!0},t)}_convertMarkerAdd(e,t,n){if(t.root.rootName=="$graveyard")return;const i=`addMarker:${e}`;if(n.consumable.add(t,i),this.fire(i,{markerName:e,markerRange:t},n),!!n.consumable.consume(t,i)){this._addConsumablesForRange(n.consumable,t,i);for(const o of t.getItems()){if(!n.consumable.test(o,i))continue;const r={item:o,range:p._createOn(o),markerName:e,markerRange:t};this.fire(i,r,n)}}}_convertMarkerRemove(e,t,n){t.root.rootName!="$graveyard"&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},n)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const n of t){const i=n.item;if(e.test(i,"insert")===null){e.add(i,"insert");for(const o of i.getAttributeKeys())e.add(i,"attribute:"+o)}}return e}_addConsumablesForRange(e,t,n){for(const i of t.getItems())e.add(i,n);return e}_addConsumablesForSelection(e,t,n){e.add(t,"selection");for(const i of n)e.add(t,"addMarker:"+i.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,n){const i=Zh(e,t),o=t.item.is("$textProxy")?n.consumable._getSymbolForTextProxy(t.item):t.item,r=this._firedEventsMap.get(n),a=r.get(o);if(!a)r.set(o,new Set([i]));else if(!a.has(i))a.add(i);else return;this.fire(i,t,n)}_testAndFireAddAttributes(e,t){const n={item:e,range:p._createOn(e)};for(const i of n.item.getAttributeKeys())n.attributeKey=i,n.attributeOldValue=null,n.attributeNewValue=n.item.getAttribute(i),this._testAndFire(`attribute:${i}`,n,t)}_createConversionApi(e,t=new Set,n={}){const i={...this._conversionApi,consumable:new Qh,writer:e,options:n,convertItem:o=>this._convertInsert(p._createOn(o),i),convertChildren:o=>this._convertInsert(p._createIn(o),i,{doNotAddConsumables:!0}),convertAttributes:o=>this._testAndFireAddAttributes(o,i),canReuseView:o=>!t.has(i.mapper.toModelElement(o))};return this._firedEventsMap.set(i,new Map),i}}function Yh(s,e,t){const n=e.getRange(),i=Array.from(s.getAncestors());return i.shift(),i.reverse(),!i.some(r=>{if(n.containsItem(r))return!!t.toViewElement(r).getCustomProperty("addHighlight")})}function Zh(s,e){const t=e.item.is("element")?e.item.name:"$text";return`${s}:${t}`}function Bo(s){const e=s.item,t=p._createFromPositionAndShift(s.previousPosition,s.length);return{item:e,range:t}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ge extends H(ot){constructor(...e){super(),this._lastRangeBackward=!1,this._attrs=new Map,this._ranges=[],e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 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 i of e._ranges)if(t.isEqual(i)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new p(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 p(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 p(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,n,i]=e;if(typeof n=="object"&&(i=n,n=void 0),t===null)this._setRanges([]);else if(t instanceof ge)this._setRanges(t.getRanges(),t.isBackward);else if(t&&typeof t.getRanges=="function")this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof p)this._setRanges([t],!!i&&!!i.backward);else if(t instanceof b)this._setRanges([new p(t)]);else if(t instanceof kt){const o=!!i&&!!i.backward;let r;if(n=="in")r=p._createIn(t);else if(n=="on")r=p._createOn(t);else if(n!==void 0)r=new p(b._createAt(t,n));else throw new m("model-selection-setto-required-second-parameter",[this,t]);this._setRanges([r],o)}else if(pe(t))this._setRanges(t,i&&!!i.backward);else throw new m("model-selection-setto-not-selectable",[this,t])}_setRanges(e,t=!1){const n=Array.from(e),i=n.some(o=>{if(!(o instanceof p))throw new m("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(r=>!r.isEqual(o))});n.length===this._ranges.length&&!i||(this._replaceAllRanges(n),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(this.anchor===null)throw new m("model-selection-setfocus-no-ranges",[this,e]);const n=b._createAt(e,t);if(n.compareWith(this.focus)=="same")return;const i=this.anchor;this._ranges.length&&this._popRange(),n.compareWith(i)=="before"?(this._pushRange(new p(n,i)),this._lastRangeBackward=!0):(this._pushRange(new p(i,n)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const n=Fo(t.start,e);ef(n,t)&&(yield n);for(const o of t.getWalker()){const r=o.item;o.type=="elementEnd"&&Xh(r,e,t)&&(yield r)}const i=Fo(t.end,e);tf(i,t)&&(yield i)}}containsEntireContent(e=this.anchor.root){const t=b._createAt(e,0),n=b._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new p(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new m("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()}}ge.prototype.is=function(s){return s==="selection"||s==="model:selection"};function zl(s,e){return e.has(s)?!1:(e.add(s),s.root.document.model.schema.isBlock(s)&&!!s.parent)}function Xh(s,e,t){return zl(s,e)&&Ps(s,t)}function Fo(s,e){const n=s.parent.root.document.model.schema,i=s.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const r=i.find(a=>o?!1:(o=n.isLimit(a),!o&&zl(a,e)));return i.forEach(a=>e.add(a)),r}function Ps(s,e){const t=nf(s);return t?!e.containsRange(p._createOn(t),!0):!0}function ef(s,e){return s?e.isCollapsed||s.isEmpty?!0:e.start.isTouching(b._createAt(s,s.maxOffset))?!1:Ps(s,e):!1}function tf(s,e){return s?e.isCollapsed||s.isEmpty?!0:e.end.isTouching(b._createAt(s,0))?!1:Ps(s,e):!1}function nf(s){const e=s.root.document.model.schema;let t=s.parent;for(;t;){if(e.isBlock(t))return t;t=t.parent}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Te extends H(p){constructor(e,t){super(e,t),sf.call(this)}detach(){this.stopListening()}toRange(){return new p(this.start,this.end)}static fromRange(e){return new Te(e.start,e.end)}}Te.prototype.is=function(s){return s==="liveRange"||s==="model:liveRange"||s=="range"||s==="model:range"};function sf(){this.listenTo(this.root.document.model,"applyOperation",(s,e)=>{const t=e[0];t.isDocumentOperation&&of.call(this,t)},{priority:"low"})}function of(s){const e=this.getTransformedByOperation(s),t=p._createFromRanges(e),n=!t.isEqual(this),i=rf(this,s);let o=null;if(n){t.root.rootName=="$graveyard"&&(s.type=="remove"?o=s.sourcePosition:o=s.deletionPosition);const r=this.toRange();this.start=t.start,this.end=t.end,this.fire("change:range",r,{deletionPosition:o})}else i&&this.fire("change:content",this.toRange(),{deletionPosition:o})}function rf(s,e){switch(e.type){case"insert":return s.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return s.containsPosition(e.sourcePosition)||s.start.isEqual(e.sourcePosition)||s.containsPosition(e.targetPosition);case"split":return s.containsPosition(e.splitPosition)||s.containsPosition(e.insertionPosition)}return!1}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const an="selection:";class Ae extends H(ot){constructor(e){super(),this._selection=new af(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return an+e}static _isStoreAttributeKey(e){return e.startsWith(an)}}Ae.prototype.is=function(s){return s==="selection"||s=="model:selection"||s=="documentSelection"||s=="model:documentSelection"};class af extends ge{constructor(e){super(),this.markers=new _e({idProperty:"name"}),this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",(t,n)=>{const i=n[0];!i.isDocumentOperation||i.type=="marker"||i.type=="rename"||i.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,i,o)=>{this._updateMarker(n,o)}),this.listenTo(this._document,"change",(t,n)=>{lf(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=De();return this._overriddenGravityRegister.add(e),this._overriddenGravityRegister.size===1&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new m("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)}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new m("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=Te.fromRange(e);return t.on("change:range",(n,i,o)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=o.deletionPosition;const r=this._ranges.indexOf(t);this._ranges.splice(r,1),t.detach()}}),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const i of this._model.markers){const o=i.name.split(":",1)[0];if(!this._observedMarkers.has(o))continue;const r=i.getRange();for(const a of this.getRanges())r.containsRange(a,!a.isCollapsed)&&e.push(i)}const n=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(e,t){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let i=!1;const o=Array.from(this.markers),r=this.markers.has(e);if(!t)r&&(this.markers.remove(e),i=!0);else{let a=!1;for(const l of this.getRanges())if(t.containsRange(l,!l.isCollapsed)){a=!0;break}a&&!r?(this.markers.add(e),i=!0):!a&&r&&(this.markers.remove(e),i=!0)}i&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=Ge(this._getSurroundingAttributes()),n=Ge(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[o,r]of this._attributePriority)r=="low"&&(this._attrs.delete(o),this._attributePriority.delete(o));this._setAttributesTo(t);const i=[];for(const[o,r]of this.getAttributes())(!n.has(o)||n.get(o)!==r)&&i.push(o);for(const[o]of n)this.hasAttribute(o)||i.push(o);i.length>0&&this.fire("change:attribute",{attributeKeys:i,directChange:!1})}_setAttribute(e,t,n=!0){const i=n?"normal":"low";return i=="low"&&this._attributePriority.get(e)=="normal"||super.getAttribute(e)===t?!1:(this._attrs.set(e,t),this._attributePriority.set(e,i),!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,i]of this.getAttributes())e.get(n)!==i&&this._removeAttribute(n,!1);for(const[n,i]of e)this._setAttribute(n,i,!1)&&t.add(n);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())t.startsWith(an)&&(yield[t.substr(an.length),e.getAttribute(t)])}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;let n=null;if(this.isCollapsed){const i=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(n=vn(i)),n||(n=vn(o)),!this.isGravityOverridden&&!n){let r=i;for(;r&&!t.isInline(r)&&!n;)r=r.previousSibling,n=vn(r)}if(!n){let r=o;for(;r&&!t.isInline(r)&&!n;)r=r.nextSibling,n=vn(r)}n||(n=this.getStoredAttributes())}else{const i=this.getFirstRange();for(const o of i){if(o.item.is("element")&&t.isObject(o.item))break;if(o.type=="text"){n=o.item.getAttributes();break}}}return n}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function vn(s){return s instanceof ke||s instanceof q?s.getAttributes():null}function lf(s,e){const t=s.document.differ;for(const n of t.getChanges()){if(n.type!="insert")continue;const i=n.position.parent;n.length===i.maxOffset&&s.enqueueChange(e,r=>{const a=Array.from(i.getAttributeKeys()).filter(l=>l.startsWith(an));for(const l of a)r.removeAttribute(l,i)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hl{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cf extends Hl{elementToElement(e){return this.add(Sf(e))}elementToStructure(e){return this.add(Pf(e))}attributeToElement(e){return this.add(xf(e))}attributeToAttribute(e){return this.add(If(e))}markerToElement(e){return this.add(Rf(e))}markerToHighlight(e){return this.add(Vf(e))}markerToData(e){return this.add(Mf(e))}}function Wl(){return(s,e,t)=>{if(!t.consumable.consume(e.item,s.name))return;const n=t.writer,i=t.mapper.toViewPosition(e.range.start),o=n.createText(e.item.data);n.insert(i,o)}}function Ul(){return(s,e,t)=>{t.convertAttributes(e.item),!e.reconversion&&e.item.is("element")&&!e.item.isEmpty&&t.convertChildren(e.item)}}function df(){return(s,e,t)=>{const n=t.mapper.toViewPosition(e.position),i=e.position.getShiftedBy(e.length),o=t.mapper.toViewPosition(i,{isPhantom:!0}),r=t.writer.createRange(n,o),a=t.writer.remove(r.getTrimmed());for(const l of t.writer.createRangeIn(a).getItems())t.mapper.unbindViewElement(l,{defer:!0})}}function $l(s,e){const t=s.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 uf(){return(s,e,t)=>{const n=e.selection;if(n.isCollapsed||!t.consumable.consume(n,"selection"))return;const i=[];for(const o of n.getRanges())i.push(t.mapper.toViewRange(o));t.writer.setSelection(i,{backward:n.isBackward})}}function hf(){return(s,e,t)=>{const n=e.selection;if(!n.isCollapsed||!t.consumable.consume(n,"selection"))return;const i=t.writer,o=n.getFirstPosition(),r=t.mapper.toViewPosition(o),a=i.breakAttributes(r);i.setSelection(a)}}function ff(){return(s,e,t)=>{const n=t.writer,i=n.document.selection;for(const o of i.getRanges())o.isCollapsed&&o.end.parent.isAttached()&&t.writer.mergeAttributes(o.start);n.setSelection(null)}}function mf(s){return(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const i=s(t.attributeOldValue,n,t),o=s(t.attributeNewValue,n,t);if(!i&&!o)return;n.consumable.consume(t.item,e.name);const r=n.writer,a=r.document.selection;if(t.item instanceof ge||t.item instanceof Ae)r.wrap(a.getFirstRange(),o);else{let l=n.mapper.toViewRange(t.range);t.attributeOldValue!==null&&i&&(l=r.unwrap(l,i)),t.attributeNewValue!==null&&o&&r.wrap(l,o)}}}function gf(s,e=zf){return(t,n,i)=>{if(!e(n.item,i.consumable,{preflight:!0}))return;const o=s(n.item,i,n);if(!o)return;e(n.item,i.consumable);const r=i.mapper.toViewPosition(n.range.start);i.mapper.bindElements(n.item,o),i.writer.insert(r,o),i.convertAttributes(n.item),Jl(o,n.item.getChildren(),i,{reconversion:n.reconversion})}}function pf(s,e){return(t,n,i)=>{if(!e(n.item,i.consumable,{preflight:!0}))return;const o=new Map;i.writer._registerSlotFactory(Nf(n.item,o,i));const r=s(n.item,i,n);if(i.writer._clearSlotFactory(),!r)return;Bf(n.item,o,i),e(n.item,i.consumable);const a=i.mapper.toViewPosition(n.range.start);i.mapper.bindElements(n.item,r),i.writer.insert(a,r),i.convertAttributes(n.item),Ff(r,o,i,{reconversion:n.reconversion})}}function wf(s){return(e,t,n)=>{t.isOpening=!0;const i=s(t,n);t.isOpening=!1;const o=s(t,n);if(!i||!o)return;const r=t.markerRange;if(r.isCollapsed&&!n.consumable.consume(r,e.name))return;for(const c of r)if(!n.consumable.consume(c.item,e.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(r.start),i),n.mapper.bindElementToMarker(i,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),o),n.mapper.bindElementToMarker(o,t.markerName)),e.stop()}}function bf(){return(s,e,t)=>{const n=t.mapper.markerNameToElements(e.markerName);if(n){for(const i of n)t.mapper.unbindElementFromMarkerName(i,e.markerName),t.writer.clear(t.writer.createRangeOn(i),i);t.writer.clearClonedElementsGroup(e.markerName),s.stop()}}}function _f(s){return(e,t,n)=>{const i=s(t.markerName,n);if(!i)return;const o=t.markerRange;n.consumable.consume(o,e.name)&&(Lo(o,!1,n,t,i),Lo(o,!0,n,t,i),e.stop())}}function Lo(s,e,t,n,i){const o=e?s.start:s.end,r=o.nodeAfter&&o.nodeAfter.is("element")?o.nodeAfter:null,a=o.nodeBefore&&o.nodeBefore.is("element")?o.nodeBefore:null;if(r||a){let c,d;e&&r||!e&&!a?(c=r,d=!0):(c=a,d=!1);const u=t.mapper.toViewElement(c);if(u){vf(u,e,d,t,n,i);return}}const l=t.mapper.toViewPosition(o);yf(l,e,t,n,i)}function vf(s,e,t,n,i,o){const r=`data-${o.group}-${e?"start":"end"}-${t?"before":"after"}`,a=s.hasAttribute(r)?s.getAttribute(r).split(","):[];a.unshift(o.name),n.writer.setAttribute(r,a.join(","),s),n.mapper.bindElementToMarker(s,i.markerName)}function yf(s,e,t,n,i){const o=`${i.group}-${e?"start":"end"}`,r=i.name?{name:i.name}:null,a=t.writer.createUIElement(o,r);t.writer.insert(s,a),t.mapper.bindElementToMarker(a,n.markerName)}function Cf(s){return(e,t,n)=>{const i=s(t.markerName,n);if(!i)return;const o=n.mapper.markerNameToElements(t.markerName);if(!o)return;for(const a of o)n.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("containerElement")?(r(`data-${i.group}-start-before`,a),r(`data-${i.group}-start-after`,a),r(`data-${i.group}-end-before`,a),r(`data-${i.group}-end-after`,a)):n.writer.clear(n.writer.createRangeOn(a),a);n.writer.clearClonedElementsGroup(t.markerName),e.stop();function r(a,l){if(l.hasAttribute(a)){const c=new Set(l.getAttribute(a).split(","));c.delete(i.name),c.size==0?n.writer.removeAttribute(a,l):n.writer.setAttribute(a,Array.from(c).join(","),l)}}}}function kf(s){return(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const i=s(t.attributeOldValue,n,t),o=s(t.attributeNewValue,n,t);if(!i&&!o)return;n.consumable.consume(t.item,e.name);const r=n.mapper.toViewElement(t.item),a=n.writer;if(!r)throw new m("conversion-attribute-to-attribute-on-text",n.dispatcher,t);if(t.attributeOldValue!==null&&i)if(i.key=="class"){const l=se(i.value);for(const c of l)a.removeClass(c,r)}else if(i.key=="style"){const l=Object.keys(i.value);for(const c of l)a.removeStyle(c,r)}else a.removeAttribute(i.key,r);if(t.attributeNewValue!==null&&o)if(o.key=="class"){const l=se(o.value);for(const c of l)a.addClass(c,r)}else if(o.key=="style"){const l=Object.keys(o.value);for(const c of l)a.setStyle(c,o.value[c],r)}else a.setAttribute(o.key,o.value,r)}}function Ef(s){return(e,t,n)=>{if(!t.item||!(t.item instanceof ge||t.item instanceof Ae)&&!t.item.is("$textProxy"))return;const i=xs(s,t,n);if(!i||!n.consumable.consume(t.item,e.name))return;const o=n.writer,r=$l(o,i),a=o.document.selection;if(t.item instanceof ge||t.item instanceof Ae)o.wrap(a.getFirstRange(),r);else{const l=n.mapper.toViewRange(t.range),c=o.wrap(l,r);for(const d of c.getItems())if(d.is("attributeElement")&&d.isSimilar(r)){n.mapper.bindElementToMarker(d,t.markerName);break}}}}function Tf(s){return(e,t,n)=>{if(!t.item||!(t.item instanceof B))return;const i=xs(s,t,n);if(!i||!n.consumable.test(t.item,e.name))return;const o=n.mapper.toViewElement(t.item);if(o&&o.getCustomProperty("addHighlight")){n.consumable.consume(t.item,e.name);for(const a of p._createIn(t.item))n.consumable.consume(a.item,e.name);o.getCustomProperty("addHighlight")(o,i,n.writer),n.mapper.bindElementToMarker(o,t.markerName)}}}function Af(s){return(e,t,n)=>{if(t.markerRange.isCollapsed)return;const i=xs(s,t,n);if(!i)return;const o=$l(n.writer,i),r=n.mapper.markerNameToElements(t.markerName);if(r){for(const a of r)n.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(a),o):a.getCustomProperty("removeHighlight")(a,i.id,n.writer);n.writer.clearClonedElementsGroup(t.markerName),e.stop()}}}function Sf(s){const e=ql(s.model),t=ln(s.view,"container");return e.attributes.length&&(e.children=!0),n=>{n.on(`insert:${e.name}`,gf(t,Gl(e)),{priority:s.converterPriority||"normal"}),(e.children||e.attributes.length)&&n.on("reduceChanges",Kl(e),{priority:"low"})}}function Pf(s){const e=ql(s.model),t=ln(s.view,"container");return e.children=!0,n=>{if(n._conversionApi.schema.checkChild(e.name,"$text"))throw new m("conversion-element-to-structure-disallowed-text",n,{elementName:e.name});n.on(`insert:${e.name}`,pf(t,Gl(e)),{priority:s.converterPriority||"normal"}),n.on("reduceChanges",Kl(e),{priority:"low"})}}function xf(s){s=vt(s);let e=s.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const i of e.values)s.view[i]=ln(s.view[i],"attribute");else s.view=ln(s.view,"attribute");const n=jl(s);return i=>{i.on(t,mf(n),{priority:s.converterPriority||"normal"})}}function If(s){s=vt(s);let e=s.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const i of e.values)s.view[i]=zo(s.view[i]);else s.view=zo(s.view);const n=jl(s);return i=>{i.on(t,kf(n),{priority:s.converterPriority||"normal"})}}function Rf(s){const e=ln(s.view,"ui");return t=>{t.on(`addMarker:${s.model}`,wf(e),{priority:s.converterPriority||"normal"}),t.on(`removeMarker:${s.model}`,bf(),{priority:s.converterPriority||"normal"})}}function Mf(s){s=vt(s);const e=s.model;let t=s.view;return t||(t=n=>({group:e,name:n.substr(s.model.length+1)})),n=>{n.on(`addMarker:${e}`,_f(t),{priority:s.converterPriority||"normal"}),n.on(`removeMarker:${e}`,Cf(t),{priority:s.converterPriority||"normal"})}}function Vf(s){return e=>{e.on(`addMarker:${s.model}`,Ef(s.view),{priority:s.converterPriority||"normal"}),e.on(`addMarker:${s.model}`,Tf(s.view),{priority:s.converterPriority||"normal"}),e.on(`removeMarker:${s.model}`,Af(s.view),{priority:s.converterPriority||"normal"})}}function ql(s){return typeof s=="string"&&(s={name:s}),s.attributes?Array.isArray(s.attributes)||(s.attributes=[s.attributes]):s.attributes=[],s.children=!!s.children,s}function ln(s,e){return typeof s=="function"?s:(t,n)=>Of(s,n,e)}function Of(s,e,t){typeof s=="string"&&(s={name:s});let n;const i=e.writer,o=Object.assign({},s.attributes);if(t=="container")n=i.createContainerElement(s.name,o);else if(t=="attribute"){const r={priority:s.priority||gt.DEFAULT_PRIORITY};n=i.createAttributeElement(s.name,o,r)}else n=i.createUIElement(s.name,o);if(s.styles){const r=Object.keys(s.styles);for(const a of r)i.setStyle(a,s.styles[a],n)}if(s.classes){const r=s.classes;if(typeof r=="string")i.addClass(r,n);else for(const a of r)i.addClass(a,n)}return n}function jl(s){return s.model.values?(e,t,n)=>{const i=s.view[e];return i?i(e,t,n):null}:s.view}function zo(s){return typeof s=="string"?e=>({key:s,value:e}):typeof s=="object"?s.value?()=>s:e=>({key:s.key,value:e}):s}function xs(s,e,t){const n=typeof s=="function"?s(e,t):s;return n?(n.priority||(n.priority=10),n.id||(n.id=e.markerName),n):null}function Df(s){return(e,t)=>{if(!e.is("element",s.name))return!1;if(t.type=="attribute"){if(s.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(s.children)return!0}return!1}}function Kl(s){const e=Df(s);return(t,n)=>{const i=[];n.reconvertedElements||(n.reconvertedElements=new Set);for(const o of n.changes){const r=o.type=="attribute"?o.range.start.nodeAfter:o.position.parent;if(!r||!e(r,o)){i.push(o);continue}if(!n.reconvertedElements.has(r)){n.reconvertedElements.add(r);const a=b._createBefore(r);let l=i.length;for(let c=i.length-1;c>=0;c--){const d=i[c],h=(d.type=="attribute"?d.range.start:d.position).compareWith(a);if(h=="before"||d.type=="remove"&&h=="same")break;l=c}i.splice(l,0,{type:"remove",name:r.name,position:a,length:1},{type:"reinsert",name:r.name,position:a,length:1})}}n.changes=i}}function Gl(s){return(e,t,n={})=>{const i=["insert"];for(const o of s.attributes)e.hasAttribute(o)&&i.push(`attribute:${o}`);return i.every(o=>t.test(e,o))?(n.preflight||i.forEach(o=>t.consume(e,o)),!0):!1}}function Nf(s,e,t){return(n,i)=>{const o=n.createContainerElement("$slot");let r=null;if(i==="children")r=Array.from(s.getChildren());else if(typeof i=="function")r=Array.from(s.getChildren()).filter(a=>i(a));else throw new m("conversion-slot-mode-unknown",t.dispatcher,{modeOrFilter:i});return e.set(o,r),o}}function Bf(s,e,t){const n=Array.from(e.values()).flat(),i=new Set(n);if(i.size!=n.length)throw new m("conversion-slot-filter-overlap",t.dispatcher,{element:s});if(i.size!=s.childCount)throw new m("conversion-slot-filter-incomplete",t.dispatcher,{element:s})}function Ff(s,e,t,n){t.mapper.on("modelToViewPosition",r,{priority:"highest"});let i=null,o=null;for([i,o]of e)Jl(s,o,t,n),t.writer.move(t.writer.createRangeIn(i),t.writer.createPositionBefore(i)),t.writer.remove(i);t.mapper.off("modelToViewPosition",r);function r(a,l){const c=l.modelPosition.nodeAfter,d=o.indexOf(c);d<0||(l.viewPosition=l.mapper.findPositionIn(i,d))}}function Jl(s,e,t,n){for(const i of e)Lf(s.root,i,t,n)||t.convertItem(i)}function Lf(s,e,t,n){const{writer:i,mapper:o}=t;if(!n.reconversion)return!1;const r=o.toViewElement(e);return!r||r.root==s||!t.canReuseView(r)?!1:(i.move(i.createRangeOn(r),o.toViewPosition(b._createBefore(e))),!0)}function zf(s,e,{preflight:t}={}){return t?e.test(s,"insert"):e.consume(s,"insert")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ql(s){const{schema:e,document:t}=s.model;for(const n of t.getRootNames()){const i=t.getRoot(n);if(i.isEmpty&&!e.checkChild(i,"$text")&&e.checkChild(i,"paragraph"))return s.insertElement("paragraph",i),!0}return!1}function Yl(s,e,t){const n=t.createContext(s);return!(!t.checkChild(n,"paragraph")||!t.checkChild(n.push("paragraph"),e))}function Zl(s,e){const t=e.createElement("paragraph");return e.insert(t,s),e.createPositionAt(t,0)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hf extends Hl{elementToElement(e){return this.add(Xl(e))}elementToAttribute(e){return this.add($f(e))}attributeToAttribute(e){return this.add(qf(e))}elementToMarker(e){return this.add(jf(e))}dataToMarker(e){return this.add(Kf(e))}}function Ho(){return(s,e,t)=>{if(!e.modelRange&&t.consumable.consume(e.viewItem,{name:!0})){const{modelRange:n,modelCursor:i}=t.convertChildren(e.viewItem,e.modelCursor);e.modelRange=n,e.modelCursor=i}}}function Wf(){return(s,e,{schema:t,consumable:n,writer:i})=>{let o=e.modelCursor;if(!n.test(e.viewItem))return;if(!t.checkChild(o,"$text")){if(!Yl(o,"$text",t)||e.viewItem.data.trim().length==0)return;const a=o.nodeBefore;o=Zl(o,i),a&&a.is("element","$marker")&&(i.move(i.createRangeOn(a),o),o=i.createPositionAfter(a))}n.consume(e.viewItem);const r=i.createText(e.viewItem.data);i.insert(r,o),e.modelRange=i.createRange(o,o.getShiftedBy(r.offsetSize)),e.modelCursor=e.modelRange.end}}function Uf(s,e){return(t,n)=>{const i=n.newSelection,o=[];for(const a of i.getRanges())o.push(e.toModelRange(a));const r=s.createSelection(o,{backward:i.isBackward});r.isEqual(s.document.selection)||s.change(a=>{a.setSelection(r)})}}function Xl(s){s=vt(s);const e=Zi(s),t=Is(s.view),n=t?`element:${t}`:"element";return i=>{i.on(n,e,{priority:s.converterPriority||"normal"})}}function $f(s){s=vt(s),ec(s);const e=tc(s,!1),t=Is(s.view),n=t?`element:${t}`:"element";return i=>{i.on(n,e,{priority:s.converterPriority||"low"})}}function qf(s){s=vt(s);let e=null;(typeof s.view=="string"||s.view.key)&&(e=Qf(s)),ec(s,e);const t=tc(s,!0);return n=>{n.on("element",t,{priority:s.converterPriority||"low"})}}function jf(s){const e=Xf(s.model);return Xl({...s,model:e})}function Kf(s){s=vt(s),s.model||(s.model=i=>i?s.view+":"+i:s.view);const e={view:s.view,model:s.model},t=Zi(Wo(e,"start")),n=Zi(Wo(e,"end"));return i=>{i.on(`element:${s.view}-start`,t,{priority:s.converterPriority||"normal"}),i.on(`element:${s.view}-end`,n,{priority:s.converterPriority||"normal"});const o=tt.get("low"),r=tt.get("highest"),a=tt.get(s.converterPriority)/r;i.on("element",Gf(e),{priority:o+a})}}function Gf(s){return(e,t,n)=>{const i=`data-${s.view}`;if(!n.consumable.test(t.viewItem,{attributes:i+"-end-after"})&&!n.consumable.test(t.viewItem,{attributes:i+"-start-after"})&&!n.consumable.test(t.viewItem,{attributes:i+"-end-before"})&&!n.consumable.test(t.viewItem,{attributes:i+"-start-before"}))return;t.modelRange||Object.assign(t,n.convertChildren(t.viewItem,t.modelCursor)),n.consumable.consume(t.viewItem,{attributes:i+"-end-after"})&&o(t.modelRange.end,t.viewItem.getAttribute(i+"-end-after").split(",")),n.consumable.consume(t.viewItem,{attributes:i+"-start-after"})&&o(t.modelRange.end,t.viewItem.getAttribute(i+"-start-after").split(",")),n.consumable.consume(t.viewItem,{attributes:i+"-end-before"})&&o(t.modelRange.start,t.viewItem.getAttribute(i+"-end-before").split(",")),n.consumable.consume(t.viewItem,{attributes:i+"-start-before"})&&o(t.modelRange.start,t.viewItem.getAttribute(i+"-start-before").split(","));function o(r,a){for(const l of a){const c=s.model(l,n),d=n.writer.createElement("$marker",{"data-name":c});n.writer.insert(d,r),t.modelCursor.isEqual(r)?t.modelCursor=t.modelCursor.getShiftedBy(1):t.modelCursor=t.modelCursor._getTransformedByInsertion(r,1),t.modelRange=t.modelRange._getTransformedByInsertion(r,1)[0]}}}}function Is(s){return typeof s=="string"?s:typeof s=="object"&&typeof s.name=="string"?s.name:null}function Zi(s){const e=new Fe(s.view);return(t,n,i)=>{const o=e.match(n.viewItem);if(!o)return;const r=o.match;if(r.name=!0,!i.consumable.test(n.viewItem,r))return;const a=Jf(s.model,n.viewItem,i);a&&i.safeInsert(a,n.modelCursor)&&(i.consumable.consume(n.viewItem,r),i.convertChildren(n.viewItem,a),i.updateConversionResult(a,n))}}function Jf(s,e,t){return s instanceof Function?s(e,t):t.writer.createElement(s)}function Qf(s){typeof s.view=="string"&&(s.view={key:s.view});const e=s.view.key;let t;if(e=="class"||e=="style")t={[e=="class"?"classes":"styles"]:s.view.value};else{const n=typeof s.view.value>"u"?/[\s\S]*/:s.view.value;t={attributes:{[e]:n}}}return s.view.name&&(t.name=s.view.name),s.view=t,e}function ec(s,e=null){const t=e===null?!0:o=>o.getAttribute(e),n=typeof s.model!="object"?s.model:s.model.key,i=typeof s.model!="object"||typeof s.model.value>"u"?t:s.model.value;s.model={key:n,value:i}}function tc(s,e){const t=new Fe(s.view);return(n,i,o)=>{if(!i.modelRange&&e)return;const r=t.match(i.viewItem);if(!r||(Yf(s.view,i.viewItem)?r.match.name=!0:delete r.match.name,!o.consumable.test(i.viewItem,r.match)))return;const a=s.model.key,l=typeof s.model.value=="function"?s.model.value(i.viewItem,o):s.model.value;if(l===null)return;i.modelRange||Object.assign(i,o.convertChildren(i.viewItem,i.modelCursor)),Zf(i.modelRange,{key:a,value:l},e,o)&&(o.consumable.test(i.viewItem,{name:!0})&&(r.match.name=!0),o.consumable.consume(i.viewItem,r.match))}}function Yf(s,e){const t=typeof s=="function"?s(e):s;return typeof t=="object"&&!Is(t)?!1:!t.classes&&!t.attributes&&!t.styles}function Zf(s,e,t,n){let i=!1;for(const o of Array.from(s.getItems({shallow:t})))n.schema.checkAttribute(o,e.key)&&(i=!0,!o.hasAttribute(e.key)&&n.writer.setAttribute(e.key,e.value,o));return i}function Xf(s){return(e,t)=>{const n=typeof s=="string"?s:s(e,t);return t.writer.createElement("$marker",{"data-name":n})}}function Wo(s,e){const t=(n,i)=>{const o=n.getAttribute("name"),r=s.model(o,i);return i.writer.createElement("$marker",{"data-name":r})};return{view:`${s.view}-${e}`,model:t}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function em(s){s.document.registerPostFixer(e=>tm(e,s))}function tm(s,e){const t=e.document.selection,n=e.schema,i=[];let o=!1;for(const r of t.getRanges()){const a=nc(r,n);a&&!a.isEqual(r)?(i.push(a),o=!0):i.push(r)}return o&&s.setSelection(om(i),{backward:t.isBackward}),!1}function nc(s,e){return s.isCollapsed?nm(s,e):im(s,e)}function nm(s,e){const t=s.start,n=e.getNearestSelectionRange(t);if(!n){const o=t.getAncestors().reverse().find(r=>e.isObject(r));return o?p._createOn(o):null}if(!n.isCollapsed)return n;const i=n.start;return t.isEqual(i)?null:new p(i)}function im(s,e){const{start:t,end:n}=s,i=e.checkChild(t,"$text"),o=e.checkChild(n,"$text"),r=e.getLimitElement(t),a=e.getLimitElement(n);if(r===a){if(i&&o)return null;if(sm(t,n,e)){const u=t.nodeAfter&&e.isSelectable(t.nodeAfter)?null:e.getNearestSelectionRange(t,"forward"),f=n.nodeBefore&&e.isSelectable(n.nodeBefore)?null:e.getNearestSelectionRange(n,"backward"),g=u?u.start:t,w=f?f.end:n;return new p(g,w)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const d=t.nodeAfter&&n.nodeBefore&&t.nodeAfter.parent===n.nodeBefore.parent,u=l&&(!d||!$o(t.nodeAfter,e)),h=c&&(!d||!$o(n.nodeBefore,e));let f=t,g=n;return u&&(f=b._createBefore(Uo(r,e))),h&&(g=b._createAfter(Uo(a,e))),new p(f,g)}return null}function Uo(s,e){let t=s,n=t;for(;e.isLimit(n)&&n.parent;)t=n,n=n.parent;return t}function sm(s,e,t){const n=s.nodeAfter&&!t.isLimit(s.nodeAfter)||t.checkChild(s,"$text"),i=e.nodeBefore&&!t.isLimit(e.nodeBefore)||t.checkChild(e,"$text");return n||i}function om(s){const e=[...s],t=new Set;let n=1;for(;n<e.length;){const o=e[n],r=e.slice(0,n);for(const[a,l]of r.entries())if(!t.has(a)){if(o.isEqual(l))t.add(a);else if(o.isIntersecting(l)){t.add(a),t.add(n);const c=o.getJoined(l);e.push(c)}}n++}return e.filter((o,r)=>!t.has(r))}function $o(s,e){return s&&e.isSelectable(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rm extends D(){constructor(e,t){super(),this.model=e,this.view=new Kh(t),this.mapper=new Fl,this.downcastDispatcher=new Ll({mapper:this.mapper,schema:e.schema});const n=this.model.document,i=n.selection,o=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(n,"change",()=>{this.view.change(r=>{this.downcastDispatcher.convertChanges(n.differ,o,r),this.downcastDispatcher.convertSelection(i,o,r)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",Uf(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",am(this.mapper,this.model.schema,this.view),{priority:"high"}),this.downcastDispatcher.on("insert:$text",Wl(),{priority:"lowest"}),this.downcastDispatcher.on("insert",Ul(),{priority:"lowest"}),this.downcastDispatcher.on("remove",df(),{priority:"low"}),this.downcastDispatcher.on("selection",ff(),{priority:"high"}),this.downcastDispatcher.on("selection",uf(),{priority:"low"}),this.downcastDispatcher.on("selection",hf(),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(r=>{if(r.rootName=="$graveyard")return null;const a=new El(this.view.document,r.name);return a.rootName=r.rootName,this.mapper.bindElements(r,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 m("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)})}}function am(s,e,t){return(n,i)=>{if(!(t.document.isComposing&&!P.isAndroid))for(let o=0;o<i.targetRanges.length;o++){const r=i.targetRanges[o],a=s.toModelRange(r),l=nc(a,e);!l||l.isEqual(a)||(i.targetRanges[o]=s.toViewRange(l))}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class sn{constructor(){this._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 lm(e),this._consumables.set(e,n)),n.add(t)}test(e,t){const n=this._consumables.get(e);return n===void 0?null:e.is("$text")||e.is("documentFragment")?n:n.test(t)}consume(e,t){return this.test(e,t)?(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0):!1}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(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},n=e.getAttributeKeys();for(const r of n)r=="style"||r=="class"||t.attributes.push(r);const i=e.getClassNames();for(const r of i)t.classes.push(r);const o=e.getStyleNames();for(const r of o)t.styles.push(r);return t}static createFrom(e,t){if(t||(t=new sn),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,sn.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const n of e.getChildren())t=sn.createFrom(n,t);return t}}const yn=["attributes","classes","styles"];class lm{constructor(e){this.element=e,this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}add(e){e.name&&(this._canConsumeName=!0);for(const t of yn)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t of yn)if(t in e){const n=this._test(t,e[t]);if(n!==!0)return n}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t of yn)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t of yn)t in e&&this._revert(t,e[t])}_add(e,t){const n=mn(t)?t:[t],i=this._consumables[e];for(const o of n){if(e==="attributes"&&(o==="class"||o==="style"))throw new m("viewconsumable-invalid-attribute",this);if(i.set(o,!0),e==="styles")for(const r of this.element.document.stylesProcessor.getRelatedStyles(o))i.set(r,!0)}}_test(e,t){const n=mn(t)?t:[t],i=this._consumables[e];for(const o of n)if(e==="attributes"&&(o==="class"||o==="style")){const r=o=="class"?"classes":"styles",a=this._test(r,[...this._consumables[r].keys()]);if(a!==!0)return a}else{const r=i.get(o);if(r===void 0)return null;if(!r)return!1}return!0}_consume(e,t){const n=mn(t)?t:[t],i=this._consumables[e];for(const o of n)if(e==="attributes"&&(o==="class"||o==="style")){const r=o=="class"?"classes":"styles";this._consume(r,[...this._consumables[r].keys()])}else if(i.set(o,!1),e=="styles")for(const r of this.element.document.stylesProcessor.getRelatedStyles(o))i.set(r,!1)}_revert(e,t){const n=mn(t)?t:[t],i=this._consumables[e];for(const o of n)if(e==="attributes"&&(o==="class"||o==="style")){const r=o=="class"?"classes":"styles";this._revert(r,[...this._consumables[r].keys()])}else i.get(o)===!1&&i.set(o,!0)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cm extends D(){constructor(){super(),this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,t)=>{t[0]=new wt(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new wt(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new m("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 m("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(t,e):!1}checkAttribute(e,t){const n=this.getDefinition(e.last);return n?n.allowAttributes.includes(t):!1}checkMerge(e,t){if(e instanceof b){const n=e.nodeBefore,i=e.nodeAfter;if(!(n instanceof B))throw new m("schema-check-merge-no-element-before",this);if(!(i instanceof B))throw new m("schema-check-merge-no-element-after",this);return this.checkMerge(n,i)}for(const n of t.getChildren())if(!this.checkChild(e,n))return!1;return!0}addChildCheck(e){this.on("checkChild",(t,[n,i])=>{if(!i)return;const o=e(n,i);typeof o=="boolean"&&(t.stop(),t.return=o)},{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",(t,[n,i])=>{const o=e(n,i);typeof o=="boolean"&&(t.stop(),t.return=o)},{priority:"high"})}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||{}}getLimitElement(e){let t;for(e instanceof b?t=e.parent:t=(e instanceof p?[e]:Array.from(e.getRanges())).reduce((i,o)=>{const r=o.getCommonAncestor();return i?i.getCommonAncestor(r,{includeSelf:!0}):r},null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new q("",e.getAttributes())];return this.checkAttribute(i,t)}else{const n=e.getRanges();for(const i of n)for(const o of i)if(this.checkAttribute(o.item,t))return!0}return!1}*getValidRanges(e,t){e=Tm(e);for(const n of e)yield*this._getValidRangesForRange(n,t)}getNearestSelectionRange(e,t="both"){if(this.checkChild(e,"$text"))return new p(e);let n,i;const o=e.getAncestors().reverse().find(r=>this.isLimit(r))||e.root;(t=="both"||t=="backward")&&(n=new Re({boundaries:p._createIn(o),startPosition:e,direction:"backward"})),(t=="both"||t=="forward")&&(i=new Re({boundaries:p._createIn(o),startPosition:e}));for(const r of Em(n,i)){const a=r.walker==n?"elementEnd":"elementStart",l=r.value;if(l.type==a&&this.isObject(l.item))return p._createOn(l.item);if(this.checkChild(l.nextPosition,"$text"))return new p(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 i=n.model;for(const[o,r]of Object.entries(t))i.schema.checkAttribute(e,o)&&n.setAttribute(o,r,e)}removeDisallowedAttributes(e,t){for(const n of e)if(n.is("$text"))qo(this,n,t);else{const o=p._createIn(n).getPositions();for(const r of o){const a=r.nodeBefore||r.parent;qo(this,a,t)}}}getAttributesWithProperty(e,t,n){const i={};for(const[o,r]of e.getAttributes()){const a=this.getAttributeProperties(o);a[t]!==void 0&&(n===void 0||n===a[t])&&(i[o]=r)}return i}createContext(e){return new wt(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,n=Object.keys(t);for(const i of n)e[i]=dm(t[i],i);for(const i of n)um(e,i);for(const i of n)hm(e,i);for(const i of n)fm(e,i);for(const i of n)mm(e,i),gm(e,i);for(const i of n)pm(e,i),wm(e,i),bm(e,i);this._compiledDefinitions=e}_checkContextMatch(e,t,n=t.length-1){const i=t.getItem(n);if(e.allowIn.includes(i.name)){if(n==0)return!0;{const o=this.getDefinition(i);return this._checkContextMatch(o,t,n-1)}}else return!1}*_getValidRangesForRange(e,t){let n=e.start,i=e.start;for(const o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(p._createIn(o),t)),this.checkAttribute(o,t)||(n.isEqual(i)||(yield new p(n,i)),n=b._createAfter(o)),i=b._createAfter(o);n.isEqual(i)||(yield new p(n,i))}}class wt{constructor(e){if(e instanceof wt)return e;let t;typeof e=="string"?t=[e]:Array.isArray(e)?t=e:t=e.getAncestors({includeSelf:!0}),this._items=t.map(km)}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 wt([e]);return t._items=[...this._items,...t._items],t}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function dm(s,e){const t={name:e,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return _m(s,t),ut(s,t,"allowIn"),ut(s,t,"allowContentOf"),ut(s,t,"allowWhere"),ut(s,t,"allowAttributes"),ut(s,t,"allowAttributesOf"),ut(s,t,"allowChildren"),ut(s,t,"inheritTypesFrom"),vm(s,t),t}function um(s,e){const t=s[e];for(const n of t.allowChildren){const i=s[n];i&&i.allowIn.push(e)}t.allowChildren.length=0}function hm(s,e){for(const t of s[e].allowContentOf)s[t]&&ym(s,t).forEach(i=>{i.allowIn.push(e)});delete s[e].allowContentOf}function fm(s,e){for(const t of s[e].allowWhere){const n=s[t];if(n){const i=n.allowIn;s[e].allowIn.push(...i)}}delete s[e].allowWhere}function mm(s,e){for(const t of s[e].allowAttributesOf){const n=s[t];if(n){const i=n.allowAttributes;s[e].allowAttributes.push(...i)}}delete s[e].allowAttributesOf}function gm(s,e){const t=s[e];for(const n of t.inheritTypesFrom){const i=s[n];if(i){const o=Object.keys(i).filter(r=>r.startsWith("is"));for(const r of o)r in t||(t[r]=i[r])}}delete t.inheritTypesFrom}function pm(s,e){const t=s[e],n=t.allowIn.filter(i=>s[i]);t.allowIn=Array.from(new Set(n))}function wm(s,e){const t=s[e];for(const n of t.allowIn)s[n].allowChildren.push(e)}function bm(s,e){const t=s[e];t.allowAttributes=Array.from(new Set(t.allowAttributes))}function _m(s,e){for(const t of s){const n=Object.keys(t).filter(i=>i.startsWith("is"));for(const i of n)e[i]=!!t[i]}}function ut(s,e,t){for(const n of s){const i=n[t];typeof i=="string"?e[t].push(i):Array.isArray(i)&&e[t].push(...i)}}function vm(s,e){for(const t of s){const n=t.inheritAllFrom;n&&(e.allowContentOf.push(n),e.allowWhere.push(n),e.allowAttributesOf.push(n),e.inheritTypesFrom.push(n))}}function ym(s,e){const t=s[e];return Cm(s).filter(n=>n.allowIn.includes(t.name))}function Cm(s){return Object.keys(s).map(e=>s[e])}function km(s){return typeof s=="string"||s.is("documentFragment")?{name:typeof s=="string"?s:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:s.is("element")?s.name:"$text",*getAttributeKeys(){yield*s.getAttributeKeys()},getAttribute(e){return s.getAttribute(e)}}}function*Em(s,e){let t=!1;for(;!t;){if(t=!0,s){const n=s.next();n.done||(t=!1,yield{walker:s,value:n.value})}if(e){const n=e.next();n.done||(t=!1,yield{walker:e,value:n.value})}}}function*Tm(s){for(const e of s)yield*e.getMinimalFlatRanges()}function qo(s,e,t){for(const n of e.getAttributeKeys())s.checkAttribute(e,n)||t.removeAttribute(n,e)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Am extends H(){constructor(e){super(),this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this._emptyElementsToKeep=new Set,this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(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=Pm(n,t),this.conversionApi.writer=t,this.conversionApi.consumable=sn.createFrom(e),this.conversionApi.store={};const{modelRange:i}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(i){this._removeEmptyElements();for(const r of Array.from(this._modelCursor.parent.getChildren()))t.append(r,o);o.markers=Sm(o,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_convertItem(e,t){const n={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,n,this.conversionApi):e.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof p))throw new m("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(e,t){let n=t.is("position")?t:b._createAt(t,0);const i=new p(n);for(const o of Array.from(e.getChildren())){const r=this._convertItem(o,n);r.modelRange instanceof p&&(i.end=r.modelRange.end,n=r.modelCursor)}return{modelRange:i,modelCursor:n}}_safeInsert(e,t){const n=this._splitToAllowedParent(e,t);return n?(this.conversionApi.writer.insert(e,n.position),!0):!1}_updateConversionResult(e,t){const n=this._getSplitParts(e),i=this.conversionApi.writer;t.modelRange||(t.modelRange=i.createRange(i.createPositionBefore(e),i.createPositionAfter(n[n.length-1])));const o=this._cursorParents.get(e);o?t.modelCursor=i.createPositionAt(o,0):t.modelCursor=t.modelRange.end}_splitToAllowedParent(e,t){const{schema:n,writer:i}=this.conversionApi;let o=n.findAllowedParent(t,e);if(o){if(o===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return Yl(t,e,n)?{position:Zl(t,i)}:null;const r=this.conversionApi.writer.split(t,o),a=[];for(const c of r.range.getWalker())if(c.type=="elementEnd")a.push(c.item);else{const d=a.pop(),u=c.item;this._registerSplitPair(d,u)}const l=r.range.end.parent;return this._cursorParents.set(e,l),{position:r.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(){let e=!1;for(const t of this._splitParts.keys())t.isEmpty&&!this._emptyElementsToKeep.has(t)&&(this.conversionApi.writer.remove(t),this._splitParts.delete(t),e=!0);e&&this._removeEmptyElements()}}function Sm(s,e){const t=new Set,n=new Map,i=p._createIn(s).getItems();for(const o of i)o.is("element","$marker")&&t.add(o);for(const o of t){const r=o.getAttribute("data-name"),a=e.createPositionBefore(o);n.has(r)?n.get(r).end=a.clone():n.set(r,new p(a.clone())),e.remove(o)}return n}function Pm(s,e){let t;for(const n of new wt(s)){const i={};for(const r of n.getAttributeKeys())i[r]=n.getAttribute(r);const o=e.createElement(n.name,i);t&&e.insert(o,t),t=b._createAt(o,0)}return t}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class xm{getHtml(e){const n=document.implementation.createHTMLDocument("").createElement("div");return n.appendChild(e),n.innerHTML}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Im{constructor(e){this.skipComments=!0,this.domParser=new DOMParser,this.domConverter=new ni(e,{renderingMode:"data"}),this.htmlWriter=new xm}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){e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(e=`<body>${e}</body>`);const t=this.domParser.parseFromString(e,"text/html"),n=t.createDocumentFragment(),i=t.body.childNodes;for(;i.length>0;)n.appendChild(i[0]);return n}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rm extends H(){constructor(e,t){super(),this.model=e,this.mapper=new Fl,this.downcastDispatcher=new Ll({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",Wl(),{priority:"lowest"}),this.downcastDispatcher.on("insert",Ul(),{priority:"lowest"}),this.upcastDispatcher=new Am({schema:e.schema}),this.viewDocument=new ei(t),this.stylesProcessor=t,this.htmlProcessor=new Im(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Pl(this.viewDocument),this.upcastDispatcher.on("text",Wf(),{priority:"lowest"}),this.upcastDispatcher.on("element",Ho(),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",Ho(),{priority:"lowest"}),D().prototype.decorate.call(this,"init"),D().prototype.decorate.call(this,"set"),D().prototype.decorate.call(this,"get"),D().prototype.decorate.call(this,"toView"),D().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},Ql)},{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:n="empty"}=e;if(!this._checkIfRootsExists([t]))throw new m("datacontroller-get-non-existent-root",this);const i=this.model.document.getRoot(t);return i.isAttached()||K("datacontroller-get-detached-root",this),n==="empty"&&!this.model.hasContent(i,{ignoreWhitespaces:!0})?"":this.stringify(i,e)}stringify(e,t={}){const n=this.toView(e,t);return this.processor.toData(n)}toView(e,t={}){const n=this.viewDocument,i=this._viewWriter;this.mapper.clearBindings();const o=p._createIn(e),r=new pt(n);this.mapper.bindElements(e,r);const a=e.is("documentFragment")?e.markers:Mm(e);return this.downcastDispatcher.convert(o,a,i,t),r}init(e){if(this.model.document.version)throw new m("datacontroller-init-document-not-empty",this);let t={};if(typeof e=="string"?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new m("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},n=>{for(const i of Object.keys(t)){const o=this.model.document.getRoot(i);n.insert(this.parse(t[i],o),o,0)}}),Promise.resolve()}set(e,t={}){let n={};if(typeof e=="string"?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))throw new m("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},i=>{i.setSelection(null),i.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const o of Object.keys(n)){const r=this.model.document.getRoot(o);i.remove(i.createRangeIn(r)),i.insert(this.parse(n[o],r),r,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 Mm(s){const e=[],t=s.root.document;if(!t)return new Map;const n=p._createIn(s);for(const i of t.model.markers){const o=i.getRange(),r=o.isCollapsed,a=o.start.isEqual(n.start)||o.end.isEqual(n.end);if(r&&a)e.push([i.name,o]);else{const l=n.getIntersection(o);l&&e.push([i.name,l])}}return e.sort(([i,o],[r,a])=>{if(o.end.compareWith(a.start)!=="after")return 1;if(o.start.compareWith(a.end)!=="before")return-1;switch(o.start.compareWith(a.start)){case"before":return 1;case"after":return-1;default:switch(o.end.compareWith(a.end)){case"before":return 1;case"after":return-1;default:return r.localeCompare(i)}}}),new Map(e)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Vm{constructor(e,t){this._helpers=new Map,this._downcast=se(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=se(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 m("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:n})}for(e){if(!this._helpers.has(e))throw new m("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:n}of pi(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 pi(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 pi(e))this.for("upcast").attributeToAttribute({view:n,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:n}){if(this._helpers.has(e))throw new m("conversion-group-exists",this);const i=n?new cf(t):new Hf(t);this._helpers.set(e,i)}}function*pi(s){if(s.model.values)for(const e of s.model.values){const t={key:s.model.key,value:e},n=s.view[e],i=s.upcastAlso?s.upcastAlso[e]:void 0;yield*jo(t,n,i)}else yield*jo(s.model,s.view,s.upcastAlso)}function*jo(s,e,t){if(yield{model:s,view:e},t)for(const n of se(t))yield{model:s,view:n}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class we{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-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Rs(s,e){const t=sc(e),n=t.reduce((r,a)=>r+a.offsetSize,0),i=s.parent;un(s);const o=s.index;return i._insertChild(o,t),dn(i,o+t.length),dn(i,o),new p(s,s.getShiftedBy(n))}function ic(s){if(!s.isFlat)throw new m("operation-utils-remove-range-not-flat",this);const e=s.start.parent;un(s.start),un(s.end);const t=e._removeChildren(s.start.index,s.end.index-s.start.index);return dn(e,s.start.index),t}function cn(s,e){if(!s.isFlat)throw new m("operation-utils-move-range-not-flat",this);const t=ic(s);return e=e._getTransformedByDeletion(s.start,s.end.offset-s.start.offset),Rs(e,t)}function Om(s,e,t){un(s.start),un(s.end);for(const n of s.getItems({shallow:!0})){const i=n.is("$textProxy")?n.textNode:n;t!==null?i._setAttribute(e,t):i._removeAttribute(e),dn(i.parent,i.index)}dn(s.end.parent,s.end.index)}function sc(s){const e=[];function t(n){if(typeof n=="string")e.push(new q(n));else if(n instanceof ke)e.push(new q(n.data,n.getAttributes()));else if(n instanceof kt)e.push(n);else if(pe(n))for(const i of n)t(i)}t(s);for(let n=1;n<e.length;n++){const i=e[n],o=e[n-1];i instanceof q&&o instanceof q&&oc(i,o)&&(e.splice(n-1,2,new q(o.data+i.data,o.getAttributes())),n--)}return e}function dn(s,e){const t=s.getChild(e-1),n=s.getChild(e);if(t&&n&&t.is("$text")&&n.is("$text")&&oc(t,n)){const i=new q(t.data+n.data,t.getAttributes());s._removeChildren(e-1,2),s._insertChild(e-1,i)}}function un(s){const e=s.textNode,t=s.parent;if(e){const n=s.offset-e.startOffset,i=e.index;t._removeChildren(i,1);const o=new q(e.data.substr(0,n),e.getAttributes()),r=new q(e.data.substr(n),e.getAttributes());t._insertChild(i,[o,r])}}function oc(s,e){const t=s.getAttributes(),n=e.getAttributes();for(const i of t){if(i[1]!==e.getAttribute(i[0]))return!1;n.next()}return n.next().done}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class O extends we{constructor(e,t,n,i){super(i),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=="$graveyard"?"remove":this.sourcePosition.root.rootName=="$graveyard"?"reinsert":"move"}get affectedSelectable(){return[p._createFromPositionAndShift(this.sourcePosition,this.howMany),p._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new O(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 O(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent,n=this.sourcePosition.offset,i=this.targetPosition.offset;if(n+this.howMany>e.maxOffset)throw new m("move-operation-nodes-do-not-exist",this);if(e===t&&n<i&&i<n+this.howMany)throw new m("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&le(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())=="prefix"){const o=this.sourcePosition.path.length-1;if(this.targetPosition.path[o]>=n&&this.targetPosition.path[o]<n+this.howMany)throw new m("move-operation-node-into-itself",this)}}_execute(){cn(p._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=b.fromJSON(e.sourcePosition,t),i=b.fromJSON(e.targetPosition,t);return new this(n,e.howMany,i,e.baseVersion)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class oe extends we{constructor(e,t,n){super(n),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new tn(sc(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new tn([...this.nodes].map(n=>n._clone(!0))),t=new oe(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new b(e,[0]);return new O(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new m("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new tn([...e].map(t=>t._clone(!0))),Rs(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 o of e.nodes)o.name?n.push(B.fromJSON(o)):n.push(q.fromJSON(o));const i=new oe(b.fromJSON(e.position,t),n,e.baseVersion);return i.shouldReceiveAttributes=e.shouldReceiveAttributes,i}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class z extends we{constructor(e,t,n,i,o){super(o),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=n,this.graveyardPosition=i?i.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new b(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new p(this.splitPosition,e)}get affectedSelectable(){const e=[p._createFromPositionAndShift(this.splitPosition,0),p._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(p._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new z(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new b(e,[0]);return new Y(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 m("split-operation-position-invalid",this);if(e.parent){if(this.howMany!=e.maxOffset-this.splitPosition.offset)throw new m("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new m("split-operation-graveyard-position-invalid",this)}else throw new m("split-operation-split-in-root",this)}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)cn(p._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const n=e._clone();Rs(this.insertionPosition,n)}const t=new p(b._createAt(e,this.splitPosition.offset),b._createAt(e,e.maxOffset));cn(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 b(e.root,t,"toPrevious")}static fromJSON(e,t){const n=b.fromJSON(e.splitPosition,t),i=b.fromJSON(e.insertionPosition,t),o=e.graveyardPosition?b.fromJSON(e.graveyardPosition,t):null;return new this(n,e.howMany,i,o,e.baseVersion)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Y extends we{constructor(e,t,n,i,o){super(o),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=i.clone()}get type(){return"merge"}get deletionPosition(){return new b(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new p(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[p._createOn(e),p._createFromPositionAndShift(this.targetPosition,0),p._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new Y(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 b(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new z(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!=e.maxOffset)throw new m("merge-operation-how-many-invalid",this)}else throw new m("merge-operation-target-position-invalid",this);else throw new m("merge-operation-source-position-invalid",this)}_execute(){const e=this.sourcePosition.parent,t=p._createIn(e);cn(t,this.targetPosition),cn(p._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=b.fromJSON(e.sourcePosition,t),i=b.fromJSON(e.targetPosition,t),o=b.fromJSON(e.graveyardPosition,t);return new this(n,e.howMany,i,o,e.baseVersion)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class he extends we{constructor(e,t,n,i,o,r){super(r),this.name=e,this.oldRange=t?t.clone():null,this.newRange=n?n.clone():null,this.affectsData=o,this._markers=i}get type(){return"marker"}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 he(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new he(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 he(e.name,e.oldRange?p.fromJSON(e.oldRange,t):null,e.newRange?p.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Z extends we{constructor(e,t,n,i,o){super(o),this.range=e.clone(),this.key=t,this.oldValue=n===void 0?null:n,this.newValue=i===void 0?null:i}get type(){return this.oldValue===null?"addAttribute":this.newValue===null?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new Z(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Z(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 m("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(this.oldValue!==null&&!no(e.getAttribute(this.key),this.oldValue))throw new m("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 m("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){no(this.oldValue,this.newValue)||Om(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new Z(p.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class te extends we{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new te(this.baseVersion)}getReversed(){return new te(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fe extends we{constructor(e,t,n,i){super(i),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 fe(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new fe(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(e instanceof B){if(e.name!==this.oldName)throw new m("rename-operation-wrong-name",this)}else throw new m("rename-operation-wrong-position",this)}_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 fe(b.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $e extends we{constructor(e,t,n,i,o){super(o),this.root=e,this.key=t,this.oldValue=n===void 0?null:n,this.newValue=i===void 0?null:i}get type(){return this.oldValue===null?"addRootAttribute":this.newValue===null?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new $e(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new $e(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new m("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 m("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 m("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 m("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new $e(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Me extends we{constructor(e,t,n,i,o){if(super(o),this.rootName=e,this.elementName=t,this.isAdd=n,this._document=i,!this._document.getRoot(this.rootName)){const r=this._document.createRoot(this.elementName,this.rootName);r._isAttached=!1}}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new Me(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new Me(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_validate(){const e=this._document.getRoot(this.rootName);if(e.isAttached()&&this.isAdd)throw new m("root-operation-root-attached",this);if(!e.isAttached()&&!this.isAdd)throw new m("root-operation-root-detached",this)}_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 Me(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const ye={};ye[Z.className]=Z;ye[oe.className]=oe;ye[he.className]=he;ye[O.className]=O;ye[te.className]=te;ye[we.className]=we;ye[fe.className]=fe;ye[$e.className]=$e;ye[Me.className]=Me;ye[z.className]=z;ye[Y.className]=Y;class Dm{static fromJSON(e,t){return ye[e.__className].fromJSON(e,t)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Xi=new Map;function V(s,e,t){let n=Xi.get(s);n||(n=new Map,Xi.set(s,n)),n.set(e,t)}function Nm(s,e){const t=Xi.get(s);return t&&t.has(e)?t.get(e):Bm}function Bm(s){return[s]}function Ko(s,e,t={}){const n=Nm(s.constructor,e.constructor);try{return s=s.clone(),n(s,e,t)}catch(i){throw i}}function Fm(s,e,t){s=s.slice(),e=e.slice();const n=new Lm(t.document,t.useRelations,t.forceWeakRemove);n.setOriginalOperations(s),n.setOriginalOperations(e);const i=n.originalOperations;if(s.length==0||e.length==0)return{operationsA:s,operationsB:e,originalOperations:i};const o=new WeakMap;for(const l of s)o.set(l,0);const r={nextBaseVersionA:s[s.length-1].baseVersion+1,nextBaseVersionB:e[e.length-1].baseVersion+1,originalOperationsACount:s.length,originalOperationsBCount:e.length};let a=0;for(;a<s.length;){const l=s[a],c=o.get(l);if(c==e.length){a++;continue}const d=e[c],u=Ko(l,d,n.getContext(l,d,!0)),h=Ko(d,l,n.getContext(d,l,!1));n.updateRelation(l,d),n.setOriginalOperations(u,l),n.setOriginalOperations(h,d);for(const f of u)o.set(f,c+h.length);s.splice(a,1,...u),e.splice(c,1,...h)}if(t.padWithNoOps){const l=s.length-r.originalOperationsACount,c=e.length-r.originalOperationsBCount;Jo(s,c-l),Jo(e,l-c)}return Go(s,r.nextBaseVersionB),Go(e,r.nextBaseVersionA),{operationsA:s,operationsB:e,originalOperations:i}}class Lm{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 i of e)this.originalOperations.set(i,n||i)}updateRelation(e,t){if(e instanceof O)t instanceof Y?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"):t instanceof O&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof z){if(t instanceof Y)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof O)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const n=p._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=n.end.offset-e.splitPosition.offset,o=e.splitPosition.offset-n.start.offset;this._setRelation(e,t,{howMany:i,offset:o})}}}else if(e instanceof Y)t instanceof Y?(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 z&&e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource");else if(e instanceof he){const n=e.newRange;if(!n)return;if(t instanceof O){const i=p._createFromPositionAndShift(t.sourcePosition,t.howMany),o=i.containsPosition(n.start)||i.start.isEqual(n.start),r=i.containsPosition(n.end)||i.end.isEqual(n.end);(o||r)&&!i.containsRange(n)&&this._setRelation(e,t,{side:o?"left":"right",path:o?n.start.path.slice():n.end.path.slice()})}else if(t instanceof Y){const i=n.start.isEqual(t.targetPosition),o=n.start.isEqual(t.deletionPosition),r=n.end.isEqual(t.deletionPosition),a=n.end.isEqual(t.sourcePosition);(i||o||r||a)&&this._setRelation(e,t,{wasInLeftElement:i,wasStartBeforeMergedElement:o,wasEndBeforeMergedElement:r,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),i=this._history.getUndoneOperation(n);if(!i)return null;const o=this.originalOperations.get(e),r=this._relations.get(o);return r&&r.get(i)||null}_setRelation(e,t,n){const i=this.originalOperations.get(e),o=this.originalOperations.get(t);let r=this._relations.get(i);r||(r=new Map,this._relations.set(i,r)),r.set(o,n)}}function Go(s,e){for(const t of s)t.baseVersion=e++}function Jo(s,e){for(let t=0;t<e;t++)s.push(new te(0))}V(Z,Z,(s,e,t)=>{if(s.key===e.key&&s.range.start.hasSameParentAs(e.range.start)){const n=s.range.getDifference(e.range).map(o=>new Z(o,s.key,s.oldValue,s.newValue,0)),i=s.range.getIntersection(e.range);return i&&t.aIsStrong&&n.push(new Z(i,e.key,e.newValue,s.newValue,0)),n.length==0?[new te(0)]:n}else return[s]});V(Z,oe,(s,e)=>{if(s.range.start.hasSameParentAs(e.position)&&s.range.containsPosition(e.position)){const n=s.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map(i=>new Z(i,s.key,s.oldValue,s.newValue,s.baseVersion));if(e.shouldReceiveAttributes){const i=rc(e,s.key,s.oldValue);i&&n.unshift(i)}return n}return s.range=s.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[s]});function rc(s,e,t){const i=s.nodes.getNode(0).getAttribute(e);if(i==t)return null;const o=new p(s.position,s.position.getShiftedBy(s.howMany));return new Z(o,e,i,t,0)}V(Z,Y,(s,e)=>{const t=[];s.range.start.hasSameParentAs(e.deletionPosition)&&(s.range.containsPosition(e.deletionPosition)||s.range.start.isEqual(e.deletionPosition))&&t.push(p._createFromPositionAndShift(e.graveyardPosition,1));const n=s.range._getTransformedByMergeOperation(e);return n.isCollapsed||t.push(n),t.map(i=>new Z(i,s.key,s.oldValue,s.newValue,s.baseVersion))});V(Z,O,(s,e)=>zm(s.range,e).map(n=>new Z(n,s.key,s.oldValue,s.newValue,s.baseVersion)));function zm(s,e){const t=p._createFromPositionAndShift(e.sourcePosition,e.howMany);let n=null,i=[];t.containsRange(s,!0)?n=s:s.start.hasSameParentAs(t.start)?(i=s.getDifference(t),n=s.getIntersection(t)):i=[s];const o=[];for(let r of i){r=r._getTransformedByDeletion(e.sourcePosition,e.howMany);const a=e.getMovedRangeStart(),l=r.start.hasSameParentAs(a),c=r._getTransformedByInsertion(a,e.howMany,l);o.push(...c)}return n&&o.push(n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]),o}V(Z,z,(s,e)=>{if(s.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||s.range.end.offset++,[s];if(s.range.start.hasSameParentAs(e.splitPosition)&&s.range.containsPosition(e.splitPosition)){const t=s.clone();return t.range=new p(e.moveTargetPosition.clone(),s.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),s.range.end=e.splitPosition.clone(),s.range.end.stickiness="toPrevious",[s,t]}return s.range=s.range._getTransformedBySplitOperation(e),[s]});V(oe,Z,(s,e)=>{const t=[s];if(s.shouldReceiveAttributes&&s.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(s.position)){const n=rc(s,e.key,e.newValue);n&&t.push(n)}return t});V(oe,oe,(s,e,t)=>s.position.isEqual(e.position)&&t.aIsStrong?[s]:(s.position=s.position._getTransformedByInsertOperation(e),[s]));V(oe,O,(s,e)=>(s.position=s.position._getTransformedByMoveOperation(e),[s]));V(oe,z,(s,e)=>(s.position=s.position._getTransformedBySplitOperation(e),[s]));V(oe,Y,(s,e)=>(s.position=s.position._getTransformedByMergeOperation(e),[s]));V(he,oe,(s,e)=>(s.oldRange&&(s.oldRange=s.oldRange._getTransformedByInsertOperation(e)[0]),s.newRange&&(s.newRange=s.newRange._getTransformedByInsertOperation(e)[0]),[s]));V(he,he,(s,e,t)=>{if(s.name==e.name)if(t.aIsStrong)s.oldRange=e.newRange?e.newRange.clone():null;else return[new te(0)];return[s]});V(he,Y,(s,e)=>(s.oldRange&&(s.oldRange=s.oldRange._getTransformedByMergeOperation(e)),s.newRange&&(s.newRange=s.newRange._getTransformedByMergeOperation(e)),[s]));V(he,O,(s,e,t)=>{if(s.oldRange&&(s.oldRange=p._createFromRanges(s.oldRange._getTransformedByMoveOperation(e))),s.newRange){if(t.abRelation){const n=p._createFromRanges(s.newRange._getTransformedByMoveOperation(e));if(t.abRelation.side=="left"&&e.targetPosition.isEqual(s.newRange.start))return s.newRange.end=n.end,s.newRange.start.path=t.abRelation.path,[s];if(t.abRelation.side=="right"&&e.targetPosition.isEqual(s.newRange.end))return s.newRange.start=n.start,s.newRange.end.path=t.abRelation.path,[s]}s.newRange=p._createFromRanges(s.newRange._getTransformedByMoveOperation(e))}return[s]});V(he,z,(s,e,t)=>{if(s.oldRange&&(s.oldRange=s.oldRange._getTransformedBySplitOperation(e)),s.newRange){if(t.abRelation){const n=s.newRange._getTransformedBySplitOperation(e);return s.newRange.start.isEqual(e.splitPosition)&&t.abRelation.wasStartBeforeMergedElement?s.newRange.start=b._createAt(e.insertionPosition):s.newRange.start.isEqual(e.splitPosition)&&!t.abRelation.wasInLeftElement&&(s.newRange.start=b._createAt(e.moveTargetPosition)),s.newRange.end.isEqual(e.splitPosition)&&t.abRelation.wasInRightElement?s.newRange.end=b._createAt(e.moveTargetPosition):s.newRange.end.isEqual(e.splitPosition)&&t.abRelation.wasEndBeforeMergedElement?s.newRange.end=b._createAt(e.insertionPosition):s.newRange.end=n.end,[s]}s.newRange=s.newRange._getTransformedBySplitOperation(e)}return[s]});V(Y,oe,(s,e)=>(s.sourcePosition.hasSameParentAs(e.position)&&(s.howMany+=e.howMany),s.sourcePosition=s.sourcePosition._getTransformedByInsertOperation(e),s.targetPosition=s.targetPosition._getTransformedByInsertOperation(e),[s]));V(Y,Y,(s,e,t)=>{if(s.sourcePosition.isEqual(e.sourcePosition)&&s.targetPosition.isEqual(e.targetPosition))if(t.bWasUndone){const n=e.graveyardPosition.path.slice();return n.push(0),s.sourcePosition=new b(e.graveyardPosition.root,n),s.howMany=0,[s]}else return[new te(0)];if(s.sourcePosition.isEqual(e.sourcePosition)&&!s.targetPosition.isEqual(e.targetPosition)&&!t.bWasUndone&&t.abRelation!="splitAtSource"){const n=s.targetPosition.root.rootName=="$graveyard",i=e.targetPosition.root.rootName=="$graveyard";if(i&&!n||!(n&&!i)&&t.aIsStrong){const l=e.targetPosition._getTransformedByMergeOperation(e),c=s.targetPosition._getTransformedByMergeOperation(e);return[new O(l,s.howMany,c,0)]}else return[new te(0)]}return s.sourcePosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.sourcePosition=s.sourcePosition._getTransformedByMergeOperation(e),s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),(!s.graveyardPosition.isEqual(e.graveyardPosition)||!t.aIsStrong)&&(s.graveyardPosition=s.graveyardPosition._getTransformedByMergeOperation(e)),[s]});V(Y,O,(s,e,t)=>{const n=p._createFromPositionAndShift(e.sourcePosition,e.howMany);return e.type=="remove"&&!t.bWasUndone&&!t.forceWeakRemove&&s.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(s.sourcePosition)?[new te(0)]:(s.sourcePosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.sourcePosition.hasSameParentAs(e.sourcePosition)&&(s.howMany-=e.howMany),s.sourcePosition=s.sourcePosition._getTransformedByMoveOperation(e),s.targetPosition=s.targetPosition._getTransformedByMoveOperation(e),s.graveyardPosition.isEqual(e.targetPosition)||(s.graveyardPosition=s.graveyardPosition._getTransformedByMoveOperation(e)),[s])});V(Y,z,(s,e,t)=>{if(e.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),s.deletionPosition.isEqual(e.graveyardPosition)&&(s.howMany=e.howMany)),s.targetPosition.isEqual(e.splitPosition)){const n=e.howMany!=0,i=e.graveyardPosition&&s.deletionPosition.isEqual(e.graveyardPosition);if(n||i||t.abRelation=="mergeTargetNotMoved")return s.sourcePosition=s.sourcePosition._getTransformedBySplitOperation(e),[s]}if(s.sourcePosition.isEqual(e.splitPosition)){if(t.abRelation=="mergeSourceNotMoved")return s.howMany=0,s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s];if(t.abRelation=="mergeSameElement"||s.sourcePosition.offset>0)return s.sourcePosition=e.moveTargetPosition.clone(),s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s]}return s.sourcePosition.hasSameParentAs(e.splitPosition)&&(s.howMany=e.splitPosition.offset),s.sourcePosition=s.sourcePosition._getTransformedBySplitOperation(e),s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s]});V(O,oe,(s,e)=>{const n=p._createFromPositionAndShift(s.sourcePosition,s.howMany)._getTransformedByInsertOperation(e,!1)[0];return s.sourcePosition=n.start,s.howMany=n.end.offset-n.start.offset,s.targetPosition.isEqual(e.position)||(s.targetPosition=s.targetPosition._getTransformedByInsertOperation(e)),[s]});V(O,O,(s,e,t)=>{const n=p._createFromPositionAndShift(s.sourcePosition,s.howMany),i=p._createFromPositionAndShift(e.sourcePosition,e.howMany);let o=t.aIsStrong,r=!t.aIsStrong;t.abRelation=="insertBefore"||t.baRelation=="insertAfter"?r=!0:(t.abRelation=="insertAfter"||t.baRelation=="insertBefore")&&(r=!1);let a;if(s.targetPosition.isEqual(e.targetPosition)&&r?a=s.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):a=s.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Qo(s,e)&&Qo(e,s))return[e.getReversed()];if(n.containsPosition(e.targetPosition)&&n.containsRange(i,!0))return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Ft([n],a);if(i.containsPosition(s.targetPosition)&&i.containsRange(n,!0))return n.start=n.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),n.end=n.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),Ft([n],a);const d=le(s.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if(d=="prefix"||d=="extension")return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Ft([n],a);s.type=="remove"&&e.type!="remove"&&!t.aWasUndone&&!t.forceWeakRemove?o=!0:s.type!="remove"&&e.type=="remove"&&!t.bWasUndone&&!t.forceWeakRemove&&(o=!1);const u=[],h=n.getDifference(i);for(const g of h){g.start=g.start._getTransformedByDeletion(e.sourcePosition,e.howMany),g.end=g.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const w=le(g.start.getParentPath(),e.getMovedRangeStart().getParentPath())=="same",v=g._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,w);u.push(...v)}const f=n.getIntersection(i);return f!==null&&o&&(f.start=f.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),f.end=f.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),u.length===0?u.push(f):u.length==1?i.start.isBefore(n.start)||i.start.isEqual(n.start)?u.unshift(f):u.push(f):u.splice(1,0,f)),u.length===0?[new te(s.baseVersion)]:Ft(u,a)});V(O,z,(s,e,t)=>{let n=s.targetPosition.clone();(!s.targetPosition.isEqual(e.insertionPosition)||!e.graveyardPosition||t.abRelation=="moveTargetAfter")&&(n=s.targetPosition._getTransformedBySplitOperation(e));const i=p._createFromPositionAndShift(s.sourcePosition,s.howMany);if(i.end.isEqual(e.insertionPosition))return e.graveyardPosition||s.howMany++,s.targetPosition=n,[s];if(i.start.hasSameParentAs(e.splitPosition)&&i.containsPosition(e.splitPosition)){let a=new p(e.splitPosition,i.end);a=a._getTransformedBySplitOperation(e);const l=[new p(i.start,e.splitPosition),a];return Ft(l,n)}s.targetPosition.isEqual(e.splitPosition)&&t.abRelation=="insertAtSource"&&(n=e.moveTargetPosition),s.targetPosition.isEqual(e.insertionPosition)&&t.abRelation=="insertBetween"&&(n=s.targetPosition);const r=[i._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const a=i.start.isEqual(e.graveyardPosition)||i.containsPosition(e.graveyardPosition);s.howMany>1&&a&&!t.aWasUndone&&r.push(p._createFromPositionAndShift(e.insertionPosition,1))}return Ft(r,n)});V(O,Y,(s,e,t)=>{const n=p._createFromPositionAndShift(s.sourcePosition,s.howMany);if(e.deletionPosition.hasSameParentAs(s.sourcePosition)&&n.containsPosition(e.sourcePosition)){if(s.type=="remove"&&!t.forceWeakRemove){if(!t.aWasUndone){const r=[];let a=e.graveyardPosition.clone(),l=e.targetPosition._getTransformedByMergeOperation(e);s.howMany>1&&(r.push(new O(s.sourcePosition,s.howMany-1,s.targetPosition,0)),a=a._getTransformedByMove(s.sourcePosition,s.targetPosition,s.howMany-1),l=l._getTransformedByMove(s.sourcePosition,s.targetPosition,s.howMany-1));const c=e.deletionPosition._getCombined(s.sourcePosition,s.targetPosition),d=new O(a,1,c,0),u=d.getMovedRangeStart().path.slice();u.push(0);const h=new b(d.targetPosition.root,u);l=l._getTransformedByMove(a,c,1);const f=new O(l,e.howMany,h,0);return r.push(d),r.push(f),r}}else if(s.howMany==1)return t.bWasUndone?(s.sourcePosition=e.graveyardPosition.clone(),s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),[s]):[new te(0)]}const o=p._createFromPositionAndShift(s.sourcePosition,s.howMany)._getTransformedByMergeOperation(e);return s.sourcePosition=o.start,s.howMany=o.end.offset-o.start.offset,s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),[s]});V(fe,oe,(s,e)=>(s.position=s.position._getTransformedByInsertOperation(e),[s]));V(fe,Y,(s,e)=>s.position.isEqual(e.deletionPosition)?(s.position=e.graveyardPosition.clone(),s.position.stickiness="toNext",[s]):(s.position=s.position._getTransformedByMergeOperation(e),[s]));V(fe,O,(s,e)=>(s.position=s.position._getTransformedByMoveOperation(e),[s]));V(fe,fe,(s,e,t)=>{if(s.position.isEqual(e.position))if(t.aIsStrong)s.oldName=e.newName;else return[new te(0)];return[s]});V(fe,z,(s,e)=>{const t=s.position.path,n=e.splitPosition.getParentPath();if(le(t,n)=="same"&&!e.graveyardPosition){const i=new fe(s.position.getShiftedBy(1),s.oldName,s.newName,0);return[s,i]}return s.position=s.position._getTransformedBySplitOperation(e),[s]});V($e,$e,(s,e,t)=>{if(s.root===e.root&&s.key===e.key){if(!t.aIsStrong||s.newValue===e.newValue)return[new te(0)];s.oldValue=e.newValue}return[s]});V(Me,Me,(s,e,t)=>s.rootName===e.rootName&&s.isAdd===e.isAdd&&!t.bWasUndone?[new te(0)]:[s]);V(z,oe,(s,e)=>(s.splitPosition.hasSameParentAs(e.position)&&s.splitPosition.offset<e.position.offset&&(s.howMany+=e.howMany),s.splitPosition=s.splitPosition._getTransformedByInsertOperation(e),s.insertionPosition=s.insertionPosition._getTransformedByInsertOperation(e),[s]));V(z,Y,(s,e,t)=>{if(!s.graveyardPosition&&!t.bWasUndone&&s.splitPosition.hasSameParentAs(e.sourcePosition)){const n=e.graveyardPosition.path.slice();n.push(0);const i=new b(e.graveyardPosition.root,n),o=z.getInsertionPosition(new b(e.graveyardPosition.root,n)),r=new z(i,0,o,null,0);return s.splitPosition=s.splitPosition._getTransformedByMergeOperation(e),s.insertionPosition=z.getInsertionPosition(s.splitPosition),s.graveyardPosition=r.insertionPosition.clone(),s.graveyardPosition.stickiness="toNext",[r,s]}return s.splitPosition.hasSameParentAs(e.deletionPosition)&&!s.splitPosition.isAfter(e.deletionPosition)&&s.howMany--,s.splitPosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.splitPosition=s.splitPosition._getTransformedByMergeOperation(e),s.insertionPosition=z.getInsertionPosition(s.splitPosition),s.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedByMergeOperation(e)),[s]});V(z,O,(s,e,t)=>{const n=p._createFromPositionAndShift(e.sourcePosition,e.howMany);if(s.graveyardPosition){const o=n.start.isEqual(s.graveyardPosition)||n.containsPosition(s.graveyardPosition);if(!t.bWasUndone&&o){const r=s.splitPosition._getTransformedByMoveOperation(e),a=s.graveyardPosition._getTransformedByMoveOperation(e),l=a.path.slice();l.push(0);const c=new b(a.root,l);return[new O(r,s.howMany,c,0)]}s.graveyardPosition=s.graveyardPosition._getTransformedByMoveOperation(e)}const i=s.splitPosition.isEqual(e.targetPosition);if(i&&(t.baRelation=="insertAtSource"||t.abRelation=="splitBefore"))return s.howMany+=e.howMany,s.splitPosition=s.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),s.insertionPosition=z.getInsertionPosition(s.splitPosition),[s];if(i&&t.abRelation&&t.abRelation.howMany){const{howMany:o,offset:r}=t.abRelation;return s.howMany+=o,s.splitPosition=s.splitPosition.getShiftedBy(r),[s]}if(s.splitPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(s.splitPosition)){const o=e.howMany-(s.splitPosition.offset-e.sourcePosition.offset);return s.howMany-=o,s.splitPosition.hasSameParentAs(e.targetPosition)&&s.splitPosition.offset<e.targetPosition.offset&&(s.howMany+=e.howMany),s.splitPosition=e.sourcePosition.clone(),s.insertionPosition=z.getInsertionPosition(s.splitPosition),[s]}return e.sourcePosition.isEqual(e.targetPosition)||(s.splitPosition.hasSameParentAs(e.sourcePosition)&&s.splitPosition.offset<=e.sourcePosition.offset&&(s.howMany-=e.howMany),s.splitPosition.hasSameParentAs(e.targetPosition)&&s.splitPosition.offset<e.targetPosition.offset&&(s.howMany+=e.howMany)),s.splitPosition.stickiness="toNone",s.splitPosition=s.splitPosition._getTransformedByMoveOperation(e),s.splitPosition.stickiness="toNext",s.graveyardPosition?s.insertionPosition=s.insertionPosition._getTransformedByMoveOperation(e):s.insertionPosition=z.getInsertionPosition(s.splitPosition),[s]});V(z,z,(s,e,t)=>{if(s.splitPosition.isEqual(e.splitPosition)){if(!s.graveyardPosition&&!e.graveyardPosition)return[new te(0)];if(s.graveyardPosition&&e.graveyardPosition&&s.graveyardPosition.isEqual(e.graveyardPosition))return[new te(0)];if(t.abRelation=="splitBefore")return s.howMany=0,s.graveyardPosition=s.graveyardPosition._getTransformedBySplitOperation(e),[s]}if(s.graveyardPosition&&e.graveyardPosition&&s.graveyardPosition.isEqual(e.graveyardPosition)){const n=s.splitPosition.root.rootName=="$graveyard",i=e.splitPosition.root.rootName=="$graveyard";if(i&&!n||!(n&&!i)&&t.aIsStrong){const l=[];return e.howMany&&l.push(new O(e.moveTargetPosition,e.howMany,e.splitPosition,0)),s.howMany&&l.push(new O(s.splitPosition,s.howMany,s.moveTargetPosition,0)),l}else return[new te(0)]}if(s.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedBySplitOperation(e)),s.splitPosition.isEqual(e.insertionPosition)&&t.abRelation=="splitBefore")return s.howMany++,[s];if(e.splitPosition.isEqual(s.insertionPosition)&&t.baRelation=="splitBefore"){const n=e.insertionPosition.path.slice();n.push(0);const i=new b(e.insertionPosition.root,n),o=new O(s.insertionPosition,1,i,0);return[s,o]}return s.splitPosition.hasSameParentAs(e.splitPosition)&&s.splitPosition.offset<e.splitPosition.offset&&(s.howMany-=e.howMany),s.splitPosition=s.splitPosition._getTransformedBySplitOperation(e),s.insertionPosition=z.getInsertionPosition(s.splitPosition),[s]});function Qo(s,e){return s.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany)===null}function Ft(s,e){const t=[];for(let n=0;n<s.length;n++){const i=s[n],o=new O(i.start,i.end.offset-i.start.offset,e,0);t.push(o);for(let r=n+1;r<s.length;r++)s[r]=s[r]._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)[0];e=e._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)}return t}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class re extends H(b){constructor(e,t,n="toNone"){if(super(e,t,n),!this.root.is("rootElement"))throw new m("model-liveposition-root-not-rootelement",e);Hm.call(this)}detach(){this.stopListening()}toPosition(){return new b(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}re.prototype.is=function(s){return s==="livePosition"||s==="model:livePosition"||s=="position"||s==="model:position"};function Hm(){this.listenTo(this.root.document.model,"applyOperation",(s,e)=>{const t=e[0];t.isDocumentOperation&&Wm.call(this,t)},{priority:"low"})}function Wm(s){const e=this.getTransformedByOperation(s);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pt{constructor(e={}){typeof e=="string"&&(e=e==="transparent"?{isUndoable:!1}:{},K("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:n=!0,isUndo:i=!1,isTyping:o=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=n,this.isUndo=i,this.isTyping=o}get type(){return K("batch-type-deprecated"),"default"}get baseVersion(){for(const e of this.operations)if(e.baseVersion!==null)return e.baseVersion;return null}addOperation(e){return e.batch=this,this.operations.push(e),e}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Um{constructor(e){this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changedRoots=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set,this._markerCollection=e}get isEmpty(){return 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),i=this._isInInsertedElement(t.targetPosition.parent);n||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const n=p._createFromPositionAndShift(t.position,1);for(const i of this._markerCollection.getMarkersIntersectingRange(n)){const o=i.getData();this.bufferMarkerChange(i.name,o,o)}break}case"split":{const n=t.splitPosition.parent;this._isInInsertedElement(n)||this._markRemove(n,t.splitPosition.offset,t.howMany),this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1);break}case"merge":{const n=t.sourcePosition.parent;this._isInInsertedElement(n.parent)||this._markRemove(n.parent,n.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1);const o=t.targetPosition.parent;this._isInInsertedElement(o)||this._markInsert(o,t.targetPosition.offset,n.maxOffset);break}case"detachRoot":case"addRoot":{this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{const n=t.root.rootName;this._bufferRootAttributeChange(n,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,n){const i=this._changedMarkers.get(e);i?(i.newMarkerData=n,i.oldMarkerData.range==null&&n.range==null&&this._changedMarkers.delete(e)):this._changedMarkers.set(e,{newMarkerData:n,oldMarkerData:t})}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._changesInElement.size>0||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,i=!e.range&&t.range,o=e.range&&t.range&&!e.range.isEqual(t.range);if(n||i||o)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const n of this._changesInElement.keys()){const i=this._changesInElement.get(n).sort((d,u)=>d.offset===u.offset?d.type!=u.type?d.type=="remove"?-1:1:0:d.offset<u.offset?-1:1),o=this._elementSnapshots.get(n),r=Yo(n.getChildren()),a=$m(o.length,i);let l=0,c=0;for(const d of a)if(d==="i")t.push(this._getInsertDiff(n,l,r[l])),l++;else if(d==="r")t.push(this._getRemoveDiff(n,l,o[c])),c++;else if(d==="a"){const u=r[l].attributes,h=o[c].attributes;let f;if(r[l].name=="$text")f=new p(b._createAt(n,l),b._createAt(n,l+1));else{const g=n.offsetToIndex(l);f=new p(b._createAt(n,l),b._createAt(n.getChild(g),0))}t.push(...this._getAttributesDiff(f,h,u)),l++,c++}else l++,c++}t.sort((n,i)=>n.position.root!=i.position.root?n.position.root.rootName<i.position.root.rootName?-1:1:n.position.isEqual(i.position)?n.changeCount-i.changeCount:n.position.isBefore(i.position)?-1:1);for(let n=1,i=0;n<t.length;n++){const o=t[i],r=t[n],a=o.type=="remove"&&r.type=="remove"&&o.name=="$text"&&r.name=="$text"&&o.position.isEqual(r.position),l=o.type=="insert"&&r.type=="insert"&&o.name=="$text"&&r.name=="$text"&&o.position.parent==r.position.parent&&o.position.offset+o.length==r.position.offset,c=o.type=="attribute"&&r.type=="attribute"&&o.position.parent==r.position.parent&&o.range.isFlat&&r.range.isFlat&&o.position.offset+o.length==r.position.offset&&o.attributeKey==r.attributeKey&&o.attributeOldValue==r.attributeOldValue&&o.attributeNewValue==r.attributeNewValue;a||l||c?(o.length++,c&&(o.range.end=o.range.end.getShiftedBy(1)),t[n]=null):i=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(qm),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._elementSnapshots.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_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,i){const o=this._changedRoots.get(e)||{name:e},r=o.attributes||{};if(r[t]){const a=r[t];i===a.oldValue?delete r[t]:a.newValue=i}else r[t]={oldValue:n,newValue:i};Object.entries(r).length===0?(delete o.attributes,o.state===void 0&&this._changedRoots.delete(e)):(o.attributes=r,this._changedRoots.set(e,o))}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e);const t=p._createOn(e);for(const n of this._markerCollection.getMarkersIntersectingRange(t)){const i=n.getData();this.bufferMarkerChange(n.name,i,i)}this._cachedChanges=null}_markInsert(e,t,n){const i={type:"insert",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,i)}_markRemove(e,t,n){const i={type:"remove",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,i),this._removeAllNestedChanges(e,t,n)}_markAttribute(e){const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshot(e);const n=this._getChangesForElement(e);this._handleChange(t,n),n.push(t);for(let i=0;i<n.length;i++)n[i].howMany<1&&(n.splice(i,1),i--)}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshot(e){this._elementSnapshots.has(e)||this._elementSnapshots.set(e,Yo(e.getChildren()))}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const n of t){const i=e.offset+e.howMany,o=n.offset+n.howMany;if(e.type=="insert"&&(n.type=="insert"&&(e.offset<=n.offset?n.offset+=e.howMany:e.offset<o&&(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<o){const r=n.howMany;n.howMany=e.offset-n.offset,t.unshift({type:"attribute",offset:i,howMany:r-n.howMany,count:this._changeCount++})}}if(e.type=="remove"){if(n.type=="insert"){if(i<=n.offset)n.offset-=e.howMany;else if(i<=o)if(e.offset<n.offset){const r=i-n.offset;n.offset=e.offset,n.howMany-=r,e.nodesToHandle-=r}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<o){const r=o-e.offset;n.howMany-=r,e.nodesToHandle-=r}}if(n.type=="remove"&&(i<=n.offset?n.offset-=e.howMany:e.offset<n.offset&&(e.nodesToHandle+=n.howMany,n.howMany=0)),n.type=="attribute"){if(i<=n.offset)n.offset-=e.howMany;else if(e.offset<n.offset){const r=i-n.offset;n.offset=e.offset,n.howMany-=r}else if(e.offset<o)if(i<=o){const r=n.howMany;n.howMany=e.offset-n.offset;const a=r-n.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:a,count:this._changeCount++})}else n.howMany-=o-e.offset}}if(e.type=="attribute"){if(n.type=="insert")if(e.offset<n.offset&&i>n.offset){if(i>o){const r={type:"attribute",offset:o,howMany:i-o,count:this._changeCount++};this._handleChange(r,t),t.push(r)}e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=n.offset&&e.offset<o&&(i>o?(e.nodesToHandle=i-o,e.offset=o):e.nodesToHandle=0);if(n.type=="remove"&&e.offset<n.offset&&i>n.offset){const r={type:"attribute",offset:n.offset,howMany:i-n.offset,count:this._changeCount++};this._handleChange(r,t),t.push(r),e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}n.type=="attribute"&&(e.offset>=n.offset&&i<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=n.offset&&i>=o&&(n.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,n){return{type:"insert",position:b._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,n){return{type:"remove",position:b._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,n){const i=[];n=new Map(n);for(const[o,r]of t){const a=n.has(o)?n.get(o):null;a!==r&&i.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:r,attributeNewValue:a,changeCount:this._changeCount++}),n.delete(o)}for(const[o,r]of n)i.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:null,attributeNewValue:r,changeCount:this._changeCount++});return i}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const n=this._changesInElement.get(t),i=e.startOffset;if(n){for(const o of n)if(o.type=="insert"&&i>=o.offset&&i<o.offset+o.howMany)return!0}return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,n){const i=new p(b._createAt(e,t),b._createAt(e,t+n));for(const o of i.getItems({shallow:!0}))o.is("element")&&(this._elementSnapshots.delete(o),this._changesInElement.delete(o),this._removeAllNestedChanges(o,0,o.maxOffset))}}function Yo(s){const e=[];for(const t of s)if(t.is("$text"))for(let n=0;n<t.data.length;n++)e.push({name:"$text",attributes:new Map(t.getAttributes())});else e.push({name:t.name,attributes:new Map(t.getAttributes())});return e}function $m(s,e){const t=[];let n=0,i=0;for(const o of e){if(o.offset>n){for(let r=0;r<o.offset-n;r++)t.push("e");i+=o.offset-n}if(o.type=="insert"){for(let r=0;r<o.howMany;r++)t.push("i");n=o.offset+o.howMany}else if(o.type=="remove"){for(let r=0;r<o.howMany;r++)t.push("r");n=o.offset,i+=o.howMany}else t.push(..."a".repeat(o.howMany).split("")),n=o.offset+o.howMany,i+=o.howMany}if(i<s)for(let o=0;o<s-i-n;o++)t.push("e");return t}function qm(s){const e="position"in s&&s.position.root.rootName=="$graveyard",t="range"in s&&s.range.root.rootName=="$graveyard";return!e&&!t}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jm{constructor(){this._operations=[],this._undoPairs=new Map,this._undoneOperations=new Set,this._baseVersionToOperationIndex=new Map,this._version=0,this._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 m("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 i=t-1;for(const[a,l]of this._gaps)e>a&&e<l&&(e=l),i>a&&i<l&&(i=a-1);if(i<n.baseVersion||e>this.lastOperation.baseVersion)return[];let o=this._baseVersionToOperationIndex.get(e);o===void 0&&(o=0);let r=this._baseVersionToOperationIndex.get(i);return r===void 0&&(r=this._operations.length-1),this._operations.slice(o,r+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-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zn extends B{constructor(e,t,n="main"){super(t),this._isAttached=!0,this._document=e,this.rootName=n}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}zn.prototype.is=function(s,e){return e?e===this.name&&(s==="rootElement"||s==="model:rootElement"||s==="element"||s==="model:element"):s==="rootElement"||s==="model:rootElement"||s==="element"||s==="model:element"||s==="node"||s==="model:node"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const wi="$graveyard";class Km extends H(){constructor(e){super(),this.model=e,this.history=new jm,this.selection=new Ae(this),this.roots=new _e({idProperty:"rootName"}),this.differ=new Um(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",wi),this.listenTo(e,"applyOperation",(t,n)=>{const i=n[0];i.isDocumentOperation&&this.differ.bufferOperation(i)},{priority:"high"}),this.listenTo(e,"applyOperation",(t,n)=>{const i=n[0];i.isDocumentOperation&&this.history.addOperation(i)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(t,n,i,o,r)=>{const a={...n.getData(),range:o};this.differ.bufferMarkerChange(n.name,r,a),i===null&&n.on("change",(l,c)=>{const d=n.getData();this.differ.bufferMarkerChange(n.name,{...d,range:c},d)})}),this.registerPostFixer(t=>{let n=!1;for(const i of this.roots)!i.isAttached()&&!i.isEmpty&&(t.remove(t.createRangeIn(i)),n=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(t.removeMarker(i),n=!0);return n})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(wi)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new m("model-document-createroot-name-exists",this,{name:t});const n=new zn(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 Array.from(this.roots).filter(t=>t.rootName!=wi&&(e||t.isAttached())).map(t=>t.rootName)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=$a(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){for(const e of this.roots)if(e!==this.graveyard)return e;return this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,n=t.schema,i=t.createPositionFromPath(e,[0]);return n.getNearestSelectionRange(i)||t.createRange(i)}_validateSelectionRange(e){return Zo(e.start)&&Zo(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 Zo(s){const e=s.textNode;if(e){const t=e.data,n=s.offset-e.startOffset;return!Cs(t,n)&&!ks(t,n)}return!0}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gm extends H(){constructor(){super(...arguments),this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Ot?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,n=!1,i=!1){const o=e instanceof Ot?e.name:e;if(o.includes(","))throw new m("markercollection-incorrect-marker-name",this);const r=this._markers.get(o);if(r){const c=r.getData(),d=r.getRange();let u=!1;return d.isEqual(t)||(r._attachLiveRange(Te.fromRange(t)),u=!0),n!=r.managedUsingOperations&&(r._managedUsingOperations=n,u=!0),typeof i=="boolean"&&i!=r.affectsData&&(r._affectsData=i,u=!0),u&&this.fire(`update:${o}`,r,d,t,c),r}const a=Te.fromRange(t),l=new Ot(o,a,n,i);return this._markers.set(o,l),this.fire(`update:${o}`,l,null,t,{...l.getData(),range:null}),l}_remove(e){const t=e instanceof Ot?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 Ot?e.name:e,n=this._markers.get(t);if(!n)throw new m("markercollection-refresh-marker-not-exists",this);const i=n.getRange();this.fire(`update:${t}`,n,i,i,n.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)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 Ot extends H(ot){constructor(e,t,n,i){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=n,this._affectsData=i}get managedUsingOperations(){if(!this._liveRange)throw new m("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new m("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new m("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new m("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new m("marker-destroyed",this);return this._liveRange.toRange()}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}Ot.prototype.is=function(s){return s==="marker"||s==="model:marker"};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jm extends we{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 m("detach-operation-on-document-node",this)}_execute(){ic(p._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ue extends ot{constructor(e){super(),this.markers=new Map,this._children=new tn,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)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const n of e)t=t.getChild(t.offsetToIndex(n));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const n of e)n.name?t.push(B.fromJSON(n)):t.push(q.fromJSON(n));return new Ue(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=Qm(t);for(const i of n)i.parent!==null&&i._remove(),i.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const i of n)i.parent=null;return n}}Ue.prototype.is=function(s){return s==="documentFragment"||s==="model:documentFragment"};function Qm(s){return typeof s=="string"?[new q(s)]:(pe(s)||(s=[s]),Array.from(s).map(e=>typeof e=="string"?new q(e):e instanceof ke?new q(e.data,e.getAttributes()):e))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ym{constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new q(e,t)}createElement(e,t){return new B(e,t)}createDocumentFragment(){return new Ue}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,n=0){if(this._assertWriterUsedCorrectly(),e instanceof q&&e.data=="")return;const i=b._createAt(t,n);if(e.parent)if(tr(e.root,i.root)){this.move(p._createOn(e),i);return}else{if(e.root.document)throw new m("model-writer-insert-forbidden-move",this);this.remove(e)}const o=i.root.document?i.root.document.version:null,r=new oe(i,e,o);if(e instanceof q&&(r.shouldReceiveAttributes=!0),this.batch.addOperation(r),this.model.applyOperation(r),e instanceof Ue)for(const[a,l]of e.markers){const c=b._createAt(l.root,0),u={range:new p(l.start._getCombined(c,i),l.end._getCombined(c,i)),usingOperation:!0,affectsData:!0};this.model.markers.has(a)?this.updateMarker(a,u):this.addMarker(a,u)}}insertText(e,t,n,i){t instanceof Ue||t instanceof B||t instanceof b?this.insert(this.createText(e),t,n):this.insert(this.createText(e,t),n,i)}insertElement(e,t,n,i){t instanceof Ue||t instanceof B||t instanceof b?this.insert(this.createElement(e),t,n):this.insert(this.createElement(e,t),n,i)}append(e,t){this.insert(e,t,"end")}appendText(e,t,n){t instanceof Ue||t instanceof B?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),n,"end")}appendElement(e,t,n){t instanceof Ue||t instanceof B?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),n,"end")}setAttribute(e,t,n){if(this._assertWriterUsedCorrectly(),n instanceof p){const i=n.getMinimalFlatRanges();for(const o of i)Xo(this,e,t,o)}else er(this,e,t,n)}setAttributes(e,t){for(const[n,i]of Ge(e))this.setAttribute(n,i,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof p){const n=t.getMinimalFlatRanges();for(const i of n)Xo(this,e,null,i)}else er(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=n=>{for(const i of n.getAttributeKeys())this.removeAttribute(i,n)};if(!(e instanceof p))t(e);else for(const n of e.getItems())t(n)}move(e,t,n){if(this._assertWriterUsedCorrectly(),!(e instanceof p))throw new m("writer-move-invalid-range",this);if(!e.isFlat)throw new m("writer-move-range-not-flat",this);const i=b._createAt(t,n);if(i.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!tr(e.root,i.root))throw new m("writer-move-different-document",this);const o=e.root.document?e.root.document.version:null,r=new O(e.start,e.end.offset-e.start.offset,i,o);this.batch.addOperation(r),this.model.applyOperation(r)}remove(e){this._assertWriterUsedCorrectly();const n=(e instanceof p?e:p._createOn(e)).getMinimalFlatRanges().reverse();for(const i of n)this._addOperationForAffectedMarkers("move",i),Zm(i.start,i.end.offset-i.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,n=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof B))throw new m("writer-merge-no-element-before",this);if(!(n instanceof B))throw new m("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(p._createIn(n),b._createAt(t,"end")),this.remove(n)}_merge(e){const t=b._createAt(e.nodeBefore,"end"),n=b._createAt(e.nodeAfter,0),i=e.root.document.graveyard,o=new b(i,[0]),r=e.root.document.version,a=new Y(n,e.nodeAfter.maxOffset,t,o,r);this.batch.addOperation(a),this.model.applyOperation(a)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof B))throw new m("writer-rename-not-element-instance",this);const n=e.root.document?e.root.document.version:null,i=new fe(b._createBefore(e),e.name,t,n);this.batch.addOperation(i),this.model.applyOperation(i)}split(e,t){this._assertWriterUsedCorrectly();let n=e.parent;if(!n.parent)throw new m("writer-split-element-no-parent",this);if(t||(t=n.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new m("writer-split-invalid-limit-element",this);let i,o;do{const r=n.root.document?n.root.document.version:null,a=n.maxOffset-e.offset,l=z.getInsertionPosition(e),c=new z(e,a,l,null,r);this.batch.addOperation(c),this.model.applyOperation(c),!i&&!o&&(i=n,o=e.parent.nextSibling),e=this.createPositionAfter(e.parent),n=e.parent}while(n!==t);return{position:e,range:new p(b._createAt(i,"end"),b._createAt(o,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new m("writer-wrap-range-not-flat",this);const n=t instanceof B?t:new B(t);if(n.childCount>0)throw new m("writer-wrap-element-not-empty",this);if(n.parent!==null)throw new m("writer-wrap-element-attached",this);this.insert(n,e.start);const i=new p(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(i,b._createAt(n,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),e.parent===null)throw new m("writer-unwrap-element-no-parent",this);this.move(p._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||typeof t.usingOperation!="boolean")throw new m("writer-addmarker-no-usingoperation",this);const n=t.usingOperation,i=t.range,o=t.affectsData===void 0?!1:t.affectsData;if(this.model.markers.has(e))throw new m("writer-addmarker-marker-exists",this);if(!i)throw new m("writer-addmarker-no-range",this);return n?(Yt(this,e,null,i,o),this.model.markers.get(e)):this.model.markers._set(e,i,n,o)}updateMarker(e,t){this._assertWriterUsedCorrectly();const n=typeof e=="string"?e:e.name,i=this.model.markers.get(n);if(!i)throw new m("writer-updatemarker-marker-not-exists",this);if(!t){K("writer-updatemarker-reconvert-using-editingcontroller",{markerName:n}),this.model.markers._refresh(i);return}const o=typeof t.usingOperation=="boolean",r=typeof t.affectsData=="boolean",a=r?t.affectsData:i.affectsData;if(!o&&!t.range&&!r)throw new m("writer-updatemarker-wrong-options",this);const l=i.getRange(),c=t.range?t.range:l;if(o&&t.usingOperation!==i.managedUsingOperations){t.usingOperation?Yt(this,n,null,c,a):(Yt(this,n,l,null,a),this.model.markers._set(n,c,void 0,a));return}i.managedUsingOperations?Yt(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 m("writer-removemarker-no-marker",this);const n=this.model.markers.get(t);if(!n.managedUsingOperations){this.model.markers._remove(t);return}const i=n.getRange();Yt(this,t,i,null,n.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const n=this.model.document.getRoot(e);if(n&&n.isAttached())throw new m("writer-addroot-root-exists",this);const i=this.model.document,o=new Me(e,t,!0,i,i.version);return this.batch.addOperation(o),this.model.applyOperation(o),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 m("writer-detachroot-no-root",this);for(const o of this.model.markers)o.getRange().root===t&&this.removeMarker(o);for(const o of t.getAttributeKeys())this.removeAttribute(o,t);this.remove(this.createRangeIn(t));const n=this.model.document,i=new Me(t.rootName,t.name,!1,n,n.version);this.batch.addOperation(i),this.model.applyOperation(i)}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,i]of Ge(e))this._setSelectionAttribute(n,i)}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 i=Ae._getStoreAttributeKey(e);this.setAttribute(i,t,n.anchor.parent)}n._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const n=Ae._getStoreAttributeKey(e);this.removeAttribute(n,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new m("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const i=n.getRange();let o=!1;if(e==="move"){const r=t;o=r.containsPosition(i.start)||r.start.isEqual(i.start)||r.containsPosition(i.end)||r.end.isEqual(i.end)}else{const r=t,a=r.nodeBefore,l=r.nodeAfter,c=i.start.parent==a&&i.start.isAtEnd,d=i.end.parent==l&&i.end.offset==0,u=i.end.nodeAfter==l,h=i.start.nodeAfter==l;o=c||d||u||h}o&&this.updateMarker(n.name,{range:i})}}}function Xo(s,e,t,n){const i=s.model,o=i.document;let r=n.start,a,l,c;for(const u of n.getWalker({shallow:!0}))c=u.item.getAttribute(e),a&&l!=c&&(l!=t&&d(),r=a),a=u.nextPosition,l=c;a instanceof b&&a!=r&&l!=t&&d();function d(){const u=new p(r,a),h=u.root.document?o.version:null,f=new Z(u,e,l,t,h);s.batch.addOperation(f),i.applyOperation(f)}}function er(s,e,t,n){const i=s.model,o=i.document,r=n.getAttribute(e);let a,l;if(r!=t){if(n.root===n){const d=n.document?o.version:null;l=new $e(n,e,r,t,d)}else{a=new p(b._createBefore(n),s.createPositionAfter(n));const d=a.root.document?o.version:null;l=new Z(a,e,r,t,d)}s.batch.addOperation(l),i.applyOperation(l)}}function Yt(s,e,t,n,i){const o=s.model,r=o.document,a=new he(e,t,n,o.markers,!!i,r.version);s.batch.addOperation(a),o.applyOperation(a)}function Zm(s,e,t,n){let i;if(s.root.document){const o=n.document,r=new b(o.graveyard,[0]);i=new O(s,e,r,o.version)}else i=new Jm(s,e);t.addOperation(i),n.applyOperation(i)}function tr(s,e){return s===e||s instanceof zn&&e instanceof zn}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Xm(s,e,t={}){if(e.isCollapsed)return;const n=e.getFirstRange();if(n.root.rootName=="$graveyard")return;const i=s.schema;s.change(o=>{if(!t.doNotResetEntireContent&&lg(i,e)){ag(o,e);return}const r={};if(!t.doNotAutoparagraph){const c=e.getSelectedElement();c&&Object.assign(r,i.getAttributesWithProperty(c,"copyOnReplace",!0))}const[a,l]=eg(n);a.isTouching(l)||o.remove(o.createRange(a,l)),t.leaveUnmerged||(ng(o,a,l),i.removeDisallowedAttributes(a.parent.getChildren(),o)),dc(o,e,a),!t.doNotAutoparagraph&&og(i,a)&&cc(o,a,e,r),a.detach(),l.detach()})}function eg(s){const e=s.root.document.model,t=s.start;let n=s.end;if(e.hasContent(s,{ignoreMarkers:!0})){const i=tg(n);if(i&&n.isTouching(e.createPositionAt(i,0))){const o=e.createSelection(s);e.modifySelection(o,{direction:"backward"});const r=o.getLastPosition(),a=e.createRange(r,n);e.hasContent(a,{ignoreMarkers:!0})||(n=r)}}return[re.fromPosition(t,"toPrevious"),re.fromPosition(n,"toNext")]}function tg(s){const e=s.parent,t=e.root.document.model.schema,n=e.getAncestors({parentFirst:!0,includeSelf:!0});for(const i of n){if(t.isLimit(i))return null;if(t.isBlock(i))return i}}function ng(s,e,t){const n=s.model;if(!Ms(s.model.schema,e,t))return;const[i,o]=sg(e,t);!i||!o||(!n.hasContent(i,{ignoreMarkers:!0})&&n.hasContent(o,{ignoreMarkers:!0})?lc(s,e,t,i.parent):ac(s,e,t,i.parent))}function ac(s,e,t,n){const i=e.parent,o=t.parent;if(!(i==n||o==n)){for(e=s.createPositionAfter(i),t=s.createPositionBefore(o),t.isEqual(e)||s.insert(o,e),s.merge(e);t.parent.isEmpty;){const r=t.parent;t=s.createPositionBefore(r),s.remove(r)}Ms(s.model.schema,e,t)&&ac(s,e,t,n)}}function lc(s,e,t,n){const i=e.parent,o=t.parent;if(!(i==n||o==n)){for(e=s.createPositionAfter(i),t=s.createPositionBefore(o),t.isEqual(e)||s.insert(i,t);e.parent.isEmpty;){const r=e.parent;e=s.createPositionBefore(r),s.remove(r)}t=s.createPositionBefore(o),ig(s,t),Ms(s.model.schema,e,t)&&lc(s,e,t,n)}}function ig(s,e){const t=e.nodeBefore,n=e.nodeAfter;t.name!=n.name&&s.rename(t,n.name),s.clearAttributes(t),s.setAttributes(Object.fromEntries(n.getAttributes()),t),s.merge(e)}function Ms(s,e,t){const n=e.parent,i=t.parent;return n==i||s.isLimit(n)||s.isLimit(i)?!1:rg(e,t,s)}function sg(s,e){const t=s.getAncestors(),n=e.getAncestors();let i=0;for(;t[i]&&t[i]==n[i];)i++;return[t[i],n[i]]}function og(s,e){const t=s.checkChild(e,"$text"),n=s.checkChild(e,"paragraph");return!t&&n}function rg(s,e,t){const n=new p(s,e);for(const i of n.getWalker())if(t.isLimit(i.item))return!1;return!0}function cc(s,e,t,n={}){const i=s.createElement("paragraph");s.model.schema.setAllowedAttributes(i,n,s),s.insert(i,e),dc(s,t,s.createPositionAt(i,0))}function ag(s,e){const t=s.model.schema.getLimitElement(e);s.remove(s.createRangeIn(t)),cc(s,s.createPositionAt(t,0),e)}function lg(s,e){const t=s.getLimitElement(e);if(!e.containsEntireContent(t))return!1;const n=e.getFirstRange();return n.start.parent==n.end.parent?!1:s.checkChild(t,"paragraph")}function dc(s,e,t){e instanceof Ae?s.setSelection(t):e.setTo(t)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function cg(s,e){return s.change(t=>{const n=t.createDocumentFragment(),i=e.getFirstRange();if(!i||i.isCollapsed)return n;const o=i.start.root,r=i.start.getCommonPath(i.end),a=o.getNodeByPath(r);let l;i.start.parent==i.end.parent?l=i:l=t.createRange(t.createPositionAt(a,i.start.path[r.length]),t.createPositionAt(a,i.end.path[r.length]+1));const c=l.end.offset-l.start.offset;for(const d of l.getItems({shallow:!0}))d.is("$textProxy")?t.appendText(d.data,d.getAttributes(),n):t.append(t.cloneElement(d,!0),n);if(l!=i){const d=i._getTransformedByMove(l.start,t.createPositionAt(n,0),c)[0],u=t.createRange(t.createPositionAt(n,0),d.start),h=t.createRange(d.end,t.createPositionAt(n,"end"));nr(h,t),nr(u,t)}return n})}function nr(s,e){const t=[];Array.from(s.getItems({direction:"backward"})).map(n=>e.createRangeOn(n)).filter(n=>(n.start.isAfter(s.start)||n.start.isEqual(s.start))&&(n.end.isBefore(s.end)||n.end.isEqual(s.end))).forEach(n=>{t.push(n.start.parent),e.remove(n)}),t.forEach(n=>{let i=n;for(;i.parent&&i.isEmpty;){const o=e.createRangeOn(i);i=i.parent,e.remove(o)}})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function dg(s,e,t){return s.change(n=>{const i=t||s.document.selection;i.isCollapsed||s.deleteContent(i,{doNotAutoparagraph:!0});const o=new ug(s,n,i.anchor),r=[];let a;if(e.is("documentFragment")){if(e.markers.size){const d=[];for(const[u,h]of e.markers){const{start:f,end:g}=h,w=f.isEqual(g);d.push({position:f,name:u,isCollapsed:w},{position:g,name:u,isCollapsed:w})}d.sort(({position:u},{position:h})=>u.isBefore(h)?1:-1);for(const{position:u,name:h,isCollapsed:f}of d){let g=null,w=null;const v=u.parent===e&&u.isAtStart,C=u.parent===e&&u.isAtEnd;!v&&!C?(g=n.createElement("$marker"),n.insert(g,u)):f&&(w=v?"start":"end"),r.push({name:h,element:g,collapsed:w})}}a=e.getChildren()}else a=[e];o.handleNodes(a);let l=o.getSelectionRange();if(e.is("documentFragment")&&r.length){const d=l?Te.fromRange(l):null,u={};for(let h=r.length-1;h>=0;h--){const{name:f,element:g,collapsed:w}=r[h],v=!u[f];if(v&&(u[f]=[]),g){const C=n.createPositionAt(g,"before");u[f].push(C),n.remove(g)}else{const C=o.getAffectedRange();if(!C){w&&u[f].push(o.position);continue}w?u[f].push(C[w]):u[f].push(v?C.start:C.end)}}for(const[h,[f,g]]of Object.entries(u))f&&g&&f.root===g.root&&n.addMarker(h,{usingOperation:!0,affectsData:!0,range:new p(f,g)});d&&(l=d.toRange(),d.detach())}/* istanbul ignore else -- @preserve */l&&(i instanceof Ae?n.setSelection(l):i.setTo(l));const c=o.getAffectedRange()||s.createRange(i.anchor);return o.destroy(),c})}class ug{constructor(e,t,n){this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null,this._nodeToSelect=null,this.model=e,this.writer=t,this.position=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))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(e);if(n.isAfter(t)){this._lastNode=e;/* istanbul ignore if -- @preserve */if(this.position.parent!=e||!this.position.isAtEnd)throw new m("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?p._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new p(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(this.schema.isObject(e)){this._handleObject(e);return}let t=this._checkAndAutoParagraphToAllowedPosition(e);if(!t&&(t=this._checkAndSplitToAllowedPosition(e),!t)){this._handleDisallowedNode(e);return}this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=re.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleObject(e){this._checkAndSplitToAllowedPosition(e)?this._appendToFragment(e):this._tryAutoparagraphing(e)}_handleDisallowedNode(e){e.is("element")?this.handleNodes(e.getChildren()):this._tryAutoparagraphing(e)}_appendToFragment(e){/* istanbul ignore if -- @preserve */if(!this.schema.checkChild(this.position,e))throw new m("insertcontent-wrong-position",this,{node:e,position:this.position});this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesOf.push(e)}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=re.fromPosition(e,"toPrevious")),(!this._affectedEnd||this._affectedEnd.isBefore(e))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=re.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof B)||!this._canMergeLeft(e))return;const t=re._createBefore(e);t.stickiness="toNext";const n=re.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=re._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=re._createAt(t.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof B)||!this._canMergeRight(e))return;const t=re._createAfter(e);t.stickiness="toNext";/* istanbul ignore if -- @preserve */if(!this.position.isEqual(t))throw new m("insertcontent-invalid-insertion-position",this);this.position=b._createAt(t.nodeBefore,"end");const n=re.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=re._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=re._createAt(t.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof B&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof B&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_tryAutoparagraphing(e){const t=this.writer.createElement("paragraph");this._getAllowedIn(this.position.parent,t)&&this.schema.checkChild(t,e)&&(t._appendChild(e),this._handleNode(t))}_checkAndAutoParagraphToAllowedPosition(e){if(this.schema.checkChild(this.position.parent,e))return!0;if(!this.schema.checkChild(this.position.parent,"paragraph")||!this.schema.checkChild("paragraph",e))return!1;this._insertPartialFragment();const t=this.writer.createElement("paragraph");return this.writer.insert(t,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=t,this.position=this.writer.createPositionAt(t,0),!0}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const 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!0}_getAllowedIn(e,t){return this.schema.checkChild(e,t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function uc(s,e,t="auto"){const n=s.getSelectedElement();if(n&&e.schema.isObject(n)&&!e.schema.isInline(n))return t=="before"||t=="after"?e.createRange(e.createPositionAt(n,t)):e.createRangeOn(n);const i=ne(s.getSelectedBlocks());if(!i)return e.createRange(s.focus);if(i.isEmpty)return e.createRange(e.createPositionAt(i,0));const o=e.createPositionAfter(i);return s.focus.isTouching(o)?e.createRange(o):e.createRange(e.createPositionBefore(i))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function hg(s,e,t,n={}){if(!s.schema.isObject(e))throw new m("insertobject-element-not-an-object",s,{object:e});const i=t||s.document.selection;let o=i;n.findOptimalPosition&&s.schema.isBlock(e)&&(o=s.createSelection(uc(i,s,n.findOptimalPosition)));const r=ne(i.getSelectedBlocks()),a={};return r&&Object.assign(a,s.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),s.change(l=>{o.isCollapsed||s.deleteContent(o,{doNotAutoparagraph:!0});let c=e;const d=o.anchor.parent;!s.schema.checkChild(d,e)&&s.schema.checkChild(d,"paragraph")&&s.schema.checkChild("paragraph",e)&&(c=l.createElement("paragraph"),l.insert(e,c)),s.schema.setAllowedAttributes(c,a,l);const u=s.insertContent(c,o);return u.isCollapsed||n.setSelection&&fg(l,e,n.setSelection,a),u})}function fg(s,e,t,n){const i=s.model;if(t=="on"){s.setSelection(e,"on");return}if(t!="after")throw new m("insertobject-invalid-place-parameter-value",i);let o=e.nextSibling;if(i.schema.isInline(e)){s.setSelection(e,"after");return}!(o&&i.schema.checkChild(o,"$text"))&&i.schema.checkChild(e.parent,"paragraph")&&(o=s.createElement("paragraph"),i.schema.setAllowedAttributes(o,n,s),i.insertContent(o,s.createPositionAfter(e))),o&&s.setSelection(o,0)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const mg=' ,.?!:;"-()';function gg(s,e,t={}){const n=s.schema,i=t.direction!="backward",o=t.unit?t.unit:"character",r=!!t.treatEmojiAsSingleUnit,a=e.focus,l=new Re({boundaries:_g(a,i),singleCharacters:!0,direction:i?"forward":"backward"}),c={walker:l,schema:n,isForward:i,unit:o,treatEmojiAsSingleUnit:r};let d;for(;d=l.next();){if(d.done)return;const u=pg(c,d.value);if(u){e instanceof Ae?s.change(h=>{h.setSelectionFocus(u)}):e.setFocus(u);return}}}function pg(s,e){const{isForward:t,walker:n,unit:i,schema:o,treatEmojiAsSingleUnit:r}=s,{type:a,item:l,nextPosition:c}=e;if(a=="text")return s.unit==="word"?bg(n,t):wg(n,i,r);if(a==(t?"elementStart":"elementEnd")){if(o.isSelectable(l))return b._createAt(l,t?"after":"before");if(o.checkChild(c,"$text"))return c}else{if(o.isLimit(l)){n.skip(()=>!0);return}if(o.checkChild(c,"$text"))return c}}function wg(s,e,t){const n=s.position.textNode;if(n){const i=n.data;let o=s.position.offset-n.startOffset;for(;Cs(i,o)||e=="character"&&ks(i,o)||t&&bl(i,o);)s.next(),o=s.position.offset-n.startOffset}return s.position}function bg(s,e){let t=s.position.textNode;for(t||(t=e?s.position.nodeAfter:s.position.nodeBefore);t&&t.is("$text");){const n=s.position.offset-t.startOffset;if(yg(t,n,e))t=e?s.position.nodeAfter:s.position.nodeBefore;else{if(vg(t.data,n,e))break;s.next()}}return s.position}function _g(s,e){const t=s.root,n=b._createAt(t,e?"end":0);return e?new p(s,n):new p(n,s)}function vg(s,e,t){const n=e+(t?0:-1);return mg.includes(s.charAt(n))}function yg(s,e,t){return e===(t?s.offsetSize:0)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */let Cg=class extends D(){constructor(){super(),this.markers=new Gm,this.document=new Km(this),this.schema=new cm,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(e=>this.decorate(e)),this.on("applyOperation",(e,t)=>{t[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck((e,t)=>{if(t.name==="$marker")return!0}),em(this),this.document.registerPostFixer(Ql),this.on("insertContent",(e,[t,n])=>{e.return=dg(this,t,n)}),this.on("insertObject",(e,[t,n,i])=>{e.return=hg(this,t,n,i)}),this.on("canEditAt",e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()})}change(e){try{return this._pendingChanges.length===0?(this._pendingChanges.push({batch:new Pt,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(t){/* istanbul ignore next -- @preserve */m.rethrowUnexpectedError(t,this)}}enqueueChange(e,t){try{e?typeof e=="function"?(t=e,e=new Pt):e instanceof Pt||(e=new Pt(e)):e=new Pt,this._pendingChanges.push({batch:e,callback:t}),this._pendingChanges.length==1&&this._runPendingChanges()}catch(n){/* istanbul ignore next -- @preserve */m.rethrowUnexpectedError(n,this)}}applyOperation(e){e._execute()}insertContent(e,t,n,...i){const o=bi(t,n);return this.fire("insertContent",[e,o,n,...i])}insertObject(e,t,n,i,...o){const r=bi(t,n);return this.fire("insertObject",[e,r,i,i,...o])}deleteContent(e,t){Xm(this,e,t)}modifySelection(e,t){gg(this,e,t)}getSelectedContent(e){return cg(this,e)}hasContent(e,t={}){const n=e instanceof p?e:p._createIn(e);if(n.isCollapsed)return!1;const{ignoreWhitespaces:i=!1,ignoreMarkers:o=!1}=t;if(!o){for(const r of this.markers.getMarkersIntersectingRange(n))if(r.affectsData)return!0}for(const r of n.getItems())if(this.schema.isContent(r))if(r.is("$textProxy"))if(i){if(r.data.search(/\S/)!==-1)return!0}else return!0;else return!0;return!1}canEditAt(e){const t=bi(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,n){return new b(e,t,n)}createPositionAt(e,t){return b._createAt(e,t)}createPositionAfter(e){return b._createAfter(e)}createPositionBefore(e){return b._createBefore(e)}createRange(e,t){return new p(e,t)}createRangeIn(e){return p._createIn(e)}createRangeOn(e){return p._createOn(e)}createSelection(...e){return new ge(...e)}createBatch(e){return new Pt(e)}createOperationFromJSON(e){return Dm.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 Ym(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 bi(s,e){if(s)return s instanceof ge||s instanceof Ae?s:s instanceof kt?e||e===0?new ge(s,e):s.is("rootElement")?new ge(s,"in"):new ge(s,"on"):new ge(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class kg extends st{constructor(){super(...arguments),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ii extends st{constructor(){super(...arguments),this.domEventType=["mousedown","mouseup","mouseover","mouseout"]}onDomEvent(e){this.fire(e.type,e)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Et{constructor(e){this.document=e}createDocumentFragment(e){return new pt(this.document,e)}createElement(e,t,n){return new Ee(this.document,e,t,n)}createText(e){return new j(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const n=e.parent;if(n){const i=n.getChildIndex(e);return this.removeChildren(i,1,n),this.insertChild(i,t,n),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){const n=new Ee(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){Ce(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 y._createAt(e,t)}createPositionAfter(e){return y._createAfter(e)}createPositionBefore(e){return y._createBefore(e)}createRange(e,t){return new A(e,t)}createRangeOn(e){return A._createOn(e)}createRangeIn(e){return A._createIn(e)}createSelection(...e){return new it(...e)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Eg{constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const n=this.get(e);if(!n)throw new m("commandcollection-command-not-found",this,{commandName:e});return n.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tg extends Be{constructor(e){super(),this.editor=e}set(e,t,n={}){if(typeof t=="string"){const i=t;t=(o,r)=>{this.editor.execute(i),r()}}super.set(e,t,n)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ag extends D(){constructor(e={}){super();const t=this.constructor,n=e.language||t.defaultConfig&&t.defaultConfig.language;this._context=e.context||new vl({language:n}),this._context._addEditor(this,!e.context);const i=Array.from(t.builtinPlugins||[]);this.config=new il(e,t.defaultConfig),this.config.define("plugins",i),this.config.define(this._context._getEditorConfig()),this.plugins=new _l(this,i,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new Eg,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.model=new Cg,this.on("change:isReadOnly",()=>{this.model.document.isReadOnly=this.isReadOnly});const o=new ch;this.data=new Rm(this.model,o),this.editing=new rm(this.model,o),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new Vm([this.editing.downcastDispatcher,this.data.downcastDispatcher],this.data.upcastDispatcher),this.conversion.addAlias("dataDowncast",this.data.downcastDispatcher),this.conversion.addAlias("editingDowncast",this.editing.downcastDispatcher),this.keystrokes=new Tg(this),this.keystrokes.listenTo(this.editing.view.document)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new m("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new m("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),this._readOnlyLocks.size===1&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new m("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),this._readOnlyLocks.size===0&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}initPlugins(){const e=this.config,t=e.get("plugins"),n=e.get("removePlugins")||[],i=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(i),n,o)}destroy(){let e=Promise.resolve();return this.state=="initializing"&&(e=new Promise(t=>this.once("ready",t))),e.then(()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()}).then(()=>this.plugins.destroy()).then(()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()}).then(()=>this._context._removeEditor(this))}execute(e,...t){try{return this.commands.execute(e,...t)}catch(n){/* istanbul ignore next -- @preserve */m.rethrowUnexpectedError(n,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function xn(s){class e extends s{setData(n){this.data.set(n)}getData(n){return this.data.get(n)}}return e}{const s=xn(Object);xn.setData=s.prototype.setData,xn.getData=s.prototype.getData}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function es(s){class e extends s{updateSourceElement(n=this.data.get()){if(!this.sourceElement)throw new m("editor-missing-sourceelement",this);const i=this.config.get("updateSourceElementOnDestroy"),o=this.sourceElement instanceof HTMLTextAreaElement;if(!i&&!o){fo(this.sourceElement,"");return}fo(this.sourceElement,n)}}return e}es.updateSourceElement=es(Object).prototype.updateSourceElement;/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Sg(s,e){if(e.ckeditorInstance)throw new m("editor-source-element-already-used",s);e.ckeditorInstance=s,s.once("destroy",()=>{delete e.ckeditorInstance})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hn extends Zn{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new _e({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if(typeof e!="string")throw new m("pendingactions-add-invalid-message",this);const t=new(D());return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}const Pg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.591 10.177 4.243 4.242a1 1 0 0 1-1.415 1.415l-4.242-4.243-4.243 4.243a1 1 0 0 1-1.414-1.415l4.243-4.242L4.52 5.934A1 1 0 0 1 5.934 4.52l4.243 4.243 4.242-4.243a1 1 0 1 1 1.415 1.414l-4.243 4.243z"/></svg>',xg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 16h9a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2z"/><path d="M17 1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14zm0 1.5H3a.5.5 0 0 0-.492.41L2.5 3v9a.5.5 0 0 0 .41.492L3 12.5h14a.5.5 0 0 0 .492-.41L17.5 12V3a.5.5 0 0 0-.41-.492L17 2.5z" fill-opacity=".6"/></svg>',Ig='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.972 16.615a.997.997 0 0 1-.744-.292l-4.596-4.596a1 1 0 1 1 1.414-1.414l3.926 3.926 9.937-9.937a1 1 0 0 1 1.414 1.415L7.717 16.323a.997.997 0 0 1-.745.292z"/></svg>',Rg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.333 2 .19 2.263a5.899 5.899 0 0 1 1.458.604L14.714 3.4 16.6 5.286l-1.467 1.733c.263.452.468.942.605 1.46L18 8.666v2.666l-2.263.19a5.899 5.899 0 0 1-.604 1.458l1.467 1.733-1.886 1.886-1.733-1.467a5.899 5.899 0 0 1-1.46.605L11.334 18H8.667l-.19-2.263a5.899 5.899 0 0 1-1.458-.604L5.286 16.6 3.4 14.714l1.467-1.733a5.899 5.899 0 0 1-.604-1.458L2 11.333V8.667l2.262-.189a5.899 5.899 0 0 1 .605-1.459L3.4 5.286 5.286 3.4l1.733 1.467a5.899 5.899 0 0 1 1.46-.605L8.666 2h2.666zM10 6.267a3.733 3.733 0 1 0 0 7.466 3.733 3.733 0 0 0 0-7.466z"/></svg>',Mg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m8.636 9.531-2.758 3.94a.5.5 0 0 0 .122.696l3.224 2.284h1.314l2.636-3.736L8.636 9.53zm.288 8.451L5.14 15.396a2 2 0 0 1-.491-2.786l6.673-9.53a2 2 0 0 1 2.785-.49l3.742 2.62a2 2 0 0 1 .491 2.785l-7.269 10.053-2.147-.066z"/><path d="M4 18h5.523v-1H4zm-2 0h1v-1H2z"/></svg>',Vg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5.085 6.22 2.943 4.078a.75.75 0 1 1 1.06-1.06l2.592 2.59A11.094 11.094 0 0 1 10 5.068c4.738 0 8.578 3.101 8.578 5.083 0 1.197-1.401 2.803-3.555 3.887l1.714 1.713a.75.75 0 0 1-.09 1.138.488.488 0 0 1-.15.084.75.75 0 0 1-.821-.16L6.17 7.304c-.258.11-.51.233-.757.365l6.239 6.24-.006.005.78.78c-.388.094-.78.166-1.174.215l-1.11-1.11h.011L4.55 8.197a7.2 7.2 0 0 0-.665.514l-.112.098 4.897 4.897-.005.006 1.276 1.276a10.164 10.164 0 0 1-1.477-.117l-.479-.479-.009.009-4.863-4.863-.022.031a2.563 2.563 0 0 0-.124.2c-.043.077-.08.158-.108.241a.534.534 0 0 0-.028.133.29.29 0 0 0 .008.072.927.927 0 0 0 .082.226c.067.133.145.26.234.379l3.242 3.365.025.01.59.623c-3.265-.918-5.59-3.155-5.59-4.668 0-1.194 1.448-2.838 3.663-3.93zm7.07.531a4.632 4.632 0 0 1 1.108 5.992l.345.344.046-.018a9.313 9.313 0 0 0 2-1.112c.256-.187.5-.392.727-.613.137-.134.27-.277.392-.431.072-.091.141-.185.203-.286.057-.093.107-.19.148-.292a.72.72 0 0 0 .036-.12.29.29 0 0 0 .008-.072.492.492 0 0 0-.028-.133.999.999 0 0 0-.036-.096 2.165 2.165 0 0 0-.071-.145 2.917 2.917 0 0 0-.125-.2 3.592 3.592 0 0 0-.263-.335 5.444 5.444 0 0 0-.53-.523 7.955 7.955 0 0 0-1.054-.768 9.766 9.766 0 0 0-1.879-.891c-.337-.118-.68-.219-1.027-.301zm-2.85.21-.069.002a.508.508 0 0 0-.254.097.496.496 0 0 0-.104.679.498.498 0 0 0 .326.199l.045.005c.091.003.181.003.272.012a2.45 2.45 0 0 1 2.017 1.513c.024.061.043.125.069.185a.494.494 0 0 0 .45.287h.008a.496.496 0 0 0 .35-.158.482.482 0 0 0 .13-.335.638.638 0 0 0-.048-.219 3.379 3.379 0 0 0-.36-.723 3.438 3.438 0 0 0-2.791-1.543l-.028-.001h-.013z"/></svg>',Og='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.91 10.54c.26-.23.64-.21.88.03l3.36 3.14 2.23-2.06a.64.64 0 0 1 .87 0l2.52 2.97V4.5H3.2v10.12l3.71-4.08zm10.27-7.51c.6 0 1.09.47 1.09 1.05v11.84c0 .59-.49 1.06-1.09 1.06H2.79c-.6 0-1.09-.47-1.09-1.06V4.08c0-.58.49-1.05 1.1-1.05h14.38zm-5.22 5.56a1.96 1.96 0 1 1 3.4-1.96 1.96 1.96 0 0 1-3.4 1.96z"/></svg>',Dg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m9.239 13.938-2.88-1.663a.75.75 0 0 1 .75-1.3L9 12.067V4.75a.75.75 0 1 1 1.5 0v7.318l1.89-1.093a.75.75 0 0 1 .75 1.3l-2.879 1.663a.752.752 0 0 1-.511.187.752.752 0 0 1-.511-.187zM4.25 17a.75.75 0 1 1 0-1.5h10.5a.75.75 0 0 1 0 1.5H4.25z"/></svg>',Ng='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.75 11.875a.752.752 0 0 1 .508.184l2.883 1.666a.75.75 0 0 1-.659 1.344l-.091-.044-1.892-1.093.001 4.318a.75.75 0 1 1-1.5 0v-4.317l-1.89 1.092a.75.75 0 0 1-.75-1.3l2.879-1.663a.752.752 0 0 1 .51-.187zM15.25 9a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5h10.5zM9.75.375a.75.75 0 0 1 .75.75v4.318l1.89-1.093.092-.045a.75.75 0 0 1 .659 1.344l-2.883 1.667a.752.752 0 0 1-.508.184.752.752 0 0 1-.511-.187L6.359 5.65a.75.75 0 0 1 .75-1.299L9 5.442V1.125a.75.75 0 0 1 .75-.75z"/></svg>',Bg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m10.261 7.062 2.88 1.663a.75.75 0 0 1-.75 1.3L10.5 8.933v7.317a.75.75 0 1 1-1.5 0V8.932l-1.89 1.093a.75.75 0 0 1-.75-1.3l2.879-1.663a.752.752 0 0 1 .511-.187.752.752 0 0 1 .511.187zM15.25 4a.75.75 0 1 1 0 1.5H4.75a.75.75 0 0 1 0-1.5h10.5z"/></svg>',Fg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75z"/></svg>',Lg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm2.286 4c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75z"/></svg>',zg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M18 3.75a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75zm0 8a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75zm0 4a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75zm0-8a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75z"/></svg>',Hg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75z"/></svg>',Wg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',Ug='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M15.003 7v5.5a1 1 0 0 1-1 1H5.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H6.5V12h6.997V7.5z"/></svg>',$g='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M18.003 7v5.5a1 1 0 0 1-1 1H8.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H9.5V12h6.997V7.5z"/></svg>',qg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M18 7v5.5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1zm-1.505.5H3.504V12h12.991V7.5z"/></svg>',jg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm11.5 9H18v1.5h-4.5zM2 15h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',Kg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm11.5 9H18v1.5h-4.5zm0-3H18v1.5h-4.5zm0-3H18v1.5h-4.5zM2 15h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',Gg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2zm0-9h5v1.5H2zm0 3h5v1.5H2zm0 3h5v1.5H2z"/><path d="M18.003 7v5.5a1 1 0 0 1-1 1H8.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H9.5V12h6.997V7.5z"/></svg>',Jg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M18.095 2H1.905C.853 2 0 2.895 0 4v12c0 1.105.853 2 1.905 2h16.19C19.147 18 20 17.105 20 16V4c0-1.105-.853-2-1.905-2zm0 1.5c.263 0 .476.224.476.5v12c0 .276-.213.5-.476.5H1.905a.489.489 0 0 1-.476-.5V4c0-.276.213-.5.476-.5h16.19z"/></svg>',Qg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M13 6H2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2zm0 1.5a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5V8a.5.5 0 0 1 .5-.5h11z"/></svg>',Yg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M7 10H2a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h5a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2zm0 1.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-4a.5.5 0 0 1 .5-.5h5z"/></svg>',Zg='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M10 8H2a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-6a2 2 0 0 0-2-2zm0 1.5a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-6a.5.5 0 0 1 .5-.5h8z"/></svg>',Xg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m7.3 17.37-.061.088a1.518 1.518 0 0 1-.934.535l-4.178.663-.806-4.153a1.495 1.495 0 0 1 .187-1.058l.056-.086L8.77 2.639c.958-1.351 2.803-1.076 4.296-.03 1.497 1.047 2.387 2.693 1.433 4.055L7.3 17.37zM9.14 4.728l-5.545 8.346 3.277 2.294 5.544-8.346L9.14 4.728zM6.07 16.512l-3.276-2.295.53 2.73 2.746-.435zM9.994 3.506 13.271 5.8c.316-.452-.16-1.333-1.065-1.966-.905-.634-1.895-.78-2.212-.328zM8 18.5 9.375 17H19v1.5H8z"/></svg>',ep='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.999 2H15a1 1 0 0 1 0 2h-1.004v13a1 1 0 1 1-2 0V4H8.999v13a1 1 0 1 1-2 0v-7A4 4 0 0 1 3 6a4 4 0 0 1 3.999-4z"/></svg>',tp='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 10.423a6.5 6.5 0 0 1 6.056-6.408l.038.67C6.448 5.423 5.354 7.663 5.22 10H9c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003v-4.574zm8 0a6.5 6.5 0 0 1 6.056-6.408l.038.67c-2.646.739-3.74 2.979-3.873 5.315H17c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003v-4.574z"/></svg>',np='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="9.5" cy="4.5" r="1.5"/><circle cx="9.5" cy="10.5" r="1.5"/><circle cx="9.5" cy="16.5" r="1.5"/></svg>',ip='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.187 17H5.773c-.637 0-1.092-.138-1.364-.415-.273-.277-.409-.718-.409-1.323V4.738c0-.617.14-1.062.419-1.332.279-.27.73-.406 1.354-.406h4.68c.69 0 1.288.041 1.793.124.506.083.96.242 1.36.478.341.197.644.447.906.75a3.262 3.262 0 0 1 .808 2.162c0 1.401-.722 2.426-2.167 3.075C15.05 10.175 16 11.315 16 13.01a3.756 3.756 0 0 1-2.296 3.504 6.1 6.1 0 0 1-1.517.377c-.571.073-1.238.11-2 .11zm-.217-6.217H7v4.087h3.069c1.977 0 2.965-.69 2.965-2.072 0-.707-.256-1.22-.768-1.537-.512-.319-1.277-.478-2.296-.478zM7 5.13v3.619h2.606c.729 0 1.292-.067 1.69-.2a1.6 1.6 0 0 0 .91-.765c.165-.267.247-.566.247-.897 0-.707-.26-1.176-.778-1.409-.519-.232-1.31-.348-2.375-.348H7z"/></svg>',sp='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.5 5.5H7v5h3.5a2.5 2.5 0 1 0 0-5zM5 3h6.5v.025a5 5 0 0 1 0 9.95V13H7v4a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z"/></svg>',op='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a1 1 0 0 0-1 1v6H3a1 1 0 1 0 0 2h6v6a1 1 0 1 0 2 0v-6h6a1 1 0 1 0 0-2h-6V3a1 1 0 0 0-1-1Z"/></svg>',rp='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)"><path d="M9.816 11.5 7.038 4.785 4.261 11.5h5.555Zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663L10.436 13Z"/><path clip-rule="evenodd" d="m12.09 17-.534-1.292.848-1.971.545 1.319L12.113 17h-.023Zm1.142-5.187.545 1.319L15.5 9.13l1.858 4.316h-3.45l.398.965h3.467L18.887 17H20l-3.873-9h-1.254l-1.641 3.813Z"/></g><defs><clipPath id="a"><path d="M0 0h20v20H0z"/></clipPath></defs></svg>',ap='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)"><path clip-rule="evenodd" d="M19 4.5 14 0H3v12.673l.868-1.041c.185-.222.4-.402.632-.54V1.5h8v5h5v7.626a2.24 2.24 0 0 1 1.5.822V4.5ZM14 5V2l3.3 3H14Zm-3.692 12.5c.062.105.133.206.213.303L11.52 19H8v-.876a2.243 2.243 0 0 0 1.82-.624h.488Zm7.518-.657a.75.75 0 0 0-1.152-.96L15.5 17.29V12H14v5.29l-1.174-1.408a.75.75 0 0 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0l2.346-2.815Zm-15.056-.38a.75.75 0 0 1-.096-1.056l2.346-2.815a.95.95 0 0 1 1.46 0l2.346 2.815a.75.75 0 1 1-1.152.96L6.5 14.96V20H5v-5.04l-1.174 1.408a.75.75 0 0 1-1.056.096Z"/></g><defs><clipPath id="a"><path d="M0 0h20v20H0z"/></clipPath></defs></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const $={bold:ip,cancel:Pg,caption:xg,check:Ig,cog:Rg,eraser:Mg,image:Og,lowVision:Vg,importExport:ap,paragraph:sp,plus:op,text:rp,alignBottom:Dg,alignMiddle:Ng,alignTop:Bg,alignLeft:Fg,alignCenter:Lg,alignRight:zg,alignJustify:Hg,objectLeft:Kg,objectCenter:Ug,objectRight:Gg,objectFullWidth:qg,objectInline:jg,objectBlockLeft:Wg,objectBlockRight:$g,objectSizeFull:Jg,objectSizeLarge:Qg,objectSizeSmall:Yg,objectSizeMedium:Zg,pencil:Xg,pilcrow:ep,quote:tp,threeVerticalDots:np};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hc{constructor(e){if(this.crashes=[],this.state="initializing",this._now=Date.now,this.crashes=[],this._crashNumberLimit=typeof e.crashNumberLimit=="number"?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod=typeof e.minimumNonErrorTimePeriod=="number"?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=t=>{const n="error"in t?t.error:t.reason;n instanceof Error&&this._handleError(n,t)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}destroy(){this._stopErrorHandling(),this._listeners={}}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){this._listeners[e]=this._listeners[e].filter(n=>n!==t)}_fire(e,...t){const n=this._listeners[e]||[];for(const i of n)i.apply(this,[null,...t])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const n=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:n}),n?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&e.context!==void 0&&e.context!==null&&this.state==="ready"&&this._isErrorComingFromThisItem(e)}_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;const e=this.crashes[this.crashes.length-1].date,t=this.crashes[this.crashes.length-1-this._crashNumberLimit].date;return(e-t)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ts(s,e=new Set){const t=[s],n=new Set;let i=0;for(;t.length>i;){const o=t[i++];if(!(n.has(o)||!lp(o)||e.has(o)))if(n.add(o),Symbol.iterator in o)try{for(const r of o)t.push(r)}catch{}else for(const r in o)r!=="defaultValue"&&t.push(o[r])}return n}function lp(s){const e=Object.prototype.toString.call(s),t=typeof s;return!(t==="number"||t==="boolean"||t==="string"||t==="symbol"||t==="function"||e==="[object Date]"||e==="[object RegExp]"||e==="[object Module]"||s===void 0||s===null||s._watchdogExcluded||s instanceof EventTarget||s instanceof Event)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function fc(s,e,t=new Set){if(s===e&&cp(s))return!0;const n=ts(s,t),i=ts(e,t);for(const o of n)if(i.has(o))return!0;return!1}function cp(s){return typeof s=="object"&&s!==null}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class mc extends hc{constructor(e,t={}){super(t),this._editor=null,this._throttledSave=Jn(this._save.bind(this),typeof t.saveInterval=="number"?t.saveInterval:5e3),e&&(this._creator=(n,i)=>e.create(n,i)),this._destructor=n=>n.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then(()=>(this.state="initializing",this._fire("stateChange"),this._destroy())).catch(e=>{console.error("An error happened during the editor destroying.",e)}).then(()=>{if(typeof this._elementOrData=="string")return this.create(this._data,this._config,this._config.context);{const e=Object.assign({},this._config,{initialData:this._data});return this.create(this._elementOrData,e,e.context)}}).then(()=>{this._fire("restart")})}create(e=this._elementOrData,t=this._config,n){return Promise.resolve().then(()=>(super._startErrorHandling(),this._elementOrData=e,this._config=this._cloneEditorConfiguration(t)||{},this._config.context=n,this._creator(e,this._config))).then(i=>{this._editor=i,i.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=i.model.document.version,this._data=this._getData(),this.state="ready",this._fire("stateChange")})}destroy(){return Promise.resolve().then(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling(),this._throttledSave.flush();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)})}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._lastDocumentVersion=e}catch(t){console.error(t,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(e){this._excludedProps=e}_getData(){const e={};for(const t of this._editor.model.document.getRootNames())e[t]=this._editor.data.get({rootName:t});return e}_isErrorComingFromThisItem(e){return fc(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return bs(e,(t,n)=>{if(qt(t)||n==="context")return t})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const on=Symbol("MainQueueId");class dp extends hc{constructor(e,t={}){super(t),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new up,this._watchdogConfig=t,this._creator=n=>e.create(n),this._destructor=n=>n.destroy(),this._actionQueues.onEmpty(()=>{this.state==="initializing"&&(this.state="ready",this._fire("stateChange"))})}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(on,()=>(this._contextConfig=e,this._create()))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=ir(e);return Promise.all(t.map(n=>this._actionQueues.enqueue(n.id,()=>{if(this.state==="destroyed")throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let i;if(this._watchdogs.has(n.id))throw new Error(`Item with the given id is already added: '${n.id}'.`);if(n.type==="editor")return i=new mc(null,this._watchdogConfig),i.setCreator(n.creator),i._setExcludedProperties(this._contextProps),n.destructor&&i.setDestructor(n.destructor),this._watchdogs.set(n.id,i),i.on("error",(o,{error:r,causesRestart:a})=>{this._fire("itemError",{itemId:n.id,error:r}),a&&this._actionQueues.enqueue(n.id,()=>new Promise(l=>{const c=()=>{i.off("restart",c),this._fire("itemRestart",{itemId:n.id}),l()};i.on("restart",c)}))}),i.create(n.sourceElementOrData,n.config,this._context);throw new Error(`Not supported item type: '${n.type}'.`)})))}remove(e){const t=ir(e);return Promise.all(t.map(n=>this._actionQueues.enqueue(n,()=>{const i=this._getWatchdog(n);return this._watchdogs.delete(n),i.destroy()})))}destroy(){return this._actionQueues.enqueue(on,()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))}_restart(){return this._actionQueues.enqueue(on,()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch(e=>{console.error("An error happened during destroying the context or items.",e)}).then(()=>this._create()).then(()=>this._fire("restart"))))}_create(){return Promise.resolve().then(()=>(this._startErrorHandling(),this._creator(this._contextConfig))).then(e=>(this._context=e,this._contextProps=ts(this._context),Promise.all(Array.from(this._watchdogs.values()).map(t=>(t._setExcludedProperties(this._contextProps),t.create(void 0,void 0,this._context))))))}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling();const e=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map(t=>t.destroy())).then(()=>this._destructor(e))})}_getWatchdog(e){const t=this._watchdogs.get(e);if(!t)throw new Error(`Item with the given id was not registered: ${e}.`);return t}_isErrorComingFromThisItem(e){for(const t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return fc(this._context,e.context)}}class up{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const n=e===on;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const o=(n?Promise.all(this._queues.values()):Promise.all([this._queues.get(on),this._queues.get(e)])).then(t),r=o.catch(()=>{});return this._queues.set(e,r),o.finally(()=>{this._activeActions--,this._queues.get(e)===r&&this._activeActions===0&&this._onEmptyCallbacks.forEach(a=>a())})}}function ir(s){return Array.isArray(s)?s:[s]}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Vs({emitter:s,activator:e,callback:t,contextElements:n}){s.listenTo(document,"mousedown",(i,o)=>{if(!e())return;const r=typeof o.composedPath=="function"?o.composedPath():[],a=typeof n=="function"?n():n;for(const l of a)if(l.contains(o.target)||r.includes(l))return;t()})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Os(s){class e extends s{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...n){super(...n),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ds({view:s}){s.listenTo(s.element,"submit",(e,t)=>{t.preventDefault(),s.fire("submit")},{useCapture:!0})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function hp({keystrokeHandler:s,focusTracker:e,gridItems:t,numberOfColumns:n,uiLanguageDirection:i}){const o=typeof n=="number"?()=>n:n;s.set("arrowright",r((c,d)=>i==="rtl"?l(c,d.length):a(c,d.length))),s.set("arrowleft",r((c,d)=>i==="rtl"?a(c,d.length):l(c,d.length))),s.set("arrowup",r((c,d)=>{let u=c-o();return u<0&&(u=c+o()*Math.floor(d.length/o()),u>d.length-1&&(u-=o())),u})),s.set("arrowdown",r((c,d)=>{let u=c+o();return u>d.length-1&&(u=c%o()),u}));function r(c){return d=>{const u=t.find(g=>g.element===e.focusedElement),h=t.getIndex(u),f=c(h,t);t.get(f).focus(),d.stopPropagation(),d.preventDefault()}}function a(c,d){return c===d-1?0:c+1}function l(c,d){return c===0?d-1:c-1}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rt extends _e{constructor(e=[]){super(e,{idProperty:"viewUid"}),this.on("add",(t,n,i)=>{this._renderViewIntoCollectionParent(n,i)}),this.on("remove",(t,n)=>{n.element&&this._parentElement&&n.element.remove()}),this._parentElement=null}destroy(){this.map(e=>e.destroy())}setParent(e){this._parentElement=e;for(const t of this)this._renderViewIntoCollectionParent(t)}delegate(...e){if(!e.length||!fp(e))throw new m("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const n of this)for(const i of e)n.delegate(i).to(t);this.on("add",(n,i)=>{for(const o of e)i.delegate(o).to(t)}),this.on("remove",(n,i)=>{for(const o of e)i.stopDelegating(o,t)})}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}remove(e){return super.remove(e)}}function fp(s){return s.every(e=>typeof e=="string")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class I extends Qe(D()){constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new _e,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",(t,n)=>{n.locale=e,n.t=e&&e.t}),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=Ve.bind(this,this)}createCollection(e){const t=new rt(e);return this._viewCollections.add(t),t}registerChild(e){pe(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){pe(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new Ve(e)}extendTemplate(e){Ve.extend(this.template,e)}render(){if(this.isRendered)throw new m("ui-view-render-already-rendered",this);this.template&&(this.element=this.template.render(),this.registerChild(this.template.getViews())),this.isRendered=!0}destroy(){this.stopListening(),this._viewCollections.map(e=>e.destroy()),this.template&&this.template._revertData&&this.template.revert(this.element)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const mp="http://www.w3.org/1999/xhtml";class Ve extends H(){constructor(e){super(),Object.assign(this,or(sr(e))),this._isRendered=!1,this._revertData=null}render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData=lr(),this._renderNode({node:e,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new m("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){function*e(t){if(t.children)for(const n of t.children)Wn(n)?yield n:Ns(n)&&(yield*e(n))}yield*e(this)}static bind(e,t){return{to(n,i){return new gp({eventNameOrFunction:n,attribute:n,observable:e,emitter:t,callback:i})},if(n,i,o){return new gc({observable:e,emitter:t,attribute:n,valueIfTrue:i,callback:o})}}}static extend(e,t){if(e._isRendered)throw new m("template-extend-render",[this,e]);_c(e,or(sr(t)))}_renderNode(e){let t;if(e.node?t=this.tag&&this.text:t=this.tag?this.text:!this.text,t)throw new m("ui-template-wrong-syntax",this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return t||(t=e.node=document.createElementNS(this.ns||mp,this.tag)),this._renderAttributes(e),this._renderElementChildren(e),this._setUpListeners(e),t}_renderText(e){let t=e.node;return t?e.revertData.text=t.textContent:t=e.node=document.createTextNode(""),In(this.text)?this._bindToObservable({schema:this.text,updater:wp(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,n=e.revertData;for(const i in this.attributes){const o=t.getAttribute(i),r=this.attributes[i];n&&(n.attributes[i]=o);const a=ar(r)?r[0].ns:null;if(In(r)){const l=ar(r)?r[0].value:r;n&&cr(i)&&l.unshift(o),this._bindToObservable({schema:l,updater:bp(t,i,a),data:e})}else if(i=="style"&&typeof r[0]!="string")this._renderStyleAttribute(r[0],e);else{n&&o&&cr(i)&&r.unshift(o);const l=r.map(c=>c&&(c.value||c)).reduce((c,d)=>c.concat(d),[]).reduce(bc,"");Ht(l)||t.setAttributeNS(a,i,l)}}}_renderStyleAttribute(e,t){const n=t.node;for(const i in e){const o=e[i];In(o)?this._bindToObservable({schema:[o],updater:_p(n,i),data:t}):n.style[i]=o}}_renderElementChildren(e){const t=e.node,n=e.intoFragment?document.createDocumentFragment():t,i=e.isApplying;let o=0;for(const r of this.children)if(Bs(r)){if(!i){r.setParent(t);for(const a of r)n.appendChild(a.element)}}else if(Wn(r))i||(r.isRendered||r.render(),n.appendChild(r.element));else if(nt(r))n.appendChild(r);else if(i){const a=e.revertData,l=lr();a.children.push(l),r._renderNode({intoFragment:!1,node:n.childNodes[o++],isApplying:!0,revertData:l})}else n.appendChild(r.render());e.intoFragment&&t.appendChild(n)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const n=this.eventListeners[t].map(i=>{const[o,r]=t.split("@");return i.activateDomEventListener(o,r,e)});e.revertData&&e.revertData.bindings.push(n)}}_bindToObservable({schema:e,updater:t,data:n}){const i=n.revertData;pc(e,t,n);const o=e.filter(r=>!Ht(r)).filter(r=>r.observable).map(r=>r.activateAttributeListener(e,t,n));i&&i.bindings.push(o)}_revertTemplateFromNode(e,t){for(const i of t.bindings)for(const o of i)o();if(t.text){e.textContent=t.text;return}const n=e;for(const i in t.attributes){const o=t.attributes[i];o===null?n.removeAttribute(i):n.setAttribute(i,o)}for(let i=0;i<t.children.length;++i)this._revertTemplateFromNode(n.childNodes[i],t.children[i])}}class hn{constructor(e){this.attribute=e.attribute,this.observable=e.observable,this.emitter=e.emitter,this.callback=e.callback}getValue(e){const t=this.observable[this.attribute];return this.callback?this.callback(t,e):t}activateAttributeListener(e,t,n){const i=()=>pc(e,t,n);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,i),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,i)}}}class gp extends hn{constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,n){const i=(o,r)=>{(!t||r.target.matches(t))&&(typeof this.eventNameOrFunction=="function"?this.eventNameOrFunction(r):this.observable.fire(this.eventNameOrFunction,r))};return this.emitter.listenTo(n.node,e,i),()=>{this.emitter.stopListening(n.node,e,i)}}}class gc extends hn{constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){const t=super.getValue(e);return Ht(t)?!1:this.valueIfTrue||!0}}function In(s){return s?(s.value&&(s=s.value),Array.isArray(s)?s.some(In):s instanceof hn):!1}function pp(s,e){return s.map(t=>t instanceof hn?t.getValue(e):t)}function pc(s,e,{node:t}){const n=pp(s,t);let i;s.length==1&&s[0]instanceof gc?i=n[0]:i=n.reduce(bc,""),Ht(i)?e.remove():e.set(i)}function wp(s){return{set(e){s.textContent=e},remove(){s.textContent=""}}}function bp(s,e,t){return{set(n){s.setAttributeNS(t,e,n)},remove(){s.removeAttributeNS(t,e)}}}function _p(s,e){return{set(t){s.style[e]=t},remove(){s.style[e]=null}}}function sr(s){return bs(s,t=>{if(t&&(t instanceof hn||Ns(t)||Wn(t)||Bs(t)))return t})}function or(s){if(typeof s=="string"?s=Cp(s):s.text&&kp(s),s.on&&(s.eventListeners=yp(s.on),delete s.on),!s.text){s.attributes&&vp(s.attributes);const e=[];if(s.children)if(Bs(s.children))e.push(s.children);else for(const t of s.children)Ns(t)||Wn(t)||nt(t)?e.push(t):e.push(new Ve(t));s.children=e}return s}function vp(s){for(const e in s)s[e].value&&(s[e].value=se(s[e].value)),wc(s,e)}function yp(s){for(const e in s)wc(s,e);return s}function Cp(s){return{text:[s]}}function kp(s){s.text=se(s.text)}function wc(s,e){s[e]=se(s[e])}function bc(s,e){return Ht(e)?s:Ht(s)?e:`${s} ${e}`}function rr(s,e){for(const t in e)s[t]?s[t].push(...e[t]):s[t]=e[t]}function _c(s,e){if(e.attributes&&(s.attributes||(s.attributes={}),rr(s.attributes,e.attributes)),e.eventListeners&&(s.eventListeners||(s.eventListeners={}),rr(s.eventListeners,e.eventListeners)),e.text&&s.text.push(...e.text),e.children&&e.children.length){if(s.children.length!=e.children.length)throw new m("ui-template-extend-children-mismatch",s);let t=0;for(const n of e.children)_c(s.children[t++],n)}}function Ht(s){return!s&&s!==0}function Wn(s){return s instanceof I}function Ns(s){return s instanceof Ve}function Bs(s){return s instanceof rt}function ar(s){return Oe(s[0])&&s[0].ns}function lr(){return{children:[],bindings:[],attributes:{}}}function cr(s){return s=="class"||s=="style"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ep extends rt{constructor(e,t=[]){super(t),this.locale=e}attachToDom(){this._bodyCollectionContainer=new Ve({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection},children:this}).render();let e=document.querySelector(".ck-body-wrapper");e||(e=zi(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(e)),e.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove();const e=document.querySelector(".ck-body-wrapper");e&&e.childElementCount==0&&e.remove()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class at extends I{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon","ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox")}})}render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",()=>{this._updateXMLContent(),this._colorFillPaths()}),this.on("change:fillColor",()=>{this._colorFillPaths()})}_updateXMLContent(){if(this.content){const t=new DOMParser().parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),n=t.getAttribute("viewBox");n&&(this.viewBox=n);for(const{name:i,value:o}of Array.from(t.attributes))at.presentationalAttributeNames.includes(i)&&this.element.setAttribute(i,o);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;t.childNodes.length>0;)this.element.appendChild(t.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach(e=>{e.style.fill=this.fillColor})}}at.presentationalAttributeNames=["alignment-baseline","baseline-shift","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-rendering","cursor","direction","display","dominant-baseline","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-overflow","text-rendering","transform","unicode-bidi","vector-effect","visibility","white-space","word-spacing","writing-mode"];/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class W extends I{constructor(e){super(e),this._focusDelayed=null;const t=this.bindTemplate,n=De();this.set("ariaChecked",void 0),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${n}`),this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke",void 0),this.set("label",void 0),this.set("role",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.labelView=this._createLabelView(),this.iconView=new at,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const i={tag:"button",attributes:{class:["ck","ck-button",t.to("class"),t.if("isEnabled","ck-disabled",o=>!o),t.if("isVisible","ck-hidden",o=>!o),t.to("isOn",o=>o?"ck-on":"ck-off"),t.if("withText","ck-button_with-text"),t.if("withKeystroke","ck-button_with-keystroke")],role:t.to("role"),type:t.to("type",o=>o||"button"),tabindex:t.to("tabindex"),"aria-label":t.to("ariaLabel"),"aria-labelledby":t.to("ariaLabelledBy"),"aria-disabled":t.if("isEnabled",!0,o=>!o),"aria-checked":t.to("isOn"),"aria-pressed":t.to("isOn",o=>this.isToggleable?String(!!o):!1),"data-cke-tooltip-text":t.to("_tooltipString"),"data-cke-tooltip-position":t.to("tooltipPosition")},children:this.children,on:{click:t.to(o=>{this.isEnabled?this.fire("execute"):o.preventDefault()})}};P.isSafari&&(this._focusDelayed||(this._focusDelayed=Ui(()=>this.focus(),0)),i.on.mousedown=t.to(()=>{this._focusDelayed()}),i.on.mouseup=t.to(()=>{this._focusDelayed.cancel()})),this.setTemplate(i)}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}destroy(){this._focusDelayed&&this._focusDelayed.cancel(),super.destroy()}_createLabelView(){const e=new I,t=this.bindTemplate;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:t.to("labelStyle"),id:this.ariaLabelledBy},children:[{text:t.to("label")}]}),e}_createKeystrokeView(){const e=new I;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",t=>wo(t))}]}),e}_getTooltipString(e,t,n){return e?typeof e=="string"?e:(n&&(n=wo(n)),e instanceof Function?e(t,n):`${t}${n?` (${n})`:""}`):""}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class si extends W{constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new I;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tp extends I{constructor(e){super(e),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${De()}`;const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Fs extends I{constructor(e,t){super(e);const n=`ck-labeled-field-view-${De()}`,i=`ck-labeled-field-view-status-${De()}`;this.fieldView=t(this,n,i),this.set("label",void 0),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class",void 0),this.set("placeholder",void 0),this.labelView=this._createLabelView(n),this.statusView=this._createStatusView(i),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",(r,a)=>r||a);const o=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",o.to("class"),o.if("isEnabled","ck-disabled",r=>!r),o.if("isEmpty","ck-labeled-field-view_empty"),o.if("isFocused","ck-labeled-field-view_focused"),o.if("placeholder","ck-labeled-field-view_placeholder"),o.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:this.fieldWrapperChildren},this.statusView]})}_createLabelView(e){const t=new Tp(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new I(this.locale),n=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",n.if("errorText","ck-labeled-field-view__status_error"),n.if("_statusText","ck-hidden",i=>!i)],id:e,role:n.if("errorText","alert")},children:[{text:n.to("_statusText")}]}),t}focus(){this.fieldView.focus()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ap extends I{constructor(e){super(e),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.focusTracker=new ve,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0),this.set("inputMode","text");const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),readonly:t.to("isReadOnly"),inputmode:t.to("inputMode"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById")},on:{input:t.to((...n)=>{this.fire("input",...n),this._updateIsEmpty()}),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",(e,t,n)=>{this._setDomElementValue(n),this._updateIsEmpty()})}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}_updateIsEmpty(){this.isEmpty=Sp(this.element)}_setDomElementValue(e){this.element.value=!e&&e!==0?"":e}}function Sp(s){return!s.value}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pp extends Ap{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class xp extends I{constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-dropdown__panel",t.to("position",n=>`ck-dropdown__panel_${n}`),t.if("isVisible","ck-dropdown__panel-visible")]},children:this.children,on:{selectstart:t.to(n=>{n.target.tagName.toLocaleLowerCase()!=="input"&&n.preventDefault()})}})}focus(){if(this.children.length){const e=this.children.first;typeof e.focus=="function"?e.focus():K("ui-dropdown-panel-focus-child-missing-focus",{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){const e=this.children.last;typeof e.focusLast=="function"?e.focusLast():e.focus()}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wt extends I{constructor(e,t,n){super(e);const i=this.bindTemplate;this.buttonView=t,this.panelView=n,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.keystrokes=new Be,this.focusTracker=new ve,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",i.to("class"),i.if("isEnabled","ck-disabled",o=>!o)],id:i.to("id"),"aria-describedby":i.to("ariaDescribedById")},children:[t,n]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":i.to("isOpen")}})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.listenTo(this.buttonView,"open",()=>{this.isOpen=!this.isOpen}),this.panelView.bind("isVisible").to(this,"isOpen"),this.on("change:isOpen",(t,n,i)=>{i&&(this.panelPosition==="auto"?this.panelView.position=Wt._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions}).name:this.panelView.position=this.panelPosition)}),this.keystrokes.listenTo(this.element);const e=(t,n)=>{this.isOpen&&(this.isOpen=!1,n())};this.keystrokes.set("arrowdown",(t,n)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,n())}),this.keystrokes.set("arrowright",(t,n)=>{this.isOpen&&n()}),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:n,southWest:i,northEast:o,northWest:r,southMiddleEast:a,southMiddleWest:l,northMiddleEast:c,northMiddleWest:d}=Wt.defaultPanelPositions;return this.locale.uiLanguageDirection!=="rtl"?[n,i,a,l,e,o,r,c,d,t]:[i,n,l,a,e,r,o,d,c,t]}}Wt.defaultPanelPositions={south:(s,e)=>({top:s.bottom,left:s.left-(e.width-s.width)/2,name:"s"}),southEast:s=>({top:s.bottom,left:s.left,name:"se"}),southWest:(s,e)=>({top:s.bottom,left:s.left-e.width+s.width,name:"sw"}),southMiddleEast:(s,e)=>({top:s.bottom,left:s.left-(e.width-s.width)/4,name:"sme"}),southMiddleWest:(s,e)=>({top:s.bottom,left:s.left-(e.width-s.width)*3/4,name:"smw"}),north:(s,e)=>({top:s.top-e.height,left:s.left-(e.width-s.width)/2,name:"n"}),northEast:(s,e)=>({top:s.top-e.height,left:s.left,name:"ne"}),northWest:(s,e)=>({top:s.top-e.height,left:s.left-e.width+s.width,name:"nw"}),northMiddleEast:(s,e)=>({top:s.top-e.height,left:s.left-(e.width-s.width)/4,name:"nme"}),northMiddleWest:(s,e)=>({top:s.top-e.height,left:s.left-(e.width-s.width)*3/4,name:"nmw"})};Wt._getOptimalPosition=hl;const vc='<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path d="M.941 4.523a.75.75 0 1 1 1.06-1.06l3.006 3.005 3.005-3.005a.75.75 0 1 1 1.06 1.06l-3.549 3.55a.75.75 0 0 1-1.168-.136L.941 4.523z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yc extends W{constructor(e){super(e),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",t=>String(t))}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new at;return e.content=vc,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Kt{constructor(e){if(this.focusables=e.focusables,this.focusTracker=e.focusTracker,this.keystrokeHandler=e.keystrokeHandler,this.actions=e.actions,e.actions&&e.keystrokeHandler)for(const t in e.actions){let n=e.actions[t];typeof n=="string"&&(n=[n]);for(const i of n)e.keystrokeHandler.set(i,(o,r)=>{this[t](),r()})}}get first(){return this.focusables.find(_i)||null}get last(){return this.focusables.filter(_i).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-1)}get current(){let e=null;return this.focusTracker.focusedElement===null?null:(this.focusables.find((t,n)=>{const i=t.element===this.focusTracker.focusedElement;return i&&(e=n),i}),e)}focusFirst(){this._focus(this.first)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(e){e&&e.focus()}_getFocusableItem(e){const t=this.current,n=this.focusables.length;if(!n)return null;if(t===null)return this[e===1?"first":"last"];let i=(t+n+e)%n;do{const o=this.focusables.get(i);if(_i(o))return o;i=(i+n+e)%n}while(i!==t);return null}}function _i(s){return!!(s.focus&&_t(s.element))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Cc extends I{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ip extends I{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Rp(s){return s.bindTemplate.to(e=>{e.target===s.element&&e.preventDefault()})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Mp(s){return Array.isArray(s)?{items:s,removeItems:[]}:s?Object.assign({items:[],removeItems:[]},s):{items:[],removeItems:[]}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const{threeVerticalDots:kc}=$,Vp={alignLeft:$.alignLeft,bold:$.bold,importExport:$.importExport,paragraph:$.paragraph,plus:$.plus,text:$.text,threeVerticalDots:$.threeVerticalDots};class Ls extends I{constructor(e,t){super(e);const n=this.bindTemplate,i=this.t;this.options=t||{},this.set("ariaLabel",i("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new ve,this.keystrokes=new Be,this.set("class",void 0),this.set("isCompact",!1),this.itemsView=new Op(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const o=e.uiLanguageDirection==="rtl";this._focusCycler=new Kt({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[o?"arrowright":"arrowleft","arrowup"],focusNext:[o?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",n.to("class"),n.if("isCompact","ck-toolbar_compact")];this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:"toolbar","aria-label":n.to("ariaLabel"),style:{maxWidth:n.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:Rp(this)}}),this._behavior=this.options.shouldGroupWhenFull?new Np(this):new Dp(this)}render(){super.render(),this.focusTracker.add(this.element);for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",(e,t)=>{this.focusTracker.add(t.element)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t.element)}),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(e,t,n){this.items.addMany(this._buildItemsFromConfig(e,t,n))}_buildItemsFromConfig(e,t,n){const i=Mp(e),o=n||i.removeItems;return this._cleanItemsConfiguration(i.items,t,o).map(a=>Oe(a)?this._createNestedToolbarDropdown(a,t,o):a==="|"?new Cc:a==="-"?new Ip:t.create(a)).filter(a=>!!a)}_cleanItemsConfiguration(e,t,n){const i=e.filter((o,r,a)=>o==="|"?!0:n.indexOf(o)!==-1?!1:o==="-"?this.options.shouldGroupWhenFull?(K("toolbarview-line-break-ignored-when-grouping-items",a),!1):!0:!Oe(o)&&!t.has(o)?(K("toolbarview-item-unavailable",{item:o}),!1):!0);return this._cleanSeparatorsAndLineBreaks(i)}_cleanSeparatorsAndLineBreaks(e){const t=r=>r!=="-"&&r!=="|",n=e.length,i=e.findIndex(t);if(i===-1)return[];const o=n-e.slice().reverse().findIndex(t);return e.slice(i,o).filter((r,a,l)=>t(r)?!0:!(a>0&&l[a-1]===r))}_createNestedToolbarDropdown(e,t,n){let{label:i,icon:o,items:r,tooltip:a=!0,withText:l=!1}=e;if(r=this._cleanItemsConfiguration(r,t,n),!r.length)return null;const c=this.locale,d=qe(c);return i||K("toolbarview-nested-toolbar-dropdown-missing-label",e),d.class="ck-toolbar__nested-toolbar-dropdown",d.buttonView.set({label:i,tooltip:a,withText:!!l}),o!==!1?d.buttonView.icon=Vp[o]||o||kc:d.buttonView.withText=!0,Hs(d,()=>d.toolbarView._buildItemsFromConfig(r,t,n)),d}}class Op extends I{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Dp{constructor(e){const t=e.bindTemplate;e.set("isVertical",!1),e.itemsView.children.bindTo(e.items).using(n=>n),e.focusables.bindTo(e.items).using(n=>n),e.extendTemplate({attributes:{class:[t.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class Np{constructor(e){this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),e.itemsView.children.bindTo(this.ungroupedItems).using(t=>t),this.ungroupedItems.on("change",this._updateFocusCycleableItems.bind(this)),e.children.on("change",this._updateFocusCycleableItems.bind(this)),e.items.on("change",(t,n)=>{const i=n.index,o=Array.from(n.added);for(const r of n.removed)i>=this.ungroupedItems.length?this.groupedItems.remove(r):this.ungroupedItems.remove(r);for(let r=i;r<i+o.length;r++){const a=o[r-i];r>this.ungroupedItems.length?this.groupedItems.add(a,r-this.ungroupedItems.length):this.ungroupedItems.add(a,r)}this._updateGrouping()}),e.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!_t(this.viewElement)){this.shouldUpdateGroupingOnNextResize=!0;return}const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,t=this.viewLocale.uiLanguageDirection,n=new L(e.lastChild),i=new L(e);if(!this.cachedPadding){const o=S.window.getComputedStyle(e),r=t==="ltr"?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(o[r])}return t==="ltr"?n.right>i.right-this.cachedPadding:n.left<i.left+this.cachedPadding}_enableGroupingOnResize(){let e;this.resizeObserver=new U(this.viewElement,t=>{(!e||e!==t.contentRect.width||this.shouldUpdateGroupingOnNextResize)&&(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)}),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",()=>{this._updateGrouping()})}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new Cc),this.viewChildren.add(this.groupedItemsDropdown),this.viewFocusTracker.add(this.groupedItemsDropdown.element)),this.groupedItems.add(this.ungroupedItems.remove(this.ungroupedItems.last),0)}_ungroupFirstItem(){this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first)),this.groupedItems.length||(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last),this.viewFocusTracker.remove(this.groupedItemsDropdown.element))}_createGroupedItemsDropdown(){const e=this.viewLocale,t=e.t,n=qe(e);return n.class="ck-toolbar__grouped-dropdown",n.panelPosition=e.uiLanguageDirection==="ltr"?"sw":"se",Hs(n,this.groupedItems),n.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:e.uiLanguageDirection==="rtl"?"se":"sw",icon:kc}),n}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map(e=>{this.viewFocusables.add(e)}),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Bp extends I{constructor(e){super(e);const t=this.bindTemplate;this.items=this.createCollection(),this.focusTracker=new ve,this.keystrokes=new Be,this._focusCycler=new Kt({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",void 0),this.set("role",void 0),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"],role:t.to("role"),"aria-label":t.to("ariaLabel")},children:this.items})}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",(e,t)=>{this.focusTracker.add(t.element)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ec extends I{constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!0),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item",t.if("isVisible","ck-hidden",n=>!n)],role:"presentation"},children:this.children})}focus(){this.children.first.focus()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Fp extends I{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zs extends I{constructor(e){super(e);const t=this.bindTemplate;this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke",void 0),this.set("withKeystroke",!1),this.set("label",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(),this.arrowView=this._createArrowView(),this.keystrokes=new Be,this.focusTracker=new ve,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",t.to("class"),t.if("isVisible","ck-hidden",n=>!n),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",(e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())}),this.keystrokes.set("arrowleft",(e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(){const e=new W;return e.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),e.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),e.delegate("execute").to(this),e}_createArrowView(){const e=new W,t=e.bindTemplate;return e.icon=vc,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",n=>String(n))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function qe(s,e=yc){const t=new e(s),n=new xp(s),i=new Wt(s,t,n);return t.bind("isEnabled").to(i),t instanceof zs?t.arrowView.bind("isOn").to(i,"isOpen"):t.bind("isOn").to(i,"isOpen"),Lp(i),i}function Hs(s,e,t={}){s.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),s.isOpen?dr(s,e,t):s.once("change:isOpen",()=>dr(s,e,t),{priority:"highest"}),t.enableActiveItemFocusOnDropdownOpen&&Tc(s,()=>s.toolbarView.items.find(n=>n.isOn))}function dr(s,e,t){const n=s.locale,i=n.t,o=s.toolbarView=new Ls(n),r=typeof e=="function"?e():e;o.ariaLabel=t.ariaLabel||i("Dropdown toolbar"),t.maxWidth&&(o.maxWidth=t.maxWidth),t.class&&(o.class=t.class),t.isCompact&&(o.isCompact=t.isCompact),t.isVertical&&(o.isVertical=!0),r instanceof rt?o.items.bindTo(r).using(a=>a):o.items.addMany(r),s.panelView.children.add(o),o.items.delegate("execute").to(s)}function Ws(s,e,t={}){s.isOpen?ur(s,e,t):s.once("change:isOpen",()=>ur(s,e,t),{priority:"highest"}),Tc(s,()=>s.listView.items.find(n=>n instanceof Ec?n.children.first.isOn:!1))}function ur(s,e,t){const n=s.locale,i=s.listView=new Bp(n),o=typeof e=="function"?e():e;i.ariaLabel=t.ariaLabel,i.role=t.role,i.items.bindTo(o).using(r=>{if(r.type==="separator")return new Fp(n);if(r.type==="button"||r.type==="switchbutton"){const a=new Ec(n);let l;return r.type==="button"?l=new W(n):l=new si(n),l.bind(...Object.keys(r.model)).to(r.model),l.delegate("execute").to(a),a.children.add(l),a}return null}),s.panelView.children.add(i),i.items.delegate("execute").to(s)}function Tc(s,e){s.on("change:isOpen",()=>{if(!s.isOpen)return;const t=e();t&&(typeof t.focus=="function"?t.focus():K("ui-dropdown-focus-child-on-open-child-missing-focus",{view:t}))},{priority:tt.low-10})}function Lp(s){zp(s),Hp(s),Wp(s),Up(s),$p(s),qp(s)}function zp(s){s.on("render",()=>{Vs({emitter:s,activator:()=>s.isOpen,callback:()=>{s.isOpen=!1},contextElements:[s.element]})})}function Hp(s){s.on("execute",e=>{e.source instanceof si||(s.isOpen=!1)})}function Wp(s){s.focusTracker.on("change:isFocused",(e,t,n)=>{s.isOpen&&!n&&(s.isOpen=!1)})}function Up(s){s.keystrokes.set("arrowdown",(e,t)=>{s.isOpen&&(s.panelView.focus(),t())}),s.keystrokes.set("arrowup",(e,t)=>{s.isOpen&&(s.panelView.focusLast(),t())})}function $p(s){s.on("change:isOpen",(e,t,n)=>{if(n)return;const i=s.panelView.element;i&&i.contains(S.document.activeElement)&&s.buttonView.focus()})}function qp(s){s.on("change:isOpen",(e,t,n)=>{n&&s.panelView.focus()},{priority:"low"})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Us(s,e,t){const n=new Pp(s.locale);return n.set({id:e,ariaDescribedById:t}),n.bind("isReadOnly").to(s,"isEnabled",i=>!i),n.bind("hasError").to(s,"errorText",i=>!!i),n.on("input",()=>{s.errorText=null}),s.bind("isEmpty","isFocused","placeholder").to(n),n}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jp{constructor(e){this._components=new Map,this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(vi(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new m("componentfactory-item-missing",this,{name:e});return this._components.get(vi(e)).callback(this.editor.locale)}has(e){return this._components.has(vi(e))}}function vi(s){return String(s).toLowerCase()}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const hr=dl("px"),fr=S.document.body;class de extends I{constructor(e){super(e);const t=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class",void 0),this._pinWhenIsVisibleCallback=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",n=>`ck-balloon-panel_${n}`),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",hr),left:t.to("left",hr)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=de.defaultPositions,n=Object.assign({},{element:this.element,positions:[t.southArrowNorth,t.southArrowNorthMiddleWest,t.southArrowNorthMiddleEast,t.southArrowNorthWest,t.southArrowNorthEast,t.northArrowSouth,t.northArrowSouthMiddleWest,t.northArrowSouthMiddleEast,t.northArrowSouthWest,t.northArrowSouthEast,t.viewportStickyNorth],limiter:fr,fitInViewport:!0},e),i=de._getOptimalPosition(n),o=parseInt(i.left),r=parseInt(i.top),a=i.name,l=i.config||{},{withArrow:c=!0}=l;this.top=r,this.left=o,this.position=a,this.withArrow=c}pin(e){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this._startPinning(e),this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback)}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(e){this.attachTo(e);const t=ns(e.target),n=e.limiter?ns(e.limiter):fr;this.listenTo(S.document,"scroll",(i,o)=>{const r=o.target,a=t&&r.contains(t),l=n&&r.contains(n);(a||l||!t||!n)&&this.attachTo(e)},{useCapture:!0}),this.listenTo(S.window,"resize",()=>{this.attachTo(e)})}_stopPinning(){this.stopListening(S.document,"scroll"),this.stopListening(S.window,"resize")}}de.arrowSideOffset=25;de.arrowHeightOffset=10;de.stickyVerticalOffset=20;de._getOptimalPosition=hl;de.defaultPositions=Ac();function ns(s){return qt(s)?s:Yn(s)?s.commonAncestorContainer:typeof s=="function"?ns(s()):null}function Ac(s={}){const{sideOffset:e=de.arrowSideOffset,heightOffset:t=de.arrowHeightOffset,stickyVerticalOffset:n=de.stickyVerticalOffset,config:i}=s;return{northWestArrowSouthWest:(a,l)=>({top:o(a,l),left:a.left-e,name:"arrow_sw",...i&&{config:i}}),northWestArrowSouthMiddleWest:(a,l)=>({top:o(a,l),left:a.left-l.width*.25-e,name:"arrow_smw",...i&&{config:i}}),northWestArrowSouth:(a,l)=>({top:o(a,l),left:a.left-l.width/2,name:"arrow_s",...i&&{config:i}}),northWestArrowSouthMiddleEast:(a,l)=>({top:o(a,l),left:a.left-l.width*.75+e,name:"arrow_sme",...i&&{config:i}}),northWestArrowSouthEast:(a,l)=>({top:o(a,l),left:a.left-l.width+e,name:"arrow_se",...i&&{config:i}}),northArrowSouthWest:(a,l)=>({top:o(a,l),left:a.left+a.width/2-e,name:"arrow_sw",...i&&{config:i}}),northArrowSouthMiddleWest:(a,l)=>({top:o(a,l),left:a.left+a.width/2-l.width*.25-e,name:"arrow_smw",...i&&{config:i}}),northArrowSouth:(a,l)=>({top:o(a,l),left:a.left+a.width/2-l.width/2,name:"arrow_s",...i&&{config:i}}),northArrowSouthMiddleEast:(a,l)=>({top:o(a,l),left:a.left+a.width/2-l.width*.75+e,name:"arrow_sme",...i&&{config:i}}),northArrowSouthEast:(a,l)=>({top:o(a,l),left:a.left+a.width/2-l.width+e,name:"arrow_se",...i&&{config:i}}),northEastArrowSouthWest:(a,l)=>({top:o(a,l),left:a.right-e,name:"arrow_sw",...i&&{config:i}}),northEastArrowSouthMiddleWest:(a,l)=>({top:o(a,l),left:a.right-l.width*.25-e,name:"arrow_smw",...i&&{config:i}}),northEastArrowSouth:(a,l)=>({top:o(a,l),left:a.right-l.width/2,name:"arrow_s",...i&&{config:i}}),northEastArrowSouthMiddleEast:(a,l)=>({top:o(a,l),left:a.right-l.width*.75+e,name:"arrow_sme",...i&&{config:i}}),northEastArrowSouthEast:(a,l)=>({top:o(a,l),left:a.right-l.width+e,name:"arrow_se",...i&&{config:i}}),southWestArrowNorthWest:a=>({top:r(a),left:a.left-e,name:"arrow_nw",...i&&{config:i}}),southWestArrowNorthMiddleWest:(a,l)=>({top:r(a),left:a.left-l.width*.25-e,name:"arrow_nmw",...i&&{config:i}}),southWestArrowNorth:(a,l)=>({top:r(a),left:a.left-l.width/2,name:"arrow_n",...i&&{config:i}}),southWestArrowNorthMiddleEast:(a,l)=>({top:r(a),left:a.left-l.width*.75+e,name:"arrow_nme",...i&&{config:i}}),southWestArrowNorthEast:(a,l)=>({top:r(a),left:a.left-l.width+e,name:"arrow_ne",...i&&{config:i}}),southArrowNorthWest:a=>({top:r(a),left:a.left+a.width/2-e,name:"arrow_nw",...i&&{config:i}}),southArrowNorthMiddleWest:(a,l)=>({top:r(a),left:a.left+a.width/2-l.width*.25-e,name:"arrow_nmw",...i&&{config:i}}),southArrowNorth:(a,l)=>({top:r(a),left:a.left+a.width/2-l.width/2,name:"arrow_n",...i&&{config:i}}),southArrowNorthMiddleEast:(a,l)=>({top:r(a),left:a.left+a.width/2-l.width*.75+e,name:"arrow_nme",...i&&{config:i}}),southArrowNorthEast:(a,l)=>({top:r(a),left:a.left+a.width/2-l.width+e,name:"arrow_ne",...i&&{config:i}}),southEastArrowNorthWest:a=>({top:r(a),left:a.right-e,name:"arrow_nw",...i&&{config:i}}),southEastArrowNorthMiddleWest:(a,l)=>({top:r(a),left:a.right-l.width*.25-e,name:"arrow_nmw",...i&&{config:i}}),southEastArrowNorth:(a,l)=>({top:r(a),left:a.right-l.width/2,name:"arrow_n",...i&&{config:i}}),southEastArrowNorthMiddleEast:(a,l)=>({top:r(a),left:a.right-l.width*.75+e,name:"arrow_nme",...i&&{config:i}}),southEastArrowNorthEast:(a,l)=>({top:r(a),left:a.right-l.width+e,name:"arrow_ne",...i&&{config:i}}),westArrowEast:(a,l)=>({top:a.top+a.height/2-l.height/2,left:a.left-l.width-t,name:"arrow_e",...i&&{config:i}}),eastArrowWest:(a,l)=>({top:a.top+a.height/2-l.height/2,left:a.right+t,name:"arrow_w",...i&&{config:i}}),viewportStickyNorth:(a,l,c)=>a.getIntersection(c)?{top:c.top+n,left:a.left+a.width/2-l.width/2,name:"arrowless",config:{withArrow:!1,...i}}:null};function o(a,l){return a.top-l.height-t}function r(a){return a.bottom+t}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const mr="ck-tooltip";class ie extends Qe(){constructor(e){if(super(),this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver=null,ie._editors.add(e),ie._instance)return ie._instance;ie._instance=this,this.tooltipTextView=new I(e.locale),this.tooltipTextView.set("text",""),this.tooltipTextView.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:this.tooltipTextView.bindTemplate.to("text")}]}),this.balloonPanelView=new de(e.locale),this.balloonPanelView.class=mr,this.balloonPanelView.content.add(this.tooltipTextView),this._pinTooltipDebounced=Dn(this._pinTooltip,600),this.listenTo(S.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(S.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(S.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(S.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(S.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;ie._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),ie._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),ie._instance=null)}static getPositioningFunctions(e){const t=ie.defaultBalloonPositions;return{s:[t.southArrowNorth,t.southArrowNorthEast,t.southArrowNorthWest],n:[t.northArrowSouth],e:[t.eastArrowWest],w:[t.westArrowEast],sw:[t.southArrowNorthEast],se:[t.southArrowNorthWest]}[e]}_onEnterOrFocus(e,{target:t}){const n=yi(t);n&&n!==this._currentElementWithTooltip&&(this._unpinTooltip(),this._pinTooltipDebounced(n,Kp(n)))}_onLeaveOrBlur(e,{target:t,relatedTarget:n}){if(e.name==="mouseleave"){if(!qt(t)||this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const i=yi(t),o=yi(n);i&&i!==o&&this._unpinTooltip()}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._unpinTooltip()}}_onScroll(e,{target:t}){this._currentElementWithTooltip&&(t.contains(this.balloonPanelView.element)&&t.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(e,{text:t,position:n,cssClass:i}){const o=ne(ie._editors.values()).ui.view.body;o.has(this.balloonPanelView)||o.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.pin({target:e,positions:ie.getPositioningFunctions(n)}),this._resizeObserver=new U(e,()=>{_t(e)||this._unpinTooltip()}),this.balloonPanelView.class=[mr,i].filter(r=>r).join(" ");for(const r of ie._editors)this.listenTo(r.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=n}_unpinTooltip(){this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of ie._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver&&this._resizeObserver.destroy()}_updateTooltipPosition(){if(!_t(this._currentElementWithTooltip)){this._unpinTooltip();return}this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:ie.getPositioningFunctions(this._currentTooltipPosition)})}}ie.defaultBalloonPositions=Ac({heightOffset:5,sideOffset:13});ie._editors=new Set;ie._instance=null;function yi(s){return qt(s)?s.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function Kp(s){return{text:s.dataset.ckeTooltipText,position:s.dataset.ckeTooltipPosition||"s",cssClass:s.dataset.ckeTooltipClass||""}}const Gp=`<svg xmlns="http://www.w3.org/2000/svg" width="53" height="10" viewBox="0 0 53 10"><g clip-path="url(#a)"><path fill="#1C2331" d="M31.724 1.492a15.139 15.139 0 0 0 .045 1.16 2.434 2.434 0 0 0-.687-.34 3.68 3.68 0 0 0-1.103-.166 2.332 2.332 0 0 0-1.14.255 1.549 1.549 0 0 0-.686.87c-.15.41-.225.98-.225 1.712 0 .939.148 1.659.444 2.161.297.503.792.754 1.487.754.452.015.9-.094 1.294-.316.296-.174.557-.4.771-.669l.14.852h1.282V.007h-1.623v1.485ZM31 6.496a1.77 1.77 0 0 1-.494.061.964.964 0 0 1-.521-.127.758.758 0 0 1-.296-.466 3.984 3.984 0 0 1-.093-.992 4.208 4.208 0 0 1 .098-1.052.753.753 0 0 1 .307-.477 1.08 1.08 0 0 1 .55-.122c.233-.004.466.026.69.089l.483.144v2.553c-.11.076-.213.143-.307.2a1.73 1.73 0 0 1-.417.189ZM35.68 0l-.702.004c-.322.002-.482.168-.48.497l.004.581c.002.33.164.493.486.49l.702-.004c.322-.002.481-.167.48-.496L36.165.49c-.002-.33-.164-.493-.486-.491ZM36.145 2.313l-1.612.01.034 5.482 1.613-.01-.035-5.482ZM39.623.79 37.989.8 38 2.306l-.946.056.006 1.009.949-.006.024 2.983c.003.476.143.844.419 1.106.275.26.658.39 1.148.387.132 0 .293-.01.483-.03.19-.02.38-.046.57-.08.163-.028.324-.068.482-.119l-.183-1.095-.702.004a.664.664 0 0 1-.456-.123.553.553 0 0 1-.14-.422l-.016-2.621 1.513-.01-.006-1.064-1.514.01-.01-1.503ZM46.226 2.388c-.41-.184-.956-.274-1.636-.27-.673.004-1.215.101-1.627.29-.402.179-.72.505-.888.91-.18.419-.268.979-.264 1.68.004.688.1 1.24.285 1.655.172.404.495.724.9.894.414.18.957.268 1.63.264.68-.004 1.224-.099 1.632-.284.4-.176.714-.501.878-.905.176-.418.263-.971.258-1.658-.004-.702-.097-1.261-.28-1.677a1.696 1.696 0 0 0-.888-.9Zm-.613 3.607a.77.77 0 0 1-.337.501 1.649 1.649 0 0 1-1.317.009.776.776 0 0 1-.343-.497 4.066 4.066 0 0 1-.105-1.02 4.136 4.136 0 0 1 .092-1.03.786.786 0 0 1 .337-.507 1.59 1.59 0 0 1 1.316-.008.79.79 0 0 1 .344.502c.078.337.113.683.105 1.03.012.343-.019.685-.092 1.02ZM52.114 2.07a2.67 2.67 0 0 0-1.128.278c-.39.191-.752.437-1.072.73l-.157-.846-1.273.008.036 5.572 1.623-.01-.024-3.78c.35-.124.646-.22.887-.286.26-.075.53-.114.8-.118l.45-.003.144-1.546-.286.001ZM22.083 7.426l-1.576-2.532a2.137 2.137 0 0 0-.172-.253 1.95 1.95 0 0 0-.304-.29.138.138 0 0 1 .042-.04 1.7 1.7 0 0 0 .328-.374l1.75-2.71c.01-.015.025-.028.024-.048-.01-.01-.021-.007-.031-.007L20.49 1.17a.078.078 0 0 0-.075.045l-.868 1.384c-.23.366-.46.732-.688 1.099a.108.108 0 0 1-.112.06c-.098-.005-.196-.001-.294-.002-.018 0-.038.006-.055-.007.002-.02.002-.039.005-.058a4.6 4.6 0 0 0 .046-.701V1.203c0-.02-.009-.032-.03-.03h-.033L16.93 1.17c-.084 0-.073-.01-.073.076v6.491c-.001.018.006.028.025.027h1.494c.083 0 .072.007.072-.071v-2.19c0-.055-.003-.11-.004-.166a3.366 3.366 0 0 0-.05-.417h.06c.104 0 .209.002.313-.002a.082.082 0 0 1 .084.05c.535.913 1.07 1.824 1.607 2.736a.104.104 0 0 0 .103.062c.554-.003 1.107-.002 1.66-.002l.069-.003-.019-.032-.188-.304ZM27.112 6.555c-.005-.08-.004-.08-.082-.08h-2.414c-.053 0-.106-.003-.159-.011a.279.279 0 0 1-.246-.209.558.558 0 0 1-.022-.15c0-.382 0-.762-.002-1.143 0-.032.007-.049.042-.044h2.504c.029.003.037-.012.034-.038V3.814c0-.089.013-.078-.076-.078h-2.44c-.07 0-.062.003-.062-.06v-.837c0-.047.004-.093.013-.14a.283.283 0 0 1 .241-.246.717.717 0 0 1 .146-.011h2.484c.024.002.035-.009.036-.033l.003-.038.03-.496c.01-.183.024-.365.034-.548.005-.085.003-.087-.082-.094-.218-.018-.437-.038-.655-.05a17.845 17.845 0 0 0-.657-.026 72.994 72.994 0 0 0-1.756-.016 1.7 1.7 0 0 0-.471.064 1.286 1.286 0 0 0-.817.655c-.099.196-.149.413-.145.633v3.875c0 .072.003.144.011.216a1.27 1.27 0 0 0 .711 1.029c.228.113.48.167.734.158.757-.005 1.515.002 2.272-.042.274-.016.548-.034.82-.053.03-.002.043-.008.04-.041-.008-.104-.012-.208-.019-.312a69.964 69.964 0 0 1-.05-.768ZM16.14 7.415l-.127-1.075c-.004-.03-.014-.04-.044-.037a13.125 13.125 0 0 1-.998.073c-.336.01-.672.02-1.008.016-.116-.001-.233-.014-.347-.039a.746.746 0 0 1-.45-.262c-.075-.1-.132-.211-.167-.33a3.324 3.324 0 0 1-.126-.773 9.113 9.113 0 0 1-.015-.749c0-.285.022-.57.065-.852.023-.158.066-.312.127-.46a.728.728 0 0 1 .518-.443 1.64 1.64 0 0 1 .397-.048c.628-.001 1.255.003 1.882.05.022.001.033-.006.036-.026l.003-.031.06-.55c.019-.177.036-.355.057-.532.004-.034-.005-.046-.04-.056a5.595 5.595 0 0 0-1.213-.21 10.783 10.783 0 0 0-.708-.02c-.24-.003-.48.01-.719.041a3.477 3.477 0 0 0-.625.14 1.912 1.912 0 0 0-.807.497c-.185.2-.33.433-.424.688a4.311 4.311 0 0 0-.24 1.096c-.031.286-.045.572-.042.86-.006.43.024.86.091 1.286.04.25.104.497.193.734.098.279.26.53.473.734.214.205.473.358.756.446.344.11.702.17 1.063.177a8.505 8.505 0 0 0 1.578-.083 6.11 6.11 0 0 0 .766-.18c.03-.008.047-.023.037-.057a.157.157 0 0 1-.003-.025Z"/><path fill="#AFE229" d="M6.016 6.69a1.592 1.592 0 0 0-.614.21c-.23.132-.422.32-.56.546-.044.072-.287.539-.287.539l-.836 1.528.009.006c.038.025.08.046.123.063.127.046.26.07.395.073.505.023 1.011-.007 1.517-.003.29.009.58.002.869-.022a.886.886 0 0 0 .395-.116.962.962 0 0 0 .312-.286c.056-.083.114-.163.164-.249.24-.408.48-.816.718-1.226.075-.128.148-.257.222-.386l.112-.192a1.07 1.07 0 0 0 .153-.518l-1.304.023s-1.258-.005-1.388.01Z"/><path fill="#771BFF" d="m2.848 9.044.76-1.39.184-.352c-.124-.067-.245-.14-.367-.21-.346-.204-.706-.384-1.045-.6a.984.984 0 0 1-.244-.207c-.108-.134-.136-.294-.144-.46-.021-.409-.002-.818-.009-1.227-.003-.195 0-.39.003-.585.004-.322.153-.553.427-.713l.833-.488c.22-.13.44-.257.662-.385.05-.029.105-.052.158-.077.272-.128.519-.047.76.085l.044.028c.123.06.242.125.358.196.318.178.635.357.952.537.095.056.187.117.275.184.194.144.254.35.266.578.016.284.007.569.006.853-.001.28.004.558 0 .838.592-.003 1.259 0 1.259 0l.723-.013c-.003-.292-.007-.584-.007-.876 0-.524.015-1.048-.016-1.571-.024-.42-.135-.8-.492-1.067a5.02 5.02 0 0 0-.506-.339A400.52 400.52 0 0 0 5.94.787C5.722.664 5.513.524 5.282.423 5.255.406 5.228.388 5.2.373 4.758.126 4.305-.026 3.807.21c-.097.046-.197.087-.29.14A699.896 699.896 0 0 0 .783 1.948c-.501.294-.773.717-.778 1.31-.004.36-.009.718-.001 1.077.016.754-.017 1.508.024 2.261.016.304.07.6.269.848.127.15.279.28.448.382.622.4 1.283.734 1.92 1.11l.183.109Z"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h52.4v10H0z"/></clipPath></defs></svg>
`;/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Jp=53,Qp=10,Yp=50,Zp=350,Xp="Powered by",Cn={top:-99999,left:-99999,name:"invalid",config:{withArrow:!1}};class ew extends Qe(){constructor(e){super(),this.editor=e,this._balloonView=null,this._lastFocusedEditableElement=null,this._showBalloonThrottled=Jn(this._showBalloon.bind(this),50,{leading:!0}),e.on("ready",this._handleEditorReady.bind(this))}destroy(){const e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const e=this.editor;/* istanbul ignore next -- @preserve */qu(e.config.get("licenseKey"))!=="VALID"&&e.ui.view&&(e.ui.focusTracker.on("change:isFocused",(t,n,i)=>{this._updateLastFocusedEditableElement(),i?this._showBalloon():this._hideBalloon()}),e.ui.focusTracker.on("change:focusedElement",(t,n,i)=>{this._updateLastFocusedEditableElement(),i&&this._showBalloon()}),e.ui.on("update",()=>{this._showBalloonThrottled()}))}_createBalloonView(){const e=this.editor,t=this._balloonView=new de,n=Pc(e),i=new tw(e.locale,n.label);t.content.add(i),t.set({class:"ck-powered-by-balloon"}),e.ui.view.body.add(t),e.ui.focusTracker.add(t.element),this._balloonView=t}_showBalloon(){if(!this._lastFocusedEditableElement)return;const e=nw(this.editor,this._lastFocusedEditableElement);e&&(this._balloonView||this._createBalloonView(),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,n=e.ui.focusTracker.focusedElement;if(!t||!n){this._lastFocusedEditableElement=null;return}const i=Array.from(e.ui.getEditableElementsNames()).map(o=>e.ui.getEditableElement(o));i.includes(n)?this._lastFocusedEditableElement=n:this._lastFocusedEditableElement=i[0]}}class tw extends I{constructor(e,t){super(e);const n=new at,i=this.bindTemplate;n.set({content:Gp,isColorInherited:!1}),n.extendTemplate({attributes:{style:{width:Jp+"px",height:Qp+"px"}}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-powered-by"],"aria-hidden":!0},children:[{tag:"a",attributes:{href:"https://ckeditor.com/?utm_source=ckeditor&utm_medium=referral&utm_campaign=701Dn000000hVgmIAE_powered_by_ckeditor_logo",target:"_blank",tabindex:"-1"},children:[...t?[{tag:"span",attributes:{class:["ck","ck-powered-by__label"]},children:[t]}]:[],n],on:{dragstart:i.to(o=>o.preventDefault())}}]})}}function nw(s,e){const t=Pc(s),n=t.side==="right"?iw(e,t):sw(e,t);return{target:e,positions:[n]}}function iw(s,e){return Sc(s,e,(t,n)=>t.left+t.width-n.width-e.horizontalOffset)}function sw(s,e){return Sc(s,e,t=>t.left+e.horizontalOffset)}function Sc(s,e,t){return(n,i)=>{const o=n.getVisible();if(!o||n.width<Zp||n.height<Yp)return Cn;let r;e.position==="inside"?r=n.bottom-i.height:r=n.bottom-i.height/2,r-=e.verticalOffset;const a=t(n,i);if(e.position==="inside"){const l=i.clone().moveTo(a,r);if(l.getIntersectionArea(o)<l.getArea())return Cn}else{const l=bu(s);if(l){const c=new L(l);if(o.bottom+i.height/2>c.bottom)return Cn}}return{top:r,left:a,name:`position_${e.position}-side_${e.side}`,config:{withArrow:!1}}}}function Pc(s){const e=s.config.get("ui.poweredBy"),t=e&&e.position||"border";return{position:t,label:Xp,verticalOffset:t==="inside"?5:0,horizontalOffset:5,side:s.locale.contentLanguageDirection==="ltr"?"right":"left",...e}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ow extends D(){constructor(e){super(),this.isReady=!1,this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[],this.editor=e,this.componentFactory=new jp(e),this.focusTracker=new ve,this.tooltipManager=new ie(e),this.poweredBy=new ew(e),this.set("viewportOffset",this._readViewportOffsetFromConfig()),this.once("ready",()=>{this.isReady=!0}),this.listenTo(e.editing.view.document,"layoutChanged",()=>this.update()),this._initFocusTracking()}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[]}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor),this.focusTracker.add(t);const n=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?n():this.once("ready",n)}removeEditableElement(e){const t=this._editableElementsMap.get(e);t&&(this._editableElementsMap.delete(e),this.editor.keystrokes.stopListening(t),this.focusTracker.remove(t),t.ckeditorInstance=null)}getEditableElement(e="main"){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}addToolbar(e,t={}){e.isRendered?(this.focusTracker.add(e.element),this.editor.keystrokes.listenTo(e.element)):e.once("render",()=>{this.focusTracker.add(e.element),this.editor.keystrokes.listenTo(e.element)}),this._focusableToolbarDefinitions.push({toolbarView:e,options:t})}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const n=e.config.get("toolbar.viewportTopOffset");return n?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:n}):{top:0}}_initFocusTracking(){const e=this.editor,t=e.editing.view;let n,i;e.keystrokes.set("Alt+F10",(o,r)=>{const a=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(a)&&!Array.from(t.domRoots.values()).includes(a)&&(n=a);const l=this._getCurrentFocusedToolbarDefinition();(!l||!i)&&(i=this._getFocusableCandidateToolbarDefinitions());for(let c=0;c<i.length;c++){const d=i.shift();if(i.push(d),d!==l&&this._focusFocusableCandidateToolbar(d)){l&&l.options.afterBlur&&l.options.afterBlur();break}}r()}),e.keystrokes.set("Esc",(o,r)=>{const a=this._getCurrentFocusedToolbarDefinition();a&&(n?(n.focus(),n=null):e.editing.view.focus(),a.options.afterBlur&&a.options.afterBlur(),r())})}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:n,options:i}=t;(_t(n.element)||i.beforeFocus)&&e.push(t)}return e.sort((t,n)=>gr(t)-gr(n)),e}_getCurrentFocusedToolbarDefinition(){for(const e of this._focusableToolbarDefinitions)if(e.toolbarView.element&&e.toolbarView.element.contains(this.focusTracker.focusedElement))return e;return null}_focusFocusableCandidateToolbar(e){const{toolbarView:t,options:{beforeFocus:n}}=e;return n&&n(),_t(t.element)?(t.focus(),!0):!1}}function gr(s){const{toolbarView:e,options:t}=s;let n=10;return _t(e.element)&&n--,t.isContextual&&n--,n}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rw extends I{constructor(e){super(e),this.body=new Ep(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class aw extends I{constructor(e,t,n){super(e),this.name=null,this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.set("isFocused",!1),this._editableElement=n,this._hasExternalElement=!!this._editableElement,this._editingView=t}render(){super.render(),this._hasExternalElement?this.template.apply(this.element=this._editableElement):this._editableElement=this.element,this.on("change:isFocused",()=>this._updateIsFocusedClasses()),this._updateIsFocusedClasses()}destroy(){this._hasExternalElement&&this.template.revert(this._editableElement),super.destroy()}get hasExternalElement(){return this._hasExternalElement}_updateIsFocusedClasses(){const e=this._editingView;e.isRenderingInProgress?n(this):t(this);function t(i){e.change(o=>{const r=e.document.getRoot(i.name);o.addClass(i.isFocused?"ck-focused":"ck-blurred",r),o.removeClass(i.isFocused?"ck-blurred":"ck-focused",r)})}function n(i){e.once("change:isRenderingInProgress",(o,r,a)=>{a?n(i):t(i)})}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lw extends aw{constructor(e,t,n,i={}){super(e,t,n);const o=e.t;this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}}),this._generateLabel=i.label||(()=>o("Editor editing area: %0",this.name))}render(){super.render();const e=this._editingView;e.change(t=>{const n=e.document.getRoot(this.name);t.setAttribute("aria-label",this._generateLabel(this),n)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class is extends Zn{static get pluginName(){return"Notification"}init(){this.on("show:warning",(e,t)=>{window.alert(t.message)},{priority:"lowest"})}showSuccess(e,t={}){this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t=e.namespace?`show:${e.type}:${e.namespace}`:`show:${e.type}`;this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $s extends D(){constructor(e,t){super(),t&&ja(this,t),e&&this.set(e)}}const cw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.463 5.187a.888.888 0 1 1 1.254 1.255L9.16 10l3.557 3.557a.888.888 0 1 1-1.254 1.255L7.26 10.61a.888.888 0 0 1 .16-1.382l4.043-4.042z"/></svg>',dw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.537 14.813a.888.888 0 1 1-1.254-1.255L10.84 10 7.283 6.442a.888.888 0 1 1 1.254-1.255L12.74 9.39a.888.888 0 0 1-.16 1.382l-4.043 4.042z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const kn=dl("px");class Un extends _{static get pluginName(){return"ContextualBalloon"}constructor(e){super(e),this._viewToStack=new Map,this._idToStack=new Map,this._view=null,this._rotatorView=null,this._fakePanelsView=null,this.positionLimiter=()=>{const t=this.editor.editing.view,i=t.document.selection.editableElement;return i?t.domConverter.mapViewToDom(i.root):null},this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}destroy(){super.destroy(),this._view&&this._view.destroy(),this._rotatorView&&this._rotatorView.destroy(),this._fakePanelsView&&this._fakePanelsView.destroy()}get view(){return this._view||this._createPanelView(),this._view}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this._view||this._createPanelView(),this.hasView(e.view))throw new m("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t)){this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,(!this._visibleStack||e.singleViewMode)&&this.showStack(t);return}const n=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),n.set(e.view,e),this._viewToStack.set(e.view,n),n===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new m("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(t.size===1?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),t.size===1?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new m("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new de(this.editor.locale),this.editor.ui.view.body.add(this._view),this.editor.ui.focusTracker.add(this._view.element),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(e){return Array.from(this._idToStack.entries()).find(n=>n[1]===e)[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new uw(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",(n,i)=>!i&&n>1),e.on("change:isNavigationVisible",()=>this.updatePosition(),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",(n,i)=>{if(i<2)return"";const o=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[o,i])}),e.buttonNextView.on("execute",()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()}),e.buttonPrevView.on("execute",()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()}),e}_createFakePanelsView(){const e=new hw(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",(t,n)=>!n&&t>=2?Math.min(t-1,2):0),e.listenTo(this.view,"change:top",()=>e.updatePosition()),e.listenTo(this.view,"change:left",()=>e.updatePosition()),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:n=!0,singleViewMode:i=!1}){this.view.class=t,this.view.withArrow=n,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),i&&(this._singleViewMode=!0)}_getBalloonPosition(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&(e.limiter||(e=Object.assign({},e,{limiter:this.positionLimiter})),e=Object.assign({},e,{viewportOffsetConfig:this.editor.ui.viewportOffset})),e}}class uw extends I{constructor(e){super(e);const t=e.t,n=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new ve,this.buttonPrevView=this._createButtonView(t("Previous"),cw),this.buttonNextView=this._createButtonView(t("Next"),dw),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",n.to("isNavigationVisible",i=>i?"":"ck-hidden")]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:n.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const n=new W(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n}}class hw extends I{constructor(e,t){super(e);const n=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",n.to("numberOfPanels",i=>i?"":"ck-hidden")],style:{top:n.to("top",kn),left:n.to("left",kn),width:n.to("width",kn),height:n.to("height",kn)}},children:this.content}),this.on("change:numberOfPanels",(i,o,r,a)=>{r>a?this._addPanels(r-a):this._removePanels(a-r),this.updatePosition()})}_addPanels(e){for(;e--;){const t=new I;t.setTemplate({tag:"div"}),this.content.add(t),this.registerChild(t)}}_removePanels(e){for(;e--;){const t=this.content.last;this.content.remove(t),this.deregisterChild(t),t.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:n,height:i}=new L(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:n,height:i})}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fw extends ow{constructor(e,t){super(e),this.view=t}init(){const e=this.editor,t=this.view,n=e.editing.view,i=t.editable,o=n.document.getRoot();i.name=o.rootName,t.render();const r=i.element;this.setEditableElement(i.name,r),t.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const e=this.view;this.editor.editing.view.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.editor,t=this.view;t.toolbar.fillFromConfig(e.config.get("toolbar"),this.componentFactory),this.addToolbar(t.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,n=t.document.getRoot();e.sourceElement;const i=e.config.get("placeholder");if(i){const o=typeof i=="string"?i:i[n.rootName];o&&yl({view:t,element:n,text:o,isDirectHost:!1,keepOnFocus:!0})}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class mw extends rw{constructor(e,t,n={}){super(e);const i=e.t;this.toolbar=new Ls(e,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull}),this.editable=new lw(e,t,n.editableElement,{label:o=>i("Rich Text Editor. Editing area: %0",o.name)}),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.toolbar,this.editable])}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qs extends xn(es(Ag)){constructor(e,t={}){if(!Rn(e)&&t.initialData!==void 0)throw new m("editor-create-initial-data",null);super(t),this.config.get("initialData")===void 0&&this.config.set("initialData",gw(e)),Rn(e)&&(this.sourceElement=e,Sg(this,e)),this.model.document.createRoot();const n=!this.config.get("toolbar.shouldNotGroupWhenFull"),i=new mw(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:n});this.ui=new fw(this,i)}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,t={}){return new Promise(n=>{if(Rn(e)&&e.tagName==="TEXTAREA")throw new m("editor-wrong-element",null);const i=new this(e,t);n(i.initPlugins().then(()=>i.ui.init()).then(()=>i.data.init(i.config.get("initialData"))).then(()=>i.fire("ready")).then(()=>i))})}}qs.Context=vl;qs.EditorWatchdog=mc;qs.ContextWatchdog=dp;function gw(s){return Rn(s)?_u(s):s}function Rn(s){return qt(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class js extends st{constructor(e){super(e),this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];const t=this.document;this.listenTo(t,"paste",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",n("dragging"),{priority:"low"});function n(i){return(o,r)=>{r.preventDefault();const a=r.dropRange?[r.dropRange]:null,l=new Ke(t,i);t.fire(l,{dataTransfer:r.dataTransfer,method:o.name,targetRanges:a,target:r.target,domEvent:r.domEvent}),l.stop.called&&r.stopPropagation()}}}onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,n=e.type=="drop"||e.type=="paste",i={dataTransfer:new Dl(t,{cacheFiles:n})};(e.type=="drop"||e.type=="dragover")&&(i.dropRange=pw(this.view,e)),this.fire(e.type,e,i)}}function pw(s,e){const t=e.target.ownerDocument,n=e.clientX,i=e.clientY;let o;return t.caretRangeFromPoint&&t.caretRangeFromPoint(n,i)?o=t.caretRangeFromPoint(n,i):e.rangeParent&&(o=t.createRange(),o.setStart(e.rangeParent,e.rangeOffset),o.collapse(!0)),o?s.domConverter.domRangeToView(o):null}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ww(s){return s=s.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br>").replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;").replace(/^\s/,"&nbsp;").replace(/\s$/,"&nbsp;").replace(/\s\s/g," &nbsp;"),(s.includes("</p><p>")||s.includes("<br>"))&&(s=`<p>${s}</p>`),s}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function bw(s){return s.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>t.length==1?" ":t).replace(/<!--[\s\S]*?-->/g,"")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const pr=["figcaption","li"];function xc(s){let e="";if(s.is("$text")||s.is("$textProxy"))e=s.data;else if(s.is("element","img")&&s.hasAttribute("alt"))e=s.getAttribute("alt");else if(s.is("element","br"))e=`
`;else{let t=null;for(const n of s.getChildren()){const i=xc(n);t&&(t.is("containerElement")||n.is("containerElement"))&&(pr.includes(t.name)||pr.includes(n.name)?e+=`
`:e+=`

`),e+=i,t=n}}return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ne extends _{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(js),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document;this.listenTo(i,"clipboardInput",(o,r)=>{r.method=="paste"&&!e.model.canEditAt(e.model.document.selection)&&o.stop()},{priority:"highest"}),this.listenTo(i,"clipboardInput",(o,r)=>{const a=r.dataTransfer;let l;if(r.content)l=r.content;else{let d="";a.getData("text/html")?d=bw(a.getData("text/html")):a.getData("text/plain")&&(d=ww(a.getData("text/plain"))),l=this.editor.data.htmlProcessor.toView(d)}const c=new Ke(this,"inputTransformation");this.fire(c,{content:l,dataTransfer:a,targetRanges:r.targetRanges,method:r.method}),c.stop.called&&o.stop(),n.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(o,r)=>{if(r.content.isEmpty)return;const l=this.editor.data.toModel(r.content,"$clipboardHolder");l.childCount!=0&&(o.stop(),t.change(()=>{this.fire("contentInsertion",{content:l,method:r.method,dataTransfer:r.dataTransfer,targetRanges:r.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(o,r)=>{r.resultRange=t.insertContent(r.content)},{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,o=(r,a)=>{const l=a.dataTransfer;a.preventDefault();const c=e.data.toView(e.model.getSelectedContent(t.selection));i.fire("clipboardOutput",{dataTransfer:l,content:c,method:r.name})};this.listenTo(i,"copy",o,{priority:"low"}),this.listenTo(i,"cut",(r,a)=>{e.model.canEditAt(e.model.document.selection)?o(r,a):a.preventDefault()},{priority:"low"}),this.listenTo(i,"clipboardOutput",(r,a)=>{a.content.isEmpty||(a.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(a.content)),a.dataTransfer.setData("text/plain",xc(a.content))),a.method=="cut"&&e.model.deleteContent(t.selection)},{priority:"low"})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ic{constructor(e,t=20){this._batch=null,this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(n,i)=>{i.isLocal&&i.isUndoable&&i!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}get size(){return this._size}input(e){this._size+=e,this._size>=this.limit&&this._reset(!0)}get isLocked(){return this._isLocked}lock(){this._isLocked=!0}unlock(){this._isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e=!1){(!this.isLocked||e)&&(this._batch=null,this._size=0)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _w extends x{constructor(e,t){super(e),this._buffer=new Ic(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,n=t.document,i=e.text||"",o=i.length;let r=n.selection;if(e.selection?r=e.selection:e.range&&(r=t.createSelection(e.range)),!t.canEditAt(r))return;const a=e.resultRange;t.enqueueChange(this._buffer.batch,l=>{this._buffer.lock(),t.deleteContent(r),i&&t.insertContent(l.createText(i,n.selection.getAttributes()),r),a?l.setSelection(a):r.is("documentSelection")||l.setSelection(r),this._buffer.unlock(),this._buffer.input(o)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const wr=["insertText","insertReplacementText"];class vw extends Le{constructor(e){super(e),P.isAndroid&&wr.push("insertCompositionText");const t=e.document;t.on("beforeinput",(n,i)=>{if(!this.isEnabled)return;const{data:o,targetRanges:r,inputType:a,domEvent:l}=i;if(!wr.includes(a))return;const c=new Ke(t,"insertText");t.fire(c,new zt(e,l,{text:o,selection:e.createSelection(r)})),c.stop.called&&n.stop()}),t.on("compositionend",(n,{data:i,domEvent:o})=>{!this.isEnabled||P.isAndroid||i&&t.fire("insertText",new zt(e,o,{text:i,selection:t.selection}))},{priority:"lowest"})}observe(){}stopObserving(){}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rc extends _{static get pluginName(){return"Input"}init(){const e=this.editor,t=e.model,n=e.editing.view,i=t.document.selection;n.addObserver(vw);const o=new _w(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",o),e.commands.add("input",o),this.listenTo(n.document,"insertText",(r,a)=>{n.document.isComposing||a.preventDefault();const{text:l,selection:c,resultRange:d}=a,u=Array.from(c.getRanges()).map(g=>e.editing.mapper.toModelRange(g));let h=l;if(P.isAndroid){const g=Array.from(u[0].getItems()).reduce((w,v)=>w+(v.is("$textProxy")?v.data:""),"");g&&(g.length<=h.length?h.startsWith(g)&&(h=h.substring(g.length),u[0].start=u[0].start.getShiftedBy(g.length)):g.startsWith(h)&&(u[0].start=u[0].start.getShiftedBy(h.length),h=""))}const f={text:h,selection:t.createSelection(u)};d&&(f.resultRange=e.editing.mapper.toModelRange(d)),e.execute("insertText",f)}),P.isAndroid?this.listenTo(n.document,"keydown",(r,a)=>{i.isCollapsed||a.keyCode!=229||!n.document.isComposing||br(t,o)}):this.listenTo(n.document,"compositionstart",()=>{i.isCollapsed||br(t,o)})}}function br(s,e){if(!e.isEnabled)return;const t=e.buffer;t.lock(),s.enqueueChange(t.batch,()=>{s.deleteContent(s.document.selection)}),t.unlock()}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _r extends x{constructor(e,t){super(e),this.direction=t,this._buffer=new Ic(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,n=t.document;t.enqueueChange(this._buffer.batch,i=>{this._buffer.lock();const o=i.createSelection(e.selection||n.selection);if(!t.canEditAt(o))return;const r=e.sequence||1,a=o.isCollapsed;if(o.isCollapsed&&t.modifySelection(o,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(r)){this._replaceEntireContentWithParagraph(i);return}if(this._shouldReplaceFirstBlockWithParagraph(o,r)){this.editor.execute("paragraph",{selection:o});return}if(o.isCollapsed)return;let l=0;o.getFirstRange().getMinimalFlatRanges().forEach(c=>{l+=Li(c.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))}),t.deleteContent(o,{doNotResetEntireContent:a,direction:this.direction}),this._buffer.input(l),i.setSelection(o),this._buffer.unlock()})}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,o=t.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(o))||!t.schema.checkChild(o,"paragraph"))return!1;const a=o.getChild(0);return!(a&&a.is("element","paragraph"))}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,o=t.schema.getLimitElement(i),r=e.createElement("paragraph");e.remove(e.createRangeIn(o)),e.insert(r,o),e.setSelection(r,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const n=this.editor.model;if(t>1||this.direction!="backward"||!e.isCollapsed)return!1;const i=e.getFirstPosition(),o=n.schema.getLimitElement(i),r=o.getChild(0);return!(i.parent!=r||!e.containsEntireContent(r)||!n.schema.checkChild(o,"paragraph")||r.name=="paragraph")}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const yw="character",vr="word",Cw="codePoint",et="selection",Dt="backward",Xt="forward",Mc={deleteContent:{unit:et,direction:Dt},deleteContentBackward:{unit:Cw,direction:Dt},deleteWordBackward:{unit:vr,direction:Dt},deleteHardLineBackward:{unit:et,direction:Dt},deleteSoftLineBackward:{unit:et,direction:Dt},deleteContentForward:{unit:yw,direction:Xt},deleteWordForward:{unit:vr,direction:Xt},deleteHardLineForward:{unit:et,direction:Xt},deleteSoftLineForward:{unit:et,direction:Xt}};class kw extends Le{constructor(e){super(e);const t=e.document;let n=0;t.on("keydown",()=>{n++}),t.on("keyup",()=>{n=0}),t.on("beforeinput",(i,o)=>{if(!this.isEnabled)return;const{targetRanges:r,domEvent:a,inputType:l}=o,c=Mc[l];if(!c)return;const d={direction:c.direction,unit:c.unit,sequence:n};d.unit==et&&(d.selectionToRemove=e.createSelection(r[0])),l==="deleteContentBackward"&&(P.isAndroid&&(d.sequence=1),Tw(r)&&(d.unit=et,d.selectionToRemove=e.createSelection(r)));const u=new jt(t,"delete",r[0]);t.fire(u,new zt(e,a,d)),u.stop.called&&i.stop()}),P.isBlink&&Ew(this)}observe(){}stopObserving(){}}function Ew(s){const e=s.view,t=e.document;let n=null,i=!1;t.on("keydown",(a,{keyCode:l})=>{n=l,i=!1}),t.on("keyup",(a,{keyCode:l,domEvent:c})=>{const d=t.selection,u=s.isEnabled&&l==n&&o(l)&&!d.isCollapsed&&!i;if(n=null,u){const h=d.getFirstRange(),f=new jt(t,"delete",h),g={unit:et,direction:r(l),selectionToRemove:d};t.fire(f,new zt(e,c,g))}}),t.on("beforeinput",(a,{inputType:l})=>{const c=Mc[l];o(n)&&c&&c.direction==r(n)&&(i=!0)},{priority:"high"}),t.on("beforeinput",(a,{inputType:l,data:c})=>{n==M.delete&&l=="insertText"&&c==""&&a.stop()},{priority:"high"});function o(a){return a==M.backspace||a==M.delete}function r(a){return a==M.backspace?Dt:Xt}}function Tw(s){if(s.length!=1||s[0].isCollapsed)return!1;const e=s[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let t=0;for(const{nextPosition:n}of e){if(!n.parent.is("$text"))t++;else{const i=n.parent.data,o=n.offset;if(Cs(i,o)||ks(i,o)||bl(i,o))continue;t++}if(t>1)return!0}return!1}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Je extends _{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,n=t.document,i=e.model.document;t.addObserver(kw),this._undoOnBackspace=!1;const o=new _r(e,"forward");e.commands.add("deleteForward",o),e.commands.add("forwardDelete",o),e.commands.add("delete",new _r(e,"backward")),this.listenTo(n,"delete",(r,a)=>{n.isComposing||a.preventDefault();const{direction:l,sequence:c,selectionToRemove:d,unit:u}=a,h=l==="forward"?"deleteForward":"delete",f={sequence:c};if(u=="selection"){const g=Array.from(d.getRanges()).map(w=>e.editing.mapper.toModelRange(w));f.selection=e.model.createSelection(g)}else f.unit=u;e.execute(h,f),t.scrollToTheSelection()},{priority:"low"}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(n,"delete",(r,a)=>{this._undoOnBackspace&&a.direction=="backward"&&a.sequence==1&&a.unit=="codePoint"&&(this._undoOnBackspace=!1,e.execute("undo"),a.preventDefault(),r.stop())},{context:"$capture"}),this.listenTo(i,"change",()=>{this._undoOnBackspace=!1}))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Aw extends _{static get requires(){return[Rc,Je]}static get pluginName(){return"Typing"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Vc(s,e){let t=s.start;return{text:Array.from(s.getItems()).reduce((i,o)=>o.is("$text")||o.is("$textProxy")?i+o.data:(t=e.createPositionAfter(o),""),""),range:e.createRange(t,s.end)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Oc extends D(){constructor(e,t){super(),this.model=e,this.testCallback=t,this._hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))}),this._startListening()}get hasMatch(){return this._hasMatch}_startListening(){const t=this.model.document;this.listenTo(t.selection,"change:range",(n,{directChange:i})=>{if(i){if(!t.selection.isCollapsed){this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1);return}this._evaluateTextBeforeSelection("selection")}}),this.listenTo(t,"change:data",(n,i)=>{i.isUndo||!i.isLocal||this._evaluateTextBeforeSelection("data",{batch:i})})}_evaluateTextBeforeSelection(e,t={}){const n=this.model,o=n.document.selection,r=n.createRange(n.createPositionAt(o.focus.parent,0),o.focus),{text:a,range:l}=Vc(r,n),c=this.testCallback(a);if(!c&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!c,c){const d=Object.assign(t,{text:a,range:l});typeof c=="object"&&Object.assign(d,c),this.fire(`matched:${e}`,d)}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $n extends _{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,n=e.editing.view,i=e.locale,o=t.document.selection;this.listenTo(n.document,"arrowKey",(r,a)=>{if(!o.isCollapsed||a.shiftKey||a.altKey||a.ctrlKey)return;const l=a.keyCode==M.arrowright,c=a.keyCode==M.arrowleft;if(!l&&!c)return;const d=i.contentLanguageDirection;let u=!1;d==="ltr"&&l||d==="rtl"&&c?u=this._handleForwardMovement(a):u=this._handleBackwardMovement(a),u===!0&&r.stop()},{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(o,"change:range",(r,a)=>{if(this._isNextGravityRestorationSkipped){this._isNextGravityRestorationSkipped=!1;return}this._isGravityOverridden&&(!a.directChange&&Mn(o.getFirstPosition(),this.attributes)||this._restoreGravity())})}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model.document.selection,o=i.getFirstPosition();return this._isGravityOverridden||o.isAtStart&&Ci(i,t)?!1:Mn(o,t)?(En(e),this._overrideGravity(),!0):!1}_handleBackwardMovement(e){const t=this.attributes,n=this.editor.model,i=n.document.selection,o=i.getFirstPosition();return this._isGravityOverridden?(En(e),this._restoreGravity(),ki(n,t,o),!0):o.isAtStart?Ci(i,t)?(En(e),ki(n,t,o),!0):!1:Sw(o,t)?o.isAtEnd&&!Ci(i,t)&&Mn(o,t)?(En(e),ki(n,t,o),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):!1}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change(e=>e.overrideSelectionGravity())}_restoreGravity(){this.editor.model.change(e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null})}}function Ci(s,e){for(const t of e)if(s.hasAttribute(t))return!0;return!1}function ki(s,e,t){const n=t.nodeBefore;s.change(i=>{n?i.setSelectionAttribute(n.getAttributes()):i.removeSelectionAttribute(e)})}function En(s){s.preventDefault()}function Sw(s,e){const t=s.getShiftedBy(-1);return Mn(t,e)}function Mn(s,e){const{nodeBefore:t,nodeAfter:n}=s;for(const i of e){const o=t?t.getAttribute(i):void 0;if((n?n.getAttribute(i):void 0)!==o)return!0}return!1}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const yr={copyright:{from:"(c)",to:"©"},registeredTrademark:{from:"(r)",to:"®"},trademark:{from:"(tm)",to:"™"},oneHalf:{from:/(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i,to:[null,"½",null]},oneThird:{from:/(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i,to:[null,"⅓",null]},twoThirds:{from:/(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i,to:[null,"⅔",null]},oneForth:{from:/(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i,to:[null,"¼",null]},threeQuarters:{from:/(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i,to:[null,"¾",null]},lessThanOrEqual:{from:"<=",to:"≤"},greaterThanOrEqual:{from:">=",to:"≥"},notEqual:{from:"!=",to:"≠"},arrowLeft:{from:"<-",to:"←"},arrowRight:{from:"->",to:"→"},horizontalEllipsis:{from:"...",to:"…"},enDash:{from:/(^| )(--)( )$/,to:[null,"–",null]},emDash:{from:/(^| )(---)( )$/,to:[null,"—",null]},quotesPrimary:{from:xt('"'),to:[null,"“",null,"”"]},quotesSecondary:{from:xt("'"),to:[null,"‘",null,"’"]},quotesPrimaryEnGb:{from:xt("'"),to:[null,"‘",null,"’"]},quotesSecondaryEnGb:{from:xt('"'),to:[null,"“",null,"”"]},quotesPrimaryPl:{from:xt('"'),to:[null,"„",null,"”"]},quotesSecondaryPl:{from:xt("'"),to:[null,"‚",null,"’"]}},Cr={symbols:["copyright","registeredTrademark","trademark"],mathematical:["oneHalf","oneThird","twoThirds","oneForth","threeQuarters","lessThanOrEqual","greaterThanOrEqual","notEqual","arrowLeft","arrowRight"],typography:["horizontalEllipsis","enDash","emDash"],quotes:["quotesPrimary","quotesSecondary"]},Pw=["symbols","mathematical","typography","quotes"];class lC extends _{static get requires(){return["Delete","Input"]}static get pluginName(){return"TextTransformation"}constructor(e){super(e),e.config.define("typing",{transformations:{include:Pw}})}init(){const t=this.editor.model.document.selection;t.on("change:range",()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")}),this._enableTransformationWatchers()}_enableTransformationWatchers(){const e=this.editor,t=e.model,n=e.plugins.get("Delete"),i=Mw(e.config.get("typing.transformations")),o=a=>{for(const l of i)if(l.from.test(a))return{normalizedTransformation:l}},r=new Oc(e.model,o);r.on("matched:data",(a,l)=>{if(!l.batch.isTyping)return;const{from:c,to:d}=l.normalizedTransformation,u=c.exec(l.text),h=d(u.slice(1)),f=l.range;let g=u.index;t.enqueueChange(w=>{for(let v=1;v<u.length;v++){const C=u[v],k=h[v-1];if(k==null){g+=C.length;continue}const N=f.start.getShiftedBy(g),X=t.createRange(N,N.getShiftedBy(C.length)),ue=Rw(N);t.insertContent(w.createText(k,ue),X),g+=k.length}t.enqueueChange(()=>{n.requestUndoOnBackspace()})})}),r.bind("isEnabled").to(this)}}function xw(s){return typeof s=="string"?new RegExp(`(${Bd(s)})$`):s}function Iw(s){return typeof s=="string"?()=>[s]:s instanceof Array?()=>s:s}function Rw(s){return(s.textNode?s.textNode:s.nodeAfter).getAttributes()}function xt(s){return new RegExp(`(^|\\s)(${s})([^${s}]*)(${s})$`)}function Mw(s){const e=s.extra||[],t=s.remove||[],n=o=>!t.includes(o),i=s.include.concat(e).filter(n);return Vw(i).filter(n).map(o=>typeof o=="string"&&yr[o]?yr[o]:o).filter(o=>typeof o=="object").map(o=>({from:xw(o.from),to:Iw(o.to)}))}function Vw(s){const e=new Set;for(const t of s)if(typeof t=="string"&&Cr[t])for(const n of Cr[t])e.add(n);else e.add(t);return Array.from(e)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ut(s,e,t,n){return n.createRange(kr(s,e,t,!0,n),kr(s,e,t,!1,n))}function kr(s,e,t,n,i){let o=s.textNode||(n?s.nodeBefore:s.nodeAfter),r=null;for(;o&&o.getAttribute(e)==t;)r=o,o=n?o.previousSibling:o.nextSibling;return r?i.createPositionAt(r,n?"before":"after"):s}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Dc(s,e,t,n){const i=s.editing.view,o=new Set;i.document.registerPostFixer(r=>{const a=s.model.document.selection;let l=!1;if(a.hasAttribute(e)){const c=Ut(a.getFirstPosition(),e,a.getAttribute(e),s.model),d=s.editing.mapper.toViewRange(c);for(const u of d.getItems())u.is("element",t)&&!u.hasClass(n)&&(r.addClass(n,u),o.add(u),l=!0)}return l}),s.conversion.for("editingDowncast").add(r=>{r.on("insert",a,{priority:"highest"}),r.on("remove",a,{priority:"highest"}),r.on("attribute",a,{priority:"highest"}),r.on("selection",a,{priority:"highest"});function a(){i.change(l=>{for(const c of o.values())l.removeClass(n,c),o.delete(c)})}})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function*Nc(s,e){for(const t of e)t&&s.getAttributeProperties(t[0]).copyOnEnter&&(yield t)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ow extends x{execute(){this.editor.model.change(e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})})}enterBlock(e){const t=this.editor.model,n=t.document.selection,i=t.schema,o=n.isCollapsed,r=n.getFirstRange(),a=r.start.parent,l=r.end.parent;if(i.isLimit(a)||i.isLimit(l))return!o&&a==l&&t.deleteContent(n),!1;if(o){const c=Nc(e.model.schema,n.getAttributes());return Er(e,r.start),e.setSelectionAttribute(c),!0}else{const c=!(r.start.isAtStart&&r.end.isAtEnd),d=a==l;if(t.deleteContent(n,{leaveUnmerged:c}),c){if(d)return Er(e,n.focus),!0;e.setSelection(l,0)}}return!1}}function Er(s,e){s.split(e),s.setSelection(e.parent.nextSibling,0)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Dw={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class Bc extends Le{constructor(e){super(e);const t=this.document;let n=!1;t.on("keydown",(i,o)=>{n=o.shiftKey}),t.on("beforeinput",(i,o)=>{if(!this.isEnabled)return;let r=o.inputType;P.isSafari&&n&&r=="insertParagraph"&&(r="insertLineBreak");const a=o.domEvent,l=Dw[r];if(!l)return;const c=new jt(t,"enter",o.targetRanges[0]);t.fire(c,new zt(e,a,{isSoft:l.isSoft})),c.stop.called&&i.stop()})}observe(){}stopObserving(){}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class oi extends _{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,n=t.document;t.addObserver(Bc),e.commands.add("enter",new Ow(e)),this.listenTo(n,"enter",(i,o)=>{n.isComposing||o.preventDefault(),!o.isSoft&&(e.execute("enter"),t.scrollToTheSelection())},{priority:"low"})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Nw extends x{execute(){const e=this.editor.model,t=e.document;e.change(n=>{Fw(e,n,t.selection),this.fire("afterExecute",{writer:n})})}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=Bw(e.schema,t.selection)}}function Bw(s,e){if(e.rangeCount>1)return!1;const t=e.anchor;if(!t||!s.checkChild(t,"softBreak"))return!1;const n=e.getFirstRange(),i=n.start.parent,o=n.end.parent;return!((ss(i,s)||ss(o,s))&&i!==o)}function Fw(s,e,t){const n=t.isCollapsed,i=t.getFirstRange(),o=i.start.parent,r=i.end.parent,a=o==r;if(n){const l=Nc(s.schema,t.getAttributes());Tr(s,e,i.end),e.removeSelectionAttribute(t.getAttributeKeys()),e.setSelectionAttribute(l)}else{const l=!(i.start.isAtStart&&i.end.isAtEnd);s.deleteContent(t,{leaveUnmerged:l}),a?Tr(s,e,t.focus):l&&e.setSelection(r,0)}}function Tr(s,e,t){const n=e.createElement("softBreak");s.insertContent(n,t),e.setSelection(n,"after")}function ss(s,e){return s.is("rootElement")?!1:e.isLimit(s)||ss(s.parent,e)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Lw extends _{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,n=e.conversion,i=e.editing.view,o=i.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(r,{writer:a})=>a.createEmptyElement("br")}),i.addObserver(Bc),e.commands.add("shiftEnter",new Nw(e)),this.listenTo(o,"enter",(r,a)=>{o.isComposing||a.preventDefault(),a.isSoft&&(e.execute("shiftEnter"),i.scrollToTheSelection())},{priority:"low"})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zw extends H(){constructor(){super(...arguments),this._stack=[]}add(e,t){const n=this._stack,i=n[0];this._insertDescriptor(e);const o=n[0];i!==o&&!Ei(i,o)&&this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}remove(e,t){const n=this._stack,i=n[0];this._removeDescriptor(e);const o=n[0];i!==o&&!Ei(i,o)&&this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,n=t.findIndex(o=>o.id===e.id);if(Ei(e,t[n]))return;n>-1&&t.splice(n,1);let i=0;for(;t[i]&&Hw(t[i],e);)i++;t.splice(i,0,e)}_removeDescriptor(e){const t=this._stack,n=t.findIndex(i=>i.id===e);n>-1&&t.splice(n,1)}}function Ei(s,e){return s&&e&&s.priority==e.priority&&qn(s.classes)==qn(e.classes)}function Hw(s,e){return s.priority>e.priority?!0:s.priority<e.priority?!1:qn(s.classes)>qn(e.classes)}function qn(s){return Array.isArray(s)?s.sort().join(","):s}const Ww='<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M4 0v1H1v3H0V.5A.5.5 0 0 1 .5 0H4zm8 0h3.5a.5.5 0 0 1 .5.5V4h-1V1h-3V0zM4 16H.5a.5.5 0 0 1-.5-.5V12h1v3h3v1zm8 0v-1h3v-3h1v3.5a.5.5 0 0 1-.5.5H12z"/><path fill-opacity=".256" d="M1 1h14v14H1z"/><g class="ck-icon__selected-indicator"><path d="M7 0h2v1H7V0zM0 7h1v2H0V7zm15 0h1v2h-1V7zm-8 8h2v1H7v-1z"/><path fill-opacity=".254" d="M1 1h14v14H1z"/></g></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Uw="ck-widget",Ar="ck-widget_selected";function G(s){return s.is("element")?!!s.getCustomProperty("widget"):!1}function Ks(s,e,t={}){if(!s.is("containerElement"))throw new m("widget-to-widget-wrong-element-type",null,{element:s});return e.setAttribute("contenteditable","false",s),e.addClass(Uw,s),e.setCustomProperty("widget",!0,s),s.getFillerOffset=Gw,e.setCustomProperty("widgetLabel",[],s),t.label&&jw(s,t.label),t.hasSelectionHandle&&Jw(s,e),Fc(s,e),s}function $w(s,e,t){if(e.classes&&t.addClass(se(e.classes),s),e.attributes)for(const n in e.attributes)t.setAttribute(n,e.attributes[n],s)}function qw(s,e,t){if(e.classes&&t.removeClass(se(e.classes),s),e.attributes)for(const n in e.attributes)t.removeAttribute(n,s)}function Fc(s,e,t=$w,n=qw){const i=new zw;i.on("change:top",(a,l)=>{l.oldDescriptor&&n(s,l.oldDescriptor,l.writer),l.newDescriptor&&t(s,l.newDescriptor,l.writer)});const o=(a,l,c)=>i.add(l,c),r=(a,l,c)=>i.remove(l,c);e.setCustomProperty("addHighlight",o,s),e.setCustomProperty("removeHighlight",r,s)}function jw(s,e){s.getCustomProperty("widgetLabel").push(e)}function Kw(s){return s.getCustomProperty("widgetLabel").reduce((t,n)=>typeof n=="function"?t?t+". "+n():n():t?t+". "+n:n,"")}function Lc(s,e,t={}){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],s),e.setAttribute("role","textbox",s),t.label&&e.setAttribute("aria-label",t.label,s),e.setAttribute("contenteditable",s.isReadOnly?"false":"true",s),s.on("change:isReadOnly",(n,i,o)=>{e.setAttribute("contenteditable",o?"false":"true",s)}),s.on("change:isFocused",(n,i,o)=>{o?e.addClass("ck-editor__nested-editable_focused",s):e.removeClass("ck-editor__nested-editable_focused",s)}),Fc(s,e),s}function zc(s,e){const t=s.getSelectedElement();if(t){const n=Xe(s);if(n)return e.createRange(e.createPositionAt(t,n))}return uc(s,e)}function Gw(){return null}function Jw(s,e){const t=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},function(n){const i=this.toDomElement(n),o=new at;return o.set("content",Ww),o.render(),i.appendChild(o.element),i});e.insert(e.createPositionAt(s,0),t),e.addClass(["ck-widget_with-selection-handle"],s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const We="widget-type-around";function ht(s,e,t){return!!s&&G(s)&&!t.isInline(e)}function Qw(s){return s.closest(".ck-widget__type-around__button")}function Yw(s){return s.classList.contains("ck-widget__type-around__button_before")?"before":"after"}function Zw(s,e){const t=s.closest(".ck-widget");return e.mapDomToView(t)}function Xe(s){return s.getAttribute(We)}const Xw='<svg viewBox="0 0 10 8" xmlns="http://www.w3.org/2000/svg"><path d="M9.055.263v3.972h-6.77M1 4.216l2-2.038m-2 2 2 2.038"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Hc=["before","after"],eb=new DOMParser().parseFromString(Xw,"image/svg+xml").firstChild,Sr="ck-widget__type-around_disabled";class tb extends _{constructor(){super(...arguments),this._currentFakeCaretModelElement=null}static get pluginName(){return"WidgetTypeAround"}static get requires(){return[oi,Je]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",(n,i,o)=>{t.change(r=>{for(const a of t.document.roots)o?r.removeClass(Sr,a):r.addClass(Sr,a)}),o||e.model.change(r=>{r.removeSelectionAttribute(We)})}),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const n=this.editor,i=n.editing.view,o=n.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(e,t),attributes:o}),i.focus(),i.scrollToTheSelection()}_listenToIfEnabled(e,t,n,i){this.listenTo(e,t,(...o)=>{this.isEnabled&&n(...o)},i)}_insertParagraphAccordingToFakeCaretPosition(){const n=this.editor.model.document.selection,i=Xe(n);if(!i)return!1;const o=n.getSelectedElement();return this._insertParagraph(o,i),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,n=e.locale.t,i={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",(o,r,a)=>{const l=a.mapper.toViewElement(r.item);l&&ht(l,r.item,t)&&(nb(a.writer,i,l),l.getCustomProperty("widgetLabel").push(()=>this.isEnabled?n("Press Enter to type after or press Shift + Enter to type before the widget"):""))},{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,n=t.document.selection,i=t.schema,o=e.editing.view;this._listenToIfEnabled(o.document,"arrowKey",(a,l)=>{this._handleArrowKeyPress(a,l)},{context:[G,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",(a,l)=>{l.directChange&&e.model.change(c=>{c.removeSelectionAttribute(We)})}),this._listenToIfEnabled(t.document,"change:data",()=>{const a=n.getSelectedElement();if(a){const l=e.editing.mapper.toViewElement(a);if(ht(l,a,i))return}e.model.change(l=>{l.removeSelectionAttribute(We)})}),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",(a,l,c)=>{const d=c.writer;if(this._currentFakeCaretModelElement){const g=c.mapper.toViewElement(this._currentFakeCaretModelElement);g&&(d.removeClass(Hc.map(r),g),this._currentFakeCaretModelElement=null)}const u=l.selection.getSelectedElement();if(!u)return;const h=c.mapper.toViewElement(u);if(!ht(h,u,i))return;const f=Xe(l.selection);f&&(d.addClass(r(f),h),this._currentFakeCaretModelElement=u)}),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",(a,l,c)=>{c||e.model.change(d=>{d.removeSelectionAttribute(We)})});function r(a){return`ck-widget_type-around_show-fake-caret_${a}`}}_handleArrowKeyPress(e,t){const n=this.editor,i=n.model,o=i.document.selection,r=i.schema,a=n.editing.view,l=t.keyCode,c=Vu(l,n.locale.contentLanguageDirection),d=a.document.selection.getSelectedElement(),u=n.editing.mapper.toModelElement(d);let h;ht(d,u,r)?h=this._handleArrowKeyPressOnSelectedWidget(c):o.isCollapsed?h=this._handleArrowKeyPressWhenSelectionNextToAWidget(c):t.shiftKey||(h=this._handleArrowKeyPressWhenNonCollapsedSelection(c)),h&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const n=this.editor.model,i=n.document.selection,o=Xe(i);return n.change(r=>{if(o){if(!(o===(e?"after":"before")))return r.removeSelectionAttribute(We),!0}else return r.setSelectionAttribute(We,e?"after":"before"),!0;return!1})}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,n=t.model,i=n.schema,o=t.plugins.get("Widget"),r=o._getObjectElementNextToSelection(e),a=t.editing.mapper.toViewElement(r);return ht(a,r,i)?(n.change(l=>{o._setSelectionOverElement(r),l.setSelectionAttribute(We,e?"before":"after")}),!0):!1}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,n=t.model,i=n.schema,o=t.editing.mapper,r=n.document.selection,a=e?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter,l=o.toViewElement(a);return ht(l,a,i)?(n.change(c=>{c.setSelection(a,"on"),c.setSelectionAttribute(We,e?"after":"before")}),!0):!1}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",(n,i)=>{const o=Qw(i.domTarget);if(!o)return;const r=Yw(o),a=Zw(o,t.domConverter),l=e.editing.mapper.toModelElement(a);this._insertParagraph(l,r),i.preventDefault(),n.stop()})}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,n=e.editing.view;this._listenToIfEnabled(n.document,"enter",(i,o)=>{if(i.eventPhase!="atTarget")return;const r=t.getSelectedElement(),a=e.editing.mapper.toViewElement(r),l=e.model.schema;let c;this._insertParagraphAccordingToFakeCaretPosition()?c=!0:ht(a,r,l)&&(this._insertParagraph(r,o.isSoft?"before":"after"),c=!0),c&&(o.preventDefault(),i.stop())},{context:G})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view.document;this._listenToIfEnabled(t,"insertText",(n,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=t.selection)},{priority:"high"}),P.isAndroid?this._listenToIfEnabled(t,"keydown",(n,i)=>{i.keyCode==229&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(t,"compositionstart",()=>{this._insertParagraphAccordingToFakeCaretPosition()},{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,n=e.model,i=n.schema;this._listenToIfEnabled(t.document,"delete",(o,r)=>{if(o.eventPhase!="atTarget")return;const a=Xe(n.document.selection);if(!a)return;const l=r.direction,c=n.document.selection.getSelectedElement(),d=a==="before",u=l=="forward";if(d===u)e.execute("delete",{selection:n.createSelection(c,"on")});else{const f=i.getNearestSelectionRange(n.createPositionAt(c,a),l);if(f)if(!f.isCollapsed)n.change(g=>{g.setSelection(f),e.execute(u?"deleteForward":"delete")});else{const g=n.createSelection(f.start);if(n.modifySelection(g,{direction:l}),!g.focus.isEqual(f.start))n.change(w=>{w.setSelection(f),e.execute(u?"deleteForward":"delete")});else{const w=ob(i,f.start.parent);n.deleteContent(n.createSelection(w,"on"),{doNotAutoparagraph:!0})}}}r.preventDefault(),o.stop()},{context:G})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,n=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",(i,[o,r])=>{if(r&&!r.is("documentSelection"))return;const a=Xe(n);if(a)return i.stop(),t.change(l=>{const c=n.getSelectedElement(),d=t.createPositionAt(c,a),u=l.createSelection(d),h=t.insertContent(o,u);return l.setSelection(u),h})},{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,n=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",(i,o)=>{const[,r,a={}]=o;if(r&&!r.is("documentSelection"))return;const l=Xe(n);l&&(a.findOptimalPosition=l,o[3]=a)},{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,n=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",(i,[o])=>{if(o&&!o.is("documentSelection"))return;Xe(n)&&i.stop()},{priority:"high"})}}function nb(s,e,t){const n=s.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},function(i){const o=this.toDomElement(i);return ib(o,e),sb(o),o});s.insert(s.createPositionAt(t,"end"),n)}function ib(s,e){for(const t of Hc){const n=new Ve({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${t}`],title:e[t],"aria-hidden":"true"},children:[s.ownerDocument.importNode(eb,!0)]});s.appendChild(n.render())}}function sb(s){const e=new Ve({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});s.appendChild(e.render())}function ob(s,e){let t=e;for(const n of e.getAncestors({parentFirst:!0})){if(n.childCount>1||s.isLimit(n))break;t=n}return t}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function rb(s){const e=s.model;return(t,n)=>{const i=n.keyCode==M.arrowup,o=n.keyCode==M.arrowdown,r=n.shiftKey,a=e.document.selection;if(!i&&!o)return;const l=o;if(r&&cb(a,l))return;const c=ab(s,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(r)return}(c.isCollapsed||lb(s,c,l))&&(e.change(d=>{const u=l?c.end:c.start;if(r){const h=e.createSelection(a.anchor);h.setFocus(u),d.setSelection(h)}else d.setSelection(u)}),t.stop(),n.preventDefault(),n.stopPropagation())}}}function ab(s,e,t){const n=s.model;if(t){const i=e.isCollapsed?e.focus:e.getLastPosition(),o=Pr(n,i,"forward");if(!o)return null;const r=n.createRange(i,o),a=xr(n.schema,r,"backward");return a?n.createRange(i,a):null}else{const i=e.isCollapsed?e.focus:e.getFirstPosition(),o=Pr(n,i,"backward");if(!o)return null;const r=n.createRange(o,i),a=xr(n.schema,r,"forward");return a?n.createRange(a,i):null}}function Pr(s,e,t){const n=s.schema,i=s.createRangeIn(e.root),o=t=="forward"?"elementStart":"elementEnd";for(const{previousPosition:r,item:a,type:l}of i.getWalker({startPosition:e,direction:t})){if(n.isLimit(a)&&!n.isInline(a))return r;if(l==o&&n.isBlock(a))return null}return null}function xr(s,e,t){const n=t=="backward"?e.end:e.start;if(s.checkChild(n,"$text"))return n;for(const{nextPosition:i}of e.getWalker({direction:t}))if(s.checkChild(i,"$text"))return i;return null}function lb(s,e,t){const n=s.model,i=s.view.domConverter;if(t){const c=n.createSelection(e.start);n.modifySelection(c),!c.focus.isAtEnd&&!e.start.isEqual(c.focus)&&(e=n.createRange(c.focus,e.end))}const o=s.mapper.toViewRange(e),r=i.viewRangeToDom(o),a=L.getDomRangeRects(r);let l;for(const c of a){if(l===void 0){l=Math.round(c.bottom);continue}if(Math.round(c.top)>=l)return!1;l=Math.max(l,Math.round(c.bottom))}return!0}function cb(s,e){return!s.isCollapsed&&s.isBackward==e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fn extends _{constructor(){super(...arguments),this._previouslySelected=new Set}static get pluginName(){return"Widget"}static get requires(){return[tb,Je]}init(){const e=this.editor,t=e.editing.view,n=t.document;this.editor.editing.downcastDispatcher.on("selection",(i,o,r)=>{const a=r.writer,l=o.selection;if(l.isCollapsed)return;const c=l.getSelectedElement();if(!c)return;const d=e.editing.mapper.toViewElement(c);G(d)&&r.consumable.consume(l,"selection")&&a.setSelection(a.createRangeOn(d),{fake:!0,label:Kw(d)})}),this.editor.editing.downcastDispatcher.on("selection",(i,o,r)=>{this._clearPreviouslySelectedWidgets(r.writer);const a=r.writer,l=a.document.selection;let c=null;for(const d of l.getRanges())for(const u of d){const h=u.item;G(h)&&!ub(h,c)&&(a.addClass(Ar,h),this._previouslySelected.add(h),c=h)}},{priority:"low"}),t.addObserver(ii),this.listenTo(n,"mousedown",(...i)=>this._onMousedown(...i)),this.listenTo(n,"arrowKey",(...i)=>{this._handleSelectionChangeOnArrowKeyPress(...i)},{context:[G,"$text"]}),this.listenTo(n,"arrowKey",(...i)=>{this._preventDefaultOnArrowKeyPress(...i)},{context:"$root"}),this.listenTo(n,"arrowKey",rb(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",(i,o)=>{this._handleDelete(o.direction=="forward")&&(o.preventDefault(),i.stop())},{context:"$root"})}_onMousedown(e,t){const n=this.editor,i=n.editing.view,o=i.document;let r=t.target;if(db(r)){if((P.isSafari||P.isGecko)&&t.domEvent.detail>=3){const l=n.editing.mapper,c=r.is("attributeElement")?r.findAncestor(u=>!u.is("attributeElement")):r,d=l.toModelElement(c);t.preventDefault(),this.editor.model.change(u=>{u.setSelection(d,"in")})}return}if(!G(r)&&(r=r.findAncestor(G),!r))return;P.isAndroid&&t.preventDefault(),o.isFocused||i.focus();const a=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(a)}_handleSelectionChangeOnArrowKeyPress(e,t){const n=t.keyCode,i=this.editor.model,o=i.schema,r=i.document.selection,a=r.getSelectedElement(),l=ys(n,this.editor.locale.contentLanguageDirection),c=l=="down"||l=="right",d=l=="up"||l=="down";if(a&&o.isObject(a)){const h=c?r.getLastPosition():r.getFirstPosition(),f=o.getNearestSelectionRange(h,c?"forward":"backward");f&&(i.change(g=>{g.setSelection(f)}),t.preventDefault(),e.stop());return}if(!r.isCollapsed&&!t.shiftKey){const h=r.getFirstPosition(),f=r.getLastPosition(),g=h.nodeAfter,w=f.nodeBefore;(g&&o.isObject(g)||w&&o.isObject(w))&&(i.change(v=>{v.setSelection(c?f:h)}),t.preventDefault(),e.stop());return}if(!r.isCollapsed)return;const u=this._getObjectElementNextToSelection(c);if(u&&o.isObject(u)){if(o.isInline(u)&&d)return;this._setSelectionOverElement(u),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const n=this.editor.model,i=n.schema,o=n.document.selection.getSelectedElement();o&&i.isObject(o)&&(t.preventDefault(),e.stop())}_handleDelete(e){const n=this.editor.model.document.selection;if(!this.editor.model.canEditAt(n)||!n.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);if(i)return this.editor.model.change(o=>{let r=n.anchor.parent;for(;r.isEmpty;){const a=r;r=a.parent,o.remove(a)}this._setSelectionOverElement(i)}),!0}_setSelectionOverElement(e){this.editor.model.change(t=>{t.setSelection(t.createRangeOn(e))})}_getObjectElementNextToSelection(e){const t=this.editor.model,n=t.schema,i=t.document.selection,o=t.createSelection(i);if(t.modifySelection(o,{direction:e?"forward":"backward"}),o.isEqual(i))return null;const r=e?o.focus.nodeBefore:o.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(Ar,t);this._previouslySelected.clear()}}function db(s){let e=s;for(;e;){if(e.is("editableElement")&&!e.is("rootElement"))return!0;if(G(e))return!1;e=e.parent}return!1}function ub(s,e){return e?Array.from(s.getAncestors()).includes(e):!1}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jn extends _{constructor(){super(...arguments),this._toolbarDefinitions=new Map}static get requires(){return[Un]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",n=>{hb(e.editing.view.document.selection)&&n.stop()},{priority:"high"})}this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",()=>{this._updateToolbarsVisibility()}),this.listenTo(e.ui,"update",()=>{this._updateToolbarsVisibility()}),this.listenTo(e.ui.focusTracker,"change:isFocused",()=>{this._updateToolbarsVisibility()},{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:n,getRelatedElement:i,balloonClassName:o="ck-toolbar-container"}){if(!n.length){K("widget-toolbar-no-items",{toolbarId:e});return}const r=this.editor,a=r.t,l=new Ls(r.locale);if(l.ariaLabel=t||a("Widget toolbar"),this._toolbarDefinitions.has(e))throw new m("widget-toolbar-duplicated",this,{toolbarId:e});const c={view:l,getRelatedElement:i,balloonClassName:o,itemsConfig:n,initialized:!1};r.ui.addToolbar(l,{isContextual:!0,beforeFocus:()=>{const d=i(r.editing.view.document.selection);d&&this._showToolbar(c,d)},afterBlur:()=>{this._hideToolbar(c)}}),this._toolbarDefinitions.set(e,c)}_updateToolbarsVisibility(){let e=0,t=null,n=null;for(const i of this._toolbarDefinitions.values()){const o=i.getRelatedElement(this.editor.editing.view.document.selection);if(!this.isEnabled||!o)this._isToolbarInBalloon(i)&&this._hideToolbar(i);else if(!this.editor.ui.focusTracker.isFocused)this._isToolbarVisible(i)&&this._hideToolbar(i);else{const r=o.getAncestors().length;r>e&&(e=r,t=o,n=i)}}n&&this._showToolbar(n,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?Ir(this.editor,t):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:Wc(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const n of this._toolbarDefinitions.values())if(this._isToolbarVisible(n)){const i=n.getRelatedElement(this.editor.editing.view.document.selection);Ir(this.editor,i)}}))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function Ir(s,e){const t=s.plugins.get("ContextualBalloon"),n=Wc(s,e);t.updatePosition(n)}function Wc(s,e){const t=s.editing.view,n=de.defaultPositions;return{target:t.domConverter.mapViewToDom(e),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}function hb(s){const e=s.getSelectedElement();return!!(e&&G(e))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fb extends D(){constructor(e){super(),this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(e,t,n){const i=new L(t);this.activeHandlePosition=wb(e),this._referenceCoordinates=gb(t,bb(this.activeHandlePosition)),this._originalWidth=i.width,this._originalHeight=i.height,this._aspectRatio=i.width/i.height;const o=n.style.width;o&&o.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(o):this._originalWidthPercents=mb(n,i)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function mb(s,e){const t=s.parentElement;let n=parseFloat(t.ownerDocument.defaultView.getComputedStyle(t).width);const i=5;let o=0,r=t;for(;isNaN(n);){if(r=r.parentElement,++o>i)return 0;n=parseFloat(t.ownerDocument.defaultView.getComputedStyle(r).width)}return e.width/n*100}function gb(s,e){const t=new L(s),n=e.split("-"),i={x:n[1]=="right"?t.right:t.left,y:n[0]=="bottom"?t.bottom:t.top};return i.x+=s.ownerDocument.defaultView.scrollX,i.y+=s.ownerDocument.defaultView.scrollY,i}function pb(s){return`ck-widget__resizer__handle-${s}`}function wb(s){const e=["top-left","top-right","bottom-right","bottom-left"];for(const t of e)if(s.classList.contains(pb(t)))return t}function bb(s){const e=s.split("-"),t={top:"bottom",bottom:"top",left:"right",right:"left"};return`${t[e[0]]}-${t[e[1]]}`}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _b extends I{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",t=>t?`ck-orientation-${t}`:"")],style:{display:e.if("_isVisible","none",t=>!t)}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",(n,i)=>n!==null&&i!==null),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",(n,i,o)=>e.unit==="px"?`${n}×${i}`:`${o}%`),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",(n,i,o)=>i<50||o<50?"above-center":n)}_dismiss(){this.unbind(),this._isVisible=!1}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rr extends D(){constructor(e){super(),this._viewResizerWrapper=null,this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",(t,n)=>t&&n),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",t=>{!this.state.proposedWidth&&!this.state.proposedWidthPercents&&(this._cleanup(),t.stop())},{priority:"high"})}get state(){return this._state}show(){this._options.editor.editing.view.change(t=>{t.removeClass("ck-hidden",this._viewResizerWrapper)})}hide(){this._options.editor.editing.view.change(t=>{t.addClass("ck-hidden",this._viewResizerWrapper)})}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change(i=>{const o=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},function(r){const a=this.toDomElement(r);return e._appendHandles(a),e._appendSizeUI(a),a});i.insert(i.createPositionAt(t,"end"),o),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=o,this.isVisible||this.hide()}),this.on("change:isVisible",()=>{this.isVisible?(this.show(),this.redraw()):this.hide()})}begin(e){this._state=new fb(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change(c=>{const d=this._options.unit||"%",u=(d==="%"?t.widthPercents:t.width)+d;c.setStyle("width",u,this._options.viewElement)});const i=this._getHandleHost(),o=new L(i),r=Math.round(o.width),a=Math.round(o.height),l=new L(i);t.width=Math.round(l.width),t.height=Math.round(l.height),this.redraw(o),this.state.update({...t,handleHostWidth:r,handleHostHeight:a})}commit(){const e=this._options.unit||"%",t=(e==="%"?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change(()=>{this._cleanup(),this._options.onCommit(t)})}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!Cb(t))return;const n=t.parentElement,i=this._getHandleHost(),o=this._viewResizerWrapper,r=[o.getStyle("width"),o.getStyle("height"),o.getStyle("left"),o.getStyle("top")];let a;if(n.isSameNode(i)){const l=e||new L(i);a=[l.width+"px",l.height+"px",void 0,void 0]}else a=[i.offsetWidth+"px",i.offsetHeight+"px",i.offsetLeft+"px",i.offsetTop+"px"];le(r,a)!=="same"&&this._options.editor.editing.view.change(l=>{l.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},o)})}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss(),this._options.editor.editing.view.change(t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){const t=this.state,n=yb(e),i=this._options.isCentered?this._options.isCentered(this):!0,o={x:t._referenceCoordinates.x-(n.x+t.originalWidth),y:n.y-t.originalHeight-t._referenceCoordinates.y};i&&t.activeHandlePosition.endsWith("-right")&&(o.x=n.x-(t._referenceCoordinates.x+t.originalWidth)),i&&(o.x*=2);let r=Math.abs(t.originalWidth+o.x),a=Math.abs(t.originalHeight+o.y);return(r/t.aspectRatio>a?"width":"height")=="width"?a=r/t.aspectRatio:r=a*t.aspectRatio,{width:Math.round(r),height:Math.round(a),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*r*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)e.appendChild(new Ve({tag:"div",attributes:{class:`ck-widget__resizer__handle ${vb(n)}`}}).render())}_appendSizeUI(e){this._sizeView=new _b,this._sizeView.render(),e.appendChild(this._sizeView.element)}}function vb(s){return`ck-widget__resizer__handle-${s}`}function yb(s){return{x:s.pageX,y:s.pageY}}function Cb(s){return s&&s.ownerDocument&&s.ownerDocument.contains(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ti extends _{constructor(){super(...arguments),this._resizers=new Map}static get pluginName(){return"WidgetResize"}init(){const e=this.editor.editing,t=S.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(ii),this._observer=new(Qe()),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=Jn(()=>this.redrawSelectedResizer(),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",()=>{for(const[i,o]of this._resizers)i.isAttached()||(this._resizers.delete(i),o.destroy())},{priority:"lowest"}),this._observer.listenTo(S.window,"resize",this._redrawSelectedResizerThrottled);const n=this.editor.editing.view.document.selection;n.on("change",()=>{const i=n.getSelectedElement(),o=this.getResizerByViewElement(i)||null;o?this.select(o):this.deselect()})}redrawSelectedResizer(){this.selectedResizer&&this.selectedResizer.isVisible&&this.selectedResizer.redraw()}destroy(){super.destroy(),this._observer.stopListening();for(const e of this._resizers.values())e.destroy();this._redrawSelectedResizerThrottled.cancel()}select(e){this.deselect(),this.selectedResizer=e,this.selectedResizer.isSelected=!0}deselect(){this.selectedResizer&&(this.selectedResizer.isSelected=!1),this.selectedResizer=null}attachTo(e){const t=new Rr(e),n=this.editor.plugins;if(t.attach(),n.has("WidgetToolbarRepository")){const r=n.get("WidgetToolbarRepository");t.on("begin",()=>{r.forceDisabled("resize")},{priority:"lowest"}),t.on("cancel",()=>{r.clearForceDisabled("resize")},{priority:"highest"}),t.on("commit",()=>{r.clearForceDisabled("resize")},{priority:"highest"})}this._resizers.set(e.viewElement,t);const o=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(o)==t&&this.select(t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const n=t.domTarget;Rr.isResizeHandle(n)&&(this._activeResizer=this._getResizerByHandle(n)||null,this._activeResizer&&(this._activeResizer.begin(n),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class kb extends _{static get pluginName(){return"DragDrop"}static get requires(){return[Ne,fn]}init(){const e=this.editor,t=e.editing.view;if(this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=Jn(n=>this._updateDropMarker(n),40),this._removeDropMarkerDelayed=Ui(()=>this._removeDropMarker(),40),this._clearDraggableAttributesDelayed=Ui(()=>this._clearDraggableAttributes(),40),e.plugins.has("DragDropExperimental")){this.forceDisabled("DragDropExperimental");return}t.addObserver(js),t.addObserver(ii),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",(n,i,o)=>{o?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(n,i,o)=>{o||this._finalizeDragging(!1)}),P.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,n=t.document,i=e.editing.view,o=i.document;this.listenTo(o,"dragstart",(r,a)=>{const l=n.selection;if(a.target&&a.target.is("editableElement")){a.preventDefault();return}const c=a.target?Or(a.target):null;if(c){const f=e.editing.mapper.toModelElement(c);this._draggedRange=Te.fromRange(t.createRangeOn(f)),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!o.selection.isCollapsed){const f=o.selection.getSelectedElement();(!f||!G(f))&&(this._draggedRange=Te.fromRange(l.getFirstRange()))}if(!this._draggedRange){a.preventDefault();return}this._draggingUid=De();const d=this.isEnabled&&e.model.canEditAt(this._draggedRange);a.dataTransfer.effectAllowed=d?"copyMove":"copy",a.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const u=t.createSelection(this._draggedRange.toRange()),h=e.data.toView(t.getSelectedContent(u));o.fire("clipboardOutput",{dataTransfer:a.dataTransfer,content:h,method:"dragstart"}),d||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(o,"dragend",(r,a)=>{this._finalizeDragging(!a.dataTransfer.isCanceled&&a.dataTransfer.dropEffect=="move")},{priority:"low"}),this.listenTo(o,"dragenter",()=>{this.isEnabled&&i.focus()}),this.listenTo(o,"dragleave",()=>{this._removeDropMarkerDelayed()}),this.listenTo(o,"dragging",(r,a)=>{if(!this.isEnabled){a.dataTransfer.dropEffect="none";return}this._removeDropMarkerDelayed.cancel();const l=Mr(e,a.targetRanges,a.target);if(!e.model.canEditAt(l)){a.dataTransfer.dropEffect="none";return}this._draggedRange||(a.dataTransfer.dropEffect="copy"),P.isGecko||(a.dataTransfer.effectAllowed=="copy"?a.dataTransfer.dropEffect="copy":["all","copyMove"].includes(a.dataTransfer.effectAllowed)&&(a.dataTransfer.dropEffect="move"));/* istanbul ignore else -- @preserve */l&&this._updateDropMarkerThrottled(l)},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,n=e.editing.view.document;this.listenTo(n,"clipboardInput",(i,o)=>{if(o.method!="drop")return;const r=Mr(e,o.targetRanges,o.target);this._removeDropMarker();/* istanbul ignore if -- @preserve */if(!r||!e.model.canEditAt(r)){this._finalizeDragging(!1),i.stop();return}if(this._draggedRange&&this._draggingUid!=o.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),Vr(o.dataTransfer)=="move"&&this._draggedRange&&this._draggedRange.containsRange(r,!0)){this._finalizeDragging(!1),i.stop();return}o.targetRanges=[e.editing.mapper.toViewRange(r)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Ne);e.on("contentInsertion",(t,n)=>{if(!this.isEnabled||n.method!=="drop")return;const i=n.targetRanges.map(o=>this.editor.editing.mapper.toModelRange(o));this.editor.model.change(o=>o.setSelection(i))},{priority:"high"}),e.on("contentInsertion",(t,n)=>{if(!this.isEnabled||n.method!=="drop")return;const i=Vr(n.dataTransfer)=="move",o=!n.resultRange||!n.resultRange.isCollapsed;this._finalizeDragging(o&&i)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,n=t.document;this.listenTo(n,"mousedown",(i,o)=>{if(P.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let r=Or(o.target);if(P.isBlink&&!r&&!n.selection.isCollapsed){const a=n.selection.getSelectedElement();if(!a||!G(a)){const l=n.selection.editableElement;l&&!l.isReadOnly&&(r=l)}}r&&(t.change(a=>{a.setAttribute("draggable","true",r)}),this._draggableElement=e.editing.mapper.toModelElement(r))}),this.listenTo(n,"mouseup",()=>{P.isAndroid||this._clearDraggableAttributesDelayed()})}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change(t=>{this._draggableElement&&this._draggableElement.root.rootName!="$graveyard"&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null})}_setupDropMarker(){const e=this.editor;e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:n})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},function(o){const r=this.toDomElement(o);return r.append("⁠",o.createElement("span"),"⁠"),r})}})}_updateDropMarker(e){const t=this.editor,n=t.model.markers;t.model.change(i=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(e)||i.updateMarker("drop-target",{range:e}):i.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})})}_removeDropMarker(){const e=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),e.markers.has("drop-target")&&e.change(t=>{t.removeMarker("drop-target")})}_finalizeDragging(e){const t=this.editor,n=t.model;this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function Mr(s,e,t){const n=s.model,i=s.editing.mapper;let o=null;const r=e?e[0].start:null;if(t.is("uiElement")&&(t=t.parent),o=Eb(s,t),o)return o;const a=Pb(s,t),l=r?i.toModelPosition(r):null;return l?(o=Ab(s,l,a),o||(o=n.schema.getNearestSelectionRange(l,P.isGecko?"forward":"backward"),o)?o:Sb(s,l.parent)):Tb(s,a)}function Eb(s,e){const t=s.model,n=s.editing.mapper;if(G(e))return t.createRangeOn(n.toModelElement(e));if(!e.is("editableElement")){const i=e.findAncestor(o=>G(o)||o.is("editableElement"));if(G(i))return t.createRangeOn(n.toModelElement(i))}return null}function Tb(s,e){const t=s.model,n=t.schema,i=t.createPositionAt(e,0);return n.getNearestSelectionRange(i,"forward")}function Ab(s,e,t){const n=s.model;if(!n.schema.checkChild(t,"$block"))return null;const i=n.createPositionAt(t,0),o=e.path.slice(0,i.path.length),a=n.createPositionFromPath(e.root,o).nodeAfter;return a&&n.schema.isObject(a)?n.createRangeOn(a):null}function Sb(s,e){const t=s.model;let n=e;for(;n;){if(t.schema.isObject(n))return t.createRangeOn(n);n=n.parent}/* istanbul ignore next -- @preserve */return null}function Pb(s,e){const t=s.editing.mapper,n=s.editing.view,i=t.toModelElement(e);if(i)return i;const o=n.createPositionBefore(e),r=t.findMappedViewAncestor(o);return t.toModelElement(r)}function Vr(s){return P.isGecko?s.dropEffect:["all","copyMove"].includes(s.effectAllowed)?"move":"copy"}function Or(s){if(s.is("editableElement"))return null;if(s.hasClass("ck-widget__selection-handle"))return s.findAncestor(G);if(G(s))return s;const e=s.findAncestor(t=>G(t)||t.is("editableElement"));return G(e)?e:null}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class xb extends _{static get pluginName(){return"PastePlainText"}static get requires(){return[Ne]}init(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document,o=t.document.selection;let r=!1;n.addObserver(js),this.listenTo(i,"keydown",(a,l)=>{r=l.shiftKey}),e.plugins.get(Ne).on("contentInsertion",(a,l)=>{!r&&!Ib(l.content,t.schema)||t.change(c=>{const d=Array.from(o.getAttributes()).filter(([h])=>t.schema.getAttributeProperties(h).isFormatting);o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),d.push(...o.getAttributes());const u=c.createRangeIn(l.content);for(const h of u.getItems())h.is("$textProxy")&&c.setAttributes(d,h)})})}}function Ib(s,e){if(s.childCount>1)return!1;const t=s.getChild(0);return e.isObject(t)?!1:Array.from(t.getAttributeKeys()).length==0}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Uc extends _{static get pluginName(){return"Clipboard"}static get requires(){return[Ne,kb,xb]}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rb extends x{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let n=e.schema.getLimitElement(t);if(t.containsEntireContent(n)||!Dr(e.schema,n))do if(n=n.parent,!n)return;while(!Dr(e.schema,n));e.change(i=>{i.setSelection(n,"in")})}}function Dr(s,e){return s.isLimit(e)&&(s.checkChild(e,"$text")||s.checkChild(e,"paragraph"))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Mb=vs("Ctrl+A");class Vb extends _{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,n=e.editing.view.document;e.commands.add("selectAll",new Rb(e)),this.listenTo(n,"keydown",(i,o)=>{Lt(o)===Mb&&(e.execute("selectAll"),o.preventDefault())})}}const Ob='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M.75 15.5a.75.75 0 0 1 .75.75V18l.008.09A.5.5 0 0 0 2 18.5h1.75a.75.75 0 1 1 0 1.5H1.5l-.144-.007a1.5 1.5 0 0 1-1.35-1.349L0 18.5v-2.25a.75.75 0 0 1 .75-.75zm18.5 0a.75.75 0 0 1 .75.75v2.25l-.007.144a1.5 1.5 0 0 1-1.349 1.35L18.5 20h-2.25a.75.75 0 1 1 0-1.5H18a.5.5 0 0 0 .492-.41L18.5 18v-1.75a.75.75 0 0 1 .75-.75zm-10.45 3c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2h1.6zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2h1.6zm.45-5.5a.75.75 0 1 1 0 1.5h-8.5a.75.75 0 1 1 0-1.5h8.5zM1.3 11c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2h1.1zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2h1.1zm-4.55-2a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5h10.5zM1.3 7c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2h1.1zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2h1.1zm-4.55-2a.75.75 0 1 1 0 1.5h-2.5a.75.75 0 1 1 0-1.5h2.5zm-5 0a.75.75 0 1 1 0 1.5h-5.5a.75.75 0 0 1 0-1.5h5.5zm-6.5-5a.75.75 0 0 1 0 1.5H2a.5.5 0 0 0-.492.41L1.5 2v1.75a.75.75 0 0 1-1.5 0V1.5l.007-.144A1.5 1.5 0 0 1 1.356.006L1.5 0h2.25zM18.5 0l.144.007a1.5 1.5 0 0 1 1.35 1.349L20 1.5v2.25a.75.75 0 1 1-1.5 0V2l-.008-.09A.5.5 0 0 0 18 1.5h-1.75a.75.75 0 1 1 0-1.5h2.25zM8.8 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2h1.6zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2h1.6z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Db extends _{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",t=>{const n=e.commands.get("selectAll"),i=new W(t),o=t.t;return i.set({label:o("Select all"),icon:Ob,keystroke:"Ctrl+A",tooltip:!0}),i.bind("isEnabled").to(n,"isEnabled"),this.listenTo(i,"execute",()=>{e.execute("selectAll"),e.editing.view.focus()}),i})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Nb extends _{static get requires(){return[Vb,Db]}static get pluginName(){return"SelectAll"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $c extends x{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",(t,n)=>{n[1]={...n[1]};const i=n[1];i.batchType||(i.batchType={isUndoable:!1})},{priority:"high"}),this.listenTo(e.data,"set",(t,n)=>{n[1].batchType.isUndoable||this.clearStack()})}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(e){const t=this.editor.model.document.selection,n={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,n){const i=this.editor.model,o=i.document,r=[],a=e.map(c=>c.getTransformedByOperations(n)),l=a.flat();for(const c of a){const d=c.filter(u=>u.root!=o.graveyard).filter(u=>!Fb(u,l));d.length&&(Bb(d),r.push(d[0]))}r.length&&i.change(c=>{c.setSelection(r,{backward:t})})}_undo(e,t){const n=this.editor.model,i=n.document;this._createdBatches.add(t);const o=e.operations.slice().filter(r=>r.isDocumentOperation);o.reverse();for(const r of o){const a=r.baseVersion+1,l=Array.from(i.history.getOperations(a)),d=Fm([r.getReversed()],l,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let u of d){const h=u.affectedSelectable;h&&!n.canEditAt(h)&&(u=new te(u.baseVersion)),t.addOperation(u),n.applyOperation(u),i.history.setOperationAsUndone(r,u)}}}}function Bb(s){s.sort((e,t)=>e.start.isBefore(t.start)?-1:1);for(let e=1;e<s.length;e++){const n=s[e-1].getJoined(s[e],!0);n&&(e--,s.splice(e,2,n))}}function Fb(s,e){return e.some(t=>t!==s&&t.containsRange(s,!0))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Lb extends $c{execute(e=null){const t=e?this._stack.findIndex(o=>o.batch==e):this._stack.length-1,n=this._stack.splice(t,1)[0],i=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(i,()=>{this._undo(n.batch,i);const o=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,o),this.fire("revert",n.batch,i)}),this.refresh()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zb extends $c{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,()=>{const i=e.batch.operations[e.batch.operations.length-1].baseVersion+1,o=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,o),this._undo(e.batch,t)}),this.refresh()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hb extends _{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor;this._undoCommand=new Lb(e),this._redoCommand=new zb(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",(t,n)=>{const i=n[0];if(!i.isDocumentOperation)return;const o=i.batch,r=this._redoCommand.createdBatches.has(o),a=this._undoCommand.createdBatches.has(o);this._batchRegistry.has(o)||(this._batchRegistry.add(o),o.isUndoable&&(r?this._undoCommand.addBatch(o):a||(this._undoCommand.addBatch(o),this._redoCommand.clearStack())))},{priority:"highest"}),this.listenTo(this._undoCommand,"revert",(t,n,i)=>{this._redoCommand.addBatch(i)}),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}const Nr='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m5.042 9.367 2.189 1.837a.75.75 0 0 1-.965 1.149l-3.788-3.18a.747.747 0 0 1-.21-.284.75.75 0 0 1 .17-.945L6.23 4.762a.75.75 0 1 1 .964 1.15L4.863 7.866h8.917A.75.75 0 0 1 14 7.9a4 4 0 1 1-1.477 7.718l.344-1.489a2.5 2.5 0 1 0 1.094-4.73l.008-.032H5.042z"/></svg>',Br='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m14.958 9.367-2.189 1.837a.75.75 0 0 0 .965 1.149l3.788-3.18a.747.747 0 0 0 .21-.284.75.75 0 0 0-.17-.945L13.77 4.762a.75.75 0 1 0-.964 1.15l2.331 1.955H6.22A.75.75 0 0 0 6 7.9a4 4 0 1 0 1.477 7.718l-.344-1.489A2.5 2.5 0 1 1 6.039 9.4l-.008-.032h8.927z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wb extends _{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,n=e.t,i=t.uiLanguageDirection=="ltr"?Nr:Br,o=t.uiLanguageDirection=="ltr"?Br:Nr;this._addButton("undo",n("Undo"),"CTRL+Z",i),this._addButton("redo",n("Redo"),"CTRL+Y",o)}_addButton(e,t,n,i){const o=this.editor;o.ui.componentFactory.add(e,r=>{const a=o.commands.get(e),l=new W(r);return l.set({label:t,icon:i,keystroke:n,tooltip:!0}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",()=>{o.execute(e),o.editing.view.focus()}),l})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qc extends _{static get requires(){return[Hb,Wb]}static get pluginName(){return"Undo"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cC extends _{static get requires(){return[Uc,oi,Nb,Lw,Aw,qc]}static get pluginName(){return"Essentials"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ub extends D(){constructor(){super();const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=t=>{this.loaded=t.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise((n,i)=>{t.onload=()=>{const o=t.result;this._data=o,n(o)},t.onerror=()=>{i("error")},t.onabort=()=>{i("aborted")},this._reader.readAsDataURL(e)})}abort(){this._reader.abort()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class je extends _{constructor(){super(...arguments),this.loaders=new _e,this._loadersMap=new Map,this._pendingAction=null}static get pluginName(){return"FileRepository"}static get requires(){return[Hn]}init(){this.loaders.on("change",()=>this._updatePendingAction()),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(e,t)=>t?e/t*100:0)}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return K("filerepository-no-upload-adapter"),null;const t=new Fr(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then(n=>{this._loadersMap.set(n,t)}).catch(()=>{}),t.on("change:uploaded",()=>{let n=0;for(const i of this.loaders)n+=i.uploaded;this.uploaded=n}),t.on("change:uploadTotal",()=>{let n=0;for(const i of this.loaders)i.uploadTotal&&(n+=i.uploadTotal);this.uploadTotal=n}),t}destroyLoader(e){const t=e instanceof Fr?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach((n,i)=>{n===t&&this._loadersMap.delete(i)})}_updatePendingAction(){const e=this.editor.plugins.get(Hn);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,n=i=>`${t("Upload in progress")} ${parseInt(i)}%.`;this._pendingAction=e.add(n(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",n)}}else e.remove(this._pendingAction),this._pendingAction=null}}class Fr extends D(){constructor(e,t){super(),this.id=De(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new Ub,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(n,i)=>i?n/i*100:0),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then(e=>this._filePromiseWrapper?e:null):Promise.resolve(null)}get data(){return this._reader.data}read(){if(this.status!="idle")throw new m("filerepository-read-wrong-status",this);return this.status="reading",this.file.then(e=>this._reader.read(e)).then(e=>{if(this.status!=="reading")throw this.status;return this.status="idle",e}).catch(e=>{throw e==="aborted"?(this.status="aborted","aborted"):(this.status="error",this._reader.error?this._reader.error:e)})}upload(){if(this.status!="idle")throw new m("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then(()=>this._adapter.upload()).then(e=>(this.uploadResponse=e,this.status="idle",e)).catch(e=>{throw this.status==="aborted"?"aborted":(this.status="error",e)})}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?e=="reading"?this._reader.abort():e=="uploading"&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch(()=>{}),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise((n,i)=>{t.rejecter=i,t.isFulfilled=!1,e.then(o=>{t.isFulfilled=!0,n(o)}).catch(o=>{t.isFulfilled=!0,i(o)})}),t}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $b extends I{constructor(e){super(e),this.buttonView=new W(e),this._fileInputView=new qb(e),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.setTemplate({tag:"span",attributes:{class:"ck-file-dialog-button"},children:[this.buttonView,this._fileInputView]}),this.buttonView.on("execute",()=>{this._fileInputView.open()})}focus(){this.buttonView.focus()}}class qb extends I{constructor(e){super(e),this.set("acceptedType",void 0),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to(()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""})}})}open(){this.element.click()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Lr="ckCsrfToken",zr=40,Hr="abcdefghijklmnopqrstuvwxyz0123456789";function jb(){let s=Kb(Lr);return(!s||s.length!=zr)&&(s=Jb(zr),Gb(Lr,s)),s}function Kb(s){s=s.toLowerCase();const e=document.cookie.split(";");for(const t of e){const n=t.split("=");if(decodeURIComponent(n[0].trim().toLowerCase())===s)return decodeURIComponent(n[1])}return null}function Gb(s,e){document.cookie=encodeURIComponent(s)+"="+encodeURIComponent(e)+";path=/"}function Jb(s){let e="";const t=new Uint8Array(s);window.crypto.getRandomValues(t);for(let n=0;n<t.length;n++){const i=Hr.charAt(t[n]%Hr.length);e+=Math.random()>.5?i.toUpperCase():i}return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class dC extends _{static get requires(){return[je]}static get pluginName(){return"CKFinderUploadAdapter"}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(je).createUploadAdapter=t=>new Qb(t,e,this.editor.t))}}class Qb{constructor(e,t,n){this.loader=e,this.url=t,this.t=n}upload(){return this.loader.file.then(e=>new Promise((t,n)=>{this._initRequest(),this._initListeners(t,n,e),this._sendRequest(e)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,n){const i=this.xhr,o=this.loader,r=this.t,a=r("Cannot upload file:")+` ${n.name}.`;i.addEventListener("error",()=>t(a)),i.addEventListener("abort",()=>t()),i.addEventListener("load",()=>{const l=i.response;if(!l||!l.uploaded)return t(l&&l.error&&l.error.message?l.error.message:a);e({default:l.url})});/* istanbul ignore else -- @preserve */i.upload&&i.upload.addEventListener("progress",l=>{l.lengthComputable&&(o.uploadTotal=l.total,o.uploaded=l.loaded)})}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",jb()),this.xhr.send(t)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ye(s,e,t,n){let i,o=null;typeof n=="function"?i=n:(o=s.commands.get(n),i=()=>{s.execute(n)}),s.model.document.on("change:data",(r,a)=>{if(o&&!o.isEnabled||!e.isEnabled)return;const l=ne(s.model.document.selection.getRanges());if(!l.isCollapsed||a.isUndo||!a.isLocal)return;const c=Array.from(s.model.document.differ.getChanges()),d=c[0];if(c.length!=1||d.type!=="insert"||d.name!="$text"||d.length!=1)return;const u=d.position.parent;if(u.is("element","codeBlock")||u.is("element","listItem")&&typeof n!="function"&&!["numberedList","bulletedList","todoList"].includes(n)||o&&o.value===!0)return;const h=u.getChild(0),f=s.model.createRangeOn(h);if(!f.containsRange(l)&&!l.end.isEqual(f.end))return;const g=t.exec(h.data.substr(0,l.end.offset));g&&s.model.enqueueChange(w=>{const v=w.createPositionAt(u,0),C=w.createPositionAt(u,g[0].length),k=new Te(v,C);if(i({match:g})!==!1){w.remove(k);const X=s.model.document.selection.getFirstRange(),ue=w.createRangeIn(u);u.isEmpty&&!ue.isEqual(X)&&!ue.containsRange(X,!0)&&w.remove(u)}k.detach(),s.model.enqueueChange(()=>{s.plugins.get("Delete").requestUndoOnBackspace()})})})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function It(s,e,t,n){let i,o;t instanceof RegExp?i=t:o=t,o=o||(r=>{let a;const l=[],c=[];for(;(a=i.exec(r))!==null&&!(a&&a.length<4);){let{index:d,"1":u,"2":h,"3":f}=a;const g=u+h+f;d+=a[0].length-g.length;const w=[d,d+u.length],v=[d+u.length+h.length,d+u.length+h.length+f.length];l.push(w),l.push(v),c.push([d+u.length,d+u.length+h.length])}return{remove:l,format:c}}),s.model.document.on("change:data",(r,a)=>{if(a.isUndo||!a.isLocal||!e.isEnabled)return;const l=s.model,c=l.document.selection;if(!c.isCollapsed)return;const d=Array.from(l.document.differ.getChanges()),u=d[0];if(d.length!=1||u.type!=="insert"||u.name!="$text"||u.length!=1)return;const h=c.focus,f=h.parent,{text:g,range:w}=Yb(l.createRange(l.createPositionAt(f,0),h),l),v=o(g),C=Wr(w.start,v.format,l),k=Wr(w.start,v.remove,l);C.length&&k.length&&l.enqueueChange(N=>{if(n(N,C)!==!1){for(const ue of k.reverse())N.remove(ue);l.enqueueChange(()=>{s.plugins.get("Delete").requestUndoOnBackspace()})}})})}function Wr(s,e,t){return e.filter(n=>n[0]!==void 0&&n[1]!==void 0).map(n=>t.createRange(s.getShiftedBy(n[0]),s.getShiftedBy(n[1])))}function Yb(s,e){let t=s.start;return{text:Array.from(s.getItems()).reduce((i,o)=>!(o.is("$text")||o.is("$textProxy"))||o.getAttribute("code")?(t=e.createPositionAfter(o),""):i+o.data,""),range:e.createRange(t,s.end)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class uC extends _{static get requires(){return[Je]}static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats()}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&Ye(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&Ye(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&Ye(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&Ye(this.editor,this,/^\[\s?x\s?\]\s$/,()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")})}_addBasicStylesAutoformats(){const e=this.editor.commands;if(e.get("bold")){const t=Tn(this.editor,"bold");It(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),It(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(e.get("italic")){const t=Tn(this.editor,"italic");It(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),It(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(e.get("code")){const t=Tn(this.editor,"code");It(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(e.get("strikethrough")){const t=Tn(this.editor,"strikethrough");It(this.editor,this,/(~~)([^~]+)(~~)$/g,t)}}_addHeadingAutoformats(){const e=this.editor.commands.get("heading");e&&e.modelElements.filter(t=>t.match(/^heading[1-6]$/)).forEach(t=>{const n=t[7],i=new RegExp(`^(#{${n}})\\s$`);Ye(this.editor,this,i,()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&Ye(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&Ye(e,this,/^```$/,()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})})}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&Ye(this.editor,this,/^---$/,"horizontalLine")}}function Tn(s,e){return(t,n)=>{if(!s.commands.get(e).isEnabled)return!1;const o=s.model.schema.getValidRanges(n,e);for(const r of o)t.setAttribute(e,!0,r);t.removeSelectionAttribute(e)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gs extends x{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,o=e.forceValue===void 0?!this.value:e.forceValue;t.change(r=>{if(i.isCollapsed)o?r.setSelectionAttribute(this.attributeKey,!0):r.removeSelectionAttribute(this.attributeKey);else{const a=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const l of a)o?r.setAttribute(this.attributeKey,o,l):r.removeAttribute(this.attributeKey,l)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.hasAttribute(this.attributeKey);for(const i of n.getRanges())for(const o of i.getItems())if(t.checkAttribute(o,this.attributeKey))return o.hasAttribute(this.attributeKey);return!1}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Rt="bold";class Zb extends _{static get pluginName(){return"BoldEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Rt}),e.model.schema.setAttributeProperties(Rt,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Rt,view:"strong",upcastAlso:["b",t=>{const n=t.getStyle("font-weight");return n&&(n=="bold"||Number(n)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(Rt,new Gs(e,Rt)),e.keystrokes.set("CTRL+B",Rt)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Ai="bold";class Xb extends _{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(Ai,n=>{const i=e.commands.get(Ai),o=new W(n);return o.set({label:t("Bold"),icon:$.bold,keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",()=>{e.execute(Ai),e.editing.view.focus()}),o})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hC extends _{static get requires(){return[Zb,Xb]}static get pluginName(){return"Bold"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const ft="code",e_="ck-code_selected";class t_ extends _{static get pluginName(){return"CodeEditing"}static get requires(){return[$n]}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:ft}),e.model.schema.setAttributeProperties(ft,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:ft,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),e.commands.add(ft,new Gs(e,ft)),e.plugins.get($n).registerAttribute(ft),Dc(e,ft,"code",e_)}}const n_='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 5.7 5.2 3.9v1.3l-5.6 4c-.1.2-.3.2-.5.2-.3-.1-.6-.7-.6-1l.3-.4 4.7-3.5L11.5 7l-.2-.2c-.1-.3-.1-.6 0-.8.2-.2.5-.4.8-.4a.8.8 0 0 1 .4.1zm-5.2 0L2 9.6v1.3l5.6 4c.1.2.3.2.5.2.3-.1.7-.7.6-1 0-.1 0-.3-.2-.4l-5-3.5L8.2 7l.2-.2c.1-.3.1-.6 0-.8-.2-.2-.5-.4-.8-.4a.8.8 0 0 0-.3.1z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Si="code";class i_ extends _{static get pluginName(){return"CodeUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(Si,n=>{const i=e.commands.get(Si),o=new W(n);return o.set({label:t("Code"),icon:n_,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",()=>{e.execute(Si),e.editing.view.focus()}),o})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fC extends _{static get requires(){return[t_,i_]}static get pluginName(){return"Code"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Mt="italic";class s_ extends _{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Mt}),e.model.schema.setAttributeProperties(Mt,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Mt,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(Mt,new Gs(e,Mt)),e.keystrokes.set("CTRL+I",Mt)}}const o_='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m9.586 14.633.021.004c-.036.335.095.655.393.962.082.083.173.15.274.201h1.474a.6.6 0 1 1 0 1.2H5.304a.6.6 0 0 1 0-1.2h1.15c.474-.07.809-.182 1.005-.334.157-.122.291-.32.404-.597l2.416-9.55a1.053 1.053 0 0 0-.281-.823 1.12 1.12 0 0 0-.442-.296H8.15a.6.6 0 0 1 0-1.2h6.443a.6.6 0 1 1 0 1.2h-1.195c-.376.056-.65.155-.823.296-.215.175-.423.439-.623.79l-2.366 9.347z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Pi="italic";class r_ extends _{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(Pi,n=>{const i=e.commands.get(Pi),o=new W(n);return o.set({label:t("Italic"),icon:o_,keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",()=>{e.execute(Pi),e.editing.view.focus()}),o})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class mC extends _{static get requires(){return[s_,r_]}static get pluginName(){return"Italic"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class a_ extends x{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.schema,i=t.document.selection,o=Array.from(i.getSelectedBlocks()),r=e.forceValue===void 0?!this.value:e.forceValue;t.change(a=>{if(!r)this._removeQuote(a,o.filter(An));else{const l=o.filter(c=>An(c)||$r(n,c));this._applyQuote(a,l)}})}_getValue(){const e=this.editor.model.document.selection,t=ne(e.getSelectedBlocks());return!!(t&&An(t))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=ne(e.getSelectedBlocks());return n?$r(t,n):!1}_removeQuote(e,t){Ur(e,t).reverse().forEach(n=>{if(n.start.isAtStart&&n.end.isAtEnd){e.unwrap(n.start.parent);return}if(n.start.isAtStart){const o=e.createPositionBefore(n.start.parent);e.move(n,o);return}n.end.isAtEnd||e.split(n.end);const i=e.createPositionAfter(n.end.parent);e.move(n,i)})}_applyQuote(e,t){const n=[];Ur(e,t).reverse().forEach(i=>{let o=An(i.start);o||(o=e.createElement("blockQuote"),e.wrap(i,o)),n.push(o)}),n.reverse().reduce((i,o)=>i.nextSibling==o?(e.merge(e.createPositionAfter(i)),i):o)}}function An(s){return s.parent.name=="blockQuote"?s.parent:null}function Ur(s,e){let t,n=0;const i=[];for(;n<e.length;){const o=e[n],r=e[n+1];t||(t=s.createPositionBefore(o)),(!r||o.nextSibling!=r)&&(i.push(s.createRange(t,s.createPositionAfter(o))),t=null),n++}return i}function $r(s,e){const t=s.checkChild(e.parent,"blockQuote"),n=s.checkChild(["$root","blockQuote"],e);return t&&n}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class l_ extends _{static get pluginName(){return"BlockQuoteEditing"}static get requires(){return[oi,Je]}init(){const e=this.editor,t=e.model.schema;e.commands.add("blockQuote",new a_(e)),t.register("blockQuote",{inheritAllFrom:"$container"}),e.conversion.elementToElement({model:"blockQuote",view:"blockquote"}),e.model.document.registerPostFixer(r=>{const a=e.model.document.differ.getChanges();for(const l of a)if(l.type=="insert"){const c=l.position.nodeAfter;if(!c)continue;if(c.is("element","blockQuote")&&c.isEmpty)return r.remove(c),!0;if(c.is("element","blockQuote")&&!t.checkChild(l.position,c))return r.unwrap(c),!0;if(c.is("element")){const d=r.createRangeIn(c);for(const u of d.getItems())if(u.is("element","blockQuote")&&!t.checkChild(r.createPositionBefore(u),u))return r.unwrap(u),!0}}else if(l.type=="remove"){const c=l.position.parent;if(c.is("element","blockQuote")&&c.isEmpty)return r.remove(c),!0}return!1});const n=this.editor.editing.view.document,i=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(n,"enter",(r,a)=>{if(!i.isCollapsed||!o.value)return;i.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"blockquote"}),this.listenTo(n,"delete",(r,a)=>{if(a.direction!="backward"||!i.isCollapsed||!o.value)return;const l=i.getLastPosition().parent;l.isEmpty&&!l.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"blockquote"})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class c_ extends _{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",n=>{const i=e.commands.get("blockQuote"),o=new W(n);return o.set({label:t("Block quote"),icon:$.quote,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",()=>{e.execute("blockQuote"),e.editing.view.focus()}),o})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class gC extends _{static get requires(){return[l_,c_]}static get pluginName(){return"BlockQuote"}}const d_='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.627 16.5zm5.873-.196zm0-7.001V8h-13v8.5h4.341c.191.54.457 1.044.785 1.5H2a1.5 1.5 0 0 1-1.5-1.5v-13A1.5 1.5 0 0 1 2 2h4.5a1.5 1.5 0 0 1 1.06.44L9.122 4H16a1.5 1.5 0 0 1 1.5 1.5v1A1.5 1.5 0 0 1 19 8v2.531a6.027 6.027 0 0 0-1.5-1.228zM16 6.5v-1H8.5l-2-2H2v13h1V8a1.5 1.5 0 0 1 1.5-1.5H16z"/><path d="M14.5 19.5a5 5 0 1 1 0-10 5 5 0 0 1 0 10zM15 14v-2h-1v2h-2v1h2v2h1v-2h2v-1h-2z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class u_ extends _{static get pluginName(){return"CKFinderUI"}init(){const e=this.editor,t=e.ui.componentFactory,n=e.t;t.add("ckfinder",i=>{const o=e.commands.get("ckfinder"),r=new W(i);return r.set({label:n("Insert image or file"),icon:d_,tooltip:!0}),r.bind("isEnabled").to(o),r.on("execute",()=>{e.execute("ckfinder"),e.editing.view.focus()}),r})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class h_ extends x{constructor(e){super(e),this.affectsData=!1,this.stopListening(this.editor.model.document,"change"),this.listenTo(this.editor.model.document,"change",()=>this.refresh(),{priority:"low"})}refresh(){const e=this.editor.commands.get("insertImage"),t=this.editor.commands.get("link");this.isEnabled=e.isEnabled||t.isEnabled}execute(){const e=this.editor,t=this.editor.config.get("ckfinder.openerMethod")||"modal";if(t!="popup"&&t!="modal")throw new m("ckfinder-unknown-openermethod",e);const n=this.editor.config.get("ckfinder.options")||{};n.chooseFiles=!0;const i=n.onInit;n.language||(n.language=e.locale.uiLanguage),n.onInit=o=>{i&&i(o),o.on("files:choose",r=>{const a=r.data.files.toArray(),l=a.filter(u=>!u.isImage()),c=a.filter(u=>u.isImage());for(const u of l)e.execute("link",u.getUrl());const d=[];for(const u of c){const h=u.getUrl();d.push(h||o.request("file:getProxyUrl",{file:u}))}d.length&&qr(e,d)}),o.on("file:choose:resizedImage",r=>{const a=r.data.resizedUrl;if(!a){const l=e.plugins.get("Notification"),c=e.locale.t;l.showWarning(c("Could not obtain resized image URL."),{title:c("Selecting resized image failed"),namespace:"ckfinder"});return}qr(e,[a])})},window.CKFinder[t](n)}}function qr(s,e){if(!s.commands.get("insertImage").isEnabled){const n=s.plugins.get("Notification"),i=s.locale.t;n.showWarning(i("Could not insert image at the current position."),{title:i("Inserting image failed"),namespace:"ckfinder"});return}s.execute("insertImage",{source:e})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class f_ extends _{static get pluginName(){return"CKFinderEditing"}static get requires(){return[is,"LinkEditing"]}init(){const e=this.editor;if(!e.plugins.has("ImageBlockEditing")&&!e.plugins.has("ImageInlineEditing"))throw new m("ckfinder-missing-image-plugin",e);e.commands.add("ckfinder",new h_(e))}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class pC extends _{static get pluginName(){return"CKFinder"}static get requires(){return["Link","CKFinderUploadAdapter",f_,u_]}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class m_ extends _{static get pluginName(){return"CloudServicesUploadAdapter"}static get requires(){return["CloudServices",je]}init(){const e=this.editor,t=e.plugins.get("CloudServices"),n=t.token,i=t.uploadUrl;if(!n)return;const o=e.plugins.get("CloudServicesCore");this._uploadGateway=o.createUploadGateway(n,i),e.plugins.get(je).createUploadAdapter=r=>new g_(this._uploadGateway,r)}}class g_{constructor(e,t){this.uploadGateway=e,this.loader=t}upload(){return this.loader.file.then(e=>(this.fileUploader=this.uploadGateway.upload(e),this.fileUploader.on("progress",(t,n)=>{this.loader.uploadTotal=n.total,this.loader.uploaded=n.uploaded}),this.fileUploader.send()))}abort(){this.fileUploader.abort()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class wC extends _{static get pluginName(){return"EasyImage"}static get requires(){return[m_,"ImageUpload"]}init(){const e=this.editor;!e.plugins.has("ImageBlockEditing")&&!e.plugins.has("ImageInlineEditing")&&K("easy-image-image-feature-missing",e)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class p_ extends x{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document,n=ne(t.selection.getSelectedBlocks());this.value=!!n&&n.is("element","paragraph"),this.isEnabled=!!n&&jr(n,e.schema)}execute(e={}){const t=this.editor.model,n=t.document,i=e.selection||n.selection;t.canEditAt(i)&&t.change(o=>{const r=i.getSelectedBlocks();for(const a of r)!a.is("element","paragraph")&&jr(a,t.schema)&&o.rename(a,"paragraph")})}}function jr(s,e){return e.checkChild(s.parent,"paragraph")&&!e.isObject(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class w_ extends x{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,n=e.attributes;let i=e.position;t.canEditAt(i)&&t.change(o=>{const r=o.createElement("paragraph");if(n&&t.schema.setAllowedAttributes(r,n,o),!t.schema.checkChild(i.parent,r)){const a=t.schema.findAllowedParent(i,r);if(!a)return;i=o.split(i,a).position}t.insertContent(r,i),o.setSelection(r,"in")})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ri extends _{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new p_(e)),e.commands.add("insertParagraph",new w_(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(n,{writer:i})=>!ri.paragraphLikeElements.has(n.name)||n.isEmpty?null:i.createElement("paragraph"),view:/.+/,converterPriority:"low"})}}ri.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class b_ extends x{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=ne(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>Kr(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,n=t.document,i=e.value;t.change(o=>{const r=Array.from(n.selection.getSelectedBlocks()).filter(a=>Kr(a,i,t.schema));for(const a of r)a.is("element",i)||o.rename(a,i)})}}function Kr(s,e,t){return t.checkChild(s.parent,e)&&!t.isObject(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Gr="paragraph";class __ extends _{static get pluginName(){return"HeadingEditing"}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[ri]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const i of t)i.model!=="paragraph"&&(e.model.schema.register(i.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(i),n.push(i.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new b_(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(i,o)=>{const r=e.model.document.selection.getFirstPosition().parent;n.some(l=>r.is("element",l.model))&&!r.is("element",Gr)&&r.childCount===0&&o.writer.rename(r,Gr)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:tt.get("low")+1})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function v_(s){const e=s.t,t={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return s.config.get("heading.options").map(n=>{const i=t[n.title];return i&&i!=n.title&&(n.title=i),n})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class y_ extends _{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,n=v_(e),i=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",r=>{const a={},l=new _e,c=e.commands.get("heading"),d=e.commands.get("paragraph"),u=[c];for(const f of n){const g={type:"button",model:new $s({label:f.title,class:f.class,role:"menuitemradio",withText:!0})};f.model==="paragraph"?(g.model.bind("isOn").to(d,"value"),g.model.set("commandName","paragraph"),u.push(d)):(g.model.bind("isOn").to(c,"value",w=>w===f.model),g.model.set({commandName:"heading",commandValue:f.model})),l.add(g),a[f.model]=f.title}const h=qe(r);return Ws(h,l,{ariaLabel:o,role:"menu"}),h.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),h.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),h.bind("isEnabled").toMany(u,"isEnabled",(...f)=>f.some(g=>g)),h.buttonView.bind("label").to(c,"value",d,"value",(f,g)=>{const w=f||g&&"paragraph";return typeof w=="boolean"||!a[w]?i:a[w]}),this.listenTo(h,"execute",f=>{const{commandName:g,commandValue:w}=f.source;e.execute(g,w?{value:w}:void 0),e.editing.view.focus()}),h})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bC extends _{static get requires(){return[__,y_]}static get pluginName(){return"Heading"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class C_ extends x{refresh(){const n=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!n,this.isEnabled&&n.hasAttribute("alt")?this.value=n.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,n=t.plugins.get("ImageUtils"),i=t.model,o=n.getClosestSelectedImageElement(i.document.selection);i.change(r=>{r.setAttribute("alt",e.newValue,o)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function k_(s){return s.createContainerElement("span",{class:"image-inline"},s.createEmptyElement("img"))}function Jr(s){return s.createContainerElement("figure",{class:"image"},[s.createEmptyElement("img"),s.createSlot("children")])}function jc(s,e){const t=s.plugins.get("ImageUtils"),n=s.plugins.has("ImageInlineEditing")&&s.plugins.has("ImageBlockEditing");return o=>t.isInlineImageView(o)?n&&(o.getStyle("display")=="block"||o.findAncestor(t.isBlockImageView)?"imageBlock":"imageInline")!==e?null:i(o):null;function i(o){const r={name:!0};return o.hasAttribute("src")&&(r.attributes=["src"]),r}}function Js(s,e){const t=ne(e.getSelectedBlocks());return!t||s.isObject(t)||t.isEmpty&&t.name!="listItem"?"imageBlock":"imageInline"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Se extends _{static get pluginName(){return"ImageUtils"}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,n=null){const i=this.editor,o=i.model,r=o.document.selection;n=Kc(i,t||r,n),e={...Object.fromEntries(r.getAttributes()),...e};for(const a in e)o.schema.checkAttribute(n,a)||delete e[a];return o.change(a=>{const l=a.createElement(n,e);return o.insertObject(l,t,null,{setSelection:"on",findOptimalPosition:!t&&n!="imageInline"?"auto":void 0}),l.parent?l:null})}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const n=e.getSelectedElement();if(n&&this.isImageWidget(n))return n;let i=t.parent;for(;i;){if(i.is("element")&&this.isImageWidget(i))return i;i=i.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const t=this.editor.model.document.selection;return E_(this.editor,t)&&T_(t)}toImageWidget(e,t,n){return t.setCustomProperty("image",!0,e),Ks(e,t,{label:()=>{const r=this.findViewImgElement(e).getAttribute("alt");return r?`${r} ${n}`:n}})}isImageWidget(e){return!!e.getCustomProperty("image")&&G(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:n}of t.createRangeIn(e))if(this.isInlineImageView(n))return n}}function E_(s,e){if(Kc(s,e,null)=="imageBlock"){const n=A_(e,s.model);if(s.model.schema.checkChild(n,"imageBlock"))return!0}else if(s.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}function T_(s){return[...s.focus.getAncestors()].every(e=>!e.is("element","imageBlock"))}function A_(s,e){const n=zc(s,e).start.parent;return n.isEmpty&&!n.is("element","$root")?n.parent:n}function Kc(s,e,t){const n=s.model.schema,i=s.config.get("image.insert.type");return s.plugins.has("ImageBlockEditing")?s.plugins.has("ImageInlineEditing")?t||(i==="inline"?"imageInline":i==="block"?"imageBlock":e.is("selection")?Js(n,e):n.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class S_ extends _{static get requires(){return[Se]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new C_(this.editor))}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class P_ extends I{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new ve,this.keystrokes=new Be,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),$.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),$.cancel,"ck-button-cancel","cancel"),this._focusables=new rt,this._focusCycler=new Kt({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),Ds({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,n,i){const o=new W(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createLabeledInputView(){const e=this.locale.t,t=new Fs(this.locale,Us);return t.label=e("Text alternative"),t}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function x_(s){const e=s.plugins.get("ContextualBalloon");if(s.plugins.get("ImageUtils").getClosestSelectedImageWidget(s.editing.view.document.selection)){const n=Gc(s);e.updatePosition(n)}}function Gc(s){const e=s.editing.view,t=de.defaultPositions,n=s.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(e.document.selection)),positions:[t.northArrowSouth,t.northArrowSouthWest,t.northArrowSouthEast,t.southArrowNorth,t.southArrowNorthWest,t.southArrowNorthEast,t.viewportStickyNorth]}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class I_ extends _{static get requires(){return[Un]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",n=>{const i=e.commands.get("imageTextAlternative"),o=new W(n);return o.set({label:t("Change image text alternative"),icon:$.lowVision,tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled"),o.bind("isOn").to(i,"value",r=>!!r),this.listenTo(o,"execute",()=>{this._showForm()}),o})}_createForm(){const e=this.editor,n=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(Os(P_))(e.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),this._form.keystrokes.set("Esc",(o,r)=>{this._hideForm(!0),r()}),this.listenTo(e.ui,"update",()=>{i.getClosestSelectedImageWidget(n.selection)?this._isVisible&&x_(e):this._hideForm(!0)}),Vs({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),n=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Gc(e)}),n.fieldView.value=n.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jc extends _{static get requires(){return[S_,I_]}static get pluginName(){return"ImageTextAlternative"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function R_(s){const e=(t,n,i)=>{if(!i.consumable.test(n.viewItem,{name:!0,classes:"image"}))return;const o=s.findViewImgElement(n.viewItem);if(!o||!i.consumable.test(o,{name:!0}))return;i.consumable.consume(n.viewItem,{name:!0,classes:"image"});const r=i.convertItem(o,n.modelCursor),a=ne(r.modelRange.getItems());if(!a){i.consumable.revert(n.viewItem,{name:!0,classes:"image"});return}i.convertChildren(n.viewItem,a),i.updateConversionResult(a,n)};return t=>{t.on("element:figure",e)}}function Qc(s,e){const t=(n,i,o)=>{if(!o.consumable.consume(i.item,n.name))return;const r=o.writer,a=o.mapper.toViewElement(i.item),l=s.findViewImgElement(a);if(i.attributeNewValue===null){const c=i.attributeOldValue;c&&c.data&&(r.removeAttribute("srcset",l),r.removeAttribute("sizes",l),c.width&&r.removeAttribute("width",l))}else{const c=i.attributeNewValue;c&&c.data&&(r.setAttribute("srcset",c.data,l),r.setAttribute("sizes","100vw",l),c.width&&r.setAttribute("width",c.width,l))}};return n=>{n.on(`attribute:srcset:${e}`,t)}}function Kn(s,e,t){const n=(i,o,r)=>{if(!r.consumable.consume(o.item,i.name))return;const a=r.writer,l=r.mapper.toViewElement(o.item),c=s.findViewImgElement(l);a.setAttribute(o.attributeKey,o.attributeNewValue||"",c)};return i=>{i.on(`attribute:${t}:${e}`,n)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Yc extends Le{observe(e){this.listenTo(e,"load",(t,n)=>{const i=n.target;this.checkShouldIgnoreEventFromTarget(i)||i.tagName=="IMG"&&this._fireEvents(n)},{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class M_ extends x{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||t==="block"&&K("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||t==="inline"&&K("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=se(e.source),n=this.editor.model.document.selection,i=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(n.getAttributes());t.forEach((r,a)=>{const l=n.getSelectedElement();if(typeof r=="string"&&(r={src:r}),a&&l&&i.isImage(l)){const c=this.editor.model.createPositionAfter(l);i.insertImage({...r,...o},c)}else i.insertImage({...r,...o})})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class V_ extends x{refresh(){const t=this.editor.plugins.get("ImageUtils"),n=this.editor.model.document.selection.getSelectedElement();this.isEnabled=t.isImage(n),this.value=this.isEnabled?n.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement();this.editor.model.change(n=>{n.setAttribute("src",e.source,t),n.removeAttribute("srcset",t),n.removeAttribute("sizes",t)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zc extends _{static get requires(){return[Se]}static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Yc),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:o=>{const r={data:o.getAttribute("srcset")};return o.hasAttribute("width")&&(r.width=o.getAttribute("width")),r}}});const n=new M_(e),i=new V_(e);e.commands.add("insertImage",n),e.commands.add("replaceImageSource",i),e.commands.add("imageInsert",n)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xc extends x{constructor(e,t){super(e),this._modelElementName=t}refresh(){const t=this.editor.plugins.get("ImageUtils"),n=t.getClosestSelectedImageElement(this.editor.model.document.selection);this._modelElementName==="imageBlock"?this.isEnabled=t.isInlineImage(n):this.isEnabled=t.isBlockImage(n)}execute(){const e=this.editor,t=this.editor.model,n=e.plugins.get("ImageUtils"),i=n.getClosestSelectedImageElement(t.document.selection),o=Object.fromEntries(i.getAttributes());return!o.src&&!o.uploadId?null:t.change(r=>{const a=Array.from(t.markers).filter(d=>d.getRange().containsItem(i)),l=n.insertImage(o,t.createSelection(i,"on"),this._modelElementName);if(!l)return null;const c=r.createRangeOn(l);for(const d of a){const u=d.getRange(),h=u.root.rootName!="$graveyard"?u.getJoined(c,!0):c;r.updateMarker(d,{range:h})}return{oldElement:i,newElement:l}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ed extends _{static get requires(){return[Zc,Se,Ne]}static get pluginName(){return"ImageBlockEditing"}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new Xc(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,n=e.conversion,i=e.plugins.get("ImageUtils");n.for("dataDowncast").elementToStructure({model:"imageBlock",view:(o,{writer:r})=>Jr(r)}),n.for("editingDowncast").elementToStructure({model:"imageBlock",view:(o,{writer:r})=>i.toImageWidget(Jr(r),r,t("image widget"))}),n.for("downcast").add(Kn(i,"imageBlock","src")).add(Kn(i,"imageBlock","alt")).add(Qc(i,"imageBlock")),n.for("upcast").elementToElement({view:jc(e,"imageBlock"),model:(o,{writer:r})=>r.createElement("imageBlock",o.hasAttribute("src")?{src:o.getAttribute("src")}:void 0)}).add(R_(i))}_setupClipboardIntegration(){const e=this.editor,t=e.model,n=e.editing.view,i=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",(r,a)=>{const l=Array.from(a.content.getChildren());let c;if(!l.every(i.isInlineImageView))return;a.targetRanges?c=e.editing.mapper.toModelRange(a.targetRanges[0]):c=t.document.selection.getFirstRange();const d=t.createSelection(c);if(Js(t.schema,d)==="imageBlock"){const u=new Et(n.document),h=l.map(f=>u.createElement("figure",{class:"image"},f));a.content=u.createDocumentFragment(h)}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class O_ extends _{static get requires(){return[ed,fn,Jc]}static get pluginName(){return"ImageBlock"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class D_ extends _{static get requires(){return[Zc,Se,Ne]}static get pluginName(){return"ImageInlineEditing"}init(){const e=this.editor,t=e.model.schema;t.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),t.addChildCheck((n,i)=>{if(n.endsWith("caption")&&i.name==="imageInline")return!1}),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new Xc(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,n=e.conversion,i=e.plugins.get("ImageUtils");n.for("dataDowncast").elementToElement({model:"imageInline",view:(o,{writer:r})=>r.createEmptyElement("img")}),n.for("editingDowncast").elementToStructure({model:"imageInline",view:(o,{writer:r})=>i.toImageWidget(k_(r),r,t("image widget"))}),n.for("downcast").add(Kn(i,"imageInline","src")).add(Kn(i,"imageInline","alt")).add(Qc(i,"imageInline")),n.for("upcast").elementToElement({view:jc(e,"imageInline"),model:(o,{writer:r})=>r.createElement("imageInline",o.hasAttribute("src")?{src:o.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,n=e.editing.view,i=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",(r,a)=>{const l=Array.from(a.content.getChildren());let c;if(!l.every(i.isBlockImageView))return;a.targetRanges?c=e.editing.mapper.toModelRange(a.targetRanges[0]):c=t.document.selection.getFirstRange();const d=t.createSelection(c);if(Js(t.schema,d)==="imageInline"){const u=new Et(n.document),h=l.map(f=>f.childCount===1?(Array.from(f.getAttributes()).forEach(g=>u.setAttribute(...g,i.findViewImgElement(f))),f.getChild(0)):f);a.content=u.createDocumentFragment(h)}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class N_ extends _{static get requires(){return[D_,fn,Jc]}static get pluginName(){return"ImageInline"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _C extends _{static get requires(){return[O_,N_]}static get pluginName(){return"Image"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class B_ extends x{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),n=e.plugins.get("ImageUtils");if(!e.plugins.has(ed)){this.isEnabled=!1,this.value=!1;return}const i=e.model.document.selection,o=i.getSelectedElement();if(!o){const r=t.getCaptionFromModelSelection(i);this.isEnabled=!!r,this.value=!!r;return}this.isEnabled=n.isImage(o),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(o):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change(n=>{this.value?this._hideImageCaption(n):this._showImageCaption(n,t)})}_showImageCaption(e,t){const i=this.editor.model.document.selection,o=this.editor.plugins.get("ImageCaptionEditing"),r=this.editor.plugins.get("ImageUtils");let a=i.getSelectedElement();const l=o._getSavedCaption(a);r.isInlineImage(a)&&(this.editor.execute("imageTypeBlock"),a=i.getSelectedElement());const c=l||e.createElement("caption");e.append(c,a),t&&e.setSelection(c,"in")}_hideImageCaption(e){const t=this.editor,n=t.model.document.selection,i=t.plugins.get("ImageCaptionEditing"),o=t.plugins.get("ImageCaptionUtils");let r=n.getSelectedElement(),a;r?a=o.getCaptionFromImageModelElement(r):(a=o.getCaptionFromModelSelection(n),r=a.parent),i._saveCaption(r,a),e.setSelection(r,"on"),e.remove(a)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class td extends _{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[Se]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),n=e.getFirstPosition().findAncestor("caption");return n&&t.isBlockImage(n.parent)?n:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return e.name=="figcaption"&&t.isBlockImageView(e.parent)?{name:!0}:null}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class F_ extends _{static get requires(){return[Se,td]}static get pluginName(){return"ImageCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new B_(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,n=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),o=e.t;e.conversion.for("upcast").elementToElement({view:r=>i.matchImageCaptionViewElement(r),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(r,{writer:a})=>n.isBlockImage(r.parent)?a.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(r,{writer:a})=>{if(!n.isBlockImage(r.parent))return null;const l=a.createEditableElement("figcaption");a.setCustomProperty("imageCaption",!0,l),yl({view:t,element:l,text:o("Enter image caption"),keepOnFocus:!0});const c=r.parent.getAttribute("alt"),d=c?o("Caption for image: %0",[c]):o("Caption for the image");return Lc(l,a,{label:d})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),i=e.commands.get("imageTypeInline"),o=e.commands.get("imageTypeBlock"),r=a=>{if(!a.return)return;const{oldElement:l,newElement:c}=a.return;/* istanbul ignore if: paranoid check -- @preserve */if(!l)return;if(t.isBlockImage(l)){const u=n.getCaptionFromImageModelElement(l);if(u){this._saveCaption(c,u);return}}const d=this._getSavedCaption(l);d&&this._saveCaption(c,d)};i&&this.listenTo(i,"execute",r,{priority:"low"}),o&&this.listenTo(o,"execute",r,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?B.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,n=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",()=>{const o=t.document.differ.getChanges();for(const r of o){if(r.attributeKey!=="alt")continue;const a=r.range.start.nodeAfter;if(n.isBlockImage(a)){const l=i.getCaptionFromImageModelElement(a);if(!l)return;e.editing.reconvertItem(l)}}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class L_ extends _{static get requires(){return[td]}static get pluginName(){return"ImageCaptionUI"}init(){const e=this.editor,t=e.editing.view,n=e.plugins.get("ImageCaptionUtils"),i=e.t;e.ui.componentFactory.add("toggleImageCaption",o=>{const r=e.commands.get("toggleImageCaption"),a=new W(o);return a.set({icon:$.caption,tooltip:!0,isToggleable:!0}),a.bind("isOn","isEnabled").to(r,"value","isEnabled"),a.bind("label").to(r,"value",l=>i(l?"Toggle caption off":"Toggle caption on")),this.listenTo(a,"execute",()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const l=n.getCaptionFromModelSelection(e.model.document.selection);if(l){const c=e.editing.mapper.toViewElement(l);t.scrollToTheSelection(),t.change(d=>{d.addClass("image__caption_highlighted",c)})}e.editing.view.focus()}),a})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vC extends _{static get requires(){return[F_,L_]}static get pluginName(){return"ImageCaption"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class z_ extends x{constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map(n=>{if(n.isDefault)for(const i of n.modelElements)this._defaultStyles[i]=n.name;return[n.name,n]}))}refresh(){const n=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!n,this.isEnabled?n.hasAttribute("imageStyle")?this.value=n.getAttribute("imageStyle"):this.value=this._defaultStyles[n.name]:this.value=!1}execute(e={}){const t=this.editor,n=t.model,i=t.plugins.get("ImageUtils");n.change(o=>{const r=e.value;let a=i.getClosestSelectedImageElement(n.document.selection);r&&this.shouldConvertImageType(r,a)&&(this.editor.execute(i.isBlockImage(a)?"imageTypeInline":"imageTypeBlock"),a=i.getClosestSelectedImageElement(n.document.selection)),!r||this._styles.get(r).isDefault?o.removeAttribute("imageStyle",a):o.setAttribute("imageStyle",r,a)})}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const{objectFullWidth:H_,objectInline:nd,objectLeft:id,objectRight:os,objectCenter:rs,objectBlockLeft:sd,objectBlockRight:od}=$,Vn={get inline(){return{name:"inline",title:"In line",icon:nd,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:id,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:sd,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:rs,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:os,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:od,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:rs,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:os,modelElements:["imageBlock"],className:"image-style-side"}}},rd={full:H_,left:sd,right:od,center:rs,inlineLeft:id,inlineRight:os,inline:nd},ad=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function W_(s){return(s.configuredStyles.options||[]).map(n=>q_(n)).filter(n=>j_(n,s))}function U_(s,e){return s&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:s?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}}function $_(s){return s.has("ImageBlockEditing")&&s.has("ImageInlineEditing")?[...ad]:[]}function q_(s){return typeof s=="string"?Vn[s]?s={...Vn[s]}:s={name:s}:s=K_(Vn[s.name],s),typeof s.icon=="string"&&(s.icon=rd[s.icon]||s.icon),s}function j_(s,{isBlockPluginLoaded:e,isInlinePluginLoaded:t}){const{modelElements:n,name:i}=s;if(!n||!n.length||!i)return ld({style:s}),!1;{const o=[e?"imageBlock":null,t?"imageInline":null];if(!n.some(r=>o.includes(r)))return K("image-style-missing-dependency",{style:s,missingPlugins:n.map(r=>r==="imageBlock"?"ImageBlockEditing":"ImageInlineEditing")}),!1}return!0}function K_(s,e){const t={...e};for(const n in s)Object.prototype.hasOwnProperty.call(e,n)||(t[n]=s[n]);return t}function ld(s){K("image-style-configuration-definition-invalid",s)}const as={normalizeStyles:W_,getDefaultStylesConfiguration:U_,getDefaultDropdownDefinitions:$_,warnInvalidStyle:ld,DEFAULT_OPTIONS:Vn,DEFAULT_ICONS:rd,DEFAULT_DROPDOWN_DEFINITIONS:ad};/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function G_(s){return(e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const i=Qr(t.attributeNewValue,s),o=Qr(t.attributeOldValue,s),r=n.mapper.toViewElement(t.item),a=n.writer;o&&a.removeClass(o.className,r),i&&a.addClass(i.className,r)}}function J_(s){const e={imageInline:s.filter(t=>!t.isDefault&&t.modelElements.includes("imageInline")),imageBlock:s.filter(t=>!t.isDefault&&t.modelElements.includes("imageBlock"))};return(t,n,i)=>{if(!n.modelRange)return;const o=n.viewItem,r=ne(n.modelRange.getItems());if(r&&i.schema.checkAttribute(r,"imageStyle"))for(const a of e[r.name])i.consumable.consume(o,{classes:a.className})&&i.writer.setAttribute("imageStyle",a.name,r)}}function Qr(s,e){for(const t of e)if(t.name===s)return t}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cd extends _{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[Se]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=as,n=this.editor,i=n.plugins.has("ImageBlockEditing"),o=n.plugins.has("ImageInlineEditing");n.config.define("image.styles",t(i,o)),this.normalizedStyles=e({configuredStyles:n.config.get("image.styles"),isBlockPluginLoaded:i,isInlinePluginLoaded:o}),this._setupConversion(i,o),this._setupPostFixer(),n.commands.add("imageStyle",new z_(n,this.normalizedStyles))}_setupConversion(e,t){const n=this.editor,i=n.model.schema,o=G_(this.normalizedStyles),r=J_(this.normalizedStyles);n.editing.downcastDispatcher.on("attribute:imageStyle",o),n.data.downcastDispatcher.on("attribute:imageStyle",o),e&&(i.extend("imageBlock",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(i.extend("imageInline",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,n=e.plugins.get(Se),i=new Map(this.normalizedStyles.map(o=>[o.name,o]));t.registerPostFixer(o=>{let r=!1;for(const a of t.differ.getChanges())if(a.type=="insert"||a.type=="attribute"&&a.attributeKey=="imageStyle"){let l=a.type=="insert"?a.position.nodeAfter:a.range.start.nodeAfter;if(l&&l.is("element","paragraph")&&l.childCount>0&&(l=l.getChild(0)),!n.isImage(l))continue;const c=l.getAttribute("imageStyle");if(!c)continue;const d=i.get(c);(!d||!d.modelElements.includes(l.name))&&(o.removeAttribute("imageStyle",l),r=!0)}return r})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Q_ extends _{static get requires(){return[cd]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],n=e.get("ImageStyleEditing"),i=Yr(n.normalizedStyles,this.localizedDefaultStylesTitles);for(const r of i)this._createButton(r);const o=Yr([...t.filter(Oe),...as.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const r of o)this._createDropdown(r,i)}_createDropdown(e,t){const n=this.editor.ui.componentFactory;n.add(e.name,i=>{let o;const{defaultItem:r,items:a,title:l}=e,c=a.filter(f=>t.find(({name:g})=>Zr(g)===f)).map(f=>{const g=n.create(f);return f===r&&(o=g),g});a.length!==c.length&&as.warnInvalidStyle({dropdown:e});const d=qe(i,zs),u=d.buttonView,h=u.arrowView;return Hs(d,c,{enableActiveItemFocusOnDropdownOpen:!0}),u.set({label:Xr(l,o.label),class:null,tooltip:!0}),h.unbind("label"),h.set({label:l}),u.bind("icon").toMany(c,"isOn",(...f)=>{const g=f.findIndex(Gt);return g<0?o.icon:c[g].icon}),u.bind("label").toMany(c,"isOn",(...f)=>{const g=f.findIndex(Gt);return Xr(l,g<0?o.label:c[g].label)}),u.bind("isOn").toMany(c,"isOn",(...f)=>f.some(Gt)),u.bind("class").toMany(c,"isOn",(...f)=>f.some(Gt)?"ck-splitbutton_flatten":void 0),u.on("execute",()=>{c.some(({isOn:f})=>f)?d.isOpen=!d.isOpen:o.fire("execute")}),d.bind("isEnabled").toMany(c,"isEnabled",(...f)=>f.some(Gt)),this.listenTo(d,"execute",()=>{this.editor.editing.view.focus()}),d})}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(Zr(t),n=>{const i=this.editor.commands.get("imageStyle"),o=new W(n);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(i,"isEnabled"),o.bind("isOn").to(i,"value",r=>r===t),o.on("execute",this._executeCommand.bind(this,t)),o})}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function Yr(s,e){for(const t of s)e[t.title]&&(t.title=e[t.title]);return s}function Zr(s){return`imageStyle:${s}`}function Xr(s,e){return(s?s+": ":"")+e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yC extends _{static get requires(){return[cd,Q_]}static get pluginName(){return"ImageStyle"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class CC extends _{static get requires(){return[jn,Se]}static get pluginName(){return"ImageToolbar"}afterInit(){const e=this.editor,t=e.t,n=e.plugins.get(jn),i=e.plugins.get("ImageUtils");n.register("image",{ariaLabel:t("Image toolbar"),items:Y_(e.config.get("image.toolbar")||[]),getRelatedElement:o=>i.getClosestSelectedImageWidget(o)})}}function Y_(s){return s.map(e=>Oe(e)?e.name:e)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function dd(s){const e=s.map(t=>t.replace("+","\\+"));return new RegExp(`^image\\/(${e.join("|")})$`)}function Z_(s){return new Promise((e,t)=>{const n=s.getAttribute("src");fetch(n).then(i=>i.blob()).then(i=>{const o=ud(i,n),a=`image.${o.replace("image/","")}`,l=new File([i],a,{type:o});e(l)}).catch(i=>i&&i.name==="TypeError"?e0(n).then(e).catch(t):t(i))})}function X_(s,e){return!s.isInlineImageView(e)||!e.getAttribute("src")?!1:!!e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||!!e.getAttribute("src").match(/^blob:/g)}function ud(s,e){return s.type?s.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}function e0(s){return t0(s).then(e=>{const t=ud(e,s),i=`image.${t.replace("image/","")}`;return new File([e],i,{type:t})})}function t0(s){return new Promise((e,t)=>{const n=S.document.createElement("img");n.addEventListener("load",()=>{const i=S.document.createElement("canvas");i.width=n.width,i.height=n.height,i.getContext("2d").drawImage(n,0,0),i.toBlob(r=>r?e(r):t())}),n.addEventListener("error",()=>t()),n.src=s})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class n0 extends _{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,n=i=>{const o=new $b(i),r=e.commands.get("uploadImage"),a=e.config.get("image.upload.types"),l=dd(a);return o.set({acceptedType:a.map(c=>`image/${c}`).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:t("Insert image"),icon:$.image,tooltip:!0}),o.buttonView.bind("isEnabled").to(r),o.on("done",(c,d)=>{const u=Array.from(d).filter(h=>l.test(h.type));u.length&&(e.execute("uploadImage",{file:u}),e.editing.view.focus())}),o};e.ui.componentFactory.add("uploadImage",n),e.ui.componentFactory.add("imageUpload",n)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class i0 extends _{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.uploadStatusChange=(t,n,i)=>{const o=this.editor,r=n.item,a=r.getAttribute("uploadId");if(!i.consumable.consume(n.item,t.name))return;const l=o.plugins.get("ImageUtils"),c=o.plugins.get(je),d=a?n.attributeNewValue:null,u=this.placeholder,h=o.editing.mapper.toViewElement(r),f=i.writer;if(d=="reading"){ea(h,f),ta(l,u,h,f);return}if(d=="uploading"){const g=c.loaders.get(a);ea(h,f),g?(na(h,f),o0(h,f,g,o.editing.view),d0(l,h,f,g)):ta(l,u,h,f);return}d=="complete"&&c.loaders.get(a)&&a0(h,f,o.editing.view),r0(h,f),na(h,f),s0(h,f)},this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}}function ea(s,e){s.hasClass("ck-appear")||e.addClass("ck-appear",s)}function s0(s,e){e.removeClass("ck-appear",s)}function ta(s,e,t,n){t.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",t);const i=s.findViewImgElement(t);i.getAttribute("src")!==e&&n.setAttribute("src",e,i),hd(t,"placeholder")||n.insert(n.createPositionAfter(i),c0(n))}function na(s,e){s.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",s),fd(s,e,"placeholder")}function o0(s,e,t,n){const i=l0(e);e.insert(e.createPositionAt(s,"end"),i),t.on("change:uploadedPercent",(o,r,a)=>{n.change(l=>{l.setStyle("width",a+"%",i)})})}function r0(s,e){fd(s,e,"progressBar")}function a0(s,e,t){const n=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(s,"end"),n),setTimeout(()=>{t.change(i=>i.remove(i.createRangeOn(n)))},3e3)}function l0(s){const e=s.createUIElement("div",{class:"ck-progress-bar"});return s.setCustomProperty("progressBar",!0,e),e}function c0(s){const e=s.createUIElement("div",{class:"ck-upload-placeholder-loader"});return s.setCustomProperty("placeholder",!0,e),e}function hd(s,e){for(const t of s.getChildren())if(t.getCustomProperty(e))return t}function fd(s,e,t){const n=hd(s,t);n&&e.remove(e.createRangeOn(n))}function d0(s,e,t,n){if(n.data){const i=s.findViewImgElement(e);t.setAttribute("src",n.data,i)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class u0 extends x{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),n=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(n)}execute(e){const t=se(e.file),n=this.editor.model.document.selection,i=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(n.getAttributes());t.forEach((r,a)=>{const l=n.getSelectedElement();if(a&&l&&i.isImage(l)){const c=this.editor.model.createPositionAfter(l);this._uploadImage(r,o,c)}else this._uploadImage(r,o)})}_uploadImage(e,t,n){const i=this.editor,r=i.plugins.get(je).createLoader(e),a=i.plugins.get("ImageUtils");r&&a.insertImage({...t,uploadId:r.id},n)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class h0 extends _{static get requires(){return[je,is,Ne,Se]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,n=e.conversion,i=e.plugins.get(je),o=e.plugins.get("ImageUtils"),r=e.plugins.get("ClipboardPipeline"),a=dd(e.config.get("image.upload.types")),l=new u0(e);e.commands.add("uploadImage",l),e.commands.add("imageUpload",l),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",(c,d)=>{if(f0(d.dataTransfer))return;const u=Array.from(d.dataTransfer.files).filter(h=>h?a.test(h.type):!1);u.length&&(c.stop(),e.model.change(h=>{d.targetRanges&&h.setSelection(d.targetRanges.map(f=>e.editing.mapper.toModelRange(f))),e.model.enqueueChange(()=>{e.execute("uploadImage",{file:u})})}))}),this.listenTo(r,"inputTransformation",(c,d)=>{const u=Array.from(e.editing.view.createRangeIn(d.content)).map(f=>f.item).filter(f=>X_(o,f)&&!f.getAttribute("uploadProcessed")).map(f=>({promise:Z_(f),imageElement:f}));if(!u.length)return;const h=new Et(e.editing.view.document);for(const f of u){h.setAttribute("uploadProcessed",!0,f.imageElement);const g=i.createLoader(f.promise);g&&(h.setAttribute("src","",f.imageElement),h.setAttribute("uploadId",g.id,f.imageElement))}}),e.editing.view.document.on("dragover",(c,d)=>{d.preventDefault()}),t.on("change",()=>{const c=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),d=new Set;for(const u of c)if(u.type=="insert"&&u.name!="$text"){const h=u.position.nodeAfter,f=u.position.root.rootName=="$graveyard";for(const g of m0(e,h)){const w=g.getAttribute("uploadId");if(!w)continue;const v=i.loaders.get(w);v&&(f?d.has(w)||v.abort():(d.add(w),this._uploadImageElements.set(w,g),v.status=="idle"&&this._readAndUpload(v)))}}}),this.on("uploadComplete",(c,{imageElement:d,data:u})=>{const h=u.urls?u.urls:u;this.editor.model.change(f=>{f.setAttribute("src",h.default,d),this._parseAndSetSrcsetAttributeOnImage(h,d,f)})},{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(e){const t=this.editor,n=t.model,i=t.locale.t,o=t.plugins.get(je),r=t.plugins.get(is),a=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return n.enqueueChange({isUndoable:!1},d=>{d.setAttribute("uploadStatus","reading",l.get(e.id))}),e.read().then(()=>{const d=e.upload(),u=l.get(e.id);/* istanbul ignore next -- @preserve */if(P.isSafari){const h=t.editing.mapper.toViewElement(u),f=a.findViewImgElement(h);t.editing.view.once("render",()=>{if(!f.parent)return;const g=t.editing.view.domConverter.mapViewToDom(f.parent);if(!g)return;const w=g.style.display;g.style.display="none",g._ckHack=g.offsetHeight,g.style.display=w})}return n.enqueueChange({isUndoable:!1},h=>{h.setAttribute("uploadStatus","uploading",u)}),d}).then(d=>{n.enqueueChange({isUndoable:!1},u=>{const h=l.get(e.id);u.setAttribute("uploadStatus","complete",h),this.fire("uploadComplete",{data:d,imageElement:h})}),c()}).catch(d=>{if(e.status!=="error"&&e.status!=="aborted")throw d;e.status=="error"&&d&&r.showWarning(d,{title:i("Upload failed"),namespace:"upload"}),n.enqueueChange({isUndoable:!1},u=>{u.remove(l.get(e.id))}),c()});function c(){n.enqueueChange({isUndoable:!1},d=>{const u=l.get(e.id);d.removeAttribute("uploadId",u),d.removeAttribute("uploadStatus",u),l.delete(e.id)}),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,n){let i=0;const o=Object.keys(e).filter(r=>{const a=parseInt(r,10);if(!isNaN(a))return i=Math.max(i,a),!0}).map(r=>`${e[r]} ${r}w`).join(", ");o!=""&&n.setAttribute("srcset",{data:o,width:i},t)}}function f0(s){return Array.from(s.types).includes("text/html")&&s.getData("text/html")!==""}function m0(s,e){const t=s.plugins.get("ImageUtils");return Array.from(s.model.createRangeOn(e)).filter(n=>t.isImage(n.item)).map(n=>n.item)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class kC extends _{static get pluginName(){return"ImageUpload"}static get requires(){return[h0,n0,i0]}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class g0 extends x{refresh(){const e=this.editor,n=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!n,!n||!n.hasAttribute("width")?this.value=null:this.value={width:n.getAttribute("width"),height:null}}execute(e){const t=this.editor,n=t.model,o=t.plugins.get("ImageUtils").getClosestSelectedImageElement(n.document.selection);this.value={width:e.width,height:null},o&&n.change(r=>{r.setAttribute("width",e.width,o)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class md extends _{static get requires(){return[Se]}static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new g0(e);this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:"width"}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:"width"})}_registerConverters(e){const t=this.editor;t.conversion.for("downcast").add(n=>n.on(`attribute:width:${e}`,(i,o,r)=>{if(!r.consumable.consume(o.item,i.name))return;const a=r.writer,l=r.mapper.toViewElement(o.item);o.attributeNewValue!==null?(a.setStyle("width",o.attributeNewValue,l),a.addClass("image_resized",l)):(a.removeStyle("width",l),a.removeClass("image_resized",l))})),t.conversion.for("upcast").attributeToAttribute({view:{name:e==="imageBlock"?"figure":"img",styles:{width:/.+/}},model:{key:"width",value:n=>n.getStyle("width")}})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const xi={small:$.objectSizeSmall,medium:$.objectSizeMedium,large:$.objectSizeLarge,original:$.objectSizeFull};class p0 extends _{static get requires(){return[md]}static get pluginName(){return"ImageResizeButtons"}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),n=e.commands.get("resizeImage");this.bind("isEnabled").to(n);for(const i of t)this._registerImageResizeButton(i);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:n,value:i,icon:o}=e,r=i?i+this._resizeUnit:null;t.ui.componentFactory.add(n,a=>{const l=new W(a),c=t.commands.get("resizeImage"),d=this._getOptionLabelValue(e,!0);if(!xi[o])throw new m("imageresizebuttons-missing-icon",t,e);return l.set({label:d,icon:xi[o],tooltip:d,isToggleable:!0}),l.bind("isEnabled").to(this),l.bind("isOn").to(c,"value",ia(r)),this.listenTo(l,"execute",()=>{t.execute("resizeImage",{width:r})}),l})}_registerImageResizeDropdown(e){const t=this.editor,n=t.t,i=e.find(r=>!r.value),o=r=>{const a=t.commands.get("resizeImage"),l=qe(r,yc),c=l.buttonView,d=n("Resize image");return c.set({tooltip:d,commandValue:i.value,icon:xi.medium,isToggleable:!0,label:this._getOptionLabelValue(i),withText:!0,class:"ck-resize-image-button",ariaLabel:d,ariaLabelledBy:void 0}),c.bind("label").to(a,"value",u=>u&&u.width?u.width:this._getOptionLabelValue(i)),l.bind("isEnabled").to(this),Ws(l,()=>this._getResizeDropdownListItemDefinitions(e,a),{ariaLabel:n("Image resize list"),role:"menu"}),this.listenTo(l,"execute",u=>{t.execute(u.source.commandName,{width:u.source.commandValue}),t.editing.view.focus()}),l};t.ui.componentFactory.add("resizeImage",o),t.ui.componentFactory.add("imageResize",o)}_getOptionLabelValue(e,t=!1){const n=this.editor.t;return e.label?e.label:t?e.value?n("Resize image to %0",e.value+this._resizeUnit):n("Resize image to the original size"):e.value?e.value+this._resizeUnit:n("Original")}_getResizeDropdownListItemDefinitions(e,t){const n=new _e;return e.map(i=>{const o=i.value?i.value+this._resizeUnit:null,r={type:"button",model:new $s({commandName:"resizeImage",commandValue:o,label:this._getOptionLabelValue(i),role:"menuitemradio",withText:!0,icon:null})};r.model.bind("isOn").to(t,"value",ia(o)),n.add(r)}),n}}function ia(s){return e=>{const t=e;return s===null&&t===s?!0:t!==null&&t.width===s}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const w0="figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img",b0=/(image|image-inline)/,Ii="image_resized";class _0 extends _{static get requires(){return[Ti]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view;t.addObserver(Yc),this.listenTo(t.document,"imageLoaded",(n,i)=>{if(!i.target.matches(w0))return;const o=e.editing.view.domConverter,a=o.domToView(i.target).findAncestor({classes:b0});let l=this.editor.plugins.get(Ti).getResizerByViewElement(a);if(l){l.redraw();return}const c=e.editing.mapper,d=c.toModelElement(a);l=e.plugins.get(Ti).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:d,viewElement:a,editor:e,getHandleHost(u){return u.querySelector("img")},getResizeHost(){return o.mapViewToDom(c.toViewElement(d.parent))},isCentered(){const u=d.getAttribute("imageStyle");return!u||u=="block"||u=="alignCenter"},onCommit(u){t.change(h=>{h.removeClass(Ii,a)}),e.execute("resizeImage",{width:u})}}),l.on("updateSize",()=>{a.hasClass(Ii)||t.change(u=>{u.addClass(Ii,a)})}),l.bind("isEnabled").to(this)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class EC extends _{static get requires(){return[md,_0,p0]}static get pluginName(){return"ImageResize"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class v0 extends _{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new yo(e)),e.commands.add("outdent",new yo(e))}}const sa='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5zM1.632 6.95 5.02 9.358a.4.4 0 0 1-.013.661l-3.39 2.207A.4.4 0 0 1 1 11.892V7.275a.4.4 0 0 1 .632-.326z"/></svg>',oa='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5zm1.618-9.55L.98 9.358a.4.4 0 0 0 .013.661l3.39 2.207A.4.4 0 0 0 5 11.892V7.275a.4.4 0 0 0-.632-.326z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class y0 extends _{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,n=e.t,i=t.uiLanguageDirection=="ltr"?sa:oa,o=t.uiLanguageDirection=="ltr"?oa:sa;this._defineButton("indent",n("Increase indent"),i),this._defineButton("outdent",n("Decrease indent"),o)}_defineButton(e,t,n){const i=this.editor;i.ui.componentFactory.add(e,o=>{const r=i.commands.get(e),a=new W(o);return a.set({label:t,icon:n,tooltip:!0}),a.bind("isEnabled").to(r,"isEnabled"),this.listenTo(a,"execute",()=>{i.execute(e),i.editing.view.focus()}),a})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class TC extends _{static get pluginName(){return"Indent"}static get requires(){return[v0,y0]}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class C0{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach(t=>this._definitions.add(t)):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",(t,n,i)=>{if(!i.consumable.test(n.item,"attribute:linkHref")||!(n.item.is("selection")||i.schema.isInline(n.item)))return;const o=i.writer,r=o.document.selection;for(const a of this._definitions){const l=o.createAttributeElement("a",a.attributes,{priority:5});a.classes&&o.addClass(a.classes,l);for(const c in a.styles)o.setStyle(c,a.styles[c],l);o.setCustomProperty("link",!0,l),a.callback(n.attributeNewValue)?n.item.is("selection")?o.wrap(r.getFirstRange(),l):o.wrap(i.mapper.toViewRange(n.range),l):o.unwrap(i.mapper.toViewRange(n.range),l)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",(t,n,{writer:i,mapper:o})=>{const r=o.toViewElement(n.item),a=Array.from(r.getChildren()).find(l=>l.is("element","a"));for(const l of this._definitions){const c=Ge(l.attributes);if(l.callback(n.attributeNewValue)){for(const[d,u]of c)d==="class"?i.addClass(u,a):i.setAttribute(d,u,a);l.classes&&i.addClass(l.classes,a);for(const d in l.styles)i.setStyle(d,l.styles[d],a)}else{for(const[d,u]of c)d==="class"?i.removeClass(u,a):i.removeAttribute(d,a);l.classes&&i.removeClass(l.classes,a);for(const d in l.styles)i.removeStyle(d,a)}}})}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const k0=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,E0=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,T0=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,A0=/^((\w+:(\/{2,})?)|(\W))/i,Ri="Ctrl+K";function S0(s){return s.is("attributeElement")&&!!s.getCustomProperty("link")}function ra(s,{writer:e}){const t=e.createAttributeElement("a",{href:s},{priority:5});return e.setCustomProperty("link",!0,t),t}function gd(s){const e=String(s);return P0(e)?e:"#"}function P0(s){return!!s.replace(k0,"").match(E0)}function x0(s,e){const t={"Open in a new tab":s("Open in a new tab"),Downloadable:s("Downloadable")};return e.forEach(n=>("label"in n&&t[n.label]&&(n.label=t[n.label]),n)),e}function I0(s){const e=[];if(s)for(const[t,n]of Object.entries(s)){const i=Object.assign({},n,{id:`link${Fd(t)}`});e.push(i)}return e}function ls(s,e){return s?e.checkAttribute(s.name,"linkHref"):!1}function R0(s){return T0.test(s)}function Qs(s,e){const t=R0(s)?"mailto:":e,n=!!t&&!pd(s);return s&&n?t+s:s}function pd(s){return A0.test(s)}function aa(s){window.open(s,"_blank","noopener")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class M0 extends x{constructor(){super(...arguments),this.manualDecorators=new _e,this.automaticDecorators=new C0}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,n=t.getSelectedElement()||ne(t.getSelectedBlocks());ls(n,e.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(n,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const i of this.manualDecorators)i.value=this._getDecoratorStateFromModel(i.id)}execute(e,t={}){const n=this.editor.model,i=n.document.selection,o=[],r=[];for(const a in t)t[a]?o.push(a):r.push(a);n.change(a=>{if(i.isCollapsed){const l=i.getFirstPosition();if(i.hasAttribute("linkHref")){const c=la(i);let d=Ut(l,"linkHref",i.getAttribute("linkHref"),n);i.getAttribute("linkHref")===c&&(d=this._updateLinkContent(n,a,d,e)),a.setAttribute("linkHref",e,d),o.forEach(u=>{a.setAttribute(u,!0,d)}),r.forEach(u=>{a.removeAttribute(u,d)}),a.setSelection(a.createPositionAfter(d.end.nodeBefore))}else if(e!==""){const c=Ge(i.getAttributes());c.set("linkHref",e),o.forEach(u=>{c.set(u,!0)});const{end:d}=n.insertContent(a.createText(e,c),l);a.setSelection(d)}["linkHref",...o,...r].forEach(c=>{a.removeSelectionAttribute(c)})}else{const l=n.schema.getValidRanges(i.getRanges(),"linkHref"),c=[];for(const u of i.getSelectedBlocks())n.schema.checkAttribute(u,"linkHref")&&c.push(a.createRangeOn(u));const d=c.slice();for(const u of l)this._isRangeToUpdate(u,c)&&d.push(u);for(const u of d){let h=u;if(d.length===1){const f=la(i);i.getAttribute("linkHref")===f&&(h=this._updateLinkContent(n,a,u,e),a.setSelection(a.createSelection(h)))}a.setAttribute("linkHref",e,h),o.forEach(f=>{a.setAttribute(f,!0,h)}),r.forEach(f=>{a.removeAttribute(f,h)})}}})}_getDecoratorStateFromModel(e){const t=this.editor.model,n=t.document.selection,i=n.getSelectedElement();return ls(i,t.schema)?i.getAttribute(e):n.getAttribute(e)}_isRangeToUpdate(e,t){for(const n of t)if(n.containsRange(e))return!1;return!0}_updateLinkContent(e,t,n,i){const o=t.createText(i,{linkHref:i});return e.insertContent(o,n)}}function la(s){if(s.isCollapsed){const e=s.getFirstPosition();return e.textNode&&e.textNode.data}else{const e=Array.from(s.getFirstRange().getItems());if(e.length>1)return null;const t=e[0];return t.is("$text")||t.is("$textProxy")?t.data:null}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class V0 extends x{refresh(){const e=this.editor.model,t=e.document.selection,n=t.getSelectedElement();ls(n,e.schema)?this.isEnabled=e.schema.checkAttribute(n,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,n=t.document.selection,i=e.commands.get("link");t.change(o=>{const r=n.isCollapsed?[Ut(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),t)]:t.schema.getValidRanges(n.getRanges(),"linkHref");for(const a of r)if(o.removeAttribute("linkHref",a),i)for(const l of i.manualDecorators)o.removeAttribute(l.id,a)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class O0 extends D(){constructor({id:e,label:t,attributes:n,classes:i,styles:o,defaultValue:r}){super(),this.id=e,this.set("value",void 0),this.defaultValue=r,this.label=t,this.attributes=n,this.classes=i,this.styles=o}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const D0="ck-link_selected",ca="automatic",N0="manual",B0=/^(https?:)?\/\//;class F0 extends _{static get pluginName(){return"LinkEditing"}static get requires(){return[$n,Rc,Ne]}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:ra}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(i,o)=>ra(gd(i),o)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:i=>i.getAttribute("href")}}),e.commands.add("link",new M0(e)),e.commands.add("unlink",new V0(e));const t=x0(e.t,I0(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter(i=>i.mode===ca)),this._enableManualDecorators(t.filter(i=>i.mode===N0)),e.plugins.get($n).registerAttribute("linkHref"),Dc(e,"linkHref","a",D0),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink(),this._enableClipboardIntegration()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:ca,callback:o=>!!o&&B0.test(o),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach(o=>{t.model.schema.extend("$text",{allowAttributes:o.id});const r=new O0(o);i.add(r),t.conversion.for("downcast").attributeToElement({model:r.id,view:(a,{writer:l,schema:c},{item:d})=>{if((d.is("selection")||c.isInline(d))&&a){const u=l.createAttributeElement("a",r.attributes,{priority:5});r.classes&&l.addClass(r.classes,u);for(const h in r.styles)l.setStyle(h,r.styles[h],u);return l.setCustomProperty("link",!0,u),u}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...r._createPattern()},model:{key:r.id}})})}_enableLinkOpen(){const e=this.editor,n=e.editing.view.document;this.listenTo(n,"click",(i,o)=>{if(!(P.isMac?o.domEvent.metaKey:o.domEvent.ctrlKey))return;let a=o.domTarget;if(a.tagName.toLowerCase()!="a"&&(a=a.closest("a")),!a)return;const l=a.getAttribute("href");l&&(i.stop(),o.preventDefault(),aa(l))},{context:"$capture"}),this.listenTo(n,"keydown",(i,o)=>{const a=e.commands.get("link").value;a&&o.keyCode===M.enter&&o.altKey&&(i.stop(),aa(a))})}_enableInsertContentSelectionAttributesFixer(){const t=this.editor.model,n=t.document.selection;this.listenTo(t,"insertContent",()=>{const i=n.anchor.nodeBefore,o=n.anchor.nodeAfter;n.hasAttribute("linkHref")&&i&&i.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change(r=>{Mi(r,Vi(t.schema))}))},{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.model;e.editing.view.addObserver(ii);let n=!1;this.listenTo(e.editing.view.document,"mousedown",()=>{n=!0}),this.listenTo(e.editing.view.document,"selectionChange",()=>{if(!n)return;n=!1;const i=t.document.selection;if(!i.isCollapsed||!i.hasAttribute("linkHref"))return;const o=i.getFirstPosition(),r=Ut(o,"linkHref",i.getAttribute("linkHref"),t);(o.isTouching(r.start)||o.isTouching(r.end))&&t.change(a=>{Mi(a,Vi(t.schema))})})}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let n=null,i=!1;this.listenTo(t.document,"delete",()=>{i=!0},{priority:"high"}),this.listenTo(e.model,"deleteContent",()=>{const o=e.model.document.selection;if(!o.isCollapsed){if(i){i=!1;return}da(e)&&L0(e.model)&&(n=o.getAttributes())}},{priority:"high"}),this.listenTo(e.model,"insertContent",(o,[r])=>{i=!1,da(e)&&n&&(e.model.change(a=>{for(const[l,c]of n)a.setAttribute(l,c,r)}),n=null)},{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,n=t.document.selection,i=e.editing.view;let o=!1,r=!1;this.listenTo(i.document,"delete",(a,l)=>{r=l.direction==="backward"},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{o=!1;const a=n.getFirstPosition(),l=n.getAttribute("linkHref");if(!l)return;const c=Ut(a,"linkHref",l,t);o=c.containsPosition(a)||c.end.isEqual(a)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{r&&(r=!1,!o&&e.model.enqueueChange(a=>{Mi(a,Vi(t.schema))}))},{priority:"low"})}_enableClipboardIntegration(){const e=this.editor,t=e.model,n=this.editor.config.get("link.defaultProtocol");n&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",(i,o)=>{t.change(r=>{const a=r.createRangeIn(o.content);for(const l of a.getItems())if(l.hasAttribute("linkHref")){const c=Qs(l.getAttribute("linkHref"),n);r.setAttribute("linkHref",c,l)}})})}}function Mi(s,e){s.removeSelectionAttribute("linkHref");for(const t of e)s.removeSelectionAttribute(t)}function L0(s){const e=s.document.selection,t=e.getFirstPosition(),n=e.getLastPosition(),i=t.nodeAfter;if(!i||!i.is("$text")||!i.hasAttribute("linkHref"))return!1;const o=n.textNode||n.nodeBefore;return i===o?!0:Ut(t,"linkHref",i.getAttribute("linkHref"),s).containsRange(s.createRange(t,n),!0)}function da(s){return s.model.change(t=>t.batch).isTyping}function Vi(s){return s.getDefinition("$text").allowAttributes.filter(t=>t.startsWith("link"))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class z0 extends I{constructor(e,t){super(e),this.focusTracker=new ve,this.keystrokes=new Be,this._focusables=new rt;const n=e.t;this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),$.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),$.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusCycler=new Kt({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const i=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&i.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:i,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce((e,t)=>(e[t.name]=t.isOn,e),{})}render(){super.render(),Ds({view:this}),[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new Fs(this.locale,Us);return t.label=e("Link URL"),t}_createButton(e,t,n,i){const o=new W(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const n of e.manualDecorators){const i=new si(this.locale);i.set({name:n.id,label:n.label,withText:!0}),i.bind("isOn").toMany([n,e],"value",(o,r)=>r===void 0&&o===void 0?!!n.defaultValue:!!o),i.on("execute",()=>{n.set("value",!i.isOn)}),t.add(i)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const n=new I;n.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map(i=>({tag:"li",children:[i],attributes:{class:["ck","ck-list__item"]}})),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(n)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}const H0='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184zm4.919 10.562-1.414 1.414a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.061-1.06l1.414 1.414 1.414-1.415a.75.75 0 0 1 1.061 1.061l-1.414 1.414 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class W0 extends I{constructor(e){super(e),this.focusTracker=new ve,this.keystrokes=new Be,this._focusables=new rt;const t=e.t;this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),H0,"unlink"),this.editButtonView=this._createButton(t("Edit link"),$.pencil,"edit"),this.set("href",void 0),this._focusCycler=new Kt({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render(),[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,n){const i=new W(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i.delegate("execute").to(this,n),i}_createPreviewButton(){const e=new W(this.locale),t=this.bindTemplate,n=this.t;return e.set({withText:!0,tooltip:n("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",i=>i&&gd(i)),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",i=>i||n("This link has no URL")),e.bind("isEnabled").to(this,"href",i=>!!i),e.template.tag="a",e.template.eventListeners={},e}}const U0='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Pe="link-ui";class $0 extends _{constructor(){super(...arguments),this.actionsView=null,this.formView=null}static get requires(){return[Un]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(kg),this._balloon=e.plugins.get(Un),this._createToolbarLinkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:Pe,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Pe,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new W0(e.locale),n=e.commands.get("link"),i=e.commands.get("unlink");return t.bind("href").to(n,"value"),t.editButtonView.bind("isEnabled").to(n),t.unlinkButtonView.bind("isEnabled").to(i),this.listenTo(t,"edit",()=>{this._addFormView()}),this.listenTo(t,"unlink",()=>{e.execute("unlink"),this._hideUI()}),t.keystrokes.set("Esc",(o,r)=>{this._hideUI(),r()}),t.keystrokes.set(Ri,(o,r)=>{this._addFormView(),r()}),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),n=e.config.get("link.defaultProtocol"),i=new(Os(z0))(e.locale,t);return i.urlInputView.fieldView.bind("value").to(t,"value"),i.urlInputView.bind("isEnabled").to(t,"isEnabled"),i.saveButtonView.bind("isEnabled").to(t),this.listenTo(i,"submit",()=>{const{value:o}=i.urlInputView.fieldView.element,r=Qs(o,n);e.execute("link",r,i.getDecoratorSwitchesState()),this._closeFormView()}),this.listenTo(i,"cancel",()=>{this._closeFormView()}),i.keystrokes.set("Esc",(o,r)=>{this._closeFormView(),r()}),i}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),n=e.t;e.ui.componentFactory.add("link",i=>{const o=new W(i);return o.isEnabled=!0,o.label=n("Link"),o.icon=U0,o.keystroke=Ri,o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(t,"isEnabled"),o.bind("isOn").to(t,"value",r=>!!r),this.listenTo(o,"execute",()=>this._showUI(!0)),o})}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),e.keystrokes.set(Ri,(n,i)=>{i(),e.commands.get("link").isEnabled&&this._showUI(!0)})}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",(e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())},{priority:"high"}),this.editor.keystrokes.set("Esc",(e,t)=>{this._isUIVisible&&(this._hideUI(),t())}),Vs({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),!this._areActionsInPanel&&this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const t=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=t.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),e.value!==void 0?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let n=this._getSelectedLinkElement(),i=r();const o=()=>{const a=this._getSelectedLinkElement(),l=r();n&&!a||!n&&l!==i?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=a,i=l};function r(){return t.selection.focus.getAncestors().reverse().find(a=>a.is("element"))}this.listenTo(e.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,n=e.document;let i;if(t.markers.has(Pe)){const o=Array.from(this.editor.editing.mapper.markerNameToElements(Pe)),r=e.createRange(e.createPositionBefore(o[0]),e.createPositionAfter(o[o.length-1]));i=e.domConverter.viewRangeToDom(r)}else i=()=>{const o=this._getSelectedLinkElement();return o?e.domConverter.mapViewToDom(o):e.domConverter.viewRangeToDom(n.selection.getFirstRange())};return{target:i}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,n=t.getSelectedElement();if(t.isCollapsed||n&&G(n))return Oi(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),o=Oi(i.start),r=Oi(i.end);return!o||o!=r?null:e.createRangeIn(o).getTrimmed().isEqual(i)?o:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const n=e.document.selection.getFirstRange();if(e.markers.has(Pe))t.updateMarker(Pe,{range:n});else if(n.start.isAtEnd){const i=n.start.getLastMatchingPosition(({item:o})=>!e.schema.isContent(o),{boundaries:n});t.addMarker(Pe,{usingOperation:!1,affectsData:!1,range:t.createRange(i,n.end)})}else t.addMarker(Pe,{usingOperation:!1,affectsData:!1,range:n})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Pe)&&e.change(t=>{t.removeMarker(Pe)})}}function Oi(s){return s.getAncestors().find(e=>S0(e))||null}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const q0=4,j0=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i"),K0=2;class G0 extends _{static get requires(){return[Je]}static get pluginName(){return"AutoLink"}init(){const t=this.editor.model.document.selection;t.on("change:range",()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")}),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new Oc(e.model,n=>{if(!J0(n))return;const i=ua(n.substr(0,n.length-1));if(i)return{url:i}});t.on("matched:data",(n,i)=>{const{batch:o,range:r,url:a}=i;if(!o.isTyping)return;const l=r.end.getShiftedBy(-1),c=l.getShiftedBy(-a.length),d=e.model.createRange(c,l);this._applyAutoLink(a,d)}),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("enter");n&&n.on("execute",()=>{const i=t.document.selection.getFirstPosition();if(!i.parent.previousSibling)return;const o=t.createRangeIn(i.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(o)})}_enableShiftEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("shiftEnter");n&&n.on("execute",()=>{const i=t.document.selection.getFirstPosition(),o=t.createRange(t.createPositionAt(i.parent,0),i.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(o)})}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:n,range:i}=Vc(e,t),o=ua(n);if(o){const r=t.createRange(i.end.getShiftedBy(-o.length),i.end);this._applyAutoLink(o,r)}}_applyAutoLink(e,t){const n=this.editor.model,i=this.editor.config.get("link.defaultProtocol"),o=Qs(e,i);!this.isEnabled||!Q0(t,n)||!pd(o)||Y0(t)||this._persistAutoLink(o,t)}_persistAutoLink(e,t){const n=this.editor.model,i=this.editor.plugins.get("Delete");n.enqueueChange(o=>{o.setAttribute("linkHref",e,t),n.enqueueChange(()=>{i.requestUndoOnBackspace()})})}}function J0(s){return s.length>q0&&s[s.length-1]===" "&&s[s.length-2]!==" "}function ua(s){const e=j0.exec(s);return e?e[K0]:null}function Q0(s,e){return e.schema.checkAttributeInSelection(e.createSelection(s),"linkHref")}function Y0(s){const e=s.start.nodeAfter;return!!e&&e.hasAttribute("linkHref")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class AC extends _{static get requires(){return[F0,$0,G0]}static get pluginName(){return"Link"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ha extends x{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.document,i=Array.from(n.selection.getSelectedBlocks()).filter(r=>ma(r,t.schema)),o=e.forceValue!==void 0?!e.forceValue:this.value;t.change(r=>{if(o){let a=i[i.length-1].nextSibling,l=Number.POSITIVE_INFINITY,c=[];for(;a&&a.name=="listItem"&&a.getAttribute("listIndent")!==0;){const d=a.getAttribute("listIndent");d<l&&(l=d);const u=d-l;c.push({element:a,listIndent:u}),a=a.nextSibling}c=c.reverse();for(const d of c)r.setAttribute("listIndent",d.listIndent,d.element)}if(!o){let a=Number.POSITIVE_INFINITY;for(const l of i)l.is("element","listItem")&&l.getAttribute("listIndent")<a&&(a=l.getAttribute("listIndent"));a=a===0?1:a,fa(i,!0,a),fa(i,!1,a)}for(const a of i.reverse())o&&a.name=="listItem"?r.rename(a,"paragraph"):!o&&a.name!="listItem"?(r.setAttributes({listType:this.type,listIndent:0},a),r.rename(a,"listItem")):!o&&a.name=="listItem"&&a.getAttribute("listType")!=this.type&&r.setAttribute("listType",this.type,a);this.fire("_executeCleanup",i)})}_getValue(){const e=ne(this.editor.model.document.selection.getSelectedBlocks());return!!e&&e.is("element","listItem")&&e.getAttribute("listType")==this.type}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=ne(e.getSelectedBlocks());return n?ma(n,t):!1}}function fa(s,e,t){const n=e?s[0]:s[s.length-1];if(n.is("element","listItem")){let i=n[e?"previousSibling":"nextSibling"],o=n.getAttribute("listIndent");for(;i&&i.is("element","listItem")&&i.getAttribute("listIndent")>=t;)o>i.getAttribute("listIndent")&&(o=i.getAttribute("listIndent")),i.getAttribute("listIndent")==o&&s[e?"unshift":"push"](i),i=i[e?"previousSibling":"nextSibling"]}}function ma(s,e){return e.checkChild(s.parent,"listItem")&&!e.isObject(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ga extends x{constructor(e,t){super(e),this._indentBy=t=="forward"?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let n=Array.from(t.selection.getSelectedBlocks());e.change(i=>{const o=n[n.length-1];let r=o.nextSibling;for(;r&&r.name=="listItem"&&r.getAttribute("listIndent")>o.getAttribute("listIndent");)n.push(r),r=r.nextSibling;this._indentBy<0&&(n=n.reverse());for(const a of n){const l=a.getAttribute("listIndent")+this._indentBy;l<0?i.rename(a,"paragraph"):i.setAttribute("listIndent",l,a)}this.fire("_executeCleanup",n)})}_checkEnabled(){const e=ne(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),n=e.getAttribute("listType");let i=e.previousSibling;for(;i&&i.is("element","listItem")&&i.getAttribute("listIndent")>=t;){if(i.getAttribute("listIndent")==t)return i.getAttribute("listType")==n;i=i.previousSibling}return!1}return!0}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Z0(s){const e=s.createContainerElement("li");return e.getFillerOffset=o1,e}function X0(s,e){const t=e.mapper,n=e.writer,i=s.getAttribute("listType")=="numbered"?"ol":"ul",o=Z0(n),r=n.createContainerElement(i,null);return n.insert(n.createPositionAt(r,0),o),t.bindElements(s,o),o}function wd(s,e,t,n){const i=e.parent,o=t.mapper,r=t.writer;let a=o.toViewPosition(n.createPositionBefore(s));const l=_d(s.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:s.getAttribute("listIndent")}),c=s.previousSibling;if(l&&l.getAttribute("listIndent")==s.getAttribute("listIndent")){const d=o.toViewElement(l);a=r.breakContainer(r.createPositionAfter(d))}else if(c&&c.name=="listItem"){a=o.toViewPosition(n.createPositionAt(c,"end"));const d=o.findMappedViewAncestor(a),u=e1(d);u?a=r.createPositionBefore(u):a=r.createPositionAt(d,"end")}else a=o.toViewPosition(n.createPositionBefore(s));if(a=bd(a),r.insert(a,i),c&&c.name=="listItem"){const d=o.toViewElement(c),h=r.createRange(r.createPositionAt(d,0),a).getWalker({ignoreElementEnd:!0});for(const f of h)if(f.item.is("element","li")){const g=r.breakContainer(r.createPositionBefore(f.item)),w=f.item.parent,v=r.createPositionAt(e,"end");be(r,v.nodeBefore,v.nodeAfter),r.move(r.createRangeOn(w),v),h._position=g}}else{const d=i.nextSibling;if(d&&(d.is("element","ul")||d.is("element","ol"))){let u=null;for(const h of d.getChildren()){const f=o.toModelElement(h);if(f&&f.getAttribute("listIndent")>s.getAttribute("listIndent"))u=h;else break}u&&(r.breakContainer(r.createPositionAfter(u)),r.move(r.createRangeOn(u.parent),r.createPositionAt(e,"end")))}}be(r,i,i.nextSibling),be(r,i.previousSibling,i)}function be(s,e,t){return!e||!t||e.name!="ul"&&e.name!="ol"||e.name!=t.name||e.getAttribute("class")!==t.getAttribute("class")?null:s.mergeContainers(s.createPositionAfter(e))}function bd(s){return s.getLastMatchingPosition(e=>e.item.is("uiElement"))}function _d(s,e){const t=!!e.sameIndent,n=!!e.smallerIndent,i=e.listIndent;let o=s;for(;o&&o.name=="listItem";){const r=o.getAttribute("listIndent");if(t&&i==r||n&&i>r)return o;e.direction==="forward"?o=o.nextSibling:o=o.previousSibling}return null}function pa(s,e,t,n){s.ui.componentFactory.add(e,i=>{const o=s.commands.get(e),r=new W(i);return r.set({label:t,icon:n,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.on("execute",()=>{s.execute(e),s.editing.view.focus()}),r})}function e1(s){for(const e of s.getChildren())if(e.name=="ul"||e.name=="ol")return e;return null}function cs(s,e){const t=[],n=s.parent,i={ignoreElementEnd:!1,startPosition:s,shallow:!0,direction:e},o=n.getAttribute("listIndent"),r=[...new Re(i)].filter(a=>a.item.is("element")).map(a=>a.item);for(const a of r){if(!a.is("element","listItem")||a.getAttribute("listIndent")<o)break;if(!(a.getAttribute("listIndent")>o)){if(a.getAttribute("listType")!==n.getAttribute("listType")||a.getAttribute("listStyle")!==n.getAttribute("listStyle")||a.getAttribute("listReversed")!==n.getAttribute("listReversed")||a.getAttribute("listStart")!==n.getAttribute("listStart"))break;e==="backward"?t.unshift(a):t.push(a)}}return t}function t1(s){let t=[...s.document.selection.getSelectedBlocks()].filter(n=>n.is("element","listItem")).map(n=>{const i=s.change(o=>o.createPositionAt(n,0));return[...cs(i,"backward"),...cs(i,"forward")]}).flat();return t=[...new Set(t)],t}const n1=["disc","circle","square"],i1=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function s1(s){return n1.includes(s)?"bulleted":i1.includes(s)?"numbered":null}function o1(){const s=!this.isEmpty&&(this.getChild(0).name=="ul"||this.getChild(0).name=="ol");return this.isEmpty||s?0:kl.call(this)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class r1 extends _{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return s1(e)}getSelectedListItems(e){return t1(e)}getSiblingNodes(e,t){return cs(e,t)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function wa(s){return(e,t,n)=>{const i=n.consumable;if(!i.test(t.item,"insert")||!i.test(t.item,"attribute:listType")||!i.test(t.item,"attribute:listIndent"))return;i.consume(t.item,"insert"),i.consume(t.item,"attribute:listType"),i.consume(t.item,"attribute:listIndent");const o=t.item,r=X0(o,n);wd(o,r,n,s)}}function a1(s){return(e,t,n)=>{const r=n.mapper.toViewPosition(t.position).getLastMatchingPosition(f=>!f.item.is("element","li")).nodeAfter,a=n.writer;a.breakContainer(a.createPositionBefore(r)),a.breakContainer(a.createPositionAfter(r));const l=r.parent,c=l.previousSibling,d=a.createRangeOn(l),u=a.remove(d);c&&c.nextSibling&&be(a,c,c.nextSibling);const h=n.mapper.toModelElement(r);vd(h.getAttribute("listIndent")+1,t.position,d.start,r,n,s);for(const f of a.createRangeIn(u).getItems())n.mapper.unbindViewElement(f);e.stop()}}const l1=(s,e,t)=>{if(!t.consumable.test(e.item,s.name))return;const n=t.mapper.toViewElement(e.item),i=t.writer;i.breakContainer(i.createPositionBefore(n)),i.breakContainer(i.createPositionAfter(n));const o=n.parent,r=e.attributeNewValue=="numbered"?"ol":"ul";i.rename(r,o)},c1=(s,e,t)=>{t.consumable.consume(e.item,s.name);const i=t.mapper.toViewElement(e.item).parent,o=t.writer;be(o,i,i.nextSibling),be(o,i.previousSibling,i)};function d1(s){return(e,t,n)=>{if(!n.consumable.consume(t.item,"attribute:listIndent"))return;const i=n.mapper.toViewElement(t.item),o=n.writer;o.breakContainer(o.createPositionBefore(i)),o.breakContainer(o.createPositionAfter(i));const r=i.parent,a=r.previousSibling,l=o.createRangeOn(r);o.remove(l),a&&a.nextSibling&&be(o,a,a.nextSibling),vd(t.attributeOldValue+1,t.range.start,l.start,i,n,s),wd(t.item,i,n,s);for(const c of t.item.getChildren())n.consumable.consume(c,"insert")}}const ba=(s,e,t)=>{if(t.consumable.test(e.item,s.name)&&e.item.name!="listItem"){let n=t.mapper.toViewPosition(e.range.start);const i=t.writer,o=[];for(;(n.parent.name=="ul"||n.parent.name=="ol")&&(n=i.breakContainer(n),n.parent.name=="li");){const r=n,a=i.createPositionAt(n.parent,"end");if(!r.isEqual(a)){const l=i.remove(i.createRange(r,a));o.push(l)}n=i.createPositionAfter(n.parent)}if(o.length>0){for(let r=0;r<o.length;r++){const a=n.nodeBefore;if(n=i.insert(n,o[r]).end,r>0){const c=be(i,a,a.nextSibling);c&&c.parent==a&&n.offset--}}be(i,n.nodeBefore,n.nodeAfter)}}},u1=(s,e,t)=>{const n=t.mapper.toViewPosition(e.position),i=n.nodeBefore,o=n.nodeAfter;be(t.writer,i,o)},h1=(s,e,t)=>{if(t.consumable.consume(e.viewItem,{name:!0})){const n=t.writer,i=n.createElement("listItem"),o=_1(e.viewItem);n.setAttribute("listIndent",o,i);const r=e.viewItem.parent&&e.viewItem.parent.name=="ol"?"numbered":"bulleted";if(n.setAttribute("listType",r,i),!t.safeInsert(i,e.modelCursor))return;const a=w1(i,e.viewItem.getChildren(),t);e.modelRange=n.createRange(e.modelCursor,a),t.updateConversionResult(i,e)}},_a=(s,e,t)=>{if(t.consumable.test(e.viewItem,{name:!0})){const n=Array.from(e.viewItem.getChildren());for(const i of n)!(i.is("element","li")||$t(i))&&i._remove()}},f1=(s,e,t)=>{if(t.consumable.test(e.viewItem,{name:!0})){if(e.viewItem.childCount===0)return;const n=[...e.viewItem.getChildren()];let i=!1;for(const o of n)i&&!$t(o)&&o._remove(),$t(o)&&(i=!0)}};function va(s){return(e,t)=>{if(t.isPhantom)return;const n=t.modelPosition.nodeBefore;if(n&&n.is("element","listItem")){const i=t.mapper.toViewElement(n),o=i.getAncestors().find($t),r=s.createPositionAt(i,0).getWalker();for(const a of r)if(a.type=="elementStart"&&a.item.is("element","li")){t.viewPosition=a.previousPosition;break}else if(a.type=="elementEnd"&&a.item==o){t.viewPosition=a.nextPosition;break}}}}function m1(s){return(e,t)=>{const n=t.viewPosition,i=n.parent,o=t.mapper;if(i.name=="ul"||i.name=="ol"){if(n.isAtEnd){const r=o.toModelElement(n.nodeBefore),a=o.getModelLength(n.nodeBefore);t.modelPosition=s.createPositionBefore(r).getShiftedBy(a)}else{const r=o.toModelElement(n.nodeAfter);t.modelPosition=s.createPositionBefore(r)}e.stop()}else if(i.name=="li"&&n.nodeBefore&&(n.nodeBefore.name=="ul"||n.nodeBefore.name=="ol")){const r=o.toModelElement(i);let a=1,l=n.nodeBefore;for(;l&&$t(l);)a+=o.getModelLength(l),l=l.previousSibling;t.modelPosition=s.createPositionBefore(r).getShiftedBy(a),e.stop()}}}function g1(s,e){const t=s.document.differ.getChanges(),n=new Map;let i=!1;for(const l of t)if(l.type=="insert"&&l.name=="listItem")o(l.position);else if(l.type=="insert"&&l.name!="listItem"){if(l.name!="$text"){const d=l.position.nodeAfter;d.hasAttribute("listIndent")&&(e.removeAttribute("listIndent",d),i=!0),d.hasAttribute("listType")&&(e.removeAttribute("listType",d),i=!0),d.hasAttribute("listStyle")&&(e.removeAttribute("listStyle",d),i=!0),d.hasAttribute("listReversed")&&(e.removeAttribute("listReversed",d),i=!0),d.hasAttribute("listStart")&&(e.removeAttribute("listStart",d),i=!0);for(const u of Array.from(s.createRangeIn(d)).filter(h=>h.item.is("element","listItem")))o(u.previousPosition)}const c=l.position.getShiftedBy(l.length);o(c)}else l.type=="remove"&&l.name=="listItem"?o(l.position):(l.type=="attribute"&&l.attributeKey=="listIndent"||l.type=="attribute"&&l.attributeKey=="listType")&&o(l.range.start);for(const l of n.values())r(l),a(l);return i;function o(l){const c=l.nodeBefore;if(!c||!c.is("element","listItem")){const d=l.nodeAfter;d&&d.is("element","listItem")&&n.set(d,d)}else{let d=c;if(n.has(d))return;for(let u=d.previousSibling;u&&u.is("element","listItem");u=d.previousSibling)if(d=u,n.has(d))return;n.set(c,d)}}function r(l){let c=0,d=null;for(;l&&l.is("element","listItem");){const u=l.getAttribute("listIndent");if(u>c){let h;d===null?(d=u-c,h=c):(d>u&&(d=u),h=u-d),e.setAttribute("listIndent",h,l),i=!0}else d=null,c=l.getAttribute("listIndent")+1;l=l.nextSibling}}function a(l){let c=[],d=null;for(;l&&l.is("element","listItem");){const u=l.getAttribute("listIndent");if(d&&d.getAttribute("listIndent")>u&&(c=c.slice(0,u+1)),u!=0)if(c[u]){const h=c[u];l.getAttribute("listType")!=h&&(e.setAttribute("listType",h,l),i=!0)}else c[u]=l.getAttribute("listType");d=l,l=l.nextSibling}}}const p1=function(s,[e,t]){const n=this;let i=e.is("documentFragment")?e.getChild(0):e,o;if(t?o=n.createSelection(t):o=n.document.selection,i&&i.is("element","listItem")){const r=o.getFirstPosition();let a=null;if(r.parent.is("element","listItem")?a=r.parent:r.nodeBefore&&r.nodeBefore.is("element","listItem")&&(a=r.nodeBefore),a){const l=a.getAttribute("listIndent");if(l>0)for(;i&&i.is("element","listItem");)i._setAttribute("listIndent",i.getAttribute("listIndent")+l),i=i.nextSibling}}};function w1(s,e,t){const{writer:n,schema:i}=t;let o=n.createPositionAfter(s);for(const r of e)if(r.name=="ul"||r.name=="ol")o=t.convertItem(r,o).modelCursor;else{const a=t.convertItem(r,n.createPositionAt(s,"end")),l=a.modelRange.start.nodeAfter;l&&l.is("element")&&!i.checkChild(s,l.name)&&(a.modelCursor.parent.is("element","listItem")?s=a.modelCursor.parent:s=b1(a.modelCursor),o=n.createPositionAfter(s))}return o}function b1(s){const e=new Re({startPosition:s});let t;do t=e.next();while(!t.value.item.is("element","listItem"));return t.value.item}function vd(s,e,t,n,i,o){const r=_d(e.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:s}),a=i.mapper,l=i.writer,c=r?r.getAttribute("listIndent"):null;let d;if(!r)d=t;else if(c==s){const u=a.toViewElement(r).parent;d=l.createPositionAfter(u)}else{const u=o.createPositionAt(r,"end");d=a.toViewPosition(u)}d=bd(d);for(const u of[...n.getChildren()])$t(u)&&(d=l.move(l.createRangeOn(u),d).end,be(l,u,u.nextSibling),be(l,u.previousSibling,u))}function $t(s){return s.is("element","ol")||s.is("element","ul")}function _1(s){let e=0,t=s.parent;for(;t;){if(t.is("element","li"))e++;else{const n=t.previousSibling;n&&n.is("element","li")&&e++}t=t.parent}return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class v1 extends _{static get pluginName(){return"ListEditing"}static get requires(){return[oi,Je,r1]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,n=e.editing;e.model.document.registerPostFixer(o=>g1(e.model,o)),n.mapper.registerViewToModelLength("li",ds),t.mapper.registerViewToModelLength("li",ds),n.mapper.on("modelToViewPosition",va(n.view)),n.mapper.on("viewToModelPosition",m1(e.model)),t.mapper.on("modelToViewPosition",va(n.view)),e.conversion.for("editingDowncast").add(o=>{o.on("insert",ba,{priority:"high"}),o.on("insert:listItem",wa(e.model)),o.on("attribute:listType:listItem",l1,{priority:"high"}),o.on("attribute:listType:listItem",c1,{priority:"low"}),o.on("attribute:listIndent:listItem",d1(e.model)),o.on("remove:listItem",a1(e.model)),o.on("remove",u1,{priority:"low"})}),e.conversion.for("dataDowncast").add(o=>{o.on("insert",ba,{priority:"high"}),o.on("insert:listItem",wa(e.model))}),e.conversion.for("upcast").add(o=>{o.on("element:ul",_a,{priority:"high"}),o.on("element:ol",_a,{priority:"high"}),o.on("element:li",f1,{priority:"high"}),o.on("element:li",h1)}),e.model.on("insertContent",p1,{priority:"high"}),e.commands.add("numberedList",new ha(e,"numbered")),e.commands.add("bulletedList",new ha(e,"bulleted")),e.commands.add("indentList",new ga(e,"forward")),e.commands.add("outdentList",new ga(e,"backward"));const i=n.view.document;this.listenTo(i,"enter",(o,r)=>{const a=this.editor.model.document,l=a.selection.getLastPosition().parent;a.selection.isCollapsed&&l.name=="listItem"&&l.isEmpty&&(this.editor.execute("outdentList"),r.preventDefault(),o.stop())},{context:"li"}),this.listenTo(i,"delete",(o,r)=>{if(r.direction!=="backward")return;const a=this.editor.model.document.selection;if(!a.isCollapsed)return;const l=a.getFirstPosition();if(!l.isAtStart)return;const c=l.parent;c.name!=="listItem"||c.previousSibling&&c.previousSibling.name==="listItem"||(this.editor.execute("outdentList"),r.preventDefault(),o.stop())},{context:"li"}),this.listenTo(e.editing.view.document,"tab",(o,r)=>{const a=r.shiftKey?"outdentList":"indentList";this.editor.commands.get(a).isEnabled&&(e.execute(a),r.stopPropagation(),r.preventDefault(),o.stop())},{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),n=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),n&&n.registerChildCommand(e.get("outdentList"))}}function ds(s){let e=1;for(const t of s.getChildren())if(t.name=="ul"||t.name=="ol")for(const n of t.getChildren())e+=ds(n);return e}const y1='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM3.5 3v5H2V3.7H1v-1h2.5V3zM.343 17.857l2.59-3.257H2.92a.6.6 0 1 0-1.04 0H.302a2 2 0 1 1 3.995 0h-.001c-.048.405-.16.734-.333.988-.175.254-.59.692-1.244 1.312H4.3v1h-4l.043-.043zM7 14.75a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z"/></svg>',C1='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0C1 4.784 1.777 4 2.75 4c.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75C1.784 7.5 1 6.723 1 5.75zm6 9c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0c0-.966.777-1.75 1.75-1.75.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75-.966 0-1.75-.777-1.75-1.75z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class k1 extends _{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;pa(this.editor,"numberedList",e("Numbered List"),y1),pa(this.editor,"bulletedList",e("Bulleted List"),C1)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class SC extends _{static get requires(){return[v1,k1]}static get pluginName(){return"List"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ya(s,e){const t=(n,i,o)=>{if(!o.consumable.consume(i.item,n.name))return;const r=i.attributeNewValue,a=o.writer,l=o.mapper.toViewElement(i.item),c=[...l.getChildren()].find(u=>u.getCustomProperty("media-content"));a.remove(c);const d=s.getMediaViewElement(a,r,e);a.insert(a.createPositionAt(l,0),d)};return n=>{n.on("attribute:url:media",t)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function E1(s,e,t){return e.setCustomProperty("media",!0,s),Ks(s,e,{label:t})}function Ca(s,e,t,n){return s.createContainerElement("figure",{class:"media"},[e.getMediaViewElement(s,t,n),s.createSlot()])}function ka(s){const e=s.getSelectedElement();return e&&e.is("element","media")?e:null}function yd(s,e,t,n){s.change(i=>{const o=i.createElement("media",{url:e});s.insertObject(o,t,null,{setSelection:"on",findOptimalPosition:n?"auto":void 0})})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class T1 extends x{refresh(){const e=this.editor.model,t=e.document.selection,n=ka(t);this.value=n?n.getAttribute("url"):void 0,this.isEnabled=S1(t)||A1(t,e)}execute(e){const t=this.editor.model,n=t.document.selection,i=ka(n);i?t.change(o=>{o.setAttribute("url",e,i)}):yd(t,e,n,!0)}}function A1(s,e){let n=zc(s,e).start.parent;return n.isEmpty&&!e.schema.isLimit(n)&&(n=n.parent),e.schema.checkChild(n,"media")}function S1(s){const e=s.getSelectedElement();return!!e&&e.name==="media"}const P1='<svg viewBox="0 0 64 42" xmlns="http://www.w3.org/2000/svg"><path d="M47.426 17V3.713L63.102 0v19.389h-.001l.001.272c0 1.595-2.032 3.43-4.538 4.098-2.506.668-4.538-.083-4.538-1.678 0-1.594 2.032-3.43 4.538-4.098.914-.244 2.032-.565 2.888-.603V4.516L49.076 7.447v9.556A1.014 1.014 0 0 0 49 17h-1.574zM29.5 17h-8.343a7.073 7.073 0 1 0-4.657 4.06v3.781H3.3a2.803 2.803 0 0 1-2.8-2.804V8.63a2.803 2.803 0 0 1 2.8-2.805h4.082L8.58 2.768A1.994 1.994 0 0 1 10.435 1.5h8.985c.773 0 1.477.448 1.805 1.149l1.488 3.177H26.7c1.546 0 2.8 1.256 2.8 2.805V17zm-11.637 0H17.5a1 1 0 0 0-1 1v.05A4.244 4.244 0 1 1 17.863 17zm29.684 2c.97 0 .953-.048.953.889v20.743c0 .953.016.905-.953.905H19.453c-.97 0-.953.048-.953-.905V19.89c0-.937-.016-.889.97-.889h28.077zm-4.701 19.338V22.183H24.154v16.155h18.692zM20.6 21.375v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616V37.53H20.6zm24.233-16.155v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615V37.53h-1.615zM29.485 25.283a.4.4 0 0 1 .593-.35l9.05 4.977a.4.4 0 0 1 0 .701l-9.05 4.978a.4.4 0 0 1-.593-.35v-9.956z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const x1="0 0 64 42";class I1{constructor(e,t){const n=t.providers,i=t.extraProviders||[],o=new Set(t.removeProviders),r=n.concat(i).filter(a=>{const l=a.name;return l?!o.has(l):(K("media-embed-no-provider-name",{provider:a}),!1)});this.locale=e,this.providerDefinitions=r}hasMedia(e){return!!this._getMedia(e)}getMediaViewElement(e,t,n){return this._getMedia(t).getViewElement(e,n)}_getMedia(e){if(!e)return new Ea(this.locale);e=e.trim();for(const t of this.providerDefinitions){const n=t.html,i=se(t.url);for(const o of i){const r=this._getUrlMatches(e,o);if(r)return new Ea(this.locale,e,r,n)}}return null}_getUrlMatches(e,t){let n=e.match(t);if(n)return n;let i=e.replace(/^https?:\/\//,"");return n=i.match(t),n||(i=i.replace(/^www\./,""),n=i.match(t),n)?n:null}}class Ea{constructor(e,t,n,i){this.url=this._getValidUrl(t),this._locale=e,this._match=n,this._previewRenderer=i}getViewElement(e,t){const n={};let i;if(t.renderForEditingView||t.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(n["data-oembed-url"]=this.url),t.renderForEditingView&&(n.class="ck-media__wrapper");const o=this._getPreviewHtml(t);i=e.createRawElement("div",n,(r,a)=>{a.setContentOf(r,o)})}else this.url&&(n.url=this.url),i=e.createEmptyElement(t.elementName,n);return e.setCustomProperty("media-content",!0,i),i}_getPreviewHtml(e){return this._previewRenderer?this._previewRenderer(this._match):this.url&&e.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const e=new at,t=this._locale.t;return e.content=P1,e.viewBox=x1,new Ve({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[e]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url,"data-cke-tooltip-text":t("Open media in new tab")},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]}]}]}).render().outerHTML}_getValidUrl(e){return e?e.match(/^https?/)?e:"https://"+e:null}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gn extends _{static get pluginName(){return"MediaEmbedEditing"}constructor(e){super(e),e.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:/^dailymotion\.com\/video\/(\w+)/,html:t=>`<div style="position: relative; padding-bottom: 100%; height: 0; "><iframe src="https://www.dailymotion.com/embed/video/${t[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" width="480" height="270" allowfullscreen allow="autoplay"></iframe></div>`},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:t=>`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 126%;"><iframe src="https://open.spotify.com/embed/${t[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe></div>`},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:t=>{const n=t[1],i=t[2];return`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;"><iframe src="https://www.youtube.com/embed/${n}${i?`?start=${i}`:""}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div>`}},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:t=>`<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;"><iframe src="https://player.vimeo.com/video/${t[1]}" style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>`},{name:"instagram",url:/^instagram\.com\/p\/(\w+)/},{name:"twitter",url:/^twitter\.com/},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new I1(e.locale,e.config.get("mediaEmbed"))}init(){const e=this.editor,t=e.model.schema,n=e.t,i=e.conversion,o=e.config.get("mediaEmbed.previewsInData"),r=e.config.get("mediaEmbed.elementName"),a=this.registry;e.commands.add("mediaEmbed",new T1(e)),t.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),i.for("dataDowncast").elementToStructure({model:"media",view:(l,{writer:c})=>{const d=l.getAttribute("url");return Ca(c,a,d,{elementName:r,renderMediaPreview:!!d&&o})}}),i.for("dataDowncast").add(ya(a,{elementName:r,renderMediaPreview:o})),i.for("editingDowncast").elementToStructure({model:"media",view:(l,{writer:c})=>{const d=l.getAttribute("url"),u=Ca(c,a,d,{elementName:r,renderForEditingView:!0});return E1(u,c,n("media widget"))}}),i.for("editingDowncast").add(ya(a,{elementName:r,renderForEditingView:!0})),i.for("upcast").elementToElement({view:l=>["oembed",r].includes(l.name)&&l.getAttribute("url")?{name:!0}:null,model:(l,{writer:c})=>{const d=l.getAttribute("url");return a.hasMedia(d)?c.createElement("media",{url:d}):null}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(l,{writer:c})=>{const d=l.getAttribute("data-oembed-url");return a.hasMedia(d)?c.createElement("media",{url:d}):null}}).add(l=>{const c=(d,u,h)=>{if(!h.consumable.consume(u.viewItem,{name:!0,classes:"media"}))return;const{modelRange:f,modelCursor:g}=h.convertChildren(u.viewItem,u.modelCursor);u.modelRange=f,u.modelCursor=g,ne(f.getItems())||h.consumable.revert(u.viewItem,{name:!0,classes:"media"})};l.on("element:figure",c)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const R1=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class M1 extends _{static get requires(){return[Uc,Je,qc]}static get pluginName(){return"AutoMediaEmbed"}constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document,n=e.plugins.get("ClipboardPipeline");this.listenTo(n,"inputTransformation",()=>{const o=t.selection.getFirstRange(),r=re.fromPosition(o.start);r.stickiness="toPrevious";const a=re.fromPosition(o.end);a.stickiness="toNext",t.once("change:data",()=>{this._embedMediaBetweenPositions(r,a),r.detach(),a.detach()},{priority:"high"})}),e.commands.get("undo").on("execute",()=>{this._timeoutId&&(S.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedMediaBetweenPositions(e,t){const n=this.editor,i=n.plugins.get(Gn).registry,o=new Te(e,t),r=o.getWalker({ignoreElementEnd:!0});let a="";for(const c of r)c.item.is("$textProxy")&&(a+=c.item.data);if(a=a.trim(),!a.match(R1)){o.detach();return}if(!i.hasMedia(a)){o.detach();return}if(!n.commands.get("mediaEmbed").isEnabled){o.detach();return}this._positionToInsert=re.fromPosition(e),this._timeoutId=S.window.setTimeout(()=>{n.model.change(c=>{this._timeoutId=null,c.remove(o),o.detach();let d=null;this._positionToInsert.root.rootName!=="$graveyard"&&(d=this._positionToInsert),yd(n.model,a,d,!1),this._positionToInsert.detach(),this._positionToInsert=null}),n.plugins.get(Je).requestUndoOnBackspace()},100)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class V1 extends I{constructor(e,t){super(t);const n=t.t;this.focusTracker=new ve,this.keystrokes=new Be,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),$.check,"ck-button-save"),this.saveButtonView.type="submit",this.saveButtonView.bind("isEnabled").to(this,"mediaURLInputValue",i=>!!i),this.cancelButtonView=this._createButton(n("Cancel"),$.cancel,"ck-button-cancel","cancel"),this._focusables=new rt,this._focusCycler=new Kt({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._validators=e,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),Ds({view:this}),[this.urlInputView,this.saveButtonView,this.cancelButtonView].forEach(n=>{this._focusables.add(n),this.focusTracker.add(n.element)}),this.keystrokes.listenTo(this.element);const t=n=>n.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(e){this.urlInputView.fieldView.element.value=e.trim()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const e=this.locale.t,t=new Fs(this.locale,Us),n=t.fieldView;return this._urlInputViewInfoDefault=e("Paste the media URL in the input."),this._urlInputViewInfoTip=e("Tip: Paste the URL into the content to embed faster."),t.label=e("Media URL"),t.infoText=this._urlInputViewInfoDefault,n.on("input",()=>{t.infoText=n.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=n.element.value.trim()}),t}_createButton(e,t,n,i){const o=new W(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:n}}),i&&o.delegate("execute").to(this,i),o}}const O1='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M18.68 3.03c.6 0 .59-.03.59.55v12.84c0 .59.01.56-.59.56H1.29c-.6 0-.59.03-.59-.56V3.58c0-.58-.01-.55.6-.55h17.38zM15.77 15V5H4.2v10h11.57zM2 4v1h1V4H2zm0 2v1h1V6H2zm0 2v1h1V8H2zm0 2v1h1v-1H2zm0 2v1h1v-1H2zm0 2v1h1v-1H2zM17 4v1h1V4h-1zm0 2v1h1V6h-1zm0 2v1h1V8h-1zm0 2v1h1v-1h-1zm0 2v1h1v-1h-1zm0 2v1h1v-1h-1zM7.5 7.177a.4.4 0 0 1 .593-.351l5.133 2.824a.4.4 0 0 1 0 .7l-5.133 2.824a.4.4 0 0 1-.593-.35V7.176v.001z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class D1 extends _{static get requires(){return[Gn]}static get pluginName(){return"MediaEmbedUI"}init(){const e=this.editor,t=e.commands.get("mediaEmbed");e.ui.componentFactory.add("mediaEmbed",n=>{const i=qe(n);return this._setUpDropdown(i,t),i})}_setUpDropdown(e,t){const n=this.editor,i=n.t,o=e.buttonView,r=n.plugins.get(Gn).registry;e.once("change:isOpen",()=>{const a=new(Os(V1))(N1(n.t,r),n.locale);e.panelView.children.add(a),o.on("open",()=>{a.disableCssTransitions(),a.url=t.value||"",a.urlInputView.fieldView.select(),a.enableCssTransitions()},{priority:"low"}),e.on("submit",()=>{a.isValid()&&(n.execute("mediaEmbed",a.url),n.editing.view.focus())}),e.on("change:isOpen",()=>a.resetFormStatus()),e.on("cancel",()=>{n.editing.view.focus()}),a.delegate("submit","cancel").to(e),a.urlInputView.fieldView.bind("value").to(t,"value"),a.urlInputView.bind("isEnabled").to(t,"isEnabled")}),e.bind("isEnabled").to(t),o.set({label:i("Insert media"),icon:O1,tooltip:!0})}}function N1(s,e){return[t=>{if(!t.url.length)return s("The URL must not be empty.")},t=>{if(!e.hasMedia(t.url))return s("This media URL is not supported.")}]}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class PC extends _{static get requires(){return[Gn,D1,M1,fn]}static get pluginName(){return"MediaEmbed"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function B1(s,e){if(!s.childCount)return;const t=new Et(s.document),n=L1(s,t);if(!n.length)return;let i=null,o=1;n.forEach((r,a)=>{const l=K1(n[a-1],r),c=l?null:n[a-1],d=J1(c,r);if(l&&(i=null,o=1),!i||d!==0){const h=z1(r,e);if(!i)i=Ta(h,r.element,t);else if(r.indent>o){const f=i.getChild(i.childCount-1),g=f.getChild(f.childCount-1);i=Ta(h,g,t),o+=1}else if(r.indent<o){const f=o-r.indent;i=Q1(i,f),o=r.indent}r.indent<=o&&(i.is("element",h.type)||(i=t.rename(h.type,i)))}const u=$1(r.element,t);t.appendChild(u,i)})}function F1(s,e){for(const t of e.createRangeIn(s)){const n=t.item;if(n.is("element","li")){const i=n.getChild(0);i&&i.is("element","p")&&e.unwrapElement(i)}}}function L1(s,e){const t=e.createRangeIn(s),n=new Fe({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),i=[];for(const o of t)if(o.type==="elementStart"&&n.match(o.item)){const r=q1(o.item);i.push({element:o.item,id:r.id,order:r.order,indent:r.indent})}return i}function z1(s,e){const t=new RegExp(`@list l${s.id}:level${s.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,i=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=t.exec(e);let r="decimal",a="ol",l=null;if(o&&o[1]){const c=n.exec(o[1]);if(c&&c[1]&&(r=c[1].trim(),a=r!=="bullet"&&r!=="image"?"ol":"ul"),r==="bullet"){const d=H1(s.element);d&&(r=d)}else{const d=i.exec(o[1]);d&&d[1]&&(l=parseInt(d[1]))}}return{type:a,startIndex:l,style:U1(r)}}function H1(s){const e=W1(s);if(!e)return null;const t=e._data;return t==="o"?"circle":t==="·"?"disc":t==="§"?"square":null}function W1(s){if(s.getChild(0).is("$text"))return null;for(const e of s.getChildren()){if(!e.is("element","span"))continue;const t=e.getChild(0);if(t)return t.is("$text")?t:t.getChild(0)}/* istanbul ignore next -- @preserve */return null}function U1(s){if(s.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(s){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return s;default:return null}}function Ta(s,e,t){const n=e.parent,i=t.createElement(s.type),o=n.getChildIndex(e)+1;return t.insertChild(o,i,n),s.style&&t.setStyle("list-style-type",s.style,i),s.startIndex&&s.startIndex>1&&t.setAttribute("start",s.startIndex,i),i}function $1(s,e){return j1(s,e),e.rename("li",s)}function q1(s){const e={},t=s.getStyle("mso-list");if(t){const n=t.match(/(^|\s{1,100})l(\d+)/i),i=t.match(/\s{0,100}lfo(\d+)/i),o=t.match(/\s{0,100}level(\d+)/i);n&&i&&o&&(e.id=n[2],e.order=i[1],e.indent=parseInt(o[1]))}return e}function j1(s,e){const t=new Fe({name:"span",styles:{"mso-list":"Ignore"}}),n=e.createRangeIn(s);for(const i of n)i.type==="elementStart"&&t.match(i.item)&&e.remove(i.item)}function K1(s,e){if(!s)return!0;if(s.id!==e.id)return e.indent-s.indent!==1;const t=e.element.previousSibling;return t?!G1(t):!0}function G1(s){return s.is("element","ol")||s.is("element","ul")}function J1(s,e){return s?e.indent-s.indent:e.indent-1}function Q1(s,e){const t=s.getAncestors({parentFirst:!0});let n=null,i=0;for(const o of t)if((o.is("element","ul")||o.is("element","ol"))&&i++,i===e){n=o;break}return n}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Y1(s,e){if(!s.childCount)return;const t=new Et(s.document),n=X1(s,t);ev(n,s,t),nv(n,s,t),tv(s,t);const i=iv(s,t);i.length&&ov(i,sv(e),t)}function Z1(s){return btoa(s.match(/\w{2}/g).map(e=>String.fromCharCode(parseInt(e,16))).join(""))}function X1(s,e){const t=e.createRangeIn(s),n=new Fe({name:/v:(.+)/}),i=[];for(const o of t){if(o.type!="elementStart")continue;const r=o.item,a=r.previousSibling,l=a&&a.is("element")?a.name:null;n.match(r)&&r.getAttribute("o:gfxdata")&&l!=="v:shapetype"&&i.push(o.item.getAttribute("id"))}return i}function ev(s,e,t){const n=t.createRangeIn(e),i=new Fe({name:"img"}),o=[];for(const r of n)if(r.item.is("element")&&i.match(r.item)){const a=r.item,l=a.getAttribute("v:shapes")?a.getAttribute("v:shapes").split(" "):[];l.length&&l.every(c=>s.indexOf(c)>-1)?o.push(a):a.getAttribute("src")||o.push(a)}for(const r of o)t.remove(r)}function tv(s,e){const t=e.createRangeIn(s),n=new Fe({name:/v:(.+)/}),i=[];for(const o of t)o.type=="elementStart"&&n.match(o.item)&&i.push(o.item);for(const o of i)e.remove(o)}function nv(s,e,t){const n=t.createRangeIn(e),i=[];for(const a of n)if(a.type=="elementStart"&&a.item.is("element","v:shape")){const l=a.item.getAttribute("id");if(s.includes(l))continue;o(a.item.parent.getChildren(),l)||i.push(a.item)}for(const a of i){const l={src:r(a)};a.hasAttribute("alt")&&(l.alt=a.getAttribute("alt"));const c=t.createElement("img",l);t.insertChild(a.index+1,c,a.parent)}function o(a,l){for(const c of a){/* istanbul ignore else -- @preserve */if(c.is("element")&&(c.name=="img"&&c.getAttribute("v:shapes")==l||o(c.getChildren(),l)))return!0}return!1}function r(a){for(const l of a.getChildren()){/* istanbul ignore else -- @preserve */if(l.is("element")&&l.getAttribute("src"))return l.getAttribute("src")}}}function iv(s,e){const t=e.createRangeIn(s),n=new Fe({name:"img"}),i=[];for(const o of t)o.item.is("element")&&n.match(o.item)&&o.item.getAttribute("src").startsWith("file://")&&i.push(o.item);return i}function sv(s){if(!s)return[];const e=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,t=new RegExp("(?:("+e.source+"))([\\da-fA-F\\s]+)\\}","g"),n=s.match(t),i=[];if(n)for(const o of n){let r=!1;o.includes("\\pngblip")?r="image/png":o.includes("\\jpegblip")&&(r="image/jpeg"),r&&i.push({hex:o.replace(e,"").replace(/[^\da-fA-F]/g,""),type:r})}return i}function ov(s,e,t){if(s.length===e.length)for(let n=0;n<s.length;n++){const i=`data:${e[n].type};base64,${Z1(e[n].hex)}`;t.setAttribute("src",i,s[n])}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const rv=/<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i,av=/xmlns:o="urn:schemas-microsoft-com/i;class lv{constructor(e){this.document=e}isActive(e){return rv.test(e)||av.test(e)}execute(e){const{body:t,stylesString:n}=e._parsedData;B1(t,n),Y1(t,e.dataTransfer.getData("text/rtf")),e.content=t}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function cv(s,e){for(const t of s.getChildren())if(t.is("element","b")&&t.getStyle("font-weight")==="normal"){const n=s.getChildIndex(t);e.remove(t),e.insertChild(n,t.getChildren(),s)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function dv(s,e){const t=new ei(e.document.stylesProcessor),n=new ni(t,{renderingMode:"data"}),i=n.blockElements,o=n.inlineObjectElements,r=[];for(const a of e.createRangeIn(s)){const l=a.item;if(l.is("element","br")){const c=Aa(l,"forward",e,{blockElements:i,inlineObjectElements:o}),d=Aa(l,"backward",e,{blockElements:i,inlineObjectElements:o}),u=Sa(c,i);(Sa(d,i)||u)&&r.push(l)}}for(const a of r)a.hasClass("Apple-interchange-newline")?e.remove(a):e.replace(a,e.createElement("p"))}function Aa(s,e,t,{blockElements:n,inlineObjectElements:i}){let o=t.createPositionAt(s,e=="forward"?"after":"before");return o=o.getLastMatchingPosition(({item:r})=>r.is("element")&&!n.includes(r.name)&&!i.includes(r.name),{direction:e}),e=="forward"?o.nodeAfter:o.nodeBefore}function Sa(s,e){return!!s&&s.is("element")&&e.includes(s.name)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const uv=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class hv{constructor(e){this.document=e}isActive(e){return uv.test(e)}execute(e){const t=new Et(this.document),{body:n}=e._parsedData;cv(n,t),F1(n,t),dv(n,t),e.content=n}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function fv(s,e){for(const t of s.getChildren())t.is("element","table")&&t.hasAttribute("xmlns")&&e.removeAttribute("xmlns",t)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function mv(s,e){for(const t of s.getChildren())if(t.is("element","google-sheets-html-origin")){const n=s.getChildIndex(t);e.remove(t),e.insertChild(n,t.getChildren(),s)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function gv(s,e){for(const t of s.getChildren())t.is("element","table")&&t.getStyle("width")==="0px"&&e.removeStyle("width",t)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const pv=/<google-sheets-html-origin/i;class wv{constructor(e){this.document=e}isActive(e){return pv.test(e)}execute(e){const t=new Et(this.document),{body:n}=e._parsedData;mv(n,t),fv(n,t),gv(n,t),e.content=n}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function bv(s){return Pa(Pa(s)).replace(/(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g,"").replace(/ <\//g," </").replace(/ <o:p><\/o:p>/g," <o:p></o:p>").replace(/<o:p>(&nbsp;|\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)</g,"><")}function _v(s){s.querySelectorAll("span[style*=spacerun]").forEach(e=>{const t=e,n=t.innerText.length||0;t.innerText=Array(n+1).join("  ").substr(0,n)})}function Pa(s){return s.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>t.length===1?" ":Array(t.length+1).join("  ").substr(0,t.length))}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function vv(s,e){const t=new DOMParser;s=s.replace(/<!--\[if gte vml 1]>/g,"");const n=bv(kv(s)),i=t.parseFromString(n,"text/html");_v(i);const o=i.body.innerHTML,r=yv(i,e),a=Cv(i);return{body:r,bodyString:o,styles:a.styles,stylesString:a.stylesString}}function yv(s,e){const t=new ei(e),n=new ni(t,{renderingMode:"data"}),i=s.createDocumentFragment(),o=s.body.childNodes;for(;o.length>0;)i.appendChild(o[0]);return n.domToView(i,{skipComments:!0})}function Cv(s){const e=[],t=[],n=Array.from(s.getElementsByTagName("style"));for(const i of n)i.sheet&&i.sheet.cssRules&&i.sheet.cssRules.length&&(e.push(i.sheet),t.push(i.innerHTML));return{styles:e,stylesString:t.join(" ")}}function kv(s){const e="</body>",t="</html>",n=s.indexOf(e);if(n<0)return s;const i=s.indexOf(t,n+e.length);return s.substring(0,n+e.length)+(i>=0?s.substring(i):"")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class xC extends _{static get pluginName(){return"PasteFromOffice"}static get requires(){return[Ne]}init(){const e=this.editor,t=e.plugins.get("ClipboardPipeline"),n=e.editing.view.document,i=[];i.push(new lv(n)),i.push(new hv(n)),i.push(new wv(n)),t.on("inputTransformation",(o,r)=>{if(r._isTransformedWithPasteFromOffice||e.model.document.selection.getFirstPosition().parent.is("element","codeBlock"))return;const l=r.dataTransfer.getData("text/html"),c=i.find(d=>d.isActive(l));c&&(r._parsedData=vv(l,n.stylesProcessor),c.execute(r),r._isTransformedWithPasteFromOffice=!0)},{priority:"high"})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Q(s,e,t,n,i=1){e!=null&&i!==void 0&&i!==null&&e>i?n.setAttribute(s,e,t):n.removeAttribute(s,t)}function Tt(s,e,t={}){const n=s.createElement("tableCell",t);return s.insertElement("paragraph",n),s.insert(n,e),n}function us(s,e){const t=e.parent.parent,n=parseInt(t.getAttribute("headingColumns")||"0"),{column:i}=s.getCellLocation(e);return!!n&&i<n}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ev(){return s=>{s.on("element:figure",(e,t,n)=>{if(!n.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const i=Sv(t.viewItem);if(!i||!n.consumable.test(i,{name:!0}))return;n.consumable.consume(t.viewItem,{name:!0,classes:"table"});const o=n.convertItem(i,t.modelCursor),r=ne(o.modelRange.getItems());if(!r){n.consumable.revert(t.viewItem,{name:!0,classes:"table"});return}n.convertChildren(t.viewItem,n.writer.createPositionAt(r,"end")),n.updateConversionResult(r,t)})}}function Tv(){return s=>{s.on("element:table",(e,t,n)=>{const i=t.viewItem;if(!n.consumable.test(i,{name:!0}))return;const{rows:o,headingRows:r,headingColumns:a}=Pv(i),l={};a&&(l.headingColumns=a),r&&(l.headingRows=r);const c=n.writer.createElement("table",l);if(n.safeInsert(c,t.modelCursor)){if(n.consumable.consume(i,{name:!0}),o.forEach(d=>n.convertItem(d,n.writer.createPositionAt(c,"end"))),n.convertChildren(i,n.writer.createPositionAt(c,"end")),c.isEmpty){const d=n.writer.createElement("tableRow");n.writer.insert(d,n.writer.createPositionAt(c,"end")),Tt(n.writer,n.writer.createPositionAt(d,"end"))}n.updateConversionResult(c,t)}})}}function Av(){return s=>{s.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&t.modelCursor.index==0&&e.stop()},{priority:"high"})}}function xa(s){return e=>{e.on(`element:${s}`,(t,n,{writer:i})=>{if(!n.modelRange)return;const o=n.modelRange.start.nodeAfter,r=i.createPositionAt(o,0);if(n.viewItem.isEmpty){i.insertElement("paragraph",r);return}const a=Array.from(o.getChildren());if(a.every(l=>l.is("element","$marker"))){const l=i.createElement("paragraph");i.insert(l,i.createPositionAt(o,0));for(const c of a)i.move(i.createRangeOn(c),i.createPositionAt(l,"end"))}},{priority:"low"})}}function Sv(s){for(const e of s.getChildren())if(e.is("element","table"))return e}function Pv(s){let e=0,t;const n=[],i=[];let o;for(const r of Array.from(s.getChildren())){if(r.name!=="tbody"&&r.name!=="thead"&&r.name!=="tfoot")continue;r.name==="thead"&&!o&&(o=r);const a=Array.from(r.getChildren()).filter(l=>l.is("element","tr"));for(const l of a)if(o&&r===o||r.name==="tbody"&&Array.from(l.getChildren()).length&&Array.from(l.getChildren()).every(c=>c.is("element","th")))e++,n.push(l);else{i.push(l);const c=xv(l);(!t||c<t)&&(t=c)}}return{headingRows:e,headingColumns:t||0,rows:[...n,...i]}}function xv(s){let e=0,t=0;const n=Array.from(s.getChildren()).filter(i=>i.name==="th"||i.name==="td");for(;t<n.length&&n[t].name==="th";){const i=n[t],o=parseInt(i.getAttribute("colspan")||"1");e=e+o,t++}return e}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class F{constructor(e,t={}){this._table=e,this._startRow=t.row!==void 0?t.row:t.startRow||0,this._endRow=t.row!==void 0?t.row:t.endRow,this._startColumn=t.column!==void 0?t.column:t.startColumn||0,this._endColumn=t.column!==void 0?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){const e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0,value:void 0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const n=this._getSpanned();if(n)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(n.cell,n.row,n.column));else{const i=e.getChild(this._cellIndex);if(!i)return this._advanceToNextRow();const o=parseInt(i.getAttribute("colspan")||"1"),r=parseInt(i.getAttribute("rowspan")||"1");(o>1||r>1)&&this._recordSpans(i,r,o),this._shouldSkipSlot()||(t=this._formatOutValue(i)),this._nextCellAtColumn=this._column+o}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return this._endRow!==void 0&&this._row>this._endRow}_isOverEndColumn(){return this._endColumn!==void 0&&this._column>this._endColumn}_formatOutValue(e,t=this._row,n=this._column){return{done:!1,value:new Iv(this,e,t,n)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,n=this._column<this._startColumn,i=this._endColumn!==void 0&&this._column>this._endColumn;return e||t||n||i}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,n){const i={cell:e,row:this._row,column:this._column};for(let o=this._row;o<this._row+t;o++)for(let r=this._column;r<this._column+n;r++)(o!=this._row||r!=this._column)&&this._markSpannedCell(o,r,i)}_markSpannedCell(e,t,n){this._spannedCells.has(e)||this._spannedCells.set(e,new Map),this._spannedCells.get(e).set(t,n)}}class Iv{constructor(e,t,n,i){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=n,this.cellAnchorColumn=i,this._cellIndex=e._cellIndex,this._rowIndex=e._rowIndex,this._table=e._table}get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||"1")}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||"1")}get rowIndex(){return this._rowIndex}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ia(s,e){return(t,{writer:n})=>{const i=t.getAttribute("headingRows")||0,o=n.createContainerElement("table",null,[]),r=n.createContainerElement("figure",{class:"table"},o);i>0&&n.insert(n.createPositionAt(o,"end"),n.createContainerElement("thead",null,n.createSlot(a=>a.is("element","tableRow")&&a.index<i))),i<s.getRows(t)&&n.insert(n.createPositionAt(o,"end"),n.createContainerElement("tbody",null,n.createSlot(a=>a.is("element","tableRow")&&a.index>=i)));for(const{positionOffset:a,filter:l}of e.additionalSlots)n.insert(n.createPositionAt(o,a),n.createSlot(l));return n.insert(n.createPositionAt(o,"after"),n.createSlot(a=>a.is("element","tableRow")?!1:!e.additionalSlots.some(({filter:l})=>l(a)))),e.asWidget?Mv(r,n):r}}function Rv(){return(s,{writer:e})=>s.isEmpty?e.createEmptyElement("tr"):e.createContainerElement("tr")}function Ra(s={}){return(e,{writer:t})=>{const n=e.parent,i=n.parent,o=i.getChildIndex(n),r=new F(i,{row:o}),a=i.getAttribute("headingRows")||0,l=i.getAttribute("headingColumns")||0;let c=null;for(const d of r)if(d.cell==e){const h=d.row<a||d.column<l?"th":"td";c=s.asWidget?Lc(t.createEditableElement(h),t):t.createContainerElement(h);break}return c}}function Ma(s={}){return(e,{writer:t})=>{if(!e.parent.is("element","tableCell")||!Cd(e))return null;if(s.asWidget)return t.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const n=t.createContainerElement("p");return t.setCustomProperty("dataPipeline:transparentRendering",!0,n),n}}}function Cd(s){return s.parent.childCount==1&&!Vv(s)}function Mv(s,e){return e.setCustomProperty("table",!0,s),Ks(s,e,{hasSelectionHandle:!0})}function Vv(s){return!s.getAttributeKeys().next().done}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ov extends x{refresh(){const e=this.editor.model,t=e.document.selection,n=e.schema;this.isEnabled=Dv(t,n)}execute(e={}){const t=this.editor,n=t.model,i=t.plugins.get("TableUtils"),o=t.config.get("table.defaultHeadings.rows"),r=t.config.get("table.defaultHeadings.columns");e.headingRows===void 0&&o&&(e.headingRows=o),e.headingColumns===void 0&&r&&(e.headingColumns=r),n.change(a=>{const l=i.createTable(a,e);n.insertObject(l,null,null,{findOptimalPosition:"auto"}),a.setSelection(a.createPositionAt(l.getNodeByPath([0,0,0]),0))})}}function Dv(s,e){const t=s.getFirstPosition().parent,n=t===t.root?t:t.parent;return e.checkChild(n,"table")}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Va extends x{constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=this.editor.model.document.selection,n=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=n}execute(){const e=this.editor,t=e.model.document.selection,n=e.plugins.get("TableUtils"),i=this.order==="above",o=n.getSelectionAffectedTableCells(t),r=n.getRowIndexes(o),a=i?r.first:r.last,l=o[0].findAncestor("table");n.insertRows(l,{at:i?a:a+1,copyStructureFromAbove:!i})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Oa extends x{constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=this.editor.model.document.selection,n=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=n}execute(){const e=this.editor,t=e.model.document.selection,n=e.plugins.get("TableUtils"),i=this.order==="left",o=n.getSelectionAffectedTableCells(t),r=n.getColumnIndexes(o),a=i?r.first:r.last,l=o[0].findAncestor("table");n.insertColumns(l,{columns:1,at:i?a:a+1})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Da extends x{constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length===1}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];this.direction==="horizontally"?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function kd(s,e,t){const{startRow:n,startColumn:i,endRow:o,endColumn:r}=e,a=t.createElement("table"),l=o-n+1;for(let d=0;d<l;d++)t.insertElement("tableRow",a,"end");const c=[...new F(s,{startRow:n,endRow:o,startColumn:i,endColumn:r,includeAllSlots:!0})];for(const{row:d,column:u,cell:h,isAnchor:f,cellAnchorRow:g,cellAnchorColumn:w}of c){const v=d-n,C=a.getChild(v);if(!f)(g<n||w<i)&&Tt(t,t.createPositionAt(C,"end"));else{const k=t.cloneElement(h);t.append(k,C),Pd(k,d,u,o,r,t)}}return Nv(a,s,n,i,t),a}function Ed(s,e,t=0){const n=[],i=new F(s,{startRow:t,endRow:e-1});for(const o of i){const{row:r,cellHeight:a}=o,l=r+a-1;r<e&&e<=l&&n.push(o)}return n}function Td(s,e,t){const n=s.parent,i=n.parent,o=n.index,r=parseInt(s.getAttribute("rowspan")),a=e-o,l={},c=r-a;c>1&&(l.rowspan=c);const d=parseInt(s.getAttribute("colspan")||"1");d>1&&(l.colspan=d);const u=o,h=u+a,f=[...new F(i,{startRow:u,endRow:h,includeAllSlots:!0})];let g=null,w;for(const v of f){const{row:C,column:k,cell:N}=v;N===s&&w===void 0&&(w=k),w!==void 0&&w===k&&C===h&&(g=Tt(t,v.getPositionBefore(),l))}return Q("rowspan",a,s,t),g}function Ad(s,e){const t=[],n=new F(s);for(const i of n){const{column:o,cellWidth:r}=i,a=o+r-1;o<e&&e<=a&&t.push(i)}return t}function Sd(s,e,t,n){const i=parseInt(s.getAttribute("colspan")),o=t-e,r={},a=i-o;a>1&&(r.colspan=a);const l=parseInt(s.getAttribute("rowspan")||"1");l>1&&(r.rowspan=l);const c=Tt(n,n.createPositionAfter(s),r);return Q("colspan",o,s,n),c}function Pd(s,e,t,n,i,o){const r=parseInt(s.getAttribute("colspan")||"1"),a=parseInt(s.getAttribute("rowspan")||"1");if(t+r-1>i){const d=i-t+1;Q("colspan",d,s,o,1)}if(e+a-1>n){const d=n-e+1;Q("rowspan",d,s,o,1)}}function Nv(s,e,t,n,i){const o=parseInt(e.getAttribute("headingRows")||"0");if(o>0){const a=o-t;Q("headingRows",a,s,i,0)}const r=parseInt(e.getAttribute("headingColumns")||"0");if(r>0){const a=r-n;Q("headingColumns",a,s,i,0)}}function hs(s,e){const t=e.getColumns(s),n=new Array(t).fill(0);for(const{column:o}of new F(s))n[o]++;const i=n.reduce((o,r,a)=>r?o:[...o,a],[]);if(i.length>0){const o=i[i.length-1];return e.removeColumns(s,{at:o}),!0}return!1}function fs(s,e){const t=[],n=e.getRows(s);for(let i=0;i<n;i++)s.getChild(i).isEmpty&&t.push(i);if(t.length>0){const i=t[t.length-1];return e.removeRows(s,{at:i}),!0}return!1}function Ys(s,e){hs(s,e)||fs(s,e)}function xd(s,e){const t=Array.from(new F(s,{startColumn:e.firstColumn,endColumn:e.lastColumn,row:e.lastRow}));if(t.every(({cellHeight:o})=>o===1))return e.lastRow;const i=t[0].cellHeight-1;return e.lastRow+i}function Id(s,e){const t=Array.from(new F(s,{startRow:e.firstRow,endRow:e.lastRow,column:e.lastColumn}));if(t.every(({cellWidth:o})=>o===1))return e.lastColumn;const i=t[0].cellWidth-1;return e.lastColumn+i}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Sn extends x{constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal=this.direction=="right"||this.direction=="left"}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,i=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],o=this.value,r=this.direction;e.change(a=>{const l=r=="right"||r=="down",c=l?i:o,d=l?o:i,u=d.parent;Lv(d,c,a);const h=this.isHorizontal?"colspan":"rowspan",f=parseInt(i.getAttribute(h)||"1"),g=parseInt(o.getAttribute(h)||"1");a.setAttribute(h,f+g,c),a.setSelection(a.createRangeIn(c));const w=this.editor.plugins.get("TableUtils"),v=u.findAncestor("table");Ys(v,w)})}_getMergeableCell(){const t=this.editor.model.document,n=this.editor.plugins.get("TableUtils"),i=n.getTableCellsContainingSelection(t.selection)[0];if(!i)return;const o=this.isHorizontal?Bv(i,this.direction,n):Fv(i,this.direction,n);if(!o)return;const r=this.isHorizontal?"rowspan":"colspan",a=parseInt(i.getAttribute(r)||"1");if(parseInt(o.getAttribute(r)||"1")===a)return o}}function Bv(s,e,t){const i=s.parent.parent,o=e=="right"?s.nextSibling:s.previousSibling,r=(i.getAttribute("headingColumns")||0)>0;if(!o)return;const a=e=="right"?s:o,l=e=="right"?o:s,{column:c}=t.getCellLocation(a),{column:d}=t.getCellLocation(l),u=parseInt(a.getAttribute("colspan")||"1"),h=us(t,a),f=us(t,l);return r&&h!=f?void 0:c+u===d?o:void 0}function Fv(s,e,t){const n=s.parent,i=n.parent,o=i.getChildIndex(n);if(e=="down"&&o===t.getRows(i)-1||e=="up"&&o===0)return null;const r=parseInt(s.getAttribute("rowspan")||"1"),a=i.getAttribute("headingRows")||0,l=e=="down"&&o+r===a,c=e=="up"&&o===a;if(a&&(l||c))return null;const d=parseInt(s.getAttribute("rowspan")||"1"),u=e=="down"?o+d:o,h=[...new F(i,{endRow:u})],g=h.find(v=>v.cell===s).column,w=h.find(({row:v,cellHeight:C,column:k})=>k!==g?!1:e=="down"?v===u:u===v+C);return w&&w.cell?w.cell:null}function Lv(s,e,t){Na(s)||(Na(e)&&t.remove(t.createRangeIn(e)),t.move(t.createRangeIn(s),t.createPositionAt(e,"end"))),t.remove(s)}function Na(s){const e=s.getChild(0);return s.childCount==1&&e.is("element","paragraph")&&e.isEmpty}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zv extends x{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const i=n.findAncestor("table"),r=e.getRows(i)-1,a=e.getRowIndexes(t),l=a.first===0&&a.last===r;this.isEnabled=!l}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(n),o=n[0],r=o.findAncestor("table"),a=t.getCellLocation(o).column;e.change(l=>{const c=i.last-i.first+1;t.removeRows(r,{at:i.first,rows:c});const d=Hv(r,i.first,a,t.getRows(r));l.setSelection(l.createPositionAt(d,0))})}}function Hv(s,e,t,n){const i=s.getChild(Math.min(e,n-1));let o=i.getChild(0),r=0;for(const a of i.getChildren()){if(r>t)return o;o=a,r+=parseInt(a.getAttribute("colspan")||"1")}return o}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wv extends x{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const i=n.findAncestor("table"),o=e.getColumns(i),{first:r,last:a}=e.getColumnIndexes(t);this.isEnabled=a-r<o-1}else this.isEnabled=!1}execute(){const e=this.editor.plugins.get("TableUtils"),[t,n]=$v(this.editor.model.document.selection,e),i=t.parent.parent,o=[...new F(i)],r={first:o.find(l=>l.cell===t).column,last:o.find(l=>l.cell===n).column},a=Uv(o,t,n,r);this.editor.model.change(l=>{const c=r.last-r.first+1;e.removeColumns(i,{at:r.first,columns:c}),l.setSelection(l.createPositionAt(a,0))})}}function Uv(s,e,t,n){return parseInt(t.getAttribute("colspan")||"1")>1?t:e.previousSibling||t.nextSibling?t.nextSibling||e.previousSibling:n.first?s.reverse().find(({column:o})=>o<n.first).cell:s.reverse().find(({column:o})=>o>n.last).cell}function $v(s,e){const t=e.getSelectionAffectedTableCells(s),n=t[0],i=t.pop(),o=[n,i];return n.isBefore(i)?o:o.reverse()}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qv extends x{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),i=n.length>0;this.isEnabled=i,this.value=i&&n.every(o=>this._isInHeading(o,o.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,i=t.getSelectionAffectedTableCells(n.document.selection),o=i[0].findAncestor("table"),{first:r,last:a}=t.getRowIndexes(i),l=this.value?r:a+1,c=o.getAttribute("headingRows")||0;n.change(d=>{if(l){const u=l>c?c:0,h=Ed(o,l,u);for(const{cell:f}of h)Td(f,l,d)}Q("headingRows",l,o,d,0)})}_isInHeading(e,t){const n=parseInt(t.getAttribute("headingRows")||"0");return!!n&&e.parent.index<n}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jv extends x{refresh(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),i=n.length>0;this.isEnabled=i,this.value=i&&n.every(o=>us(t,o))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,i=t.getSelectionAffectedTableCells(n.document.selection),o=i[0].findAncestor("table"),{first:r,last:a}=t.getColumnIndexes(i),l=this.value?r:a+1;n.change(c=>{if(l){const d=Ad(o,l);for(const{cell:u,column:h}of d)Sd(u,h,l,c)}Q("headingColumns",l,o,c,0)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ce extends _{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,n=t.parent,i=n.getChildIndex(t),o=new F(n,{row:i});for(const{cell:r,row:a,column:l}of o)if(r===e)return{row:a,column:l};/* istanbul ignore next -- @preserve */}createTable(e,t){const n=e.createElement("table"),i=t.rows||2,o=t.columns||2;return Di(e,n,0,i,o),t.headingRows&&Q("headingRows",Math.min(t.headingRows,i),n,e,0),t.headingColumns&&Q("headingColumns",Math.min(t.headingColumns,o),n,e,0),n}insertRows(e,t={}){const n=this.editor.model,i=t.at||0,o=t.rows||1,r=t.copyStructureFromAbove!==void 0,a=t.copyStructureFromAbove?i-1:i,l=this.getRows(e),c=this.getColumns(e);if(i>l)throw new m("tableutils-insertrows-insert-out-of-range",this,{options:t});n.change(d=>{const u=e.getAttribute("headingRows")||0;if(u>i&&Q("headingRows",u+o,e,d,0),!r&&(i===0||i===l)){Di(d,e,i,o,c);return}const h=r?Math.max(i,a):i,f=new F(e,{endRow:h}),g=new Array(c).fill(1);for(const{row:w,column:v,cellHeight:C,cellWidth:k,cell:N}of f){const X=w+C-1,ue=w<i&&i<=X,T=w<=a&&a<=X;ue?(d.setAttribute("rowspan",C+o,N),g[v]=-k):r&&T&&(g[v]=k)}for(let w=0;w<o;w++){const v=d.createElement("tableRow");d.insert(v,e,i);for(let C=0;C<g.length;C++){const k=g[C],N=d.createPositionAt(v,"end");k>0&&Tt(d,N,k>1?{colspan:k}:void 0),C+=Math.abs(k)-1}}})}insertColumns(e,t={}){const n=this.editor.model,i=t.at||0,o=t.columns||1;n.change(r=>{const a=e.getAttribute("headingColumns");i<a&&r.setAttribute("headingColumns",a+o,e);const l=this.getColumns(e);if(i===0||l===i){for(const d of e.getChildren())d.is("element","tableRow")&&Nt(o,r,r.createPositionAt(d,i?"end":0));return}const c=new F(e,{column:i,includeAllSlots:!0});for(const d of c){const{row:u,cell:h,cellAnchorColumn:f,cellAnchorRow:g,cellWidth:w,cellHeight:v}=d;if(f<i){r.setAttribute("colspan",w+o,h);const C=g+v-1;for(let k=u;k<=C;k++)c.skipRow(k)}else Nt(o,r,d.getPositionBefore())}})}removeRows(e,t){const n=this.editor.model,i=t.rows||1,o=this.getRows(e),r=t.at,a=r+i-1;if(a>o-1)throw new m("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});n.change(l=>{const c={first:r,last:a},{cellsToMove:d,cellsToTrim:u}=Jv(e,c);if(d.size){const h=a+1;Qv(e,h,d,l)}for(let h=a;h>=r;h--)l.remove(e.getChild(h));for(const{rowspan:h,cell:f}of u)Q("rowspan",h,f,l);Gv(e,c,l),hs(e,this)||fs(e,this)})}removeColumns(e,t){const n=this.editor.model,i=t.at,o=t.columns||1,r=t.at+o-1;n.change(a=>{Kv(e,{first:i,last:r},a);for(let l=r;l>=i;l--)for(const{cell:c,column:d,cellWidth:u}of[...new F(e)])d<=l&&u>1&&d+u>l?Q("colspan",u-1,c,a):d===l&&a.remove(c);fs(e,this)||hs(e,this)})}splitCellVertically(e,t=2){const n=this.editor.model,o=e.parent.parent,r=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");n.change(l=>{if(a>1){const{newCellsSpan:c,updatedSpan:d}=Ba(a,t);Q("colspan",d,e,l);const u={};c>1&&(u.colspan=c),r>1&&(u.rowspan=r);const h=a>t?t-1:a-1;Nt(h,l,l.createPositionAfter(e),u)}if(a<t){const c=t-a,d=[...new F(o)],{column:u}=d.find(({cell:w})=>w===e),h=d.filter(({cell:w,cellWidth:v,column:C})=>{const k=w!==e&&C===u,N=C<u&&C+v>u;return k||N});for(const{cell:w,cellWidth:v}of h)l.setAttribute("colspan",v+c,w);const f={};r>1&&(f.rowspan=r),Nt(c,l,l.createPositionAfter(e),f);const g=o.getAttribute("headingColumns")||0;g>u&&Q("headingColumns",g+c,o,l)}})}splitCellHorizontally(e,t=2){const n=this.editor.model,i=e.parent,o=i.parent,r=o.getChildIndex(i),a=parseInt(e.getAttribute("rowspan")||"1"),l=parseInt(e.getAttribute("colspan")||"1");n.change(c=>{if(a>1){const d=[...new F(o,{startRow:r,endRow:r+a-1,includeAllSlots:!0})],{newCellsSpan:u,updatedSpan:h}=Ba(a,t);Q("rowspan",h,e,c);const{column:f}=d.find(({cell:w})=>w===e),g={};u>1&&(g.rowspan=u),l>1&&(g.colspan=l);for(const w of d){const{column:v,row:C}=w,k=C>=r+h,N=v===f,X=(C+r+h)%u===0;k&&N&&X&&Nt(1,c,w.getPositionBefore(),g)}}if(a<t){const d=t-a,u=[...new F(o,{startRow:0,endRow:r})];for(const{cell:g,cellHeight:w,row:v}of u)if(g!==e&&v+w>r){const C=w+d;c.setAttribute("rowspan",C,g)}const h={};l>1&&(h.colspan=l),Di(c,o,r+1,d,1,h);const f=o.getAttribute("headingRows")||0;f>r&&Q("headingRows",f+d,o,c)}})}getColumns(e){return[...e.getChild(0).getChildren()].reduce((n,i)=>{const o=parseInt(i.getAttribute("colspan")||"1");return n+o},0)}getRows(e){return Array.from(e.getChildren()).reduce((t,n)=>n.is("element","tableRow")?t+1:t,0)}createTableWalker(e,t={}){return new F(e,t)}getSelectedTableCells(e){const t=[];for(const n of this.sortRanges(e.getRanges())){const i=n.getContainedElement();i&&i.is("element","tableCell")&&t.push(i)}return t}getTableCellsContainingSelection(e){const t=[];for(const n of e.getRanges()){const i=n.start.findAncestor("tableCell");i&&t.push(i)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map(n=>n.parent.index);return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),i=[...new F(t)].filter(o=>e.includes(o.cell)).map(o=>o.column);return this._getFirstLastIndexesObject(i)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,n=new Set;let i=0;for(const r of e){const{row:a,column:l}=this.getCellLocation(r),c=parseInt(r.getAttribute("rowspan"))||1,d=parseInt(r.getAttribute("colspan"))||1;t.add(a),n.add(l),c>1&&t.add(a+c-1),d>1&&n.add(l+d-1),i+=c*d}return Zv(t,n)==i}sortRanges(e){return Array.from(e).sort(Yv)}_getFirstLastIndexesObject(e){const t=e.sort((o,r)=>o-r),n=t[0],i=t[t.length-1];return{first:n,last:i}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),n=this.getRowIndexes(e),i=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(n,i))return!1;const o=this.getColumnIndexes(e),r=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(o,r)}_areIndexesInSameSection({first:e,last:t},n){const i=e<n,o=t<n;return i===o}}function Di(s,e,t,n,i,o={}){for(let r=0;r<n;r++){const a=s.createElement("tableRow");s.insert(a,e,t),Nt(i,s,s.createPositionAt(a,"end"),o)}}function Nt(s,e,t,n={}){for(let i=0;i<s;i++)Tt(e,t,n)}function Ba(s,e){if(s<e)return{newCellsSpan:1,updatedSpan:1};const t=Math.floor(s/e),n=s-t*e+t;return{newCellsSpan:t,updatedSpan:n}}function Kv(s,e,t){const n=s.getAttribute("headingColumns")||0;if(n&&e.first<n){const i=Math.min(n-1,e.last)-e.first+1;t.setAttribute("headingColumns",n-i,s)}}function Gv(s,{first:e,last:t},n){const i=s.getAttribute("headingRows")||0;if(e<i){const o=t<i?i-(t-e+1):e;Q("headingRows",o,s,n,0)}}function Jv(s,{first:e,last:t}){const n=new Map,i=[];for(const{row:o,column:r,cellHeight:a,cell:l}of new F(s,{endRow:t})){const c=o+a-1;if(o>=e&&o<=t&&c>t){const h=t-o+1,f=a-h;n.set(r,{cell:l,rowspan:f})}if(o<e&&c>=e){let h;c>=t?h=t-e+1:h=c-e+1,i.push({cell:l,rowspan:a-h})}}return{cellsToMove:n,cellsToTrim:i}}function Qv(s,e,t,n){const o=[...new F(s,{includeAllSlots:!0,row:e})],r=s.getChild(e);let a;for(const{column:l,cell:c,isAnchor:d}of o)if(t.has(l)){const{cell:u,rowspan:h}=t.get(l),f=a?n.createPositionAfter(a):n.createPositionAt(r,0);n.move(n.createRangeOn(u),f),Q("rowspan",h,u,n),a=u}else d&&(a=c)}function Yv(s,e){const t=s.start,n=e.start;return t.isBefore(n)?-1:1}function Zv(s,e){const t=Array.from(s.values()),n=Array.from(e.values()),i=Math.max(...t),o=Math.min(...t),r=Math.max(...n),a=Math.min(...n);return(i-o+1)*(r-a+1)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xv extends x{refresh(){const e=this.editor.plugins.get(ce),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(ce);e.change(n=>{const i=t.getSelectedTableCells(e.document.selection),o=i.shift(),{mergeWidth:r,mergeHeight:a}=ty(o,i,t);Q("colspan",r,o,n),Q("rowspan",a,o,n);for(const c of i)ey(c,o,n);const l=o.findAncestor("table");Ys(l,t),n.setSelection(o,"in")})}}function ey(s,e,t){Fa(s)||(Fa(e)&&t.remove(t.createRangeIn(e)),t.move(t.createRangeIn(s),t.createPositionAt(e,"end"))),t.remove(s)}function Fa(s){const e=s.getChild(0);return s.childCount==1&&e.is("element","paragraph")&&e.isEmpty}function ty(s,e,t){let n=0,i=0;for(const c of e){const{row:d,column:u}=t.getCellLocation(c);n=La(c,u,n,"colspan"),i=La(c,d,i,"rowspan")}const{row:o,column:r}=t.getCellLocation(s),a=n-r,l=i-o;return{mergeWidth:a,mergeHeight:l}}function La(s,e,t,n){const i=parseInt(s.getAttribute(n)||"1");return Math.max(t,e+i)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ny extends x{constructor(e){super(e),this.affectsData=!1}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(n),o=n[0].findAncestor("table"),r=[];for(let a=i.first;a<=i.last;a++)for(const l of o.getChild(a).getChildren())r.push(e.createRangeOn(l));e.change(a=>{a.setSelection(r)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class iy extends x{constructor(e){super(e),this.affectsData=!1}refresh(){const t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=t.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),i=n[0],o=n.pop(),r=i.findAncestor("table"),a=e.getCellLocation(i),l=e.getCellLocation(o),c=Math.min(a.column,l.column),d=Math.max(a.column,l.column),u=[];for(const h of new F(r,{startColumn:c,endColumn:d}))u.push(t.createRangeOn(h.cell));t.change(h=>{h.setSelection(u)})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function sy(s){s.document.registerPostFixer(e=>oy(e,s))}function oy(s,e){const t=e.document.differ.getChanges();let n=!1;const i=new Set;for(const o of t){let r=null;o.type=="insert"&&o.name=="table"&&(r=o.position.nodeAfter),(o.type=="insert"||o.type=="remove")&&(o.name=="tableRow"||o.name=="tableCell")&&(r=o.position.findAncestor("table")),dy(o)&&(r=o.range.start.findAncestor("table")),r&&!i.has(r)&&(n=ry(r,s)||n,n=ay(r,s)||n,i.add(r))}return n}function ry(s,e){let t=!1;const n=ly(s);if(n.length){t=!0;for(const i of n)Q("rowspan",i.rowspan,i.cell,e,1)}return t}function ay(s,e){let t=!1;const n=cy(s),i=[];for(const[l,c]of n.entries())!c&&s.getChild(l).is("element","tableRow")&&i.push(l);if(i.length){t=!0;for(const l of i.reverse())e.remove(s.getChild(l)),n.splice(l,1)}const o=n.filter((l,c)=>s.getChild(c).is("element","tableRow")),r=o[0];if(!o.every(l=>l===r)){const l=o.reduce((c,d)=>d>c?d:c,0);for(const[c,d]of o.entries()){const u=l-d;if(u){for(let h=0;h<u;h++)Tt(e,e.createPositionAt(s.getChild(c),"end"));t=!0}}}return t}function ly(s){const e=parseInt(s.getAttribute("headingRows")||"0"),t=Array.from(s.getChildren()).reduce((i,o)=>o.is("element","tableRow")?i+1:i,0),n=[];for(const{row:i,cell:o,cellHeight:r}of new F(s)){if(r<2)continue;const l=i<e?e:t;if(i+r>l){const c=l-i;n.push({cell:o,rowspan:c})}}return n}function cy(s){const e=new Array(s.childCount).fill(0);for(const{rowIndex:t}of new F(s,{includeAllSlots:!0}))e[t]++;return e}function dy(s){if(s.type!=="attribute")return!1;const e=s.attributeKey;return e==="headingRows"||e==="colspan"||e==="rowspan"}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function uy(s){s.document.registerPostFixer(e=>hy(e,s))}function hy(s,e){const t=e.document.differ.getChanges();let n=!1;for(const i of t)i.type=="insert"&&i.name=="table"&&(n=fy(i.position.nodeAfter,s)||n),i.type=="insert"&&i.name=="tableRow"&&(n=Rd(i.position.nodeAfter,s)||n),i.type=="insert"&&i.name=="tableCell"&&(n=ms(i.position.nodeAfter,s)||n),(i.type=="remove"||i.type=="insert")&&my(i)&&(n=ms(i.position.parent,s)||n);return n}function fy(s,e){let t=!1;for(const n of s.getChildren())n.is("element","tableRow")&&(t=Rd(n,e)||t);return t}function Rd(s,e){let t=!1;for(const n of s.getChildren())t=ms(n,e)||t;return t}function ms(s,e){if(s.childCount==0)return e.insertElement("paragraph",s),!0;const t=Array.from(s.getChildren()).filter(n=>n.is("$text"));for(const n of t)e.wrap(e.createRangeOn(n),"paragraph");return!!t.length}function my(s){return s.position.parent.is("element","tableCell")?s.type=="insert"&&s.name=="$text"||s.type=="remove":!1}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function gy(s,e){const t=s.document.differ;for(const n of t.getChanges()){let i,o=!1;if(n.type=="attribute"){const c=n.range.start.nodeAfter;if(!c||!c.is("element","table")||n.attributeKey!="headingRows"&&n.attributeKey!="headingColumns")continue;i=c,o=n.attributeKey=="headingRows"}else(n.name=="tableRow"||n.name=="tableCell")&&(i=n.position.findAncestor("table"),o=n.name=="tableRow");if(!i)continue;const r=i.getAttribute("headingRows")||0,a=i.getAttribute("headingColumns")||0,l=new F(i);for(const c of l){const u=c.row<r||c.column<a?"th":"td",h=e.mapper.toViewElement(c.cell);h&&h.is("element")&&h.name!=u&&e.reconvertItem(o?c.cell.parent:c.cell)}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function py(s,e){const t=s.document.differ,n=new Set;for(const i of t.getChanges()){const o=i.type=="attribute"?i.range.start.parent:i.position.parent;o.is("element","tableCell")&&n.add(o)}for(const i of n.values()){const o=Array.from(i.getChildren()).filter(r=>wy(r,e.mapper));for(const r of o)e.reconvertItem(r)}}function wy(s,e){if(!s.is("element","paragraph"))return!1;const t=e.toViewElement(s);return t?Cd(s)!==t.is("element","span"):!1}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class by extends _{static get pluginName(){return"TableEditing"}static get requires(){return[ce]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,n=t.schema,i=e.conversion,o=e.plugins.get(ce);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),n.register("tableRow",{allowIn:"table",isLimit:!0}),n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),i.for("upcast").add(Ev()),i.for("upcast").add(Tv()),i.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Ia(o,{asWidget:!0,additionalSlots:this._additionalSlots})}),i.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Ia(o,{additionalSlots:this._additionalSlots})}),i.for("upcast").elementToElement({model:"tableRow",view:"tr"}),i.for("upcast").add(Av()),i.for("downcast").elementToElement({model:"tableRow",view:Rv()}),i.for("upcast").elementToElement({model:"tableCell",view:"td"}),i.for("upcast").elementToElement({model:"tableCell",view:"th"}),i.for("upcast").add(xa("td")),i.for("upcast").add(xa("th")),i.for("editingDowncast").elementToElement({model:"tableCell",view:Ra({asWidget:!0})}),i.for("dataDowncast").elementToElement({model:"tableCell",view:Ra()}),i.for("editingDowncast").elementToElement({model:"paragraph",view:Ma({asWidget:!0}),converterPriority:"high"}),i.for("dataDowncast").elementToElement({model:"paragraph",view:Ma(),converterPriority:"high"}),i.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),i.for("upcast").attributeToAttribute({model:{key:"colspan",value:za("colspan")},view:"colspan"}),i.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),i.for("upcast").attributeToAttribute({model:{key:"rowspan",value:za("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new Ov(e)),e.commands.add("insertTableRowAbove",new Va(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Va(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new Oa(e,{order:"left"})),e.commands.add("insertTableColumnRight",new Oa(e,{order:"right"})),e.commands.add("removeTableRow",new zv(e)),e.commands.add("removeTableColumn",new Wv(e)),e.commands.add("splitTableCellVertically",new Da(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Da(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new Xv(e)),e.commands.add("mergeTableCellRight",new Sn(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new Sn(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new Sn(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new Sn(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new jv(e)),e.commands.add("setTableRowHeader",new qv(e)),e.commands.add("selectTableRow",new ny(e)),e.commands.add("selectTableColumn",new iy(e)),sy(t),uy(t),this.listenTo(t.document,"change:data",()=>{gy(t,e.editing),py(t,e.editing)})}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function za(s){return e=>{const t=parseInt(e.getAttribute(s));return Number.isNaN(t)||t<=0?null:t}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _y extends I{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new Be,this.focusTracker=new ve,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(n,i)=>`${i} × ${n}`),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to(n=>{n.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(n,i)=>{const{row:o,column:r}=i.target.dataset;this.items.get((parseInt(o,10)-1)*10+(parseInt(r,10)-1)).focus()}),this.focusTracker.on("change:focusedElement",(n,i,o)=>{if(!o)return;const{row:r,column:a}=o.dataset;this.set({rows:parseInt(r),columns:parseInt(a)})}),this.on("change:columns",()=>this._highlightGridBoxes()),this.on("change:rows",()=>this._highlightGridBoxes())}render(){super.render(),hp({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map((n,i)=>{const o=Math.floor(i/10),r=i%10,a=o<e&&r<t;n.set("isOn",a)})}_createGridButton(e,t,n,i){const o=new W(e);return o.set({label:i,class:"ck-insert-table-dropdown-grid-box"}),o.extendTemplate({attributes:{"data-row":t,"data-column":n}}),o}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const n=Math.floor(t/10),i=t%10,o=`${n+1} × ${i+1}`;e.push(this._createGridButton(this.locale,n+1,i+1,o))}return this.createCollection(e)}}const vy='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 6v3h4V6H3zm0 4v3h4v-3H3zm0 4v3h4v-3H3zm5 3h4v-3H8v3zm5 0h4v-3h-4v3zm4-4v-3h-4v3h4zm0-4V6h-4v3h4zm1.5 8a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 17V4c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5v13zM12 13v-3H8v3h4zm0-4V6H8v3h4z"/></svg>',yy='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M18 7v1H2V7h16zm0 5v1H2v-1h16z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1zm-2 1H8v4h4V2zm0 6H8v4h4V8zm0 6H8v4h4v-4z"/></svg>',Cy='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v16h-1V2z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1 2v4h4V8H2zm6 0v4h4V8H8zm6 0v4h4V8h-4z"/></svg>',ky='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ey extends _{static get pluginName(){return"TableUI"}init(){const e=this.editor,t=this.editor.t,i=e.locale.contentLanguageDirection==="ltr";e.ui.componentFactory.add("insertTable",o=>{const r=e.commands.get("insertTable"),a=qe(o);a.bind("isEnabled").to(r),a.buttonView.set({icon:vy,label:t("Insert table"),tooltip:!0});let l;return a.on("change:isOpen",()=>{l||(l=new _y(o),a.panelView.children.add(l),l.delegate("execute").to(a),a.on("execute",()=>{e.execute("insertTable",{rows:l.rows,columns:l.columns}),e.editing.view.focus()}))}),a}),e.ui.componentFactory.add("tableColumn",o=>{const r=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:i?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:i?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),yy,r,o)}),e.ui.componentFactory.add("tableRow",o=>{const r=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),Cy,r,o)}),e.ui.componentFactory.add("mergeTableCells",o=>{const r=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:i?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:i?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),ky,r,o)})}_prepareDropdown(e,t,n,i){const o=this.editor,r=qe(i),a=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(a,"isEnabled",(...l)=>l.some(c=>c)),this.listenTo(r,"execute",l=>{o.execute(l.source.commandName),l.source instanceof si||o.editing.view.focus()}),r}_prepareMergeSplitButtonDropdown(e,t,n,i){const o=this.editor,r=qe(i,zs),a="mergeTableCells",l=o.commands.get(a),c=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([l,...c],"isEnabled",(...d)=>d.some(u=>u)),this.listenTo(r.buttonView,"execute",()=>{o.execute(a),o.editing.view.focus()}),this.listenTo(r,"execute",d=>{o.execute(d.source.commandName),o.editing.view.focus()}),r}_fillDropdownWithListOptions(e,t){const n=this.editor,i=[],o=new _e;for(const r of t)Ty(r,n,i,o);return Ws(e,o),i}}function Ty(s,e,t,n){if(s.type==="button"||s.type==="switchbutton"){const i=s.model=new $s(s.model),{commandName:o,bindIsOn:r}=s.model,a=e.commands.get(o);t.push(a),i.set({commandName:o}),i.bind("isEnabled").to(a),r&&i.bind("isOn").to(a,"value"),i.set({withText:!0})}n.add(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bt extends _{static get pluginName(){return"TableSelection"}static get requires(){return[ce,ce]}init(){const e=this.editor,t=e.model,n=e.editing.view;this.listenTo(t,"deleteContent",(i,o)=>this._handleDeleteContent(i,o),{priority:"high"}),this.listenTo(n.document,"insertText",(i,o)=>this._handleInsertTextEvent(i,o),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(ce),t=this.editor.model.document.selection,n=e.getSelectedTableCells(t);return n.length==0?null:n}getSelectionAsFragment(){const e=this.editor.plugins.get(ce),t=this.getSelectedTableCells();return t?this.editor.model.change(n=>{const i=n.createDocumentFragment(),{first:o,last:r}=e.getColumnIndexes(t),{first:a,last:l}=e.getRowIndexes(t),c=t[0].findAncestor("table");let d=l,u=r;if(e.isSelectionRectangular(t)){const g={firstColumn:o,lastColumn:r,firstRow:a,lastRow:l};d=xd(c,g),u=Id(c,g)}const f=kd(c,{startRow:a,startColumn:o,endRow:d,endColumn:u},n);return n.insert(f,i,0),i}):null}setCellSelection(e,t){const n=this._getCellsToSelect(e,t);this.editor.model.change(i=>{i.setSelection(n.cells.map(o=>i.createRangeOn(o)),{backward:n.backward})})}getFocusCell(){const n=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return n&&n.is("element","tableCell")?n:null}getAnchorCell(){const e=this.editor.model.document.selection,n=ne(e.getRanges()).getContainedElement();return n&&n.is("element","tableCell")?n:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(i=>i.on("selection",(o,r,a)=>{const l=a.writer;n(l);const c=this.getSelectedTableCells();if(!c)return;for(const u of c){const h=a.mapper.toViewElement(u);l.addClass("ck-editor__editable_selected",h),t.add(h)}const d=a.mapper.toViewElement(c[c.length-1]);l.setSelection(d,0)},{priority:"lowest"}));function n(i){for(const o of t)i.removeClass("ck-editor__editable_selected",o);t.clear()}}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change(n=>{const i=n.createPositionAt(t[0],0),o=e.model.schema.getNearestSelectionRange(i);n.setSelection(o)})}})}_handleDeleteContent(e,t){const n=this.editor.plugins.get(ce),i=t[0],o=t[1],r=this.editor.model,a=!o||o.direction=="backward",l=n.getSelectedTableCells(i);l.length&&(e.stop(),r.change(c=>{const d=l[a?l.length-1:0];r.change(h=>{for(const f of l)r.deleteContent(h.createSelection(f,"in"))});const u=r.schema.getNearestSelectionRange(c.createPositionAt(d,0));i.is("documentSelection")?c.setSelection(u):i.setTo(u)}))}_handleInsertTextEvent(e,t){const n=this.editor,i=this.getSelectedTableCells();if(!i)return;const o=n.editing.view,r=n.editing.mapper,a=i.map(l=>o.createRangeOn(r.toViewElement(l)));t.selection=o.createSelection(a)}_getCellsToSelect(e,t){const n=this.editor.plugins.get("TableUtils"),i=n.getCellLocation(e),o=n.getCellLocation(t),r=Math.min(i.row,o.row),a=Math.max(i.row,o.row),l=Math.min(i.column,o.column),c=Math.max(i.column,o.column),d=new Array(a-r+1).fill(null).map(()=>[]),u={startRow:r,endRow:a,startColumn:l,endColumn:c};for(const{row:g,cell:w}of new F(e.findAncestor("table"),u))d[g-r].push(w);const h=o.row<i.row,f=o.column<i.column;return h&&d.reverse(),f&&d.forEach(g=>g.reverse()),{cells:d.flat(),backward:h||f}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ay extends _{static get pluginName(){return"TableClipboard"}static get requires(){return[bt,ce]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",(n,i)=>this._onCopyCut(n,i)),this.listenTo(t,"cut",(n,i)=>this._onCopyCut(n,i)),this.listenTo(e.model,"insertContent",(n,[i,o])=>this._onInsertContent(n,i,o),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const n=this.editor.plugins.get(bt);if(!n.getSelectedTableCells()||e.name=="cut"&&!this.editor.model.canEditAt(this.editor.model.document.selection))return;t.preventDefault(),e.stop();const i=this.editor.data,o=this.editor.editing.view.document,r=i.toView(n.getSelectionAsFragment());o.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,n){if(n&&!n.is("documentSelection"))return;const i=this.editor.model,o=this.editor.plugins.get(ce);let r=this.getTableIfOnlyTableInContent(t,i);if(!r)return;const a=o.getSelectionAffectedTableCells(i.document.selection);if(!a.length){Ys(r,o);return}e.stop(),i.change(l=>{const c={width:o.getColumns(r),height:o.getRows(r)},d=Sy(a,c,l,o),u=d.lastRow-d.firstRow+1,h=d.lastColumn-d.firstColumn+1,f={startRow:0,startColumn:0,endRow:Math.min(u,c.height)-1,endColumn:Math.min(h,c.width)-1};r=kd(r,f,l);const g=a[0].findAncestor("table"),w=this._replaceSelectedCellsWithPasted(r,c,g,d,l);if(this.editor.plugins.get("TableSelection").isEnabled){const v=o.sortRanges(w.map(C=>l.createRangeOn(C)));l.setSelection(v)}else l.setSelection(w[0],0)})}_replaceSelectedCellsWithPasted(e,t,n,i,o){const{width:r,height:a}=t,l=xy(e,r,a),c=[...new F(n,{startRow:i.firstRow,endRow:i.lastRow,startColumn:i.firstColumn,endColumn:i.lastColumn,includeAllSlots:!0})],d=[];let u;for(const v of c){const{row:C,column:k}=v;k===i.firstColumn&&(u=v.getPositionBefore());const N=C-i.firstRow,X=k-i.firstColumn,ue=l[N%a][X%r],T=ue?o.cloneElement(ue):null,R=this._replaceTableSlotCell(v,T,u,o);R&&(Pd(R,C,k,i.lastRow,i.lastColumn,o),d.push(R),u=o.createPositionAfter(R))}const h=parseInt(n.getAttribute("headingRows")||"0"),f=parseInt(n.getAttribute("headingColumns")||"0"),g=i.firstRow<h&&h<=i.lastRow,w=i.firstColumn<f&&f<=i.lastColumn;if(g){const v={first:i.firstColumn,last:i.lastColumn},C=gs(n,h,v,o,i.firstRow);d.push(...C)}if(w){const v={first:i.firstRow,last:i.lastRow},C=ps(n,f,v,o);d.push(...C)}return d}_replaceTableSlotCell(e,t,n,i){const{cell:o,isAnchor:r}=e;return r&&i.remove(o),t?(i.insert(t,n),t):null}getTableIfOnlyTableInContent(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(e.childCount==1&&e.getChild(0).is("element","table"))return e.getChild(0);const n=t.createRangeIn(e);for(const i of n.getItems())if(i.is("element","table")){const o=t.createRange(n.start,t.createPositionBefore(i));if(t.hasContent(o,{ignoreWhitespaces:!0}))return null;const r=t.createRange(t.createPositionAfter(i),n.end);return t.hasContent(r,{ignoreWhitespaces:!0})?null:i}return null}}function Sy(s,e,t,n){const i=s[0].findAncestor("table"),o=n.getColumnIndexes(s),r=n.getRowIndexes(s),a={firstColumn:o.first,lastColumn:o.last,firstRow:r.first,lastRow:r.last},l=s.length===1;return l&&(a.lastRow+=e.height-1,a.lastColumn+=e.width-1,Py(i,a.lastRow+1,a.lastColumn+1,n)),l||!n.isSelectionRectangular(s)?Iy(i,a,t):(a.lastRow=xd(i,a),a.lastColumn=Id(i,a)),a}function Py(s,e,t,n){const i=n.getColumns(s),o=n.getRows(s);t>i&&n.insertColumns(s,{at:i,columns:t-i}),e>o&&n.insertRows(s,{at:o,rows:e-o})}function xy(s,e,t){const n=new Array(t).fill(null).map(()=>new Array(e).fill(null));for(const{column:i,row:o,cell:r}of new F(s))n[o][i]=r;return n}function Iy(s,e,t){const{firstRow:n,lastRow:i,firstColumn:o,lastColumn:r}=e,a={first:n,last:i},l={first:o,last:r};ps(s,o,a,t),ps(s,r+1,a,t),gs(s,n,l,t),gs(s,i+1,l,t,n)}function gs(s,e,t,n,i=0){return e<1?void 0:Ed(s,e,i).filter(({column:a,cellWidth:l})=>Md(a,l,t)).map(({cell:a})=>Td(a,e,n))}function ps(s,e,t,n){return e<1?void 0:Ad(s,e).filter(({row:r,cellHeight:a})=>Md(r,a,t)).map(({cell:r,column:a})=>Sd(r,a,e,n))}function Md(s,e,t){const n=s+e-1,{first:i,last:o}=t,r=s>=i&&s<=o,a=s<i&&n>=i;return r||a}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ry extends _{static get pluginName(){return"TableKeyboard"}static get requires(){return[bt,ce]}init(){const t=this.editor.editing.view.document;this.listenTo(t,"arrowKey",(...n)=>this._onArrowKey(...n),{context:"table"}),this.listenTo(t,"tab",(...n)=>this._handleTabOnSelectedTable(...n),{context:"figure"}),this.listenTo(t,"tab",(...n)=>this._handleTab(...n),{context:["th","td"]})}_handleTabOnSelectedTable(e,t){const n=this.editor,o=n.model.document.selection.getSelectedElement();!o||!o.is("element","table")||(t.preventDefault(),t.stopPropagation(),e.stop(),n.model.change(r=>{r.setSelection(r.createRangeIn(o.getChild(0).getChild(0)))}))}_handleTab(e,t){const n=this.editor,i=this.editor.plugins.get(ce),o=this.editor.plugins.get("TableSelection"),r=n.model.document.selection,a=!t.shiftKey;let l=i.getTableCellsContainingSelection(r)[0];if(l||(l=o.getFocusCell()),!l)return;t.preventDefault(),t.stopPropagation(),e.stop();const c=l.parent,d=c.parent,u=d.getChildIndex(c),h=c.getChildIndex(l),f=h===0;if(!a&&f&&u===0){n.model.change(C=>{C.setSelection(C.createRangeOn(d))});return}const g=h===c.childCount-1,w=u===i.getRows(d)-1;if(a&&w&&g&&(n.execute("insertTableRowBelow"),u===i.getRows(d)-1)){n.model.change(C=>{C.setSelection(C.createRangeOn(d))});return}let v;if(a&&g)v=d.getChild(u+1).getChild(0);else if(!a&&f){const C=d.getChild(u-1);v=C.getChild(C.childCount-1)}else v=c.getChild(h+(a?1:-1));n.model.change(C=>{C.setSelection(C.createRangeIn(v))})}_onArrowKey(e,t){const n=this.editor,i=t.keyCode,o=ys(i,n.locale.contentLanguageDirection);this._handleArrowKeys(o,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const n=this.editor.plugins.get(ce),i=this.editor.plugins.get("TableSelection"),o=this.editor.model,r=o.document.selection,a=["right","down"].includes(e),l=n.getSelectedTableCells(r);if(l.length){let d;return t?d=i.getFocusCell():d=a?l[l.length-1]:l[0],this._navigateFromCellInDirection(d,e,t),!0}const c=r.focus.findAncestor("tableCell");/* istanbul ignore if: paranoid check -- @preserve */if(!c)return!1;if(!r.isCollapsed)if(t){if(r.isBackward==a&&!r.containsEntireContent(c))return!1}else{const d=r.getSelectedElement();if(!d||!o.schema.isObject(d))return!1}return this._isSelectionAtCellEdge(r,c,a)?(this._navigateFromCellInDirection(c,e,t),!0):!1}_isSelectionAtCellEdge(e,t,n){const i=this.editor.model,o=this.editor.model.schema,r=n?e.getLastPosition():e.getFirstPosition();if(!o.getLimitElement(r).is("element","tableCell"))return i.createPositionAt(t,n?"end":0).isTouching(r);const a=i.createSelection(r);return i.modifySelection(a,{direction:n?"forward":"backward"}),r.isEqual(a.focus)}_navigateFromCellInDirection(e,t,n=!1){const i=this.editor.model,o=e.findAncestor("table"),r=[...new F(o,{includeAllSlots:!0})],{row:a,column:l}=r[r.length-1],c=r.find(({cell:k})=>k==e);let{row:d,column:u}=c;switch(t){case"left":u--;break;case"up":d--;break;case"right":u+=c.cellWidth;break;case"down":d+=c.cellHeight;break}const h=d<0||d>a,f=u<0&&d<=0,g=u>l&&d>=a;if(h||f||g){i.change(k=>{k.setSelection(k.createRangeOn(o))});return}u<0?(u=n?0:l,d--):u>l&&(u=n?l:0,d++);const w=r.find(k=>k.row==d&&k.column==u).cell,v=["right","down"].includes(t),C=this.editor.plugins.get("TableSelection");if(n&&C.isEnabled){const k=C.getAnchorCell()||e;C.setCellSelection(k,w)}else{const k=i.createPositionAt(w,v?0:"end");i.change(N=>{N.setSelection(k)})}}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class My extends st{constructor(){super(...arguments),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Vy extends _{static get pluginName(){return"TableMouse"}static get requires(){return[bt,ce]}init(){this.editor.editing.view.addObserver(My),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(ce);let n=!1;const i=e.plugins.get(bt);this.listenTo(e.editing.view.document,"mousedown",(o,r)=>{const a=e.model.document.selection;if(!this.isEnabled||!i.isEnabled||!r.domEvent.shiftKey)return;const l=i.getAnchorCell()||t.getTableCellsContainingSelection(a)[0];if(!l)return;const c=this._getModelTableCellFromDomEvent(r);c&&Ha(l,c)&&(n=!0,i.setCellSelection(l,c),r.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{n=!1}),this.listenTo(e.editing.view.document,"selectionChange",o=>{n&&o.stop()},{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,n,i=!1,o=!1;const r=e.plugins.get(bt);this.listenTo(e.editing.view.document,"mousedown",(a,l)=>{!this.isEnabled||!r.isEnabled||l.domEvent.shiftKey||l.domEvent.ctrlKey||l.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(l))}),this.listenTo(e.editing.view.document,"mousemove",(a,l)=>{if(!l.domEvent.buttons||!t)return;const c=this._getModelTableCellFromDomEvent(l);c&&Ha(t,c)&&(n=c,!i&&n!=t&&(i=!0)),i&&(o=!0,r.setCellSelection(t,n),l.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{i=!1,o=!1,t=null,n=null}),this.listenTo(e.editing.view.document,"selectionChange",a=>{o&&a.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,n=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function Ha(s,e){return s.parent.parent==e.parent.parent}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class IC extends _{static get requires(){return[by,Ey,bt,Vy,Ry,Ay,fn]}static get pluginName(){return"Table"}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Oy(s){const e=s.getSelectedElement();return e&&Vd(e)?e:null}function Dy(s){const e=s.getFirstPosition();if(!e)return null;let t=e.parent;for(;t;){if(t.is("element")&&Vd(t))return t;t=t.parent}return null}function Vd(s){return!!s.getCustomProperty("table")&&G(s)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class RC extends _{static get requires(){return[jn]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,n=e.plugins.get(jn),i=e.config.get("table.contentToolbar"),o=e.config.get("table.tableToolbar");i&&n.register("tableContent",{ariaLabel:t("Table toolbar"),items:i,getRelatedElement:Dy}),o&&n.register("table",{ariaLabel:t("Table toolbar"),items:o,getRelatedElement:Oy})}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Ny={autoRefresh:!0},Wa=36e5;class Zs extends D(){constructor(e,t={}){if(super(),!e)throw new m("token-missing-token-url",this);t.initValue&&this._validateTokenValue(t.initValue),this.set("value",t.initValue),typeof e=="function"?this._refresh=e:this._refresh=()=>By(e),this._options={...Ny,...t}}init(){return new Promise((e,t)=>{if(!this.value){this.refreshToken().then(e).catch(t);return}this._options.autoRefresh&&this._registerRefreshTokenTimeout(),e(this)})}refreshToken(){return this._refresh().then(e=>(this._validateTokenValue(e),this.set("value",e),this._options.autoRefresh&&this._registerRefreshTokenTimeout(),this))}destroy(){clearTimeout(this._tokenRefreshTimeout)}_validateTokenValue(e){const t=typeof e=="string",n=!/^".*"$/.test(e),i=t&&e.split(".").length===3;if(!(n&&i))throw new m("token-not-in-jwt-format",this)}_registerRefreshTokenTimeout(){const e=this._getTokenRefreshTimeoutTime();clearTimeout(this._tokenRefreshTimeout),this._tokenRefreshTimeout=setTimeout(()=>{this.refreshToken()},e)}_getTokenRefreshTimeoutTime(){try{const[,e]=this.value.split("."),{exp:t}=JSON.parse(atob(e));return t?Math.floor((t*1e3-Date.now())/2):Wa}catch{return Wa}}static create(e,t={}){return new Zs(e,t).init()}}function By(s){return new Promise((e,t)=>{const n=new XMLHttpRequest;n.open("GET",s),n.addEventListener("load",()=>{const i=n.status,o=n.response;return i<200||i>299?t(new m("token-cannot-download-new-token",null)):e(o)}),n.addEventListener("error",()=>t(new Error("Network Error"))),n.addEventListener("abort",()=>t(new Error("Abort"))),n.send()})}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const ws=/^data:(\S*?);base64,/;class Fy extends H(){constructor(e,t,n){if(super(),!e)throw new m("fileuploader-missing-file",null);if(!t)throw new m("fileuploader-missing-token",null);if(!n)throw new m("fileuploader-missing-api-address",null);this.file=zy(e)?Ly(e):e,this._token=t,this._apiAddress=n}onProgress(e){return this.on("progress",(t,n)=>e(n)),this}onError(e){return this.once("error",(t,n)=>e(n)),this}abort(){this.xhr.abort()}send(){return this._prepareRequest(),this._attachXHRListeners(),this._sendRequest()}_prepareRequest(){const e=new XMLHttpRequest;e.open("POST",this._apiAddress),e.setRequestHeader("Authorization",this._token.value),e.responseType="json",this.xhr=e}_attachXHRListeners(){const e=this.xhr,t=n=>()=>this.fire("error",n);e.addEventListener("error",t("Network Error")),e.addEventListener("abort",t("Abort"));/* istanbul ignore else -- @preserve */e.upload&&e.upload.addEventListener("progress",n=>{n.lengthComputable&&this.fire("progress",{total:n.total,uploaded:n.loaded})}),e.addEventListener("load",()=>{const n=e.status,i=e.response;if(n<200||n>299)return this.fire("error",i.message||i.error)})}_sendRequest(){const e=new FormData,t=this.xhr;return e.append("file",this.file),new Promise((n,i)=>{t.addEventListener("load",()=>{const o=t.status,r=t.response;return o<200||o>299?r.message?i(new m("fileuploader-uploading-data-failed",this,{message:r.message})):i(r.error):n(r)}),t.addEventListener("error",()=>i(new Error("Network Error"))),t.addEventListener("abort",()=>i(new Error("Abort"))),t.send(e)})}}function Ly(s,e=512){try{const t=s.match(ws)[1],n=atob(s.replace(ws,"")),i=[];for(let o=0;o<n.length;o+=e){const r=n.slice(o,o+e),a=new Array(r.length);for(let l=0;l<r.length;l++)a[l]=r.charCodeAt(l);i.push(new Uint8Array(a))}return new Blob(i,{type:t})}catch{throw new m("fileuploader-decoding-image-data-error",null)}}function zy(s){if(typeof s!="string")return!1;const e=s.match(ws);return!!(e&&e.length)}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Hy{constructor(e,t){if(!e)throw new m("uploadgateway-missing-token",null);if(!t)throw new m("uploadgateway-missing-api-address",null);this._token=e,this._apiAddress=t}upload(e){return new Fy(e,this._token,this._apiAddress)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wy extends Zn{static get pluginName(){return"CloudServicesCore"}createToken(e,t){return new Zs(e,t)}createUploadGateway(e,t){return new Hy(e,t)}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class MC extends Zn{constructor(){super(...arguments),this.token=null,this._tokens=new Map}static get pluginName(){return"CloudServices"}static get requires(){return[Wy]}async init(){const t=this.context.config.get("cloudServices")||{};for(const[i,o]of Object.entries(t))this[i]=o;if(!this.tokenUrl){this.token=null;return}const n=this.context.plugins.get("CloudServicesCore");this.token=await n.createToken(this.tokenUrl).init(),this._tokens.set(this.tokenUrl,this.token)}async registerTokenUrl(e){if(this._tokens.has(e))return this.getTokenFor(e);const n=await this.context.plugins.get("CloudServicesCore").createToken(e).init();return this._tokens.set(e,n),n}getTokenFor(e){const t=this._tokens.get(e);if(!t)throw new m("cloudservices-token-not-registered",this);return t}destroy(){super.destroy();for(const e of this._tokens.values())e.destroy()}}/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Uy(s){const e=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"br",isVoid:!0},{name:"details",isVoid:!1},{name:"dialog",isVoid:!1},{name:"dd",isVoid:!1},{name:"div",isVoid:!1},{name:"dl",isVoid:!1},{name:"dt",isVoid:!1},{name:"fieldset",isVoid:!1},{name:"figcaption",isVoid:!1},{name:"figure",isVoid:!1},{name:"footer",isVoid:!1},{name:"form",isVoid:!1},{name:"h1",isVoid:!1},{name:"h2",isVoid:!1},{name:"h3",isVoid:!1},{name:"h4",isVoid:!1},{name:"h5",isVoid:!1},{name:"h6",isVoid:!1},{name:"header",isVoid:!1},{name:"hgroup",isVoid:!1},{name:"hr",isVoid:!0},{name:"input",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"textarea",isVoid:!1},{name:"th",isVoid:!1},{name:"thead",isVoid:!1},{name:"tr",isVoid:!1},{name:"ul",isVoid:!1}],t=e.map(o=>o.name).join("|"),n=s.replace(new RegExp(`</?(${t})( .*?)?>`,"g"),`
$&
`).split(`
`);let i=0;return n.filter(o=>o.length).map(o=>$y(o,e)?Ni(o,i++):qy(o,e)?Ni(o,--i):Ni(o,i)).join(`
`)}function $y(s,e){return e.some(t=>!(t.isVoid||!new RegExp(`<${t.name}( .*?)?>`).test(s)))}function qy(s,e){return e.some(t=>new RegExp(`</${t.name}>`).test(s))}function Ni(s,e,t="    "){return`${t.repeat(Math.max(0,e))}${s}`}const jy='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 0 5 4.5v15.003h-16V0h11zM3 1.5v3.25l-1.497 1-.003 8 1.5 1v3.254L7.685 18l-.001 1.504H17.5V8.002L16 9.428l-.004-4.22-4.222-3.692L3 1.5z"/><path d="M4.06 6.64a.75.75 0 0 1 .958 1.15l-.085.07L2.29 9.75l2.646 1.89c.302.216.4.62.232.951l-.058.095a.75.75 0 0 1-.951.232l-.095-.058-3.5-2.5V9.14l3.496-2.5zm4.194 6.22a.75.75 0 0 1-.958-1.149l.085-.07 2.643-1.89-2.646-1.89a.75.75 0 0 1-.232-.952l.058-.095a.75.75 0 0 1 .95-.232l.096.058 3.5 2.5v1.22l-3.496 2.5zm7.644-.836 2.122 2.122-5.825 5.809-2.125-.005.003-2.116zm2.539-1.847 1.414 1.414a.5.5 0 0 1 0 .707l-1.06 1.06-2.122-2.12 1.061-1.061a.5.5 0 0 1 .707 0z"/></svg>';/**
 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Ua="SourceEditingMode";class VC extends _{static get pluginName(){return"SourceEditing"}static get requires(){return[Hn]}constructor(e){super(e),this.set("isSourceEditingMode",!1),this._elementReplacer=new mu,this._replacedRoots=new Map,this._dataFromRoots=new Map}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("sourceEditing",n=>{const i=new W(n);return i.set({label:t("Source"),icon:jy,tooltip:!0,withText:!0,class:"ck-source-editing-button"}),i.bind("isOn").to(this,"isSourceEditingMode"),i.bind("isEnabled").to(this,"isEnabled",e,"isReadOnly",e.plugins.get(Hn),"hasAny",(o,r,a)=>!(!o||r||a)),this.listenTo(i,"execute",()=>{this.isSourceEditingMode=!this.isSourceEditingMode}),i}),this._isAllowedToHandleSourceEditingMode()&&(this.on("change:isSourceEditingMode",(n,i,o)=>{o?(this._showSourceEditing(),this._disableCommands()):(this._hideSourceEditing(),this._enableCommands())}),this.on("change:isEnabled",(n,i,o)=>this._handleReadOnlyMode(!o)),this.listenTo(e,"change:isReadOnly",(n,i,o)=>this._handleReadOnlyMode(o))),e.data.on("get",()=>{this.isSourceEditingMode&&this.updateEditorData()},{priority:"high"})}afterInit(){const e=this.editor;["RealTimeCollaborativeEditing","CommentsEditing","TrackChangesEditing","RevisionHistory"].some(n=>e.plugins.has(n))&&console.warn("You initialized the editor with the source editing feature and at least one of the collaboration features. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the collaboration features."),e.plugins.has("RestrictedEditingModeEditing")&&console.warn("You initialized the editor with the source editing feature and restricted editing feature. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the restricted editing feature.")}updateEditorData(){const e=this.editor,t={};for(const[n,i]of this._replacedRoots){const o=this._dataFromRoots.get(n),r=i.dataset.value;o!==r&&(t[n]=r)}Object.keys(t).length&&e.data.set(t,{batchType:{isUndoable:!0}})}_showSourceEditing(){const e=this.editor,t=e.editing.view,n=e.model;n.change(i=>{i.setSelection(null),i.removeSelectionAttribute(n.document.selection.getAttributeKeys())});for(const[i,o]of t.domRoots){const r=Ky(e.data.get({rootName:i})),a=zi(o.ownerDocument,"textarea",{rows:"1","aria-label":"Source code editing area"}),l=zi(o.ownerDocument,"div",{class:"ck-source-editing-area","data-value":r},[a]);a.value=r,a.setSelectionRange(0,0),a.addEventListener("input",()=>{l.dataset.value=a.value,e.ui.update()}),t.change(c=>{const d=t.document.getRoot(i);c.addClass("ck-hidden",d)}),e.ui.setEditableElement("sourceEditing:"+i,a),this._replacedRoots.set(i,l),this._elementReplacer.replace(o,l),this._dataFromRoots.set(i,r)}this._focusSourceEditing()}_hideSourceEditing(){const t=this.editor.editing.view;this.updateEditorData(),t.change(n=>{for(const[i]of this._replacedRoots)n.removeClass("ck-hidden",t.document.getRoot(i))}),this._elementReplacer.restore(),this._replacedRoots.clear(),this._dataFromRoots.clear(),t.focus()}_focusSourceEditing(){const e=this.editor,[t]=this._replacedRoots.values(),n=t.querySelector("textarea");e.editing.view.document.isFocused=!1,n.focus()}_disableCommands(){const e=this.editor;for(const t of e.commands.commands())t.forceDisabled(Ua)}_enableCommands(){const e=this.editor;for(const t of e.commands.commands())t.clearForceDisabled(Ua)}_handleReadOnlyMode(e){if(this.isSourceEditingMode)for(const[,t]of this._replacedRoots)t.querySelector("textarea").readOnly=e}_isAllowedToHandleSourceEditingMode(){const t=this.editor.ui.view.editable;return t&&!t.hasExternalElement}}function Ky(s){return Gy(s)?Uy(s):s}function Gy(s){return s.startsWith("<")}export{uC as A,W as B,x as C,qs as D,cC as E,bC as H,mC as I,AC as L,PC as M,_ as P,VC as S,IC as T,fn as W,dC as a,hC as b,fC as c,gC as d,pC as e,zc as f,MC as g,wC as h,_C as i,vC as j,yC as k,CC as l,kC as m,EC as n,md as o,_0 as p,TC as q,SC as r,xC as s,RC as t,lC as u};
