var W0=Object.defineProperty,j0=(n,e,t)=>e in n?W0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>j0(n,typeof e!="symbol"?e+"":e,t);function U0(n,e){for(var t=0;ti[o]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}function q0(n,e){const t={};for(let i=0;iObject.prototype.propertyIsEnumerable.call(n,e))}function Ar(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const cg="[object RegExp]",Bc="[object String]",Mc="[object Number]",Lc="[object Boolean]",xr="[object Arguments]",ug="[object Symbol]",hg="[object Date]",dg="[object Map]",mg="[object Set]",fg="[object Array]",G0="[object Function]",gg="[object ArrayBuffer]",cr="[object Object]",K0="[object Error]",pg="[object DataView]",wg="[object Uint8Array]",bg="[object Uint8ClampedArray]",_g="[object Uint16Array]",vg="[object Uint32Array]",Z0="[object BigUint64Array]",yg="[object Int8Array]",kg="[object Int16Array]",Cg="[object Int32Array]",J0="[object BigInt64Array]",Ag="[object Float32Array]",xg="[object Float64Array]";function Q0(n,e){return eo(n,void 0,n,new Map,e)}function eo(n,e,t,i=new Map,o=void 0){const s=o?.(n,e,t,i);if(s!=null)return s;if(Vc(n))return n;if(i.has(n))return i.get(n);if(Array.isArray(n)){const r=new Array(n.length);i.set(n,r);for(let a=0;aWo(d,f,void 0,n,e,t,i));if(m===-1)return!1;c.splice(m,1)}return!0}case fg:case wg:case bg:case _g:case vg:case Z0:case yg:case kg:case Cg:case J0:case Ag:case xg:{if(typeof Buffer<"u"&&Buffer.isBuffer(n)!==Buffer.isBuffer(e)||n.length!==e.length)return!1;for(let l=0;l=0}const e_=new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+","gu");function t_(n){return Array.from(n.match(e_)??[])}function i_(n){return n!=null&&typeof n!="function"&&X0(n.length)}function Sg(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}function Pg(n){return Object.is(n,-0)?"-0":n.toString()}function Fc(n){const e=[],t=n.length;if(t===0)return e;let i=0,o="",s="",r=!1;for(n.charCodeAt(0)===46&&(e.push(""),i++);i{const r=e?.(t,i,o,s);if(r!=null)return r;if(typeof n=="object")switch(Object.prototype.toString.call(n)){case Mc:case Bc:case Lc:{const a=new n.constructor(n?.valueOf());return gn(a,n),a}case xr:{const a={};return gn(a,n),a.length=n.length,a[Symbol.iterator]=n[Symbol.iterator],a}default:return}})}function mt(n){return Xr(n)}const s_=/^(?:0|[1-9]\d*)$/;function r_(n,e=Number.MAX_SAFE_INTEGER){switch(typeof n){case"number":return Number.isInteger(n)&&n>=0&&n{s!==null&&(n.apply(o,s),o=void 0,s=null)},c=()=>{a&&l(),f()};let u=null;const d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,c()},e)},m=()=>{u!==null&&(clearTimeout(u),u=null)},f=()=>{m(),o=void 0,s=null},g=()=>{m(),l()},p=function(..._){if(t!=null&&t.aborted)return;o=this,s=_;const v=u==null;d(),r&&v&&l()};return p.schedule=d,p.cancel=f,p.flush=g,t?.addEventListener("abort",f,{once:!0}),p}function St(n,e=0,t={}){typeof t!="object"&&(t={});const{signal:i,leading:o=!1,trailing:s=!0,maxWait:r}=t,a=Array(2);o&&(a[0]="leading"),s&&(a[1]="trailing");let l,c=null;const u=h_(function(...f){l=n.apply(this,f),c=null},e,{signal:i,edges:a}),d=function(...f){if(r!=null){if(c===null)c=Date.now();else if(Date.now()-c>=r)return l=n.apply(this,f),c=Date.now(),u.cancel(),u.schedule(),l}return u.apply(this,f),l},m=()=>(u.flush(),l);return d.cancel=u.cancel,d.flush=m,d}function co(n,e=0,t={}){typeof t!="object"&&(t={});const{leading:i=!0,trailing:o=!0,signal:s}=t;return St(n,e,{leading:i,trailing:o,signal:s,maxWait:e})}function ea(n){if(n==null)return"";if(Array.isArray(n))return n.map(ea).join(",");const e=String(n);return e==="0"&&Object.is(Number(n),-0)?"-0":e}function d_(n){return typeof Buffer<"u"&&Buffer.isBuffer(n)}function m_(n){const e=n?.constructor,t=typeof e=="function"?e.prototype:Object.prototype;return n===t}function Vg(n){return Rc(n)}function f_(n,e){if(n=u_(n),n<1||!Number.isSafeInteger(n))return[];const t=new Array(n);for(let i=0;ie!=="constructor")}function w_(n){const e=f_(n.length,i=>`${i}`),t=new Set(e);return d_(n)&&(t.add("offset"),t.add("parent")),Vg(n)&&(t.add("buffer"),t.add("byteLength"),t.add("byteOffset")),[...e,...Er(n).filter(i=>!t.has(i))]}function Rg(n,...e){for(let t=0;t{if(++t>=n)return e(...i)}}function Bg(n,e,t=kr){return typeof t!="function"&&(t=kr),Eg(n,e,(...i)=>{const o=t(...i);if(o!==void 0)return!!o;if(n instanceof Map&&e instanceof Map||n instanceof Set&&e instanceof Set)return Bg(Array.from(n),Array.from(e),y_(2,t))})}function k_(n){return typeof n!="string"&&(n=ea(n)),n.replace(/['\u2019]/g,"")}function C_(n){return n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}function ta(n){return C_(ea(n))}function A_(n){const e=t_(k_(n).trim());let t="";for(let i=0;i-1}function S_(n){return n.indexOf("windows")>-1}function P_(n){return!!n.match(/gecko\/\d+/)}function I_(n){return n.indexOf(" applewebkit/")>-1&&n.indexOf("chrome")===-1}function V_(n){return!!n.match(/iphone|ipad/i)||Mg(n)&&navigator.maxTouchPoints>0}function R_(n){return n.indexOf("android")>-1}function O_(n){return n.indexOf("chrome/")>-1&&n.indexOf("edge/")<0}function B_(){return I.window.matchMedia?I.window.matchMedia("(forced-colors: active)").matches:!1}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Lg(n,e,t,i){t=t||function(a,l){return a===l};const o=Array.isArray(n)?n:Array.prototype.slice.call(n),s=Array.isArray(e)?e:Array.prototype.slice.call(e),r=M_(o,s,t);return i?F_(r,s.length):L_(s,r)}function M_(n,e,t){const i=ih(n,e,t);if(i===-1)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const o=nh(n,i),s=nh(e,i),r=ih(o,s,t),a=n.length-r,l=e.length-r;return{firstIndex:i,lastIndexOld:a,lastIndexNew:l}}function ih(n,e,t){for(let i=0;i0&&t.push({index:i,type:"insert",values:n.slice(i,s)}),o-i>0&&t.push({index:i+(s-i),type:"delete",howMany:o-i}),t}function F_(n,e){const{firstIndex:t,lastIndexOld:i,lastIndexNew:o}=n;if(t===-1)return Array(e).fill("equal");let s=[];return t>0&&(s=s.concat(Array(t).fill("equal"))),o-t>0&&(s=s.concat(Array(o-t).fill("insert"))),i-t>0&&(s=s.concat(Array(i-t).fill("delete"))),o200||o>200||i+o>300)return oo.fastDiff(n,e,t,!0);let s,r;if(ov?-1:1;u[p+E]&&(u[p]=u[p+E].slice(0)),u[p]||(u[p]=[]),u[p].push(_>v?s:r);let M=Math.max(_,v),G=M-p;for(;Gc;g--)d[g]=m(g);d[c]=m(c),f++}while(d[c]!==l);return u[c].slice(1)}oo.fastDiff=Lg;/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function oh(){return function n(){n.called=!0}}class Ti{constructor(e,t){h(this,"source"),h(this,"name"),h(this,"path"),h(this,"stop"),h(this,"off"),h(this,"return"),this.source=e,this.name=t,this.path=[],this.stop=oh(),this.off=oh()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Qe=new Array(256).fill("").map((n,e)=>("0"+e.toString(16)).slice(-2));function ze(){const[n,e,t,i]=crypto.getRandomValues(new Uint32Array(4));return"e"+Qe[n>>0&255]+Qe[n>>8&255]+Qe[n>>16&255]+Qe[n>>24&255]+Qe[e>>0&255]+Qe[e>>8&255]+Qe[e>>16&255]+Qe[e>>24&255]+Qe[t>>0&255]+Qe[t>>8&255]+Qe[t>>16&255]+Qe[t>>24&255]+Qe[i>>0&255]+Qe[i>>8&255]+Qe[i>>16&255]+Qe[i>>24&255]}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const kt={get(n="normal"){return typeof n!="number"?this[n]||this.normal:n},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function Fg(n,e){const t=kt.get(e.priority);let i=0,o=n.length;for(;i>1;kt.get(n[s].priority){if(typeof r=="object"&&r!==null){if(t.has(r))return`[object ${r.constructor.name}]`;t.add(r)}return r})}`:"",o=Ng(n);return n+i+o}function Dg(n,e){const t=Ng(n);return e?[n,e,t]:[n,t]}const zg="45.2.0",H_=new Date(2025,5,4);/* istanbul ignore next -- @preserve */if(globalThis.CKEDITOR_VERSION)throw new b("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION=zg;const Gn=Symbol("listeningTo"),Ol=Symbol("emitterId"),fi=Symbol("delegations"),Hg=ge(Object);function ge(n){if(!n)return Hg;class e extends n{on(i,o,s){this.listenTo(this,i,o,s)}once(i,o,s){let r=!1;const a=(l,...c)=>{r||(r=!0,l.off(),o.call(this,l,...c))};this.listenTo(this,i,a,s)}off(i,o){this.stopListening(this,i,o)}listenTo(i,o,s,r={}){let a,l;this[Gn]||(this[Gn]={});const c=this[Gn];Sa(i)||$g(i);const u=Sa(i);(a=c[u])||(a=c[u]={emitter:i,callbacks:{}}),(l=a.callbacks[o])||(l=a.callbacks[o]=[]),l.push(s),q_(this,i,o,s,r)}stopListening(i,o,s){const r=this[Gn];let a=i&&Sa(i);const l=r&&a?r[a]:void 0,c=l&&o?l.callbacks[o]:void 0;if(!(!r||i&&!l||o&&!c))if(s)Pa(this,i,o,s),c.indexOf(s)!==-1&&(c.length===1?delete l.callbacks[o]:Pa(this,i,o,s));else if(c){for(;s=c.pop();)Pa(this,i,o,s);delete l.callbacks[o]}else if(l){for(o in l.callbacks)this.stopListening(i,o);delete r[a]}else{for(a in r)this.stopListening(r[a].emitter);delete this[Gn]}}fire(i,...o){try{const s=i instanceof Ti?i:new Ti(this,i),r=s.name;let a=U_(this,r);if(s.path.push(this),a){a=a.slice();for(let c=0;c{this[fi]||(this[fi]=new Map),i.forEach(r=>{const a=this[fi].get(r);a?a.set(o,s):this[fi].set(r,new Map([[o,s]]))})}}}stopDelegating(i,o){if(this[fi])if(!i)this[fi].clear();else if(!o)this[fi].delete(i);else{const s=this[fi].get(i);s&&s.delete(o)}}_addEventListener(i,o,s){j_(this,i);const r=Bl(this,i),a=kt.get(s.priority),l={callback:o,priority:a};for(const c of r)Fg(c,l)}_removeEventListener(i,o){const s=Bl(this,i);for(const r of s)for(let a=0;a{ge[n]=Hg.prototype[n]});function $_(n,e){const t=n[Gn];return t&&t[e]?t[e].emitter:null}function $g(n,e){n[Ol]||(n[Ol]=e||ze())}function Sa(n){return n[Ol]}function Wg(n){return n._events||Object.defineProperty(n,"_events",{value:{}}),n._events}function W_(){return{callbacks:[],childEvents:[]}}function j_(n,e){const t=Wg(n);if(t[e])return;let i=e,o=null;const s=[];for(;i!==""&&!t[i];)t[i]=W_(),s.push(t[i]),o&&t[i].childEvents.push(o),o=i,i=i.substr(0,i.lastIndexOf(":"));if(i!==""){for(const r of s)r.callbacks=t[i].callbacks.slice();t[i].childEvents.push(o)}}function Bl(n,e){const t=Wg(n)[e];if(!t)return[];let i=[t.callbacks];for(let o=0;o-1?t.substring(0,o):""}while(t);return null}function sh(n,e,t){for(let[i,o]of n){o?typeof o=="function"&&(o=o(e.name)):o=e.name;const s=new Ti(e.source,o);s.path=[...e.path],i.fire(s,...t)}}function q_(n,e,t,i,o){e._addEventListener?e._addEventListener(t,i,o):n._addEventListener.call(e,t,i,o)}function Pa(n,e,t,i){e._removeEventListener?e._removeEventListener(t,i):n._removeEventListener.call(e,t,i)}const Zo=Symbol("observableProperties"),as=Symbol("boundObservables"),Jo=Symbol("boundProperties"),rn=Symbol("decoratedMethods"),rh=Symbol("decoratedOriginal"),jg=ue(ge());function ue(n){var e,t,i,o,s;if(!n)return jg;class r extends(s=n,o=Zo,i=rn,t=Jo,e=as,s){constructor(){super(...arguments),h(this,o),h(this,i),h(this,t),h(this,e)}set(l,c){if(Et(l)){Object.keys(l).forEach(d=>{this.set(d,l[d])},this);return}Ia(this);const u=this[Zo];if(l in this&&!u.has(l))throw new b("observable-set-cannot-override",this);Object.defineProperty(this,l,{enumerable:!0,configurable:!0,get(){return u.get(l)},set(d){const m=u.get(l);let f=this.fire(`set:${l}`,l,d,m);f===void 0&&(f=d),(m!==f||!u.has(l))&&(u.set(l,f),this.fire(`change:${l}`,l,f,m))}}),this[l]=c}bind(...l){if(!l.length||!ah(l))throw new b("observable-bind-wrong-properties",this);if(new Set(l).size!==l.length)throw new b("observable-bind-duplicate-properties",this);Ia(this);const c=this[Jo];l.forEach(d=>{if(c.has(d))throw new b("observable-bind-rebind",this)});const u=new Map;return l.forEach(d=>{const m={property:d,to:[]};c.set(d,m),u.set(d,m)}),{to:G_,toMany:K_,_observable:this,_bindProperties:l,_to:[],_bindings:u}}unbind(...l){if(!this[Zo])return;const c=this[Jo],u=this[as];if(l.length){if(!ah(l))throw new b("observable-unbind-wrong-properties",this);l.forEach(d=>{const m=c.get(d);m&&(m.to.forEach(([f,g])=>{const p=u.get(f),_=p[g];_.delete(m),_.size||delete p[g],Object.keys(p).length||(u.delete(f),this.stopListening(f,"change"))}),c.delete(d))})}else u.forEach((d,m)=>{this.stopListening(m,"change")}),u.clear(),c.clear()}decorate(l){Ia(this);const c=this[l];if(!c)throw new b("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:l});this.on(l,(u,d)=>{u.return=c.apply(this,d)}),this[l]=function(...u){return this.fire(l,u)},this[l][rh]=c,this[rn]||(this[rn]=[]),this[rn].push(l)}stopListening(l,c,u){if(!l&&this[rn]){for(const d of this[rn])this[d]=this[d][rh];delete this[rn]}super.stopListening(l,c,u)}}return r}["set","bind","unbind","decorate","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(n=>{ue[n]=jg.prototype[n]});function Ia(n){n[Zo]||(Object.defineProperty(n,Zo,{value:new Map}),Object.defineProperty(n,as,{value:new Map}),Object.defineProperty(n,Jo,{value:new Map}))}function G_(...n){const e=J_(...n),t=Array.from(this._bindings.keys()),i=t.length;if(!e.callback&&e.to.length>1)throw new b("observable-bind-to-no-callback",this);if(i>1&&e.callback)throw new b("observable-bind-to-extra-callback",this);e.to.forEach(o=>{if(o.properties.length&&o.properties.length!==i)throw new b("observable-bind-to-properties-length",this);o.properties.length||(o.properties=this._bindProperties)}),this._to=e.to,e.callback&&(this._bindings.get(t[0]).callback=e.callback),X_(this._observable,this._to),Y_(this),this._bindProperties.forEach(o=>{Ug(this._observable,o)})}function K_(n,e,t){if(this._bindings.size>1)throw new b("observable-bind-to-many-not-one-binding",this);this.to(...Z_(n,e),t)}function Z_(n,e){const t=n.map(i=>[i,e]);return Array.prototype.concat.apply([],t)}function ah(n){return n.every(e=>typeof e=="string")}function J_(...n){if(!n.length)throw new b("observable-bind-to-parse-error",null);const e={to:[]};let t;return typeof n[n.length-1]=="function"&&(e.callback=n.pop()),n.forEach(i=>{if(typeof i=="string")t.properties.push(i);else if(typeof i=="object")t={observable:i,properties:[]},e.to.push(t);else throw new b("observable-bind-to-parse-error",null)}),e}function Q_(n,e,t,i){const o=n[as],s=o.get(t),r=s||{};r[i]||(r[i]=new Set),r[i].add(e),s||o.set(t,r)}function Y_(n){let e;n._bindings.forEach((t,i)=>{n._to.forEach(o=>{e=o.properties[t.callback?0:n._bindProperties.indexOf(i)],t.to.push([o.observable,e]),Q_(n._observable,t,o.observable,e)})})}function Ug(n,e){const t=n[Jo].get(e);let i;t.callback?i=t.callback.apply(n,t.to.map(o=>o[0][o[1]])):(i=t.to[0],i=i[0][i[1]]),Object.prototype.hasOwnProperty.call(n,e)?n[e]=i:n.set(e,i)}function X_(n,e){e.forEach(t=>{const i=n[as];let o;i.get(t.observable)||n.listenTo(t.observable,"change",(s,r)=>{o=i.get(t.observable)[r],o&&o.forEach(a=>{Ug(n,a.property)})})})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ml(n){let e=0;for(const t of n)e++;return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Xe(n,e){const t=Math.min(n.length,e.length);for(let i=0;i{this._setToTarget(e,o,t[o],i)})}}function lh(n){return Xr(n,ev)}function ev(n){return xi(n)||typeof n=="function"?n:void 0}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Zi(n){if(n){if(n.defaultView)return n instanceof n.defaultView.Document;if(n.ownerDocument&&n.ownerDocument.defaultView)return n instanceof n.ownerDocument.defaultView.Node}return!1}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Sr(n){const e=Object.prototype.toString.apply(n);return e=="[object Window]"||e=="[object global]"}const Gg=st(ge());function st(n){if(!n)return Gg;class e extends n{listenTo(i,o,s,r={}){if(Zi(i)||Sr(i)||i instanceof I.window.EventTarget){const a={capture:!!r.useCapture,passive:!!r.usePassive},l=this._getProxyEmitter(i,a)||new tv(i,a);this.listenTo(l,o,s,r)}else super.listenTo(i,o,s,r)}stopListening(i,o,s){if(Zi(i)||Sr(i)||i instanceof I.window.EventTarget){const r=this._getAllProxyEmitters(i);for(const a of r)this.stopListening(a,o,s)}else super.stopListening(i,o,s)}_getProxyEmitter(i,o){return $_(this,Kg(i,o))}_getAllProxyEmitters(i){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map(o=>this._getProxyEmitter(i,o)).filter(o=>!!o)}}return e}["_getProxyEmitter","_getAllProxyEmitters","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(n=>{st[n]=Gg.prototype[n]});class tv extends ge(){constructor(e,t){super(),h(this,"_domNode"),h(this,"_options"),h(this,"_domListeners"),$g(this,Kg(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,i){this.attach(e),ge().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){ge().prototype._removeEventListener.call(this,e,t),this.detach(e)}_createDomListener(e){const t=i=>{this.fire(e,i)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}}function iv(n){return n["data-ck-expando"]||(n["data-ck-expando"]=ze())}function Kg(n,e){let t=iv(n);for(const i of Object.keys(e).sort())e[i]&&(t+="-"+i);return t}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Zg(n){const e=[];let t=n;for(;t&&t.nodeType!=Node.DOCUMENT_NODE;)e.unshift(t),t=t.parentNode;return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Jg(n){return n instanceof HTMLTextAreaElement?n.value:n.innerHTML}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Dc(n){const e=n.ownerDocument.defaultView.getComputedStyle(n);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-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Qg(n){if(!n.target)return null;const e=n.target.ownerDocument,t=n.clientX,i=n.clientY;let o=null;return e.caretRangeFromPoint&&e.caretRangeFromPoint(t,i)?o=e.caretRangeFromPoint(t,i):n.rangeParent&&(o=e.createRange(),o.setStart(n.rangeParent,n.rangeOffset),o.collapse(!0)),o}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function xe(n){return Object.prototype.toString.call(n)=="[object Text]"}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ia(n){return Object.prototype.toString.apply(n)=="[object Range]"}function Yg(n){return!n||!n.parentNode||n.offsetParent===I.document.body?null:n.offsetParent}const Xg=["top","right","bottom","left","width","height"];class z{constructor(e){h(this,"top"),h(this,"right"),h(this,"bottom"),h(this,"left"),h(this,"width"),h(this,"height"),h(this,"_source");const t=ia(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),Fl(e)||t)if(t){const i=z.getDomRangeRects(e);Ns(this,z.getBoundingRect(i))}else Ns(this,e.getBoundingClientRect());else if(Sr(e)){const{innerWidth:i,innerHeight:o}=e;Ns(this,{top:0,right:i,bottom:o,left:0,width:i,height:o})}else Ns(this,e)}clone(){return new z(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};if(t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0)return null;{const i=new z(t);return i._source=this._source,i}}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(ch(e))return t;let i=e,o=e.parentNode||e.commonAncestorContainer,s;for(;o&&!ch(o);){const r=nv(o)==="visible";i instanceof HTMLElement&&uh(i)==="absolute"&&(s=i);const a=uh(o);if(r||s&&(a==="relative"&&r||a!=="relative")){i=o,o=o.parentNode;continue}const l=new z(o),c=t.getIntersection(l);if(c)c.getArea(){for(const t of e){const i=Be._getElementCallbacks(t.target);if(i)for(const o of i)o(t)}})}};h(Nl,"_observerInstance",null),h(Nl,"_elementCallbacks",null);let bo=Nl;/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function hh(n,e){n instanceof HTMLTextAreaElement&&(n.value=e),n.innerHTML=e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Vi(n){return e=>e+n}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function to(n){let e=0;for(;n.previousSibling;)n=n.previousSibling,e++;return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ep(n,e,t){n.insertBefore(t,n.childNodes[e]||null)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Qo(n){return n&&n.nodeType===Node.COMMENT_NODE}function tp(n){try{I.document.createAttribute(n)}catch{return!1}return!0}function Gt(n){return n?xe(n)?Gt(n.parentElement):n.getClientRects?!!n.getClientRects().length:!1:!1}function zc({element:n,target:e,positions:t,limiter:i,fitInViewport:o,viewportOffsetConfig:s}){Tr(e)&&(e=e()),Tr(i)&&(i=i());const r=Yg(n),a=sv(s),l=new z(n),c=dh(e,a);let u;if(!c||!a.getIntersection(c))return null;const d={targetRect:c,elementRect:l,positionedElementAncestor:r,viewportRect:a};if(!i&&!o)u=new ip(t[0],d);else{if(i){const m=dh(i,a);m&&(d.limiterRect=m)}u=rv(t,d)}return u}function dh(n,e){const t=new z(n).getVisible();return t?t.getIntersection(e):null}function sv(n){n=Object.assign({top:0,bottom:0,left:0,right:0},n);const e=new z(I.window);return e.top+=n.top,e.height-=n.top,e.bottom-=n.bottom,e.height-=n.bottom,e}function rv(n,e){const{elementRect:t}=e,i=t.getArea(),o=n.map(a=>new ip(a,e)).filter(a=>!!a.name);let s=0,r=null;for(const a of o){const{limiterIntersectionArea:l,viewportIntersectionArea:c}=a;if(l===i)return a;const u=c**2+l**2;u>s&&(s=u,r=a)}return r}class ip{constructor(e,t){h(this,"name"),h(this,"config"),h(this,"_positioningFunctionCoordinates"),h(this,"_options"),h(this,"_cachedRect"),h(this,"_cachedAbsoluteRect");const i=e(t.targetRect,t.elementRect,t.viewportRect,t.limiterRect);if(!i)return;const{left:o,top:s,name:r,config:a}=i;this.name=r,this.config=a,this._positioningFunctionCoordinates={left:o,top:s},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;return e?e.getIntersectionArea(this._rect):0}get viewportIntersectionArea(){return this._options.viewportRect.getIntersectionArea(this._rect)}get _rect(){return this._cachedRect?this._cachedRect:(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCoordinates.left,this._positioningFunctionCoordinates.top),this._cachedRect)}get _absoluteRect(){return this._cachedAbsoluteRect?this._cachedAbsoluteRect:(this._cachedAbsoluteRect=this._rect.toAbsoluteRect(),this._cachedAbsoluteRect)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function mh(n){const e=n.parentNode;e&&e.removeChild(n)}function av(){const n=I.window.visualViewport;if(!n||!(N.isiOS||N.isSafari))return{left:0,top:0};const e=Math.max(Math.round(n.offsetLeft),0),t=Math.max(Math.round(n.offsetTop),0);return{left:e,top:t}}function np({target:n,viewportOffset:e=0,ancestorOffset:t=0,alignToTop:i,forceScroll:o}){const s=Hc(n);let r=s,a=null;for(e=uv(e);r;){let l;r==s?l=fh(n):l=fh(a),cv({parent:l,getRect:()=>Va(n,r),alignToTop:i,ancestorOffset:t,forceScroll:o});let c=Va(n,r);const u=Va(l,r);if(c.height>u.height){const d=c.getIntersection(u);d&&(c=d)}if(lv({window:r,rect:c,viewportOffset:e,alignToTop:i,forceScroll:o}),r.parent!=r){if(a=r.frameElement,r=r.parent,!a)return}else r=null}}function lv({window:n,rect:e,alignToTop:t,forceScroll:i,viewportOffset:o}){const s=e.clone().moveBy(0,o.bottom),r=e.clone().moveBy(0,-o.top),a=new z(n).excludeScrollbarsAndBorders(),l=[r,s],c=t&&i,u=l.every(p=>a.contains(p));let{scrollX:d,scrollY:m}=n;const f=d,g=m;c?m-=a.top-e.top+o.top:u||(sp(r,a)?m-=a.top-e.top+o.top:op(s,a)&&(t?m+=e.top-a.top-o.top:m+=e.bottom-a.bottom+o.bottom)),u||(rp(e,a)?d-=a.left-e.left+o.left:ap(e,a)&&(d+=e.right-a.right+o.right)),(d!=f||m!==g)&&n.scrollTo(d,m)}function cv({parent:n,getRect:e,alignToTop:t,forceScroll:i,ancestorOffset:o=0,limiterElement:s}){const r=Hc(n),a=t&&i;let l,c,u;const d=s||r.document.body;for(;n!=d;)c=e(),l=new z(n).excludeScrollbarsAndBorders(),u=l.contains(c),a?n.scrollTop-=l.top-c.top+o:u||(sp(c,l)?n.scrollTop-=l.top-c.top+o:op(c,l)&&(t?n.scrollTop+=c.top-l.top-o:n.scrollTop+=c.bottom-l.bottom+o)),u||(rp(c,l)?n.scrollLeft-=l.left-c.left+o:ap(c,l)&&(n.scrollLeft+=c.right-l.right+o)),n=n.parentNode}function op(n,e){return n.bottom>e.bottom}function sp(n,e){return n.tope.right}function Hc(n){return ia(n)?n.startContainer.ownerDocument.defaultView:n.ownerDocument.defaultView}function fh(n){if(ia(n)){let e=n.commonAncestorContainer;return xe(e)&&(e=e.parentNode),e}else return n.parentNode}function Va(n,e){const t=Hc(n),i=new z(n);if(t===e)return i;{let o=t;for(;o!=e;){const s=o.frameElement,r=new z(s).excludeScrollbarsAndBorders();i.moveBy(r.left,r.top),o=o.parent}}return i}function uv(n){return typeof n=="number"?{top:n,bottom:n,left:n,right:n}:n}const hv={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},dv={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},gh={37:"←",38:"↑",39:"→",40:"↓",9:"⇥",33:"Page Up",34:"Page Down"},Z=wv(),mv=Object.fromEntries(Object.entries(Z).map(([n,e])=>{let t;return e in gh?t=gh[e]:t=n.charAt(0).toUpperCase()+n.slice(1),[e,t]}));function yn(n){let e;if(typeof n=="string"){if(e=Z[n.toLowerCase()],!e)throw new b("keyboard-unknown-key",null,{key:n})}else e=n.keyCode+(n.altKey?Z.alt:0)+(n.ctrlKey?Z.ctrl:0)+(n.shiftKey?Z.shift:0)+(n.metaKey?Z.cmd:0);return e}function na(n){return typeof n=="string"&&(n=bv(n)),n.map(e=>typeof e=="string"?gv(e):e).reduce((e,t)=>t+e,0)}function ph(n,e){let t=na(n);const i=N.isMac||N.isiOS;return Object.entries(i?hv:dv).reduce((o,[s,r])=>((t&Z[s])!=0&&(t&=~Z[s],o+=r),o),"")+(t?mv[t]:"")}function fv(n){return n==Z.arrowright||n==Z.arrowleft||n==Z.arrowup||n==Z.arrowdown}function oa(n,e){const t=e==="ltr";switch(n){case Z.arrowleft:return t?"left":"right";case Z.arrowright:return t?"right":"left";case Z.arrowup:return"up";case Z.arrowdown:return"down"}}function gv(n){if(n.endsWith("!"))return yn(n.slice(0,-1));const e=yn(n);return(N.isMac||N.isiOS)&&e==Z.ctrl?Z.cmd:e}function pv(n,e){const t=oa(n,e);return t==="down"||t==="right"}function wv(){const n={pageup:33,pagedown:34,end:35,home:36,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);n[t.toLowerCase()]=e}for(let e=48;e<=57;e++)n[e-48]=e;for(let e=112;e<=123;e++)n["f"+(e-111)]=e;return Object.assign(n,{"'":222,",":108,"-":109,".":110,"/":111,";":186,"=":187,"[":219,"\\":220,"]":221,"`":223}),n}function bv(n){return n.split("+").map(e=>e.trim())}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const _v=["ar","ara","dv","div","fa","per","fas","he","heb","ku","kur","ug","uig","ur","urd"];function Dl(n){return _v.includes(n)?"rtl":"ltr"}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function he(n){return Array.isArray(n)?n:[n]}/* istanbul ignore else -- @preserve */I.window.CKEDITOR_TRANSLATIONS||(I.window.CKEDITOR_TRANSLATIONS={});function vv(n,e,t=1,i){if(typeof t!="number")throw new b("translation-service-quantity-not-a-number",null,{quantity:t});const o=i||I.window.CKEDITOR_TRANSLATIONS,s=Cv(o);s===1&&(n=Object.keys(o)[0]);const r=e.id||e.string;if(s===0||!kv(n,r,o))return t!==1?e.plural:e.string;const a=o[n].dictionary,l=o[n].getPluralForm||(d=>d===1?0:1),c=a[r];if(typeof c=="string")return c;const u=Number(l(t));return c[u]}function yv(n){return Array.isArray(n)?n.reduce((e,t)=>Nc(e,t)):n}function kv(n,e,t){return!!t[n]&&!!t[n].dictionary[e]}function Cv(n){return Object.keys(n).length}class lp{constructor({uiLanguage:e="en",contentLanguage:t,translations:i}={}){h(this,"uiLanguage"),h(this,"uiLanguageDirection"),h(this,"contentLanguage"),h(this,"contentLanguageDirection"),h(this,"t"),h(this,"translations"),this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=Dl(this.uiLanguage),this.contentLanguageDirection=Dl(this.contentLanguage),this.translations=yv(i),this.t=(o,s)=>this._t(o,s)}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=he(t),typeof e=="string"&&(e={string:e});const i=e.plural?t[0]:1,o=vv(this.uiLanguage,e,i,this.translations);return Av(o,t)}}function Av(n,e){return n.replace(/%(\d+)/g,(t,i)=>ithis._items.length||t<0)throw new b("collection-add-item-invalid-index",this);let i=0;for(const o of e){const s=this._getItemIdBeforeAdding(o),r=t+i;this._items.splice(r,0,o),this._itemMap.set(s,o),this.fire("add",o,r),i++}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 b("collection-get-invalid-arg",this);return t||null}has(e){if(typeof e=="string")return this._itemMap.has(e);{const t=this._idProperty,i=e[t];return i&&this._itemMap.has(i)}}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,i]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:i}),t}map(e,t){return this._items.map(e,t)}forEach(e,t){this._items.forEach(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 b("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:t=>{this._setUpBindToBinding(i=>new t(i))},using:t=>{typeof t=="function"?this._setUpBindToBinding(t):this._setUpBindToBinding(i=>i[t])}}}_setUpBindToBinding(e){const t=this._bindToCollection,i=(o,s,r)=>{const a=t._bindToCollection==this,l=t._bindToInternalToExternalMap.get(s);if(a&&l)this._bindToExternalToInternalMap.set(s,l),this._bindToInternalToExternalMap.set(l,s);else{const c=e(s);if(!c){this._skippedIndexesFromExternal.push(r);return}let u=r;for(const d of this._skippedIndexesFromExternal)r>d&&u--;for(const d of t._skippedIndexesFromExternal)u>=d&&u++;this._bindToExternalToInternalMap.set(s,c),this._bindToInternalToExternalMap.set(c,s),this.add(c,u);for(let d=0;d{const a=this._bindToExternalToInternalMap.get(s);a&&this.remove(a),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce((l,c)=>(rc&&l.push(c),l),[])})}_getItemIdBeforeAdding(e){const t=this._idProperty;let i;if(t in e){if(i=e[t],typeof i!="string")throw new b("collection-add-invalid-id",this);if(this.get(i))throw new b("collection-add-item-already-exists",this)}else e[t]=i=ze();return i}_remove(e){let t,i,o,s=!1;const r=this._idProperty;if(typeof e=="string"?(i=e,o=this._itemMap.get(i),s=!o,o&&(t=this._items.indexOf(o))):typeof e=="number"?(t=e,o=this._items[t],s=!o,o&&(i=o[r])):(o=e,i=o[r],t=this._items.indexOf(o),s=t==-1||!this._itemMap.get(i)),s)throw new b("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const a=this._bindToInternalToExternalMap.get(o);return this._bindToInternalToExternalMap.delete(o),this._bindToExternalToInternalMap.delete(a),this.fire("remove",o,t),[o,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ae(n){const e=n.next();return e.done?null:e.value}class ee extends st(ue()){constructor(){super(),h(this,"_elements",new Set),h(this,"_externalViews",new Set),h(this,"_blurTimeout",null),this.set("isFocused",!1),this.set("focusedElement",null)}get elements(){return Array.from(this._elements.values())}get externalViews(){return Array.from(this._externalViews.values())}add(e){if(bh(e))this._addElement(e);else if(wh(e))this._addView(e);else{if(!e.element)throw new b("focustracker-add-view-missing-element",{focusTracker:this,view:e});this._addElement(e.element)}}remove(e){bh(e)?this._removeElement(e):wh(e)?this._removeView(e):this._removeElement(e.element)}_addElement(e){if(this._elements.has(e))throw new b("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",()=>{const t=this.externalViews.find(i=>xv(e,i));t?this._focus(t.element):this._focus(e)},{useCapture:!0}),this.listenTo(e,"blur",()=>{this._blur()},{useCapture:!0}),this._elements.add(e)}_removeElement(e){this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e)),e===this.focusedElement&&this._blur()}_addView(e){e.element&&this._addElement(e.element),this.listenTo(e.focusTracker,"change:focusedElement",()=>{e.focusTracker.focusedElement?e.element&&this._focus(e.element):this._blur()}),this._externalViews.add(e)}_removeView(e){e.element&&this._removeElement(e.element),this.stopListening(e.focusTracker),this._externalViews.delete(e)}destroy(){this.stopListening(),this._elements.clear(),this._externalViews.clear(),this.isFocused=!1,this.focusedElement=null}_focus(e){this._clearBlurTimeout(),this.focusedElement=e,this.isFocused=!0}_blur(){this.elements.find(e=>e.contains(document.activeElement))||this.externalViews.find(e=>e.focusTracker.isFocused&&!e.focusTracker._blurTimeout)||(this._clearBlurTimeout(),this._blurTimeout=setTimeout(()=>{this.focusedElement=null,this.isFocused=!1},0))}_clearBlurTimeout(){clearTimeout(this._blurTimeout),this._blurTimeout=null}}function wh(n){return"focusTracker"in n&&n.focusTracker instanceof ee}function bh(n){return xi(n)}function xv(n,e){return _h(n,e)?!0:!!e.focusTracker.externalViews.find(t=>_h(n,t))}function _h(n,e){return!!e.element&&e.element.contains(document.activeElement)&&n.contains(e.element)}class te{constructor(){h(this,"_listener"),this._listener=new(st())}listenTo(e){this._listener.listenTo(e,"keydown",(t,i)=>{this._listener.fire("_keydown:"+yn(i),i)})}set(e,t,i={}){const o=na(e),s=i.priority;this._listener.listenTo(this._listener,"_keydown:"+o,(r,a)=>{i.filter&&!i.filter(a)||(t(a,()=>{a.preventDefault(),a.stopPropagation(),r.stop()}),r.return=!0)},{priority:s})}press(e){return!!this._listener.fire("_keydown:"+yn(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Tv(n){const e=new Map;for(const t in n)e.set(t,n[t]);return e}function ri(n){return Pt(n)?new Map(n):Tv(n)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function vh(n,e,t){const i=n.length,o=e.length;for(let s=i-1;s>=t;s--)n[s+o]=n[s];for(let s=0;sn(...o),e)}return i.cancel=()=>{clearTimeout(t)},i}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Wc(n){try{if(!n.startsWith("ey"))return null;const e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}catch{return null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ev(){const n=[];for(let e=0;e<256;e++){let t=e;for(let i=0;i<8;i++)t&1?t=3988292384^t>>>1:t=t>>>1;n[e]=t}return n}function Sv(n){const e=Array.isArray(n)?n:[n],t=Ev();let i=-1;const o=e.map(s=>Array.isArray(s)?s.join(""):String(s)).join("");for(let s=0;s>>8^t[(i^r)&255]}return i=(i^-1)>>>0,i.toString(16).padStart(8,"0")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Pv(n){return!!n&&n.length==1&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(n)}function Iv(n){return!!n&&n.length==1&&/[\ud800-\udbff]/.test(n)}function Vv(n){return!!n&&n.length==1&&/[\udc00-\udfff]/.test(n)}function jc(n,e){return Iv(n.charAt(e-1))&&Vv(n.charAt(e))}function Uc(n,e){return Pv(n.charAt(e))}const Rv=Ov();function cp(n,e){const t=String(n).matchAll(Rv);return Array.from(t).some(i=>i.indexo.source).join("|")+")",i=`${e}|${t}(?:${t})*`;return new RegExp(i,"ug")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const To=new WeakMap;let yh=!1;function sa({view:n,element:e,text:t,isDirectHost:i=!0,keepOnFocus:o=!1}){const s=n.document;To.has(s)||(To.set(s,new Map),s.registerPostFixer(a=>Ra(To.get(s),a)),s.on("change:isComposing",()=>{n.change(a=>Ra(To.get(s),a))},{priority:"high"})),e.is("editableElement")&&e.on("change:placeholder",(a,l,c)=>r(c)),e.placeholder?r(e.placeholder):t&&r(t),t&&Dv();function r(a){const l={text:a,isDirectHost:i,keepOnFocus:o,hostElement:i?e:null};To.get(s).set(e,l),n.change(c=>Ra([[e,l]],c))}}function Bv(n,e){return e.hasClass("ck-placeholder")?!1:(n.addClass("ck-placeholder",e),!0)}function Mv(n,e){return e.hasClass("ck-placeholder")?(n.removeClass("ck-placeholder",e),!0):!1}function Lv(n,e){if(!n.isAttached()||Fv(n))return!1;const t=n.document,i=t.selection.anchor;return t.isComposing&&i&&i.parent===n?!1:e||!t.isFocused?!0:!!i&&i.parent!==n}function Fv(n){for(const e of n.getChildren())if(!e.is("uiElement"))return!0;return!1}function Ra(n,e){const t=[];let i=!1;for(const[o,s]of n)s.isDirectHost&&(t.push(o),kh(e,o,s)&&(i=!0));for(const[o,s]of n){if(s.isDirectHost)continue;const r=Nv(o);r&&(t.includes(r)||(s.hostElement=r,kh(e,o,s)&&(i=!0)))}return i}function kh(n,e,t){const{text:i,isDirectHost:o,hostElement:s}=t;let r=!1;return s.getAttribute("data-placeholder")!==i&&(n.setAttribute("data-placeholder",i,s),r=!0),(o||e.childCount==1)&&Lv(s,t.keepOnFocus)?Bv(n,s)&&(r=!0):Mv(n,s)&&(r=!0),r}function Nv(n){if(n.childCount){const e=n.getChild(0);if(e.is("element")&&!e.is("uiElement")&&!e.is("attributeElement"))return e}return null}function Dv(){yh||J("enableplaceholder-deprecated-text-option"),yh=!0}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/let Cn=class{is(){throw new Error("is() method is abstract")}},An=class extends ge(Cn){constructor(n){super(),h(this,"document"),h(this,"parent"),this.document=n,this.parent=null}get index(){let n;if(!this.parent)return null;if((n=this.parent.getChildIndex(this))==-1)throw new b("view-node-not-found-in-parent",this);return n}get nextSibling(){const n=this.index;return n!==null&&this.parent.getChild(n+1)||null}get previousSibling(){const n=this.index;return n!==null&&this.parent.getChild(n-1)||null}get root(){let n=this;for(;n.parent;)n=n.parent;return n}isAttached(){return this.root.is("rootElement")}getPath(){const n=[];let e=this;for(;e.parent;)n.unshift(e.index),e=e.parent;return n}getAncestors(n={}){const e=[];let t=n.includeSelf?this:this.parent;for(;t;)e[n.parentFirst?"push":"unshift"](t),t=t.parent;return e}getCommonAncestor(n,e={}){const t=this.getAncestors(e),i=n.getAncestors(e);let o=0;for(;t[o]==i[o]&&t[o];)o++;return o===0?null:t[o-1]}isBefore(n){if(this==n||this.root!==n.root)return!1;const e=this.getPath(),t=n.getPath(),i=Xe(e,t);switch(i){case"prefix":return!0;case"extension":return!1;default:return e[i]n.data.length)throw new b("view-textproxy-wrong-offsetintext",this);if(t<0||e+t>n.data.length)throw new b("view-textproxy-wrong-length",this);this.data=n.data.substring(e,e+t),this.offsetInText=e}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(n={}){const e=[];let t=n.includeSelf?this.textNode:this.parent;for(;t!==null;)e[n.parentFirst?"push":"unshift"](t),t=t.parent;return e}};_i.prototype.is=function(n){return n==="$textProxy"||n==="view:$textProxy"||n==="textProxy"||n==="view:textProxy"};class Pr{constructor(){h(this,"_consumables",new Map)}add(e,t){let i;if(e.is("$text")||e.is("documentFragment")){this._consumables.set(e,!0);return}this._consumables.has(e)?i=this._consumables.get(e):(i=new zv(e),this._consumables.set(e,i)),i.add(t?jo(t):e._getConsumables())}test(e,t){const i=this._consumables.get(e);return i===void 0?null:e.is("$text")||e.is("documentFragment")?i:i.test(jo(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return this.test(e,t)?(this._consumables.set(e,!1),!0):!1;const i=this._consumables.get(e);return i===void 0?!1:i.consume(jo(t))}revert(e,t){const i=this._consumables.get(e);i!==void 0&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(jo(t)))}static createFrom(e,t){if(t||(t=new Pr),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment")){t.add(e);for(const i of e.getChildren())Pr.createFrom(i,t)}return t}}class zv{constructor(e){h(this,"element"),h(this,"_canConsumeName",null),h(this,"_attributes",new Map),this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes)if(i){let o=this._attributes.get(t);(!o||typeof o=="boolean")&&(o=new Map,this._attributes.set(t,o)),o.set(i,!0)}else{if(t=="style"||t=="class")throw new b("viewconsumable-invalid-attribute",this);this._attributes.set(t,!0)}}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const[t,i]of e.attributes){const o=this._attributes.get(t);if(o===void 0)return null;if(o===!1)return!1;if(o!==!0){if(i){const s=o.get(i);if(s===void 0)return null;if(!s)return!1}else for(const s of o.values())if(!s)return!1}}return!0}consume(e){if(!this.test(e))return!1;e.name&&(this._canConsumeName=!1);for(const[t,i]of e.attributes){const o=this._attributes.get(t);if(typeof o=="boolean")for(const[s]of this.element._getConsumables(t,i).attributes)this._attributes.set(s,!1);else if(i)for(const[,s]of this.element._getConsumables(t,i).attributes)o.set(s,!1);else for(const s of o.keys())o.set(s,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes){const o=this._attributes.get(t);if(o===!1){this._attributes.set(t,!0);continue}if(!(o===void 0||o===!0))if(i)o.get(i)===!1&&o.set(i,!0);else for(const s of o.keys())o.set(s,!0)}}}function jo(n){const e=[];return"attributes"in n&&n.attributes&&Oa(e,n.attributes),"classes"in n&&n.classes&&Oa(e,n.classes,"class"),"styles"in n&&n.styles&&Oa(e,n.styles,"style"),{name:n.name||!1,attributes:e}}function Oa(n,e,t){if(typeof e=="string"){n.push(t?[t,e]:[e]);return}for(const i of e)Array.isArray(i)?n.push(i):n.push(t?[t,i]:[i])}class ft{constructor(...e){h(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 i of this._patterns){const o=this._isElementMatching(t,i);if(o)return{element:t,pattern:i,match:o}}return null}matchAll(...e){const t=[];for(const i of e)for(const o of this._patterns){const s=this._isElementMatching(i,o);s&&t.push({element:i,pattern:o,match:s})}return t.length>0?t:null}getElementName(){if(this._patterns.length!==1)return null;const e=this._patterns[0],t=e.name;return typeof e!="function"&&t&&!(t instanceof RegExp)?t:null}_isElementMatching(e,t){if(typeof t=="function"){const s=t(e);return!s||typeof s!="object"?s:jo(s)}const i={};if(t.name&&(i.name=Hv(t.name,e.name),!i.name))return null;const o=[];return t.attributes&&!$v(t.attributes,e,o)||t.classes&&!Wv(t.classes,e,o)||t.styles&&!jv(t.styles,e,o)?null:(o.length&&(i.attributes=o),i)}}function Ir(n,e){return n===!0||n===e||n instanceof RegExp&&!!String(e).match(n)}function Hv(n,e){return n instanceof RegExp?!!e.match(n):n===e}function qc(n,e){if(Array.isArray(n))return n.map(i=>typeof i!="object"||i instanceof RegExp?e?[e,i,!0]:[i,!0]:((i.key===void 0||i.value===void 0)&&J("matcher-pattern-missing-key-or-value",i),e?[e,i.key,i.value]:[i.key,i.value]));if(typeof n!="object"||n instanceof RegExp)return[e?[e,n,!0]:[n,!0]];const t=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&t.push(e?[e,i,n[i]]:[i,n[i]]);return t}function $v(n,e,t){let i;return typeof n=="object"&&!(n instanceof RegExp)&&!Array.isArray(n)?(n.style!==void 0&&J("matcher-pattern-deprecated-attributes-style-key",n),n.class!==void 0&&J("matcher-pattern-deprecated-attributes-class-key",n)):i=["class","style"],e._collectAttributesMatch(qc(n),t,i)}function Wv(n,e,t){return e._collectAttributesMatch(qc(n,"class"),t)}function jv(n,e,t){return e._collectAttributesMatch(qc(n,"style"),t)}class so{constructor(e){h(this,"_styles"),h(this,"_cachedStyleNames",null),h(this,"_cachedExpandedStyleNames",null),h(this,"_styleProcessor"),this._styles={},this._styleProcessor=e}get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=qv(e);for(const[i,o]of t)this._styleProcessor.toNormalizedForm(i,o,this._styles);return this}has(e){if(this.isEmpty)return!1;const t=this._styleProcessor.getReducedForm(e,this._styles).find(([i])=>i===e);return Array.isArray(t)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,Et(e))for(const[i,o]of Object.entries(e))this._styleProcessor.toNormalizedForm(i,o,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){for(const t of he(e)){this._cachedStyleNames=null,this._cachedExpandedStyleNames=null;const i=Hl(t);v_(this._styles,i),delete this._styles[t],this._cleanEmptyObjectsOnPath(i)}}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]&&!Et(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find(([i])=>i===e);if(Array.isArray(t))return t[1]}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||(this._cachedExpandedStyleNames=this._styleProcessor.getStyleNames(this._styles)),this._cachedExpandedStyleNames):(this._cachedStyleNames||(this._cachedStyleNames=this.getStylesEntries().map(([t])=>t)),this._cachedStyleNames)}keys(){return this.getStyleNames()}clear(){this._styles={},this._cachedStyleNames=null,this._cachedExpandedStyleNames=null}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.getStyleNames())if(!e.has(t)||e.getAsString(t)!==this.getAsString(t))return!1;return!0}getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_clone(){const e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){const i=[];for(const o of this.getStyleNames(!0))if(Ir(e,o)){if(t===!0){i.push(o);continue}const s=this.getAsString(o);Ir(t,s)&&i.push(o)}return i.length?i:void 0}_getConsumables(e){const t=[];if(e){t.push(e);for(const i of this._styleProcessor.getRelatedStyles(e))t.push(i)}else for(const i of this.getStyleNames()){for(const o of this._styleProcessor.getRelatedStyles(i))t.push(o);t.push(i)}return t}_canMergeFrom(e){for(const t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(const t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(const t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),o=Ki(this._styles,i);o&&!Object.keys(o).length&&this.remove(i)}}class Uv{constructor(){h(this,"_normalizers"),h(this,"_extractors"),h(this,"_reducers"),h(this,"_consumables"),this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(Et(t)){Ba(i,Hl(e),t);return}if(this._normalizers.has(e)){const o=this._normalizers.get(e),{path:s,value:r}=o(t);Ba(i,s,r)}else Ba(i,e,t)}getNormalized(e,t){if(!e)return Nc({},t);if(t[e]!==void 0)return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if(typeof i=="string")return Ki(t,i);const o=i(e,t);if(o)return o}return Ki(t,Hl(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);return i===void 0?[]:this._reducers.has(e)?this._reducers.get(e)(i):[[e,i]]}getStyleNames(e){const t=new Set;for(const i of this._consumables.keys()){const o=this.getNormalized(i,e);o&&(typeof o!="object"||Object.keys(o).length)&&t.add(i)}for(const i of Object.keys(e))t.add(i);return Array.from(t)}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function qv(n){let e=null,t=0,i=0,o=null;const s=new Map;if(n==="")return s;n.charAt(n.length-1)!=";"&&(n=n+";");for(let r=0;ro!="style"&&o!="class").map(o=>`${o[0]}="${o[1]}"`).sort().join(" ");return this.name+(e==""?"":` class="${e}"`)+(t?` style="${t}"`:"")+(i==""?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const o of this.getChildren())t.push(o._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this,{index:e});let i=0;const o=Gv(this.document,t);for(const s of o)s.parent!==null&&s._remove(),s.parent=this,s.document=this.document,this._children.splice(e,0,s),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let i=e;is&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}}ra.prototype.is=function(n,e){return e?e===this.name&&(n==="editableElement"||n==="view:editableElement"||n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"):n==="editableElement"||n==="view:editableElement"||n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};const Ch=Symbol("rootName");class hp extends ra{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(Ch)}set rootName(e){this._setCustomProperty(Ch,e)}set _name(e){this.name=e}}hp.prototype.is=function(n,e){return e?e===this.name&&(n==="rootElement"||n==="view:rootElement"||n==="editableElement"||n==="view:editableElement"||n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"):n==="rootElement"||n==="view:rootElement"||n==="editableElement"||n==="view:editableElement"||n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};let bn=class{constructor(n={}){if(h(this,"direction"),h(this,"boundaries"),h(this,"singleCharacters"),h(this,"shallow"),h(this,"ignoreElementEnd"),h(this,"_position"),h(this,"_boundaryStartParent"),h(this,"_boundaryEndParent"),!n.boundaries&&!n.startPosition)throw new b("view-tree-walker-no-start-position",null);if(n.direction&&n.direction!="forward"&&n.direction!="backward")throw new b("view-tree-walker-unknown-direction",n.startPosition,{direction:n.direction});this.boundaries=n.boundaries||null,n.startPosition?this._position=V._createAt(n.startPosition):this._position=V._createAt(n.boundaries[n.direction=="backward"?"end":"start"]),this.direction=n.direction||"forward",this.singleCharacters=!!n.singleCharacters,this.shallow=!!n.shallow,this.ignoreElementEnd=!!n.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(n){let e,t;do t=this.position,e=this.next();while(!e.done&&n(e.value));e.done||(this._position=t)}jumpTo(n){this._boundaryStartParent&&n.isBefore(this.boundaries.start)?n=this.boundaries.start:this._boundaryEndParent&&n.isAfter(this.boundaries.end)&&(n=this.boundaries.end),this._position=n.clone()}next(){return this.direction=="forward"?this._next():this._previous()}_next(){let n=this.position.clone();const e=this.position,t=n.parent;if(t.parent===null&&n.offset===t.childCount)return{done:!0,value:void 0};if(t===this._boundaryEndParent&&n.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let i;if(t&&t.is("view:$text")){if(n.isAtEnd)return this._position=V._createAfter(t),this._next();i=t.data[n.offset]}else i=t.getChild(n.offset);if(typeof i=="string"){let o;this.singleCharacters?o=1:o=(t===this._boundaryEndParent?this.boundaries.end.offset:t.data.length)-n.offset;const s=new _i(t,n.offset,o);return n.offset+=o,this._position=n,this._formatReturnValue("text",s,e,n,o)}if(i&&i.is("view:element")){if(!this.shallow)n=new V(i,0);else{if(this.boundaries&&this.boundaries.end.isBefore(n))return{done:!0,value:void 0};n.offset++}return this._position=n,this._formatReturnValue("elementStart",i,e,n,1)}if(i&&i.is("view:$text")){if(this.singleCharacters)return n=new V(i,0),this._position=n,this._next();let o=i.data.length,s;return i==this._boundaryEndParent?(o=this.boundaries.end.offset,s=new _i(i,0,o),n=V._createAfter(s)):(s=new _i(i,0,i.data.length),n.offset++),this._position=n,this._formatReturnValue("text",s,e,n,o)}return n=V._createAfter(t),this._position=n,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",t,e,n)}_previous(){let n=this.position.clone();const e=this.position,t=n.parent;if(t.parent===null&&n.offset===0)return{done:!0,value:void 0};if(t==this._boundaryStartParent&&n.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let i;if(t.is("view:$text")){if(n.isAtStart)return this._position=V._createBefore(t),this._previous();i=t.data[n.offset-1]}else i=t.getChild(n.offset-1);if(typeof i=="string"){let o;if(this.singleCharacters)o=1;else{const r=t===this._boundaryStartParent?this.boundaries.start.offset:0;o=n.offset-r}n.offset-=o;const s=new _i(t,n.offset,o);return this._position=n,this._formatReturnValue("text",s,e,n,o)}if(i&&i.is("view:element"))return this.shallow?(n.offset--,this._position=n,this._formatReturnValue("elementStart",i,e,n,1)):(n=new V(i,i.childCount),this._position=n,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",i,e,n));if(i&&i.is("view:$text")){if(this.singleCharacters)return n=new V(i,i.data.length),this._position=n,this._previous();let o=i.data.length,s;if(i==this._boundaryStartParent){const r=this.boundaries.start.offset;s=new _i(i,r,i.data.length-r),o=s.data.length,n=V._createBefore(s)}else s=new _i(i,0,i.data.length),n.offset--;return this._position=n,this._formatReturnValue("text",s,e,n,o)}return n=V._createBefore(t),this._position=n,this._formatReturnValue("elementStart",t,e,n,1)}_formatReturnValue(n,e,t,i,o){return e.is("view:$textProxy")&&(e.offsetInText+e.data.length==e.textNode.data.length&&(this.direction=="forward"&&!(this.boundaries&&this.boundaries.end.isEqual(this.position))?(i=V._createAfter(e.textNode),this._position=i):t=V._createAfter(e.textNode)),e.offsetInText===0&&(this.direction=="backward"&&!(this.boundaries&&this.boundaries.start.isEqual(this.position))?(i=V._createBefore(e.textNode),this._position=i):t=V._createBefore(e.textNode))),{done:!1,value:{type:n,item:e,previousPosition:t,nextPosition:i,length:o}}}},V=class pi extends Cn{constructor(e,t){super(),h(this,"parent"),h(this,"offset"),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 ra);)if(e.parent)e=e.parent;else return null;return e}getShiftedBy(e){const t=pi._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new bn(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let o=0;for(;t[o]==i[o]&&t[o];)o++;return o===0?null:t[o-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():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const o=Xe(t,i);switch(o){case"prefix":return"before";case"extension":return"after";default:return t[o]0?new this(i,o):new this(o,i)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(V._createBefore(e),t)}};Q.prototype.is=function(n){return n==="range"||n==="view:range"};function Ds(n){return!!(n.item.is("attributeElement")||n.item.is("uiElement"))}let ki=class dp extends ge(Cn){constructor(...e){super(),h(this,"_ranges"),h(this,"_lastRangeBackward"),h(this,"_isFake"),h(this,"_fakeSelectionLabel"),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 i=!1;for(const o of e._ranges)if(t.isEqual(o)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Ml(this.getRanges()),i=Ml(e.getRanges());if(t!=i)return!1;if(t==0)return!0;for(let o of this.getRanges()){o=o.getTrimmed();let s=!1;for(let r of e.getRanges())if(r=r.getTrimmed(),o.start.isEqual(r.start)&&o.end.isEqual(r.end)){s=!0;break}if(!s)return!1}return!0}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,o]=e;if(typeof i=="object"&&(o=i,i=void 0),t===null)this._setRanges([]),this._setFakeOptions(o);else if(t instanceof dp||t instanceof Gc)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Q)this._setRanges([t],o&&o.backward),this._setFakeOptions(o);else if(t instanceof V)this._setRanges([new Q(t)]),this._setFakeOptions(o);else if(t instanceof An){const s=!!o&&!!o.backward;let r;if(i===void 0)throw new b("view-selection-setto-required-second-parameter",this);i=="in"?r=Q._createIn(t):i=="on"?r=Q._createOn(t):r=new Q(V._createAt(t,i)),this._setRanges([r],s),this._setFakeOptions(o)}else if(Pt(t))this._setRanges(t,o&&o.backward),this._setFakeOptions(o);else throw new b("view-selection-setto-not-selectable",this);this.fire("change")}setFocus(e,t){if(this.anchor===null)throw new b("view-selection-setfocus-no-ranges",this);const i=V._createAt(e,t);if(i.compareWith(this.focus)=="same")return;const o=this.anchor;this._ranges.pop(),i.compareWith(o)=="before"?this._addRange(new Q(i,o),!0):this._addRange(new Q(o,i)),this.fire("change")}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const i of e)this._addRange(i);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof Q))throw new b("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 b("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Q(e.start,e.end))}};ki.prototype.is=function(n){return n==="selection"||n==="view:selection"};let Gc=class extends ge(Cn){constructor(...n){super(),h(this,"_selection"),this._selection=new ki,this._selection.delegate("change").to(this),n.length&&this._selection.setTo(...n)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(n){return this._selection.isEqual(n)}isSimilar(n){return this._selection.isSimilar(n)}_setTo(...n){this._selection.setTo(...n)}_setFocus(n,e){this._selection.setFocus(n,e)}};Gc.prototype.is=function(n){return n==="selection"||n=="documentSelection"||n=="view:selection"||n=="view:documentSelection"};class xn extends Ti{constructor(e,t,i){super(e,t),h(this,"startRange"),h(this,"_eventPhase"),h(this,"_currentTarget"),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const La=Symbol("bubbling contexts");function $l(n){class e extends n{fire(i,...o){try{const s=i instanceof Ti?i:new Ti(this,i),r=Fa(this);if(!r.size)return;if(So(s,"capturing",this),Fn(r,"$capture",s,...o))return s.return;const a=s.startRange||this.selection.getFirstRange(),l=a?a.getContainedElement():null,c=l?!!mp(r,l):!1;let u=l||Zv(a);if(So(s,"atTarget",u),!c){if(Fn(r,"$text",s,...o))return s.return;So(s,"bubbling",u)}for(;u;){if(u.is("rootElement")){if(Fn(r,"$root",s,...o))return s.return}else if(u.is("element")&&Fn(r,u.name,s,...o))return s.return;if(Fn(r,u,s,...o))return s.return;u=u.parent,So(s,"bubbling",u)}return So(s,"bubbling",this),Fn(r,"$document",s,...o),s.return}catch(s){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(s,this)}}_addEventListener(i,o,s){const r=he(s.context||"$document"),a=Fa(this);for(const l of r){let c=a.get(l);c||(c=new(ge()),a.set(l,c)),this.listenTo(c,i,o,s)}}_removeEventListener(i,o){const s=Fa(this);for(const r of s.values())this.stopListening(r,i,o)}}return e}{const n=$l(Object);["fire","_addEventListener","_removeEventListener"].forEach(e=>{$l[e]=n.prototype[e]})}function So(n,e,t){n instanceof xn&&(n._eventPhase=e,n._currentTarget=t)}function Fn(n,e,t,...i){const o=typeof e=="string"?n.get(e):mp(n,e);return o?(o.fire(t,...i),t.stop.called):!1}function mp(n,e){for(const[t,i]of n)if(typeof t=="function"&&t(e))return i;return null}function Fa(n){return n[La]||(n[La]=new Map),n[La]}function Zv(n){if(!n)return null;const e=n.start.parent,t=n.end.parent,i=e.getPath(),o=t.getPath();return i.length>o.length?e:t}let aa=class extends $l(ue()){constructor(n){super(),h(this,"selection"),h(this,"roots"),h(this,"stylesProcessor"),h(this,"_postFixers",new Set),this.selection=new Gc,this.roots=new _e({idProperty:"rootName"}),this.stylesProcessor=n,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(n="main"){return this.roots.get(n)}registerPostFixer(n){this._postFixers.add(n)}destroy(){this.roots.forEach(n=>n.destroy()),this.stopListening()}_callPostFixers(n){let e=!1;do for(const t of this._postFixers)if(e=t(n),e)break;while(e)}};const fp=10;class _n extends ai{constructor(e,t,i,o){super(e,t,i,o),h(this,"_priority",fp),h(this,"_id",null),h(this,"_clonesGroup",null),this.getFillerOffset=Jv}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(this.id===null)throw new b("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}_canMergeAttributesFrom(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canSubtractAttributesOf(e)}}h(_n,"DEFAULT_PRIORITY",fp);_n.prototype.is=function(n,e){return e?e===this.name&&(n==="attributeElement"||n==="view:attributeElement"||n==="element"||n==="view:element"):n==="attributeElement"||n==="view:attributeElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function Jv(){if(Na(this))return null;let n=this.parent;for(;n&&n.is("attributeElement");){if(Na(n)>1)return null;n=n.parent}return!n||Na(n)>1?null:this.childCount}function Na(n){return Array.from(n.getChildren()).filter(e=>!e.is("uiElement")).length}class Kc extends ai{constructor(e,t,i,o){super(e,t,i,o),this.getFillerOffset=Qv}_insertChild(e,t){if(t&&(t instanceof An||Array.from(t).length>0))throw new b("view-emptyelement-cannot-add",[this,t]);return 0}}Kc.prototype.is=function(n,e){return e?e===this.name&&(n==="emptyElement"||n==="view:emptyElement"||n==="element"||n==="view:element"):n==="emptyElement"||n==="view:emptyElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function Qv(){return null}class la extends ai{constructor(e,t,i,o){super(e,t,i,o),this.getFillerOffset=Xv}_insertChild(e,t){if(t&&(t instanceof An||Array.from(t).length>0))throw new b("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 i of this.getAttributeKeys())t.setAttribute(i,this.getAttribute(i));return t}}la.prototype.is=function(n,e){return e?e===this.name&&(n==="uiElement"||n==="view:uiElement"||n==="element"||n==="view:element"):n==="uiElement"||n==="view:uiElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function Yv(n){n.document.on("arrowKey",(e,t)=>ey(e,t,n.domConverter),{priority:"low"})}function Xv(){return null}function ey(n,e,t){if(e.keyCode==Z.arrowright){const i=e.domTarget.ownerDocument.defaultView.getSelection(),o=i.rangeCount==1&&i.getRangeAt(0).collapsed;if(o||e.shiftKey){const s=i.focusNode,r=i.focusOffset,a=t.domPositionToView(s,r);if(a===null)return;let l=!1;const c=a.getLastMatchingPosition(u=>(u.item.is("uiElement")&&(l=!0),!!(u.item.is("uiElement")||u.item.is("attributeElement"))));if(l){const u=t.viewPositionToDom(c);o?i.collapse(u.parent,u.offset):i.extend(u.parent,u.offset)}}}}class Zc extends ai{constructor(e,t,i,o){super(e,t,i,o),this.getFillerOffset=ty}_insertChild(e,t){if(t&&(t instanceof An||Array.from(t).length>0))throw new b("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}Zc.prototype.is=function(n,e){return e?e===this.name&&(n==="rawElement"||n==="view:rawElement"||n==="element"||n==="view:element"):n==="rawElement"||n==="view:rawElement"||n===this.name||n==="view:"+this.name||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function ty(){return null}let vn=class extends ge(Cn){constructor(n,e){super(),h(this,"document"),h(this,"_children",[]),h(this,"_customProperties",new Map),this.document=n,e&&this._insertChild(0,e)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return this.childCount===0}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(n){return this._customProperties.get(n)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(n){return this._insertChild(this.childCount,n)}getChild(n){return this._children[n]}getChildIndex(n){return this._children.indexOf(n)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(n,e){this._fireChange("children",this,{index:n});let t=0;const i=iy(this.document,e);for(const o of i)o.parent!==null&&o._remove(),o.parent=this,this._children.splice(n,0,o),n++,t++;return t}_removeChildren(n,e=1){this._fireChange("children",this,{index:n});for(let t=n;ttypeof t=="string"?new Ge(n,t):t instanceof _i?new Ge(n,t.data):t))}class gp{constructor(e){h(this,"document"),h(this,"_cloneGroups",new Map),h(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 vn(this.document,e)}createText(e){return new Ge(this.document,e)}createAttributeElement(e,t,i={}){const o=new _n(this.document,e,t);return typeof i.priority=="number"&&(o._priority=i.priority),i.id&&(o._id=i.id),i.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),o}createContainerElement(e,t,i={},o={}){let s=null;Ut(i)?o=i:s=i;const r=new ls(this.document,e,t,s);return o.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...o.renderUnsafeAttributes),r}createEditableElement(e,t,i={}){const o=new ra(this.document,e,t);return i.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),o}createEmptyElement(e,t,i={}){const o=new Kc(this.document,e,t);return i.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),o}createUIElement(e,t,i){const o=new la(this.document,e,t);return i&&(o.render=i),o}createRawElement(e,t,i,o={}){const s=new Zc(this.document,e,t);return i&&(s.render=i),o.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...o.renderUnsafeAttributes),s}setAttribute(e,t,i,o){o!==void 0?o._setAttribute(e,t,i):i._setAttribute(e,t)}removeAttribute(e,t,i){i!==void 0?i._removeAttribute(e,t):t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){Ut(e)&&i===void 0?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof V?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new b("view-writer-break-non-container-element",this.document);if(!t.parent)throw new b("view-writer-break-root",this.document);if(e.isAtStart)return V._createBefore(t);if(!e.isAtEnd){const i=t._clone(!1);this.insert(V._createAfter(t),i);const o=new Q(e,V._createAt(t,"end")),s=new V(i,0);this.move(o,s)}return V._createAfter(t)}mergeAttributes(e){const t=e.offset,i=e.parent;if(i.is("$text"))return e;if(i.is("attributeElement")&&i.childCount===0){const r=i.parent,a=i.index;return i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new V(r,a))}const o=i.getChild(t-1),s=i.getChild(t);if(!o||!s)return e;if(o.is("$text")&&s.is("$text"))return xh(o,s);if(o.is("attributeElement")&&s.is("attributeElement")&&o.isSimilar(s)){const r=o.childCount;return o._appendChild(s.getChildren()),s._remove(),this._removeFromClonedElementsGroup(s),this.mergeAttributes(new V(o,r))}return e}mergeContainers(e){const t=e.nodeBefore,i=e.nodeAfter;if(!t||!i||!t.is("containerElement")||!i.is("containerElement"))throw new b("view-writer-merge-containers-invalid-position",this.document);const o=t.getChild(t.childCount-1),s=o instanceof Ge?V._createAt(o,"end"):V._createAt(t,"end");return this.move(Q._createIn(i),V._createAt(t,"end")),this.remove(Q._createOn(i)),s}insert(e,t){t=Pt(t)?[...t]:[t],pp(t,this.document);const i=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 o=null,s=e;for(const{nodes:r,breakAttributes:a}of i){const l=this._insertNodes(s,r,a);o||(o=l.start),s=l.end}return o?new Q(o,s):new Q(e)}remove(e){const t=e instanceof Q?e:Q._createOn(e);if(Po(t,this.document),t.isCollapsed)return new vn(this.document);const{start:i,end:o}=this._breakAttributesRange(t,!0),s=i.parent,r=o.offset-i.offset,a=s._removeChildren(i.offset,r);for(const c of a)this._removeFromClonedElementsGroup(c);const l=this.mergeAttributes(i);return t.start=l,t.end=l.clone(),new vn(this.document,a)}clear(e,t){Po(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const o of i){const s=o.item;let r;if(s.is("element")&&t.isSimilar(s))r=Q._createOn(s);else if(!o.nextPosition.isAfter(e.start)&&s.is("$textProxy")){const a=s.getAncestors().find(l=>l.is("element")&&t.isSimilar(l));a&&(r=Q._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 i;if(t.isAfter(e.end)){t=this._breakAttributes(t,!0);const o=t.parent,s=o.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=o.childCount-s}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof _n))throw new b("view-writer-wrap-invalid-attribute",this.document);if(Po(e,this.document),e.isCollapsed){let i=e.start;i.parent.is("element")&&!ny(i.parent)&&(i=i.getLastMatchingPosition(s=>s.item.is("uiElement"))),i=this._wrapPosition(i,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(i),new Q(i)}else return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof _n))throw new b("view-writer-unwrap-invalid-attribute",this.document);if(Po(e,this.document),e.isCollapsed)return e;const{start:i,end:o}=this._breakAttributesRange(e,!0),s=i.parent,r=this._unwrapChildren(s,i.offset,o.offset,t),a=this.mergeAttributes(r.start);a.isEqual(r.start)||r.end.offset--;const l=this.mergeAttributes(r.end);return new Q(a,l)}rename(e,t){const i=new ls(this.document,e,t.getAttributes());return this.insert(V._createAfter(t),i),this.move(Q._createIn(t),V._createAt(i,0)),this.remove(Q._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return V._createAt(e,t)}createPositionAfter(e){return V._createAfter(e)}createPositionBefore(e){return V._createBefore(e)}createRange(e,t){return new Q(e,t)}createRangeOn(e){return Q._createOn(e)}createRangeIn(e){return Q._createIn(e)}createSelection(...e){return new ki(...e)}createSlot(e="children"){if(!this._slotFactory)throw new b("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let o;if(i?o=Wl(e):o=e.parent.is("$text")?e.parent.parent:e.parent,!o)throw new b("view-writer-invalid-position-container",this.document);let s;i?s=this._breakAttributes(e,!0):s=e.parent.is("$text")?Da(e):e;const r=o._insertChild(s.offset,t);for(const u of t)this._addToClonedElementsGroup(u);const a=s.getShiftedBy(r),l=this.mergeAttributes(s);l.isEqual(s)||a.offset--;const c=this.mergeAttributes(a);return new Q(l,c)}_wrapChildren(e,t,i,o){let s=t;const r=[];for(;s!1,e.parent._insertChild(e.offset,i);const o=new Q(e,e.getShiftedBy(1));this.wrap(o,t);const s=new V(i.parent,i.index);i._remove();const r=s.nodeBefore,a=s.nodeAfter;return r&&r.is("view:$text")&&a&&a.is("view:$text")?xh(r,a):Ah(s)}_breakAttributesRange(e,t=!1){const i=e.start,o=e.end;if(Po(e,this.document),e.isCollapsed){const l=this._breakAttributes(e.start,t);return new Q(l,l)}const s=this._breakAttributes(o,t),r=s.parent.childCount,a=this._breakAttributes(i,t);return s.offset+=s.parent.childCount-r,new Q(a,s)}_breakAttributes(e,t=!1){const i=e.offset,o=e.parent;if(e.parent.is("emptyElement"))throw new b("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new b("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new b("view-writer-cannot-break-raw-element",this.document);if(!t&&o.is("$text")&&jl(o.parent)||jl(o))return e.clone();if(o.is("$text"))return this._breakAttributes(Da(e),t);const s=o.childCount;if(i==s){const r=new V(o.parent,o.index+1);return this._breakAttributes(r,t)}else if(i===0){const r=new V(o.parent,o.index);return this._breakAttributes(r,t)}else{const r=o.index+1,a=o._clone();o.parent._insertChild(r,a),this._addToClonedElementsGroup(a);const l=o.childCount-i,c=o._removeChildren(i,l);a._appendChild(c);const u=new V(o.parent,r);return this._breakAttributes(u,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const o of e.getChildren())this._addToClonedElementsGroup(o);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const o of e.getChildren())this._removeFromClonedElementsGroup(o);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function ny(n){return Array.from(n.getChildren()).some(e=>!e.is("uiElement"))}function Wl(n){let e=n.parent;for(;!jl(e);){if(!e)return;e=e.parent}return e}function oy(n,e){return n.prioritye.priority?!1:n.getIdentity()t instanceof i))throw new b("view-writer-insert-invalid-node-type",e);t.is("$text")||pp(t.getChildren(),e)}}function jl(n){return n&&(n.is("containerElement")||n.is("documentFragment"))}function Po(n,e){const t=Wl(n.start),i=Wl(n.end);if(!t||!i||t!==i)throw new b("view-writer-invalid-range-container",e)}const wp=n=>n.createTextNode(" "),bp=n=>{const e=n.createElement("span");return e.dataset.ckeFiller="true",e.innerText=" ",e},_p=n=>{const e=n.createElement("br");return e.dataset.ckeFiller="true",e},Ct=7,cs="".repeat(Ct);function it(n){return typeof n=="string"?n.substr(0,Ct)===cs:xe(n)&&n.data.substr(0,Ct)===cs}function io(n){return n.data.length==Ct&&it(n)}function Th(n){const e=typeof n=="string"?n:n.data;return it(n)?e.slice(Ct):e}function ry(n){n.document.on("arrowKey",ay,{priority:"low"})}function ay(n,e){if(e.keyCode==Z.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(t.rangeCount==1&&t.getRangeAt(0).collapsed){const i=t.getRangeAt(0).startContainer,o=t.getRangeAt(0).startOffset;it(i)&&o<=Ct&&t.collapse(i,0)}}}class ly extends ue(){constructor(e,t){super(),h(this,"domDocuments",new Set),h(this,"domConverter"),h(this,"markedAttributes",new Set),h(this,"markedChildren",new Set),h(this,"markedTexts",new Set),h(this,"selection"),h(this,"_inlineFiller",null),h(this,"_fakeSelectionContainer",null),this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),N.isBlink&&!N.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}markToSync(e,t){if(e==="text")this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if(e==="attributes")this.markedAttributes.add(t);else if(e==="children")this.markedChildren.add(t);else throw new b("view-renderer-unknown-type",this)}}render(){if(this.isComposing&&!N.isAndroid)return;let e=null;const t=N.isBlink&&!N.isAndroid?!this.isSelecting:!0;for(const i of this.markedChildren)this._updateChildrenMappings(i);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=V._createBefore(e.parent)));for(const i of this.markedAttributes)this._updateAttrs(i);for(const i of this.markedChildren)this._updateChildren(i,{inlineFillerPosition:e});for(const i of this.markedTexts)!this.markedChildren.has(i.parent)&&this.domConverter.mapViewToDom(i.parent)&&this._updateText(i,{inlineFillerPosition:e});if(t)if(e){const i=this.domConverter.viewPositionToDom(e),o=i.parent.ownerDocument;it(i.parent)?this._inlineFiller=i.parent:this._inlineFiller=Eh(o,i.parent,i.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.childNodes),o=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),s=this._diffNodeLists(i,o),r=this._findUpdateActions(s,i,o,uy);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,u=a.equal+a.delete,d=e.getChild(c);d&&!d.is("uiElement")&&!d.is("rawElement")&&this._updateElementMappings(d,i[u]),mh(o[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")?V._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&&xe(t.parent)&&it(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!it(e))throw new b("view-renderer-filler-was-lost",this);io(e)?e.remove():e.data=e.data.substr(Ct),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root)||!t.is("element")||!cy(t))return!1;const o=e.nodeBefore,s=e.nodeAfter;return!(o instanceof Ge||s instanceof Ge||i===t.getFillerOffset()&&(!o||!o.is("element","br"))||N.isAndroid&&(o||s))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let o=this.domConverter.viewToDom(e).data;const s=t.inlineFillerPosition;s&&s.parent==e.parent&&s.offset==e.index&&(o=cs+o),this._updateTextNode(i,o)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(t){for(const i of Array.from(t.attributes)){const o=i.name;e.hasAttribute(o)||this.domConverter.removeDomElementAttribute(t,o)}for(const i of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e)}}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;if(N.isAndroid){let d=null;for(const m of Array.from(i.childNodes)){if(d&&xe(d)&&xe(m)){i.normalize();break}d=m}}const o=t.inlineFillerPosition,s=i.childNodes,r=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));o&&o.parent===e&&Eh(i.ownerDocument,r,o.offset);const a=this._diffNodeLists(s,r),l=this._findUpdateActions(a,s,r,hy);let c=0;const u=new Set;for(const d of l)d==="delete"?(u.add(s[c]),mh(s[c])):(d==="equal"||d==="update")&&c++;c=0;for(const d of l)d==="insert"?(ep(i,c,r[c]),c++):d==="update"?(this._updateTextNode(s[c],r[c].data),c++):d==="equal"&&(this._markDescendantTextToSync(this.domConverter.domToView(r[c])),c++);for(const d of u)d.parentNode||this.domConverter.unbindDomElement(d)}_diffNodeLists(e,t){return e=fy(e,this._fakeSelectionContainer),oo(e,t,dy.bind(null,this.domConverter))}_findUpdateActions(e,t,i,o){if(e.indexOf("insert")===-1||e.indexOf("delete")===-1)return e;let s=[],r=[],a=[];const l={equal:0,insert:0,delete:0};for(const c of e)c==="insert"?a.push(i[l.equal+l.insert]):c==="delete"?r.push(t[l.equal+l.delete]):(s=s.concat(oo(r,a,o).map(u=>u==="equal"?"update":u)),s.push("equal"),r=[],a=[]),l[c]++;return s.concat(oo(r,a,o).map(c=>c==="equal"?"update":c))}_updateTextNode(e,t){const i=e.data;i!=t&&(N.isAndroid&&this.isComposing&&i.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){const i=Lg(e.data,t);for(const o of i)o.type==="insert"?e.insertData(o.index,o.values.join("")):e.deleteData(o.index,o.howMany)}_markDescendantTextToSync(e){if(e){if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}}_updateSelection(){if(N.isBlink&&!N.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(this.selection.rangeCount===0){this._removeDomSelection(),this._removeFakeSelection();return}const e=this.domConverter.mapViewToDom(this.selection.editableElement);if(!this.isFocused||!e){!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection();return}this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&N.isAndroid||this._updateDomSelection(e)}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=gy(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;(!i.parentElement||i.parentElement!=e)&&e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const o=t.getSelection(),s=t.createRange();o.removeAllRanges(),s.selectNodeContents(i),o.addRange(s)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),o=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,o.parent,o.offset),N.isGecko&&my(o,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||i.anchorNode!==t&&!t.contains(i.anchorNode)?!0:t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,o=this.domConverter.mapDomToView(i);i&&o&&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 cy(n){if(n.getAttribute("contenteditable")=="false")return!1;const e=n.findAncestor(t=>t.hasAttribute("contenteditable"));return!e||e.getAttribute("contenteditable")=="true"}function Eh(n,e,t){const i=e instanceof Array?e:e.childNodes,o=i[t];if(xe(o))return o.data=cs+o.data,o;{const s=n.createTextNode(cs);return Array.isArray(e)?i.splice(t,0,s):ep(e,t,s),s}}function uy(n,e){return Zi(n)&&Zi(e)&&!xe(n)&&!xe(e)&&!Qo(n)&&!Qo(e)&&n.tagName.toLowerCase()===e.tagName.toLowerCase()}function hy(n,e){return Zi(n)&&Zi(e)&&xe(n)&&xe(e)}function dy(n,e,t){return e===t?!0:xe(e)&&xe(t)?e.data===t.data:!!(n.isBlockFiller(e)&&n.isBlockFiller(t))}function my(n,e){let t=n.parent,i=n.offset;if(xe(t)&&io(t)&&(i=to(t)+1,t=t.parentNode),t.nodeType!=Node.ELEMENT_NODE||i!=t.childNodes.length-1)return;const o=t.childNodes[i];o&&o.tagName=="BR"&&e.addRange(e.getRangeAt(0))}function fy(n,e){const t=Array.from(n);return t.length==0||!e||t[t.length-1]==e&&t.pop(),t}function gy(n){const e=n.createElement("div");return e.className="ck-fake-selection-container",Object.assign(e.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),e.textContent=" ",e}const py=_p(I.document),wy=wp(I.document),by=bp(I.document),zs="data-ck-unsafe-attribute-",Sh="data-ck-unsafe-element";class ca{constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){h(this,"document"),h(this,"renderingMode"),h(this,"blockFillerMode"),h(this,"preElements"),h(this,"blockElements"),h(this,"inlineObjectElements"),h(this,"unsafeElements"),h(this,"_domDocument"),h(this,"_domToViewMapping",new WeakMap),h(this,"_viewToDomMapping",new WeakMap),h(this,"_fakeSelectionMapping",new WeakMap),h(this,"_rawContentElementMatcher",new ft),h(this,"_inlineObjectElementMatcher",new ft),h(this,"_elementsWithTemporaryCustomProperties",new Set),this.document=e,this.renderingMode=i,this.blockFillerMode=t||(i==="editing"?"br":"nbsp"),this.preElements=["pre","textarea"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument=this.renderingMode==="editing"?I.document:I.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new ki(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 i of e.children)this.unbindDomElement(i)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return this.renderingMode==="data"?!0:(e=e.toLowerCase(),e.startsWith("on")||e==="srcdoc"&&t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i)?!1:i==="img"&&(e==="src"||e==="srcset")||i==="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 i=new DOMParser().parseFromString(t,"text/html"),o=i.createDocumentFragment(),s=i.body.childNodes;for(;s.length>0;)o.appendChild(s[0]);const r=i.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),a=[];let l;for(;l=r.nextNode();)a.push(l);for(const c of a){for(const d of c.getAttributeNames())this.setDomElementAttribute(c,d,c.getAttribute(d));const u=c.tagName.toLowerCase();this._shouldRenameElement(u)&&(Rh(u),c.replaceWith(this._createReplacementDomElement(u,c)))}for(;e.firstChild;)e.firstChild.remove();e.append(o)}viewToDom(e,t={}){if(e.is("$text")){const i=this._processDataFromViewText(e);return this._domDocument.createTextNode(i)}else{const i=e;if(this.mapViewToDom(i))if(i.getCustomProperty("editingPipeline:doNotReuseOnce"))this._elementsWithTemporaryCustomProperties.add(i);else return this.mapViewToDom(i);let o;if(i.is("documentFragment"))o=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(o,i);else{if(i.is("uiElement"))return i.name==="$comment"?o=this._domDocument.createComment(i.getCustomProperty("$rawContent")):o=i.render(this._domDocument,this),t.bind&&this.bindElements(o,i),o;this._shouldRenameElement(i.name)?(Rh(i.name),o=this._createReplacementDomElement(i.name)):i.hasAttribute("xmlns")?o=this._domDocument.createElementNS(i.getAttribute("xmlns"),i.name):o=this._domDocument.createElement(i.name),i.is("rawElement")&&i.render(o,this),t.bind&&this.bindElements(o,i);for(const s of i.getAttributeKeys())this.setDomElementAttribute(o,s,i.getAttribute(s),i)}if(t.withChildren!==!1)for(const s of this.viewChildrenToDom(i,t))o instanceof HTMLTemplateElement?o.content.appendChild(s):o.appendChild(s);return o}}setDomElementAttribute(e,t,i,o){const s=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||o&&o.shouldRenderUnsafeAttribute(t);if(s||J("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),!tp(t)){J("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i});return}e.hasAttribute(t)&&!s?e.removeAttribute(t):e.hasAttribute(zs+t)&&s&&e.removeAttribute(zs+t),e.setAttribute(s?t:zs+t,i)}removeDomElementAttribute(e,t){t!=Sh&&(e.removeAttribute(t),e.removeAttribute(zs+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let o=0;for(const s of e.getChildren()){i===o&&(yield this._getBlockFiller());const r=s.is("element")&&!!s.getCustomProperty("dataPipeline:transparentRendering")&&!ae(s.getAttributes());if(r&&this.renderingMode=="data")if(s.is("rawElement")){const a=this._domDocument.createElement(s.name);s.render(a,this),yield*[...a.childNodes]}else yield*this.viewChildrenToDom(s,t);else r&&J("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:s}),yield this.viewToDom(s,t);o++}i===o&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),o=this._domDocument.createRange();return o.setStart(t.parent,t.offset),o.setEnd(i.parent,i.offset),o}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let o=e.offset;return it(i)&&(o+=Ct),{parent:i,offset:o}}else{let i,o,s;if(e.offset===0){if(i=this.mapViewToDom(t),!i)return null;s=i.childNodes[0]}else{const a=e.nodeBefore;if(o=a.is("$text")?this.findCorrespondingDomText(a):this.mapViewToDom(a),!o)return null;i=o.parentNode,s=o.nextSibling}if(xe(s)&&it(s))return{parent:s,offset:Ct};const r=o?to(o)+1:0;return{parent:i,offset:r}}}domToView(e,t={}){const i=[],o=this._domToView(e,t,i),s=o.next().value;return!s||(o.next(),this._processDomInlineNodes(null,i,t),this.blockFillerMode=="br"&&Ih(s))||s.is("$text")&&s.data.length==0?null:s}*domChildrenToView(e,t={},i=[]){let o=[];e instanceof HTMLTemplateElement?o=[...e.content.childNodes]:o=[...e.childNodes];for(let s=0;s{const{scrollLeft:a,scrollTop:l}=r;s.push([a,l])}),t.focus(),Ph(t,r=>{const[a,l]=s.shift();r.scrollLeft=a,r.scrollTop=l}),I.window.scrollTo(i,o)}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return this.blockFillerMode=="br"?e.isEqualNode(py):Vh(e,this.blockElements)?!0:e.isEqualNode(by)||vy(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 i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=Zg(e);for(t.pop();t.length;){const i=t.pop(),o=this._domToViewMapping.get(i);if(o&&(o.is("uiElement")||o.is("rawElement")))return o}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return wp(this._domDocument);case"markedNbsp":return bp(this._domDocument);case"br":return _p(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(xe(e)&&it(e)&&t0?t[s-1]:null,u=s+1t.is("element")&&e.includes(t.name))}function Ph(n,e){let t=n;for(;t;)e(t),t=t.parentElement}function vy(n,e){return n.isEqualNode(wy)&&vp(n,e)&&n.parentNode.childNodes.length===1}function vp(n,e){const t=n.parentNode;return!!t&&!!t.tagName&&e.includes(t.tagName.toLowerCase())}function yy(n,e,t){return e==" "&&n&&n.is("element")&&n.childCount==1&&t.includes(n.name)}function ky(n,e){return e==" "&&n&&n.is("element","span")&&n.childCount==1&&n.hasAttribute("data-cke-filler")}function Ih(n){return n.is("element","br")&&n.hasAttribute("data-cke-filler")}function Vh(n,e){return n.tagName==="BR"&&vp(n,e)&&n.parentNode.childNodes.length===1}function Rh(n){n==="script"&&J("domconverter-unsafe-script-element-detected"),n==="style"&&J("domconverter-unsafe-style-element-detected")}function Cy(n){if(!N.isGecko||!n.rangeCount)return!1;const e=n.getRangeAt(0).startContainer;try{Object.prototype.toString.call(e)}catch{return!0}return!1}class Zt extends st(){constructor(e){super(),h(this,"view"),h(this,"document"),h(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] *")}}class kn{constructor(e,t,i){h(this,"view"),h(this,"document"),h(this,"domEvent"),h(this,"domTarget"),this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,Rg(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class ui extends Zt{constructor(){super(...arguments),h(this,"useCapture",!1),h(this,"usePassive",!1)}observe(e){(typeof this.domEventType=="string"?[this.domEventType]:this.domEventType).forEach(t=>{this.listenTo(e,t,(i,o)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(o.target)&&this.onDomEvent(o)},{useCapture:this.useCapture,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new kn(this.view,t,i))}}class Ay extends ui{constructor(){super(...arguments),h(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 yn(this)}};this.fire(e.type,e,t)}}class xy extends Zt{constructor(e){super(e),h(this,"_fireSelectionChangeDoneDebounced"),this._fireSelectionChangeDoneDebounced=St(t=>{this.document.fire("selectionChangeDone",t)},200)}observe(){const e=this.document;e.on("arrowKey",(t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()},{context:"$capture"}),e.on("arrowKey",(t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)},{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new ki(t.getRanges(),{backward:t.isBackward,fake:!1});(e==Z.arrowleft||e==Z.arrowup)&&i.setTo(i.getFirstPosition()),(e==Z.arrowright||e==Z.arrowdown)&&i.setTo(i.getLastPosition());const o={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",o),this._fireSelectionChangeDoneDebounced(o)}}let yp=class extends Zt{constructor(n){super(n),h(this,"domConverter"),h(this,"_config"),h(this,"_domElements"),h(this,"_mutationObserver"),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=n.domConverter,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(n){this._domElements.add(n),this.isEnabled&&this._mutationObserver.observe(n,this._config)}stopObserving(n){if(this._domElements.delete(n),this.isEnabled){this._mutationObserver.disconnect();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}}enable(){super.enable();for(const n of this._domElements)this._mutationObserver.observe(n,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(n){if(n.length===0)return;const e=this.domConverter,t=new Set,i=new Set;for(const s of n){const r=e.mapDomToView(s.target);r&&(r.is("uiElement")||r.is("rawElement")||s.type==="childList"&&!this._isBogusBrMutation(s)&&i.add(r))}for(const s of n){const r=e.mapDomToView(s.target);if(!(r&&(r.is("uiElement")||r.is("rawElement")))&&s.type==="characterData"){const a=e.findCorrespondingViewText(s.target);a&&!i.has(a.parent)?t.add(a):!a&&it(s.target)&&i.add(e.mapDomToView(s.target.parentNode))}}const o=[];for(const s of t)o.push({type:"text",node:s});for(const s of i){const r=e.mapViewToDom(s),a=Array.from(s.getChildren()),l=Array.from(e.domChildrenToView(r,{withChildren:!1}));Bg(a,l,Ty)||o.push({type:"children",node:s})}o.length&&this.document.fire("mutations",{mutations:o})}_isBogusBrMutation(n){let e=null;return n.nextSibling===null&&n.removedNodes.length===0&&n.addedNodes.length==1&&(e=this.domConverter.domToView(n.addedNodes[0],{withChildren:!1})),e&&e.is("element","br")}};function Ty(n,e){if(!Array.isArray(n))return n===e?!0:n.is("$text")&&e.is("$text")?n.data===e.data:!1}class Vr extends ui{constructor(e){super(e),h(this,"_renderTimeoutId",null),h(this,"_isFocusChanging",!1),h(this,"domEventType",["focus","blur"]),this.useCapture=!0;const t=this.document;t.on("focus",()=>this._handleFocus()),t.on("blur",(i,o)=>this._handleBlur(o)),t.on("beforeinput",()=>{t.isFocused||this._handleFocus()},{priority:"highest"})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._clearTimeout(),super.destroy()}_handleFocus(){this._clearTimeout(),this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this._renderTimeoutId=null,this.flush(),this.view.change(()=>{})},50)}_handleBlur(e){const t=this.document.selection.editableElement;(t===null||t===e.target)&&(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class Ey extends Zt{constructor(e){super(e),h(this,"mutationObserver"),h(this,"focusObserver"),h(this,"selection"),h(this,"domConverter"),h(this,"_documents",new WeakSet),h(this,"_fireSelectionChangeDoneDebounced"),h(this,"_clearInfiniteLoopInterval"),h(this,"_documentIsSelectingInactivityTimeoutDebounced"),h(this,"_loopbackCounter",0),h(this,"_pendingSelectionChange",new Set),this.mutationObserver=e.getObserver(yp),this.focusObserver=e.getObserver(Vr),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=St(t=>{this.document.fire("selectionChangeDone",t)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=St(()=>this.document.isSelecting=!1,5e3),this.view.document.on("change:isFocused",(t,i,o)=>{if(o&&this._pendingSelectionChange.size){for(const s of Array.from(this._pendingSelectionChange))this._handleSelectionChange(s);this._pendingSelectionChange.clear()}})}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},o=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",i,{priority:"highest"}),this.listenTo(e,"keydown",o,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",o,{priority:"highest",useCapture:!0}),!this._documents.has(t)&&(this.listenTo(t,"mouseup",o,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",()=>{this.document.isComposing&&!N.isAndroid||(this._handleSelectionChange(t),this._documentIsSelectingInactivityTimeoutDebounced())}),this.listenTo(this.view.document,"compositionstart",()=>{this._handleSelectionChange(t)},{priority:"lowest"}),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e){if(!this.isEnabled)return;const t=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(t.anchorNode))return;this.mutationObserver.flush();const i=this.domConverter.domSelectionToView(t);if(i.rangeCount==0){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.view.document.isFocused&&!this.view.document.isReadOnly){this._pendingSelectionChange.add(e);return}if(this._pendingSelectionChange.delete(e),!(this.selection.isEqual(i)&&this.domConverter.isDomSelectionCorrect(t))){if(++this._loopbackCounter>60){this._reportInfiniteLoop();return}if(this.selection.isSimilar(i))this.view.forceRender();else{const o={oldSelection:this.selection,newSelection:i,domSelection:t};this.document.fire("selectionChange",o),this._fireSelectionChangeDoneDebounced(o)}}}_clearInfiniteLoop(){this._loopbackCounter=0}}class Sy extends ui{constructor(e){super(e),h(this,"domEventType",["compositionstart","compositionupdate","compositionend"]);const t=this.document;t.on("compositionstart",()=>{t.isComposing=!0}),t.on("compositionend",()=>{t.isComposing=!1})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class kp{constructor(e,t={}){h(this,"_files"),h(this,"_native"),this._files=t.cacheFiles?Oh(e):null,this._native=e}get files(){return this._files||(this._files=Oh(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return this._native.dropEffect=="none"||!!this._native.mozUserCancelled}}function Oh(n){const e=Array.from(n.files||[]),t=Array.from(n.items||[]);return e.length?e:t.filter(i=>i.kind==="file").map(i=>i.getAsFile())}class Py extends ui{constructor(){super(...arguments),h(this,"domEventType","beforeinput")}onDomEvent(e){const t=e.getTargetRanges(),i=this.view,o=i.document;let s=null,r=null,a=[];if(e.dataTransfer&&(s=new kp(e.dataTransfer)),e.data!==null?r=e.data:s&&(r=s.getData("text/plain")),o.selection.isFake)a=Array.from(o.selection.getRanges()),e.preventDefault();else if(t.length)a=t.map(l=>{let c=i.domConverter.domPositionToView(l.startContainer,l.startOffset);const u=i.domConverter.domPositionToView(l.endContainer,l.endOffset);if(c&&it(l.startContainer)&&l.startOffset!!(m.item.is("attributeElement")||m.item.is("uiElement")||m.item.is("$textProxy")&&d--),{direction:"backward",singleCharacters:!0})}if(Iy(l.endContainer,l.endOffset)&&e.preventDefault(),c)return i.createRange(c,u);if(u)return i.createRange(u)}).filter(l=>!!l);else if(N.isAndroid){const l=e.target.ownerDocument.defaultView.getSelection();a=Array.from(i.domConverter.domSelectionToView(l).getRanges())}if(N.isAndroid&&e.inputType=="insertCompositionText"&&r&&r.endsWith(`
`)){this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(a[0].end)]});return}if(["insertText","insertReplacementText"].includes(e.inputType)&&r&&r.includes(`
`)){const l=r.split(/\n{1,2}/g);let c=a;e.preventDefault();for(let u=0;u{if(this.isEnabled&&fv(i.keyCode)){const o=new xn(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(o,i),o.stop.called&&t.stop()}})}observe(){}stopObserving(){}}class Ry extends Zt{constructor(e){super(e);const t=this.document;t.on("keydown",(i,o)=>{if(!this.isEnabled||o.keyCode!=Z.tab||o.ctrlKey)return;const s=new xn(t,"tab",t.selection.getFirstRange());t.fire(s,o),s.stop.called&&i.stop()})}observe(){}stopObserving(){}}let Oy=class extends ue(){constructor(n){super(),h(this,"document"),h(this,"domConverter"),h(this,"domRoots",new Map),h(this,"_renderer"),h(this,"_initialDomRootAttributes",new WeakMap),h(this,"_observers",new Map),h(this,"_writer"),h(this,"_ongoingChange",!1),h(this,"_postFixersInProgress",!1),h(this,"_renderingDisabled",!1),h(this,"_hasChangedSinceTheLastRendering",!1),this.document=new aa(n),this.domConverter=new ca(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new ly(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new gp(this.document),this.addObserver(yp),this.addObserver(Vr),this.addObserver(Ey),this.addObserver(Ay),this.addObserver(xy),this.addObserver(Sy),this.addObserver(Vy),this.addObserver(Py),this.addObserver(Ry),ry(this),Yv(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}),N.isiOS&&this.listenTo(this.document,"blur",(e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(e,{mutations:t})=>{t.forEach(i=>this._renderer.markToSync(i.type,i.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(n,e="main"){const t=this.document.getRoot(e);t._name=n.tagName.toLowerCase();const i={};for(const{name:s,value:r}of Array.from(n.attributes))i[s]=r,s==="class"?this._writer.addClass(r.split(" "),t):t.hasAttribute(s)||this._writer.setAttribute(s,r,t);this._initialDomRootAttributes.set(n,i);const o=()=>{this._writer.setAttribute("contenteditable",(!t.isReadOnly).toString(),t),t.isReadOnly?this._writer.addClass("ck-read-only",t):this._writer.removeClass("ck-read-only",t)};o(),this.domRoots.set(e,n),this.domConverter.bindElements(n,t),this._renderer.markToSync("children",t),this._renderer.markToSync("attributes",t),this._renderer.domDocuments.add(n.ownerDocument),t.on("change:children",(s,r)=>this._renderer.markToSync("children",r)),t.on("change:attributes",(s,r)=>this._renderer.markToSync("attributes",r)),t.on("change:text",(s,r)=>this._renderer.markToSync("text",r)),t.on("change:isReadOnly",()=>this.change(o)),t.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const s of this._observers.values())s.observe(n,e)}detachDomRoot(n){const e=this.domRoots.get(n);Array.from(e.attributes).forEach(({name:i})=>e.removeAttribute(i));const t=this._initialDomRootAttributes.get(e);for(const i in t)e.setAttribute(i,t[i]);this.domRoots.delete(n),this.domConverter.unbindDomElement(e);for(const i of this._observers.values())i.stopObserving(e)}getDomRoot(n="main"){return this.domRoots.get(n)}addObserver(n){let e=this._observers.get(n);if(e)return e;e=new n(this),this._observers.set(n,e);for(const[t,i]of this.domRoots)e.observe(i,t);return e.enable(),e}getObserver(n){return this._observers.get(n)}disableObservers(){for(const n of this._observers.values())n.disable()}enableObservers(){for(const n of this._observers.values())n.enable()}scrollToTheSelection({alignToTop:n,forceScroll:e,viewportOffset:t=20,ancestorOffset:i=20}={}){const o=this.document.selection.getFirstRange();if(!o)return;const s=mt({alignToTop:n,forceScroll:e,viewportOffset:t,ancestorOffset:i});typeof t=="number"&&(t={top:t,bottom:t,left:t,right:t});const r={target:this.domConverter.viewRangeToDom(o),viewportOffset:t,ancestorOffset:i,alignToTop:n,forceScroll:e};this.fire("scrollToTheSelection",r,s),np(r)}focus(){if(!this.document.isFocused){const n=this.document.selection.editableElement;n&&(this.domConverter.focus(n),this.forceRender())}}change(n){if(this.isRenderingInProgress||this._postFixersInProgress)throw new b("cannot-change-view-tree",this);try{if(this._ongoingChange)return n(this._writer);this._ongoingChange=!0;const e=n(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),e}catch(e){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Vr).flush(),this.change(()=>{})}destroy(){for(const n of this._observers.values())n.destroy();this.document.destroy(),this.stopListening()}createPositionAt(n,e){return V._createAt(n,e)}createPositionAfter(n){return V._createAfter(n)}createPositionBefore(n){return V._createBefore(n)}createRange(n,e){return new Q(n,e)}createRangeOn(n){return Q._createOn(n)}createRangeIn(n){return Q._createIn(n)}createSelection(...n){return new ki(...n)}_disableRendering(n){this._renderingDisabled=n,n==!1&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}};/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Yi{is(){throw new Error("is() method is abstract")}}class Lt extends Yi{constructor(e,t,i){if(super(),h(this,"textNode"),h(this,"data"),h(this,"offsetInText"),this.textNode=e,t<0||t>e.offsetSize)throw new b("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new b("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),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 i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}Lt.prototype.is=function(n){return n==="$textProxy"||n==="model:$textProxy"||n==="textProxy"||n==="model:textProxy"};class yi{constructor(e){if(h(this,"direction"),h(this,"boundaries"),h(this,"singleCharacters"),h(this,"shallow"),h(this,"ignoreElementEnd"),h(this,"_position"),h(this,"_boundaryStartParent"),h(this,"_boundaryEndParent"),h(this,"_visitedParent"),!e||!e.boundaries&&!e.startPosition)throw new b("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if(t!="forward"&&t!="backward")throw new b("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=C._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,i,o,s;do o=this.position,s=this._visitedParent,{done:t,value:i}=this.next();while(!t&&e(i));t||(this._position=o,this._visitedParent=s)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone(),this._visitedParent=e.parent}next(){return this.direction=="forward"?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(i.parent===null&&t.offset===i.maxOffset)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const o=Yo(t,i),s=o||Cp(t,i,o);if(s&&s.is("model:element")){if(!this.shallow)t.path.push(0),this._visitedParent=s;else{if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}return this._position=t,an("elementStart",s,e,t,1)}if(s&&s.is("model:$text")){let r;if(this.singleCharacters)r=1;else{let c=s.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offsetu&&(u=this.boundaries.start.offset),a=t.offset-u}const l=t.offset-r.startOffset,c=new Lt(r,l-a,a);return t.offset-=a,this._position=t,an("text",c,e,t,a)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,an("elementStart",i,e,t,1)}}function an(n,e,t,i,o){return{done:!1,value:{type:n,item:e,previousPosition:t,nextPosition:i,length:o}}}class C extends Yi{constructor(e,t,i="toNone"){if(super(),h(this,"root"),h(this,"path"),h(this,"stickiness"),!e.is("element")&&!e.is("documentFragment"))throw new b("model-position-root-invalid",e);if(!Array.isArray(t)||t.length===0)throw new b("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t1)return!1;if(o===1)return Bh(e,this,i);if(o===-1)return Bh(this,e,i)}return this.path.length===e.path.length?!0:this.path.length>e.path.length?Ul(this.path,t):Ul(e.path,t)}hasSameParentAs(e){if(this.root!==e.root)return!1;const t=this.getParentPath(),i=e.getParentPath();return Xe(t,i)=="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=C._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,i=t.containsPosition(this)||t.start.isEqual(this);let o;return i?(o=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(o=o._getTransformedByDeletion(e.deletionPosition,1))):this.isEqual(e.deletionPosition)?o=C._createAt(e.deletionPosition):o=this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),o}_getTransformedByDeletion(e,t){const i=C._createAt(this);if(this.root!=e.root)return i;if(Xe(e.getParentPath(),this.getParentPath())=="same"){if(e.offsetthis.offset)return null;i.offset-=t}}else if(Xe(e.getParentPath(),this.getParentPath())=="prefix"){const o=e.path.length-1;if(e.offset<=this.path[o]){if(e.offset+t>this.path[o])return null;i.path[o]-=t}}return i}_getTransformedByInsertion(e,t){const i=C._createAt(this);if(this.root!=e.root)return i;if(Xe(e.getParentPath(),this.getParentPath())=="same")(e.offset=e;){if(n.path[i]+o!==t.maxOffset)return!1;o=1,i--,t=t.parent}return!0}class y extends Yi{constructor(e,t){super(),h(this,"start"),h(this,"end"),this.start=C._createAt(e),this.end=t?C._createAt(t):C._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new yi({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){const e=this.start.getParentPath(),t=this.end.getParentPath();return Xe(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 i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),o=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&o}containsItem(e){const t=C._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 y(this.start,e.start)),this.containsPosition(e.end)&&t.push(new y(e.end,this.end))):t.push(new y(this.start,this.end)),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,i=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(i=e.end),new y(t,i)}return null}getJoined(e,t=!1){let i=this.isIntersecting(e);if(i||(this.start.isBefore(e.start)?i=t?this.end.isTouching(e.start):this.end.isEqual(e.start):i=t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!i)return null;let o=this.start,s=this.end;return e.start.isBefore(o)&&(o=e.start),e.end.isAfter(s)&&(s=e.end),new y(o,s)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,i=C._createAt(this.start);let o=i.parent;for(;i.path.length>t+1;){const s=o.maxOffset-i.offset;s!==0&&e.push(new y(i,i.getShiftedBy(s))),i.path=i.path.slice(0,-1),i.offset++,o=o.parent}for(;i.path.length<=this.end.path.length;){const s=this.end.path[i.path.length-1],r=s-i.offset;r!==0&&e.push(new y(i,i.getShiftedBy(r))),i.offset=s,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new yi(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new yi(e);for(const i of t)yield i.item}*getPositions(e={}){e.boundaries=this;const t=new yi(e);yield t.position;for(const i of t)yield i.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 y(this.start,this.end)]}getTransformedByOperations(e){const t=[new y(this.start,this.end)];for(const i of e)for(let o=0;o0?new this(i,o):new this(o,i)}static _createIn(e){return new this(C._createAt(e,0),C._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(C._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(e.length===0)throw new b("range-create-from-ranges-empty-array",null);if(e.length==1)return e[0].clone();const t=e[0];e.sort((s,r)=>s.start.isAfter(r.start)?1:-1);const i=e.indexOf(t),o=new this(t.start,t.end);for(let s=i-1;s>=0&&e[s].end.isEqual(o.start);s--)o.start=C._createAt(e[s].start);for(let s=i+1;s{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new b("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),o=this._viewToModelMapping.get(i),s=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=C._createAt(o,s)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const o of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(o);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)&&this._cache.stopTracking(t)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const o=this._elementToMarkerNames.get(e)||new Set;o.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,o)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),i.size==0&&this._markerNameToElements.delete(t));const o=this._elementToMarkerNames.get(e);o&&(o.delete(t),o.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 y(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Q(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const o of t)if(o.is("attributeElement"))for(const s of o.getElementsWithSameId())i.add(s);else i.add(o);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e){const s=this._toModelOffset(e.parent,e.index,i),r=this._toModelOffset(e,t,e);return s+r}if(e.is("$text"))return t;let o=0;for(let s=0;s0;){const o=t.pop(),s=o.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(o.name);if(s)i+=s(o);else if(this._viewToModelMapping.has(o))i+=1;else if(o.is("$text"))i+=o.data.length;else{if(o.is("uiElement"))continue;for(const r of o.getChildren())t.push(r)}}return i}findPositionIn(e,t){if(t===0)return this._moveViewPositionToTextNode(new V(e,0));if(this._viewToModelLengthCallbacks.size==0&&this._viewToModelMapping.has(e)){const i=this._cache.getClosest(e,t);return this._findPositionStartingFrom(i.viewPosition,i.modelOffset,t,e,!0)}else return this._findPositionStartingFrom(new V(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,i,o,s){let r=e.parent,a=e.offset;if(r.is("$text"))return new V(r,i-t);let l,c=t,u=0;for(;c{this._clearCacheInsideParent(t,i.index)}),h(this,"_invalidateOnTextChangeCallback",(e,t)=>{this._clearCacheStartingBefore(t)})}save(e,t,i,o){const s=this._cachedMapping.get(i),r=s.cacheMap.get(o);if(r){const c=e.getChild(t-1),u=r.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(r.viewPosition.nodeBefore):0;this._nodeToCacheListIndex.set(c,u);return}const a={viewPosition:new V(e,t),modelOffset:o};s.maxModelOffset=o>s.maxModelOffset?o:s.maxModelOffset,s.cacheMap.set(o,a);let l=s.cacheList.length-1;for(;l>=0&&s.cacheList[l].modelOffset>o;)l--;if(s.cacheList.splice(l+1,0,a),t>0){const c=e.getChild(t-1);this._nodeToCacheListIndex.set(c,l+1)}}getClosest(e,t){const i=this._cachedMapping.get(e);let o;if(i)if(t>i.maxModelOffset)o=i.cacheList[i.cacheList.length-1];else{const r=i.cacheMap.get(t);r?o=r:o=this._findInCacheList(i.cacheList,t)}else o=this.startTracking(e);const s=this._hoistViewPosition(o.viewPosition);return{modelOffset:o.modelOffset,viewPosition:s}}_hoistViewPosition(e){for(;e.parent.parent&&!this._cachedMapping.has(e.parent)&&e.isAtEnd;){const t=e.parent.parent,i=t.getChildIndex(e.parent)+1;e=new V(t,i)}return e}startTracking(e){const t={viewPosition:new V(e,0),modelOffset:0},i={maxModelOffset:0,cacheList:[t],cacheMap:new Map([[0,t]])};return this._cachedMapping.set(e,i),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),t}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(t==0)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheStartingBefore(e);else{const i=e.getChild(t-1);this._clearCacheStartingBefore(i)}}_clearCacheAll(e){const t=this._cachedMapping.get(e);t.maxModelOffset>0&&(t.maxModelOffset=0,t.cacheList.length=1,t.cacheMap.clear(),t.cacheMap.set(0,t.cacheList[0]))}_clearCacheStartingBefore(e){const t=this._nodeToCacheListIndex.get(e);if(t===void 0){const o=e.parent;this._cachedMapping.has(o)||this._clearCacheStartingBefore(o);return}let i=e.parent;for(;!this._cachedMapping.has(i);)i=i.parent;this._clearCacheFromIndex(i,t)}_clearCacheFromIndex(e,t){t===0&&(t=1);const i=this._cachedMapping.get(e),o=i.cacheList[t-1];if(!o)return;i.maxModelOffset=o.modelOffset;const s=i.cacheList.splice(t);for(const r of s){i.cacheMap.delete(r.modelOffset);const a=r.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(a)}}_findInCacheList(e,t){let i=0,o=e.length-1,s=o-i>>1,r=e[s];for(;i>1),r=e[s];return r.modelOffset<=t?r:e[s-1]}}class Ly{constructor(){h(this,"_consumable",new Map),h(this,"_textProxyRegistry",new Map)}add(e,t){t=Hs(t),e instanceof Lt&&(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=Hs(t),e instanceof Lt&&(e=this._getSymbolForTextProxy(e)),this.test(e,t)?(this._consumable.get(e).set(t,!1),!0):!1}test(e,t){t=Hs(t),e instanceof Lt&&(e=this._getSymbolForTextProxy(e));const i=this._consumable.get(e);if(i===void 0)return null;const o=i.get(t);return o===void 0?null:o}revert(e,t){t=Hs(t),e instanceof Lt&&(e=this._getSymbolForTextProxy(e));const i=this.test(e,t);return i===!1?(this._consumable.get(e).set(t,!0),!0):i===!0?!1:null}verifyAllConsumed(e){const t=[];for(const[i,o]of this._consumable)for(const[s,r]of o){const a=s.split(":")[0];r&&e==a&&t.push({event:s,item:i.name||i.description})}if(t.length)throw new b("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const i=this._textProxyRegistry.get(e.startOffset);if(i){const o=i.get(e.endOffset);o&&(t=o.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,i=e.endOffset,o=e.parent,s=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(i),a||(a=new Map,r.set(i,a)),a.set(o,s),s}}function Hs(n){const e=n.split(":");return e[0]=="insert"?e[0]:e[0]=="addMarker"||e[0]=="removeMarker"?n:e.length>1?e[0]+":"+e[1]:e[0]}class Tp extends ge(){constructor(e){super(),h(this,"_conversionApi"),h(this,"_firedEventsMap"),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const o=this._createConversionApi(i,e.getRefreshedItems());for(const r of e.getMarkersToRemove())this._convertMarkerRemove(r.name,r.range,o);const s=this._reduceChanges(e.getChanges());for(const r of s)r.type==="insert"?this._convertInsert(y._createFromPositionAndShift(r.position,r.length),o):r.type==="reinsert"?this._convertReinsert(y._createFromPositionAndShift(r.position,r.length),o):r.type==="remove"?this._convertRemove(r.position,r.length,r.name,o):this._convertAttribute(r.range,r.attributeKey,r.attributeOldValue,r.attributeNewValue,o);o.mapper.flushDeferredBindings();for(const r of o.mapper.flushUnboundMarkerNames()){const a=t.get(r).getRange();this._convertMarkerRemove(r,a,o),this._convertMarkerAdd(r,a,o)}for(const r of e.getMarkersToAdd())this._convertMarkerAdd(r.name,r.range,o);o.consumable.verifyAllConsumed("insert")}convert(e,t,i,o={}){const s=this._createConversionApi(i,void 0,o);this._convertInsert(e,s);for(const[r,a]of t)this._convertMarkerAdd(r,a,s);s.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const o=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},o);const s=e.getFirstPosition().root;if(!o.mapper.toViewElement(s))return;const r=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(o.consumable,e,r),this.fire("selection",{selection:e},o),!!e.isCollapsed){for(const a of r)if(o.consumable.test(e,"addMarker:"+a.name)){const l=a.getRange();if(!Fy(e.getFirstPosition(),a,o.mapper))continue;const c={item:e,markerName:a.name,markerRange:l};this.fire(`addMarker:${a.name}`,c,o)}for(const a of e.getAttributeKeys())if(o.consumable.test(e,"attribute:"+a)){const l={item:e,range:e.getFirstRange(),attributeKey:a,attributeOldValue:null,attributeNewValue:e.getAttribute(a)};this.fire(`attribute:${a}:$text`,l,o)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const o of e.getWalker({shallow:!0}))this._testAndFire("insert",Mh(o),t)}_convertRemove(e,t,i,o){this.fire(`remove:${i}`,{position:e,length:t},o)}_convertAttribute(e,t,i,o,s){this._addConsumablesForRange(s.consumable,e,`attribute:${t}`);for(const r of e){const a={item:r.item,range:y._createFromPositionAndShift(r.previousPosition,r.length),attributeKey:t,attributeOldValue:i,attributeNewValue:o};this._testAndFire(`attribute:${t}`,a,s)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const o of i.map(Mh))this._testAndFire("insert",{...o,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if(t.root.rootName=="$graveyard")return;const o=`addMarker:${e}`;if(i.consumable.add(t,o),this.fire(o,{markerName:e,markerRange:t},i),!!i.consumable.consume(t,o)){this._addConsumablesForRange(i.consumable,t,o);for(const s of t.getItems()){if(!i.consumable.test(s,o))continue;const r={item:s,range:y._createOn(s),markerName:e,markerRange:t};this.fire(o,r,i)}}}_convertMarkerRemove(e,t,i){t.root.rootName!="$graveyard"&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const i of t){const o=i.item;if(e.test(o,"insert")===null){e.add(o,"insert");for(const s of o.getAttributeKeys())e.add(o,"attribute:"+s)}}return e}_addConsumablesForRange(e,t,i){for(const o of t.getItems())e.add(o,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const o of i)e.add(t,"addMarker:"+o.name);for(const o of t.getAttributeKeys())e.add(t,"attribute:"+o);return e}_testAndFire(e,t,i){const o=Ny(e,t),s=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,r=this._firedEventsMap.get(i),a=r.get(s);if(!a)r.set(s,new Set([o]));else if(!a.has(o))a.add(o);else return;this.fire(o,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:y._createOn(e)};for(const o of i.item.getAttributeKeys())i.attributeKey=o,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(o),this._testAndFire(`attribute:${o}`,i,t)}_createConversionApi(e,t=new Set,i={}){const o={...this._conversionApi,consumable:new Ly,writer:e,options:i,convertItem:s=>this._convertInsert(y._createOn(s),o),convertChildren:s=>this._convertInsert(y._createIn(s),o,{doNotAddConsumables:!0}),convertAttributes:s=>this._testAndFireAddAttributes(s,o),canReuseView:s=>!t.has(o.mapper.toModelElement(s))};return this._firedEventsMap.set(o,new Map),o}}function Fy(n,e,t){const i=e.getRange(),o=Array.from(n.getAncestors());return o.shift(),o.reverse(),!o.some(s=>{if(i.containsItem(s))return!!t.toViewElement(s).getCustomProperty("addHighlight")})}function Ny(n,e){const t=e.item.is("element")?e.item.name:"$text";return`${n}:${t}`}function Mh(n){return{item:n.item,range:y._createFromPositionAndShift(n.previousPosition,n.length)}}let Tn=class extends Yi{constructor(n){super(),h(this,"parent",null),h(this,"_attrs"),h(this,"_index",null),h(this,"_startOffset",null),this._attrs=ri(n)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return this.startOffset===null?null:this.startOffset+this.offsetSize}get nextSibling(){const n=this.index;return n!==null&&this.parent.getChild(n+1)||null}get previousSibling(){const n=this.index;return n!==null&&this.parent.getChild(n-1)||null}get root(){let n=this;for(;n.parent;)n=n.parent;return n}isAttached(){return this.parent===null?!1:this.root.isAttached()}getPath(){const n=[];let e=this;for(;e.parent;)n.unshift(e.startOffset),e=e.parent;return n}getAncestors(n={}){const e=[];let t=n.includeSelf?this:this.parent;for(;t;)e[n.parentFirst?"push":"unshift"](t),t=t.parent;return e}getCommonAncestor(n,e={}){const t=this.getAncestors(e),i=n.getAncestors(e);let o=0;for(;t[o]==i[o]&&t[o];)o++;return o===0?null:t[o-1]}isBefore(n){if(this==n||this.root!==n.root)return!1;const e=this.getPath(),t=n.getPath(),i=Xe(e,t);switch(i){case"prefix":return!0;case"extension":return!1;default:return e[i](e[t[0]]=t[1],e),{})),n}_clone(n){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(n,e){this._attrs.set(n,e)}_setAttributesTo(n){this._attrs=ri(n)}_removeAttribute(n){return this._attrs.delete(n)}_clearAttributes(){this._attrs.clear()}};Tn.prototype.is=function(n){return n==="node"||n==="model:node"};class yt extends ge(Yi){constructor(...e){super(),h(this,"_lastRangeBackward",!1),h(this,"_attrs",new Map),h(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 i=!1;for(const o of e._ranges)if(t.isEqual(o)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new y(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 y(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 y(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,i,o]=e;if(typeof i=="object"&&(o=i,i=void 0),t===null)this._setRanges([]);else if(t instanceof yt)this._setRanges(t.getRanges(),t.isBackward);else if(t&&typeof t.getRanges=="function")this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof y)this._setRanges([t],!!o&&!!o.backward);else if(t instanceof C)this._setRanges([new y(t)]);else if(t instanceof Tn){const s=!!o&&!!o.backward;let r;if(i=="in")r=y._createIn(t);else if(i=="on")r=y._createOn(t);else if(i!==void 0)r=new y(C._createAt(t,i));else throw new b("model-selection-setto-required-second-parameter",[this,t]);this._setRanges([r],s)}else if(Pt(t))this._setRanges(t,o&&!!o.backward);else throw new b("model-selection-setto-not-selectable",[this,t])}_setRanges(e,t=!1){const i=Array.from(e),o=i.some(s=>{if(!(s instanceof y))throw new b("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(r=>!r.isEqual(s))});i.length===this._ranges.length&&!o||(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(this.anchor===null)throw new b("model-selection-setfocus-no-ranges",[this,e]);const i=C._createAt(e,t);if(i.compareWith(this.focus)=="same")return;const o=this.anchor;this._ranges.length&&this._popRange(),i.compareWith(o)=="before"?(this._pushRange(new y(i,o)),this._lastRangeBackward=!0):(this._pushRange(new y(o,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=Lh(t.start,e);zy(i,t)&&(yield i);const o=t.getWalker();for(const r of o){const a=r.item;r.type=="elementEnd"&&Dy(a,e,t)?yield a:r.type=="elementStart"&&a.is("model:element")&&a.root.document.model.schema.isBlock(a)&&o.jumpTo(C._createAt(a,"end"))}const s=Lh(t.end,e);Hy(s,t)&&(yield s)}}containsEntireContent(e=this.anchor.root){const t=C._createAt(e,0),i=C._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new y(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}yt.prototype.is=function(n){return n==="selection"||n==="model:selection"};function Ep(n,e){return e.has(n)?!1:(e.add(n),n.root.document.model.schema.isBlock(n)&&!!n.parent)}function Dy(n,e,t){return Ep(n,e)&&Jc(n,t)}function Lh(n,e){const t=n.parent.root.document.model.schema,i=n.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const s=i.find(r=>o?!1:(o=t.isLimit(r),!o&&Ep(r,e)));return i.forEach(r=>e.add(r)),s}function Jc(n,e){const t=$y(n);return t?!e.containsRange(y._createOn(t),!0):!0}function zy(n,e){return n?e.isCollapsed||n.isEmpty?!0:e.start.isTouching(C._createAt(n,n.maxOffset))?!1:Jc(n,e):!1}function Hy(n,e){return n?e.isCollapsed||n.isEmpty?!0:e.end.isTouching(C._createAt(n,0))?!1:Jc(n,e):!1}function $y(n){const e=n.root.document.model.schema;let t=n.parent;for(;t;){if(e.isBlock(t))return t;t=t.parent}}class ht extends ge(y){constructor(e,t){super(e,t),Wy.call(this)}detach(){this.stopListening()}toRange(){return new y(this.start,this.end)}static fromRange(e){return new ht(e.start,e.end)}}ht.prototype.is=function(n){return n==="liveRange"||n==="model:liveRange"||n=="range"||n==="model:range"};function Wy(){this.listenTo(this.root.document.model,"applyOperation",(n,e)=>{const t=e[0];t.isDocumentOperation&&jy.call(this,t)},{priority:"low"})}function jy(n){const e=this.getTransformedByOperation(n),t=y._createFromRanges(e),i=!t.isEqual(this),o=Uy(this,n);let s=null;if(i){t.root.rootName=="$graveyard"&&(n.type=="remove"?s=n.sourcePosition:s=n.deletionPosition);const r=this.toRange();this.start=t.start,this.end=t.end,this.fire("change:range",r,{deletionPosition:s})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:s})}function Uy(n,e){switch(e.type){case"insert":return n.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return n.containsPosition(e.sourcePosition)||n.start.isEqual(e.sourcePosition)||n.containsPosition(e.targetPosition);case"split":return n.containsPosition(e.splitPosition)||n.containsPosition(e.insertionPosition)}return!1}class Ce extends Tn{constructor(e,t){super(t),h(this,"_data"),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 Ce(this.data,this.getAttributes())}static fromJSON(e){return new Ce(e.data,e.attributes)}}Ce.prototype.is=function(n){return n==="$text"||n==="model:$text"||n==="text"||n==="model:text"||n==="node"||n==="model:node"};const us="selection:";class Kt extends ge(Yi){constructor(e){super(),h(this,"_selection"),this._selection=new qy(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 us+e}static _isStoreAttributeKey(e){return e.startsWith(us)}}Kt.prototype.is=function(n){return n==="selection"||n=="model:selection"||n=="documentSelection"||n=="model:documentSelection"};class qy extends yt{constructor(e){super(),h(this,"markers",new _e({idProperty:"name"})),h(this,"_model"),h(this,"_document"),h(this,"_attributePriority",new Map),h(this,"_selectionRestorePosition",null),h(this,"_hasChangedRange",!1),h(this,"_overriddenGravityRegister",new Set),h(this,"_observedMarkers",new Set),this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",(t,i)=>{const o=i[0];!o.isDocumentOperation||o.type=="marker"||o.type=="rename"||o.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,i,o,s)=>{this._updateMarker(i,s)}),this.listenTo(this._document,"change",(t,i)=>{Gy(this._model,i)})}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{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=s.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 o of this._model.markers){const s=o.name.split(":",1)[0];if(!this._observedMarkers.has(s))continue;const r=o.getRange();for(const a of this.getRanges())r.containsRange(a,!a.isCollapsed)&&e.push(o)}const i=Array.from(this.markers);for(const o of e)this.markers.has(o)||(this.markers.add(o),t=!0);for(const o of Array.from(this.markers))e.includes(o)||(this.markers.remove(o),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let o=!1;const s=Array.from(this.markers),r=this.markers.has(e);if(!t)r&&(this.markers.remove(e),o=!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),o=!0):!a&&r&&(this.markers.remove(e),o=!0)}o&&this.fire("change:marker",{oldMarkers:s,directChange:!1})}_updateAttributes(e){const t=ri(this._getSurroundingAttributes()),i=ri(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[s,r]of this._attributePriority)r=="low"&&(this._attrs.delete(s),this._attributePriority.delete(s));this._setAttributesTo(t);const o=[];for(const[s,r]of this.getAttributes())(!i.has(s)||i.get(s)!==r)&&o.push(s);for(const[s]of i)this.hasAttribute(s)||o.push(s);o.length>0&&this.fire("change:attribute",{attributeKeys:o,directChange:!1})}_setAttribute(e,t,i=!0){const o=i?"normal":"low";return o=="low"&&this._attributePriority.get(e)=="normal"||super.getAttribute(e)===t?!1:(this._attrs.set(e,t),this._attributePriority.set(e,o),!0)}_removeAttribute(e,t=!0){const i=t?"normal":"low";return i=="low"&&this._attributePriority.get(e)=="normal"||(this._attributePriority.set(e,i),!super.hasAttribute(e))?!1:(this._attrs.delete(e),!0)}_setAttributesTo(e){const t=new Set;for(const[i,o]of this.getAttributes())e.get(i)!==o&&this._removeAttribute(i,!1);for(const[i,o]of e)this._setAttribute(i,o,!1)&&t.add(i);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())t.startsWith(us)&&(yield[t.substr(us.length),e.getAttribute(t)])}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if(e.root.rootName=="$graveyard")return null;let i=null;if(this.isCollapsed){const o=e.textNode?e.textNode:e.nodeBefore,s=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=Io(o,t)),i||(i=Io(s,t)),!this.isGravityOverridden&&!i){let r=o;for(;r&&!i;)r=r.previousSibling,i=Io(r,t)}if(!i){let r=s;for(;r&&!i;)r=r.nextSibling,i=Io(r,t)}i||(i=this.getStoredAttributes())}else{const o=this.getFirstRange();for(const s of o){if(s.item.is("element")&&t.isObject(s.item)){i=Io(s.item,t);break}if(s.type=="text"){i=s.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Io(n,e){if(!n)return null;if(n instanceof Lt||n instanceof Ce)return n.getAttributes();if(!e.isInline(n))return null;if(!e.isObject(n))return[];const t=[];for(const[i,o]of n.getAttributes())e.checkAttribute("$text",i)&&e.getAttributeProperties(i).copyFromObject!==!1&&t.push([i,o]);return t}function Gy(n,e){const t=n.document.differ;for(const i of t.getChanges()){if(i.type!="insert")continue;const o=i.position.parent;i.length===o.maxOffset&&n.enqueueChange(e,s=>{const r=Array.from(o.getAttributeKeys()).filter(a=>a.startsWith(us));for(const a of r)s.removeAttribute(a,o)})}}class Xo{constructor(e){h(this,"_nodes",[]),h(this,"_offsetToNode",[]),e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._offsetToNode.length}getNode(e){return this._nodes[e]||null}getNodeAtOffset(e){return this._offsetToNode[e]||null}getNodeIndex(e){return e.index}getNodeStartOffset(e){return e.startOffset}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new b("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){if(e==this._offsetToNode.length)return this._nodes.length;const t=this._offsetToNode[e];if(!t)throw new b("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}_insertNodes(e,t){const i=[];for(const s of t){if(!(s instanceof Tn))throw new b("model-nodelist-insertnodes-not-node",this);i.push(s)}let o=this.indexToOffset(e);vh(this._nodes,i,e),vh(this._offsetToNode,Ky(i),o);for(let s=e;si.index!==null),this._offsetToNode=this._offsetToNode.filter(i=>i.index!==null);let t=0;for(let i=0;ie.toJSON())}}function Ky(n){const e=[];let t=0;for(const i of n)for(let o=0;o0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Jy(this._children):void 0;return new ne(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=Zy(t);for(const o of i)o.parent!==null&&o._remove(),o.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const o of i)o.parent=null;return i}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}static fromJSON(e){let t;if(e.children){t=[];for(const i of e.children)i.name?t.push(ne.fromJSON(i)):t.push(Ce.fromJSON(i))}return new ne(e.name,e.attributes,t)}}ne.prototype.is=function(n,e){return e?e===this.name&&(n==="element"||n==="model:element"):n==="element"||n==="model:element"||n==="node"||n==="model:node"};function Zy(n){if(typeof n=="string")return[new Ce(n)];Pt(n)||(n=[n]);const e=[];for(const t of n)typeof t=="string"?e.push(new Ce(t)):t instanceof Lt?e.push(new Ce(t.data,t.getAttributes())):e.push(t);return e}function Jy(n){const e=[];for(const t of n)e.push(t._clone(!0));return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Sp{constructor(e){h(this,"_dispatchers"),this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class Qy extends Sp{elementToElement(e){return this.add(gk(e))}elementToStructure(e){return this.add(pk(e))}attributeToElement(e){return this.add(wk(e))}attributeToAttribute(e){return this.add(bk(e))}markerToElement(e){return this.add(_k(e))}markerToHighlight(e){return this.add(yk(e))}markerToData(e){return this.add(vk(e))}}function Pp(){return(n,e,t)=>{if(!t.consumable.consume(e.item,n.name))return;const i=t.writer,o=t.mapper.toViewPosition(e.range.start),s=i.createText(e.item.data);i.insert(o,s)}}function Ip(){return(n,e,t)=>{t.convertAttributes(e.item),!e.reconversion&&e.item.is("element")&&!e.item.isEmpty&&t.convertChildren(e.item)}}function Yy(){return(n,e,t)=>{const i=t.mapper.toViewPosition(e.position),o=e.position.getShiftedBy(e.length),s=t.mapper.toViewPosition(o,{isPhantom:!0}),r=t.writer.createRange(i,s),a=t.writer.remove(r.getTrimmed());for(const l of t.writer.createRangeIn(a).getItems())t.mapper.unbindViewElement(l,{defer:!0})}}function Vp(n,e){const t=n.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 Xy(){return(n,e,t)=>{const i=e.selection;if(i.isCollapsed||!t.consumable.consume(i,"selection"))return;const o=[];for(const s of i.getRanges())o.push(t.mapper.toViewRange(s));t.writer.setSelection(o,{backward:i.isBackward})}}function ek(){return(n,e,t)=>{const i=e.selection;if(!i.isCollapsed||!t.consumable.consume(i,"selection"))return;const o=t.writer,s=i.getFirstPosition(),r=t.mapper.toViewPosition(s),a=o.breakAttributes(r);o.setSelection(a)}}function tk(){return(n,e,t)=>{const i=t.writer,o=i.document.selection;for(const s of o.getRanges())s.isCollapsed&&s.end.parent.isAttached()&&t.writer.mergeAttributes(s.start);i.setSelection(null)}}function ik(n){return(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const o=n(t.attributeOldValue,i,t),s=n(t.attributeNewValue,i,t);if(!o&&!s)return;i.consumable.consume(t.item,e.name);const r=i.writer,a=r.document.selection;if(t.item instanceof yt||t.item instanceof Kt)r.wrap(a.getFirstRange(),s);else{let l=i.mapper.toViewRange(t.range);t.attributeOldValue!==null&&o&&(l=r.unwrap(l,o)),t.attributeNewValue!==null&&s&&r.wrap(l,s)}}}function nk(n,e=Sk){return(t,i,o)=>{if(!e(i.item,o.consumable,{preflight:!0}))return;const s=n(i.item,o,i);if(!s)return;e(i.item,o.consumable);const r=o.mapper.toViewPosition(i.range.start);o.mapper.bindElements(i.item,s),o.writer.insert(r,s),o.convertAttributes(i.item),Lp(s,i.item.getChildren(),o,{reconversion:i.reconversion})}}function ok(n,e){return(t,i,o)=>{if(!e(i.item,o.consumable,{preflight:!0}))return;const s=new Map;o.writer._registerSlotFactory(Ak(i.item,s,o));const r=n(i.item,o,i);if(o.writer._clearSlotFactory(),!r)return;xk(i.item,s,o),e(i.item,o.consumable);const a=o.mapper.toViewPosition(i.range.start);o.mapper.bindElements(i.item,r),o.writer.insert(a,r),o.convertAttributes(i.item),Tk(r,s,o,{reconversion:i.reconversion})}}function sk(n){return(e,t,i)=>{t.isOpening=!0;const o=n(t,i);t.isOpening=!1;const s=n(t,i);if(!o||!s)return;const r=t.markerRange;if(r.isCollapsed&&!i.consumable.consume(r,e.name))return;for(const c of r)if(!i.consumable.consume(c.item,e.name))return;const a=i.mapper,l=i.writer;l.insert(a.toViewPosition(r.start),o),i.mapper.bindElementToMarker(o,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),s),i.mapper.bindElementToMarker(s,t.markerName)),e.stop()}}function rk(){return(n,e,t)=>{const i=t.mapper.markerNameToElements(e.markerName);if(i){for(const o of i)t.mapper.unbindElementFromMarkerName(o,e.markerName),t.writer.clear(t.writer.createRangeOn(o),o);t.writer.clearClonedElementsGroup(e.markerName),n.stop()}}}function ak(n){return(e,t,i)=>{const o=n(t.markerName,i);if(!o)return;const s=t.markerRange;i.consumable.consume(s,e.name)&&(Fh(s,!1,i,t,o),Fh(s,!0,i,t,o),e.stop())}}function Fh(n,e,t,i,o){const s=e?n.start:n.end,r=s.nodeAfter&&s.nodeAfter.is("element")?s.nodeAfter:null,a=s.nodeBefore&&s.nodeBefore.is("element")?s.nodeBefore:null;if(r||a){let c,u;e&&r||!e&&!a?(c=r,u=!0):(c=a,u=!1);const d=t.mapper.toViewElement(c);if(d){lk(d,e,u,t,i,o);return}}const l=t.mapper.toViewPosition(s);ck(l,e,t,i,o)}function lk(n,e,t,i,o,s){const r=`data-${s.group}-${e?"start":"end"}-${t?"before":"after"}`,a=n.hasAttribute(r)?n.getAttribute(r).split(","):[];a.unshift(s.name),i.writer.setAttribute(r,a.join(","),n),i.mapper.bindElementToMarker(n,o.markerName)}function ck(n,e,t,i,o){const s=`${o.group}-${e?"start":"end"}`,r=o.name?{name:o.name}:null,a=t.writer.createUIElement(s,r);t.writer.insert(n,a),t.mapper.bindElementToMarker(a,i.markerName)}function uk(n){return(e,t,i)=>{const o=n(t.markerName,i);if(!o)return;const s=i.mapper.markerNameToElements(t.markerName);if(!s)return;for(const a of s)i.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("containerElement")?(r(`data-${o.group}-start-before`,a),r(`data-${o.group}-start-after`,a),r(`data-${o.group}-end-before`,a),r(`data-${o.group}-end-after`,a)):i.writer.clear(i.writer.createRangeOn(a),a);i.writer.clearClonedElementsGroup(t.markerName),e.stop();function r(a,l){if(l.hasAttribute(a)){const c=new Set(l.getAttribute(a).split(","));c.delete(o.name),c.size==0?i.writer.removeAttribute(a,l):i.writer.setAttribute(a,Array.from(c).join(","),l)}}}}function hk(n){return(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const o=n(t.attributeOldValue,i,t),s=n(t.attributeNewValue,i,t);if(!o&&!s)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new b("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(t.attributeOldValue!==null&&o){let l=o.value;o.key=="style"&&(typeof o.value=="string"?l=new so(a.document.stylesProcessor).setTo(o.value).getStylesEntries().map(([c])=>c):l=Object.keys(o.value)),a.removeAttribute(o.key,l,r)}if(t.attributeNewValue!==null&&s){let l=s.value;s.key=="style"&&typeof s.value=="string"&&(l=Object.fromEntries(new so(a.document.stylesProcessor).setTo(s.value).getStylesEntries())),a.setAttribute(s.key,l,!1,r)}}}function dk(n){return(e,t,i)=>{if(!t.item||!(t.item instanceof yt||t.item instanceof Kt)&&!t.item.is("$textProxy"))return;const o=Qc(n,t,i);if(!o||!i.consumable.consume(t.item,e.name))return;const s=i.writer,r=Vp(s,o),a=s.document.selection;if(t.item instanceof yt||t.item instanceof Kt)s.wrap(a.getFirstRange(),r);else{const l=i.mapper.toViewRange(t.range),c=s.wrap(l,r);for(const u of c.getItems())if(u.is("attributeElement")&&u.isSimilar(r)){i.mapper.bindElementToMarker(u,t.markerName);break}}}}function mk(n){return(e,t,i)=>{if(!t.item||!(t.item instanceof ne))return;const o=Qc(n,t,i);if(!o||!i.consumable.test(t.item,e.name))return;const s=i.mapper.toViewElement(t.item);if(s&&s.getCustomProperty("addHighlight")){i.consumable.consume(t.item,e.name);for(const r of y._createIn(t.item))i.consumable.consume(r.item,e.name);s.getCustomProperty("addHighlight")(s,o,i.writer),i.mapper.bindElementToMarker(s,t.markerName)}}}function fk(n){return(e,t,i)=>{if(t.markerRange.isCollapsed)return;const o=Qc(n,t,i);if(!o)return;const s=Vp(i.writer,o),r=i.mapper.markerNameToElements(t.markerName);if(r){for(const a of r)i.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("attributeElement")?i.writer.unwrap(i.writer.createRangeOn(a),s):a.getCustomProperty("removeHighlight")(a,o.id,i.writer);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}}function gk(n){const e=Rp(n.model),t=hs(n.view,"container");return e.attributes.length&&(e.children=!0),i=>{i.on(`insert:${e.name}`,nk(t,Mp(e)),{priority:n.converterPriority||"normal"}),(e.children||e.attributes.length)&&i.on("reduceChanges",Bp(e),{priority:"low"})}}function pk(n){const e=Rp(n.model),t=hs(n.view,"container");return e.children=!0,i=>{if(i._conversionApi.schema.checkChild(e.name,"$text"))throw new b("conversion-element-to-structure-disallowed-text",i,{elementName:e.name});i.on(`insert:${e.name}`,ok(t,Mp(e)),{priority:n.converterPriority||"normal"}),i.on("reduceChanges",Bp(e),{priority:"low"})}}function wk(n){n=mt(n);let e=n.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const o of e.values)n.view[o]=hs(n.view[o],"attribute");else n.view=hs(n.view,"attribute");const i=Op(n);return o=>{o.on(t,ik(i),{priority:n.converterPriority||"normal"})}}function bk(n){n=mt(n);let e=n.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const o of e.values)n.view[o]=Nh(n.view[o]);else n.view=Nh(n.view);const i=Op(n);return o=>{o.on(t,hk(i),{priority:n.converterPriority||"normal"})}}function _k(n){const e=hs(n.view,"ui");return t=>{t.on(`addMarker:${n.model}`,sk(e),{priority:n.converterPriority||"normal"}),t.on(`removeMarker:${n.model}`,rk(),{priority:n.converterPriority||"normal"})}}function vk(n){n=mt(n);const e=n.model;let t=n.view;return t||(t=i=>({group:e,name:i.substr(n.model.length+1)})),i=>{i.on(`addMarker:${e}`,ak(t),{priority:n.converterPriority||"normal"}),i.on(`removeMarker:${e}`,uk(t),{priority:n.converterPriority||"normal"})}}function yk(n){return e=>{e.on(`addMarker:${n.model}`,dk(n.view),{priority:n.converterPriority||"normal"}),e.on(`addMarker:${n.model}`,mk(n.view),{priority:n.converterPriority||"normal"}),e.on(`removeMarker:${n.model}`,fk(n.view),{priority:n.converterPriority||"normal"})}}function Rp(n){return typeof n=="string"&&(n={name:n}),{name:n.name,attributes:n.attributes?he(n.attributes):[],children:!!n.children}}function hs(n,e){return typeof n=="function"?n:(t,i)=>kk(n,i,e)}function kk(n,e,t){typeof n=="string"&&(n={name:n});let i;const o=e.writer,s=Object.assign({},n.attributes);if(t=="container")i=o.createContainerElement(n.name,s);else if(t=="attribute"){const r={priority:n.priority||_n.DEFAULT_PRIORITY};i=o.createAttributeElement(n.name,s,r)}else i=o.createUIElement(n.name,s);if(n.styles){const r=Object.keys(n.styles);for(const a of r)o.setStyle(a,n.styles[a],i)}if(n.classes){const r=n.classes;if(typeof r=="string")o.addClass(r,i);else for(const a of r)o.addClass(a,i)}return i}function Op(n){return n.model.values?(e,t,i)=>{const o=n.view[e];return o?o(e,t,i):null}:n.view}function Nh(n){return typeof n=="string"?e=>({key:n,value:e}):typeof n=="object"?n.value?()=>n:e=>({key:n.key,value:e}):n}function Qc(n,e,t){const i=typeof n=="function"?n(e,t):n;return i?(i.priority||(i.priority=10),i.id||(i.id=e.markerName),i):null}function Ck(n){return(e,t)=>{if(!e.is("element",n.name))return!1;if(t.type=="attribute"){if(n.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(n.children)return!0}return!1}}function Bp(n){const e=Ck(n);return(t,i)=>{const o=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const s of i.changes){const r=s.type=="attribute"?s.range.start.nodeAfter:s.position.parent;if(!r||!e(r,s)){o.push(s);continue}if(!i.reconvertedElements.has(r)){i.reconvertedElements.add(r);const a=C._createBefore(r);let l=o.length;for(let c=o.length-1;c>=0;c--){const u=o[c],d=(u.type=="attribute"?u.range.start:u.position).compareWith(a);if(d=="before"||u.type=="remove"&&d=="same")break;l=c}o.splice(l,0,{type:"remove",name:r.name,position:a,length:1},{type:"reinsert",name:r.name,position:a,length:1})}}i.changes=o}}function Mp(n){return(e,t,i={})=>{const o=["insert"];for(const s of n.attributes)e.hasAttribute(s)&&o.push(`attribute:${s}`);return o.every(s=>t.test(e,s))?(i.preflight||o.forEach(s=>t.consume(e,s)),!0):!1}}function Ak(n,e,t){return(i,o)=>{const s=i.createContainerElement("$slot");let r=null;if(o==="children")r=Array.from(n.getChildren());else if(typeof o=="function")r=Array.from(n.getChildren()).filter(a=>o(a));else throw new b("conversion-slot-mode-unknown",t.dispatcher,{modeOrFilter:o});return e.set(s,r),s}}function xk(n,e,t){const i=Array.from(e.values()).flat(),o=new Set(i);if(o.size!=i.length)throw new b("conversion-slot-filter-overlap",t.dispatcher,{element:n});if(o.size!=n.childCount)throw new b("conversion-slot-filter-incomplete",t.dispatcher,{element:n})}function Tk(n,e,t,i){t.mapper.on("modelToViewPosition",r,{priority:"highest"});let o=null,s=null;for([o,s]of e)Lp(n,s,t,i),t.writer.move(t.writer.createRangeIn(o),t.writer.createPositionBefore(o)),t.writer.remove(o);t.mapper.off("modelToViewPosition",r);function r(a,l){const c=l.modelPosition.nodeAfter,u=s.indexOf(c);u<0||(l.viewPosition=l.mapper.findPositionIn(o,u))}}function Lp(n,e,t,i){for(const o of e)Ek(n.root,o,t,i)||t.convertItem(o)}function Ek(n,e,t,i){const{writer:o,mapper:s}=t;if(!i.reconversion)return!1;const r=s.toViewElement(e);return!r||r.root==n||!t.canReuseView(r)?!1:(o.move(o.createRangeOn(r),s.toViewPosition(C._createBefore(e))),!0)}function Sk(n,e,{preflight:t}={}){return t?e.test(n,"insert"):e.consume(n,"insert")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Fp(n){const{schema:e,document:t}=n.model;for(const i of t.getRoots())if(i.isEmpty&&!e.checkChild(i,"$text")&&e.checkChild(i,"paragraph"))return n.insertElement("paragraph",i),!0;return!1}function Np(n,e,t){const i=t.createContext(n);return!(!t.checkChild(i,"paragraph")||!t.checkChild(i.push("paragraph"),e))}function Dp(n,e){const t=e.createElement("paragraph");return e.insert(t,n),e.createPositionAt(t,0)}class Pk extends Sp{elementToElement(e){return this.add(zp(e))}elementToAttribute(e){return this.add(Rk(e))}attributeToAttribute(e){return this.add(Ok(e))}elementToMarker(e){return this.add(Bk(e))}dataToMarker(e){return this.add(Mk(e))}}function Dh(){return(n,e,t)=>{if(!e.modelRange&&t.consumable.consume(e.viewItem,{name:!0})){const{modelRange:i,modelCursor:o}=t.convertChildren(e.viewItem,e.modelCursor);e.modelRange=i,e.modelCursor=o}}}function Ik(){return(n,e,{schema:t,consumable:i,writer:o})=>{let s=e.modelCursor;if(!i.test(e.viewItem))return;if(!t.checkChild(s,"$text")){if(!Np(s,"$text",t)||e.viewItem.data.trim().length==0)return;s=Dp(s,o)}i.consume(e.viewItem);const r=o.createText(e.viewItem.data);o.insert(r,s),e.modelRange=o.createRange(s,s.getShiftedBy(r.offsetSize)),e.modelCursor=e.modelRange.end}}function Vk(n,e){return(t,i)=>{const o=i.newSelection,s=[];for(const a of o.getRanges())s.push(e.toModelRange(a));const r=n.createSelection(s,{backward:o.isBackward});r.isEqual(n.document.selection)||n.change(a=>{a.setSelection(r)})}}function zp(n){n=mt(n);const e=ql(n),t=Yc(n.view),i=t?`element:${t}`:"element";return o=>{o.on(i,e,{priority:n.converterPriority||"normal"})}}function Rk(n){n=mt(n),Hp(n);const e=$p(n,!1),t=Yc(n.view),i=t?`element:${t}`:"element";return o=>{o.on(i,e,{priority:n.converterPriority||"low"})}}function Ok(n){n=mt(n);let e=null;(typeof n.view=="string"||n.view.key)&&(e=Nk(n)),Hp(n,e);const t=$p(n,!0);return i=>{i.on("element",t,{priority:n.converterPriority||"low"})}}function Bk(n){const e=Hk(n.model);return zp({...n,model:e})}function Mk(n){n=mt(n),n.model||(n.model=o=>o?n.view+":"+o:n.view);const e={view:n.view,model:n.model},t=ql(zh(e,"start")),i=ql(zh(e,"end"));return o=>{o.on(`element:${n.view}-start`,t,{priority:n.converterPriority||"normal"}),o.on(`element:${n.view}-end`,i,{priority:n.converterPriority||"normal"});const s=kt.low,r=kt.highest,a=kt.get(n.converterPriority)/r;o.on("element",Lk(e),{priority:s+a})}}function Lk(n){return(e,t,i)=>{const o=`data-${n.view}`;if(!i.consumable.test(t.viewItem,{attributes:o+"-end-after"})&&!i.consumable.test(t.viewItem,{attributes:o+"-start-after"})&&!i.consumable.test(t.viewItem,{attributes:o+"-end-before"})&&!i.consumable.test(t.viewItem,{attributes:o+"-start-before"}))return;t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor)),i.consumable.consume(t.viewItem,{attributes:o+"-end-after"})&&s(t.modelRange.end,t.viewItem.getAttribute(o+"-end-after").split(",")),i.consumable.consume(t.viewItem,{attributes:o+"-start-after"})&&s(t.modelRange.end,t.viewItem.getAttribute(o+"-start-after").split(",")),i.consumable.consume(t.viewItem,{attributes:o+"-end-before"})&&s(t.modelRange.start,t.viewItem.getAttribute(o+"-end-before").split(",")),i.consumable.consume(t.viewItem,{attributes:o+"-start-before"})&&s(t.modelRange.start,t.viewItem.getAttribute(o+"-start-before").split(","));function s(r,a){for(const l of a){const c=n.model(l,i),u=i.writer.createElement("$marker",{"data-name":c});i.writer.insert(u,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 Yc(n){return typeof n=="string"?n:typeof n=="object"&&typeof n.name=="string"?n.name:null}function ql(n){const e=new ft(n.view);return(t,i,o)=>{const s=e.match(i.viewItem);if(!s)return;const r=s.match;if(r.name=!0,!o.consumable.test(i.viewItem,r))return;const a=Fk(n.model,i.viewItem,o);a&&o.safeInsert(a,i.modelCursor)&&(o.consumable.consume(i.viewItem,r),o.convertChildren(i.viewItem,a),o.updateConversionResult(a,i))}}function Fk(n,e,t){return n instanceof Function?n(e,t):t.writer.createElement(n)}function Nk(n){typeof n.view=="string"&&(n.view={key:n.view});const e=n.view.key,t=typeof n.view.value>"u"?/[\s\S]*/:n.view.value;let i;return e=="class"||e=="style"?i={[e=="class"?"classes":"styles"]:t}:i={attributes:{[e]:t}},n.view.name&&(i.name=n.view.name),n.view=i,e}function Hp(n,e=null){const t=e===null?!0:s=>s.getAttribute(e),i=typeof n.model!="object"?n.model:n.model.key,o=typeof n.model!="object"||typeof n.model.value>"u"?t:n.model.value;n.model={key:i,value:o}}function $p(n,e){const t=new ft(n.view);return(i,o,s)=>{if(!o.modelRange&&e)return;const r=t.match(o.viewItem);if(!r||(Dk(n.view,o.viewItem)?r.match.name=!0:delete r.match.name,!s.consumable.test(o.viewItem,r.match)))return;const a=n.model.key,l=typeof n.model.value=="function"?n.model.value(o.viewItem,s,o):n.model.value;l!==null&&(o.modelRange||Object.assign(o,s.convertChildren(o.viewItem,o.modelCursor)),zk(o.modelRange,{key:a,value:l},e,s)&&(s.consumable.test(o.viewItem,{name:!0})&&(r.match.name=!0),s.consumable.consume(o.viewItem,r.match)))}}function Dk(n,e){const t=typeof n=="function"?n(e):n;return typeof t=="object"&&!Yc(t)?!1:!t.classes&&!t.attributes&&!t.styles}function zk(n,e,t,i){let o=!1;for(const s of Array.from(n.getItems({shallow:t})))i.schema.checkAttribute(s,e.key)&&(o=!0,!s.hasAttribute(e.key)&&i.writer.setAttribute(e.key,e.value,s));return o}function Hk(n){return(e,t)=>{const i=typeof n=="string"?n:n(e,t);return t.writer.createElement("$marker",{"data-name":i})}}function zh(n,e){const t=(i,o)=>{const s=i.getAttribute("name"),r=n.model(s,o);return o.writer.createElement("$marker",{"data-name":r})};return{view:`${n.view}-${e}`,model:t}}function $k(n){n.document.registerPostFixer(e=>Wk(e,n))}function Wk(n,e){const t=e.document.selection,i=e.schema,o=[];let s=!1;for(const r of t.getRanges()){const a=Wp(r,i);a&&!a.isEqual(r)?(o.push(a),s=!0):o.push(r)}return s&&n.setSelection(Gk(o),{backward:t.isBackward}),!1}function Wp(n,e){return n.isCollapsed?jk(n,e):Uk(n,e)}function jk(n,e){const t=n.start,i=e.getNearestSelectionRange(t);if(!i){const s=t.getAncestors().reverse().find(r=>e.isObject(r));return s?y._createOn(s):null}if(!i.isCollapsed)return i;const o=i.start;return t.isEqual(o)?null:new y(o)}function Uk(n,e){const{start:t,end:i}=n,o=e.checkChild(t,"$text"),s=e.checkChild(i,"$text"),r=e.getLimitElement(t),a=e.getLimitElement(i);if(r===a){if(o&&s)return null;if(qk(t,i,e)){const u=t.nodeAfter&&e.isSelectable(t.nodeAfter)?null:e.getNearestSelectionRange(t,"forward"),d=i.nodeBefore&&e.isSelectable(i.nodeBefore)?null:e.getNearestSelectionRange(i,"backward"),m=u?u.start:t,f=d?d.end:i;return new y(m,f)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const u=t.nodeAfter&&i.nodeBefore&&t.nodeAfter.parent===i.nodeBefore.parent,d=l&&(!u||!$h(t.nodeAfter,e)),m=c&&(!u||!$h(i.nodeBefore,e));let f=t,g=i;return d&&(f=C._createBefore(Hh(r,e))),m&&(g=C._createAfter(Hh(a,e))),new y(f,g)}return null}function Hh(n,e){let t=n,i=t;for(;e.isLimit(i)&&i.parent;)t=i,i=i.parent;return t}function qk(n,e,t){const i=n.nodeAfter&&!t.isLimit(n.nodeAfter)||t.checkChild(n,"$text"),o=e.nodeBefore&&!t.isLimit(e.nodeBefore)||t.checkChild(e,"$text");return i||o}function Gk(n){const e=[...n],t=new Set;let i=1;for(;i!t.has(s))}function $h(n,e){return n&&e.isSelectable(n)}class Kk extends ue(){constructor(e,t){super(),h(this,"model"),h(this,"view"),h(this,"mapper"),h(this,"downcastDispatcher"),this.model=e,this.view=new Oy(t),this.mapper=new xp,this.downcastDispatcher=new Tp({mapper:this.mapper,schema:e.schema});const i=this.model.document,o=i.selection,s=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(i,"change",()=>{this.view.change(r=>{this.downcastDispatcher.convertChanges(i.differ,s,r),this.downcastDispatcher.convertSelection(o,s,r)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",Vk(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",Zk(this.mapper,this.model.schema,this.view),{priority:"high"}),this.downcastDispatcher.on("insert:$text",Pp(),{priority:"lowest"}),this.downcastDispatcher.on("insert",Ip(),{priority:"lowest"}),this.downcastDispatcher.on("remove",Yy(),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",tk()),this.downcastDispatcher.on("selection",Xy(),{priority:"low"}),this.downcastDispatcher.on("selection",ek(),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(r=>{if(r.rootName=="$graveyard")return null;const a=new hp(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,i=this.model.markers.get(t);if(!i)throw new b("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(i)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}function Zk(n,e,t){return(i,o)=>{if(!(t.document.isComposing&&!N.isAndroid))for(let s=0;s{t[0]=new Ui(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new Ui(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new b("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 b("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return typeof e=="string"?t=e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?t="$text":t=e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!!(t&&t.isBlock)}isLimit(e){const t=this.getDefinition(e);return t?!!(t.isLimit||t.isObject):!1}isObject(e){const t=this.getDefinition(e);return t?!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent):!1}isInline(e){const t=this.getDefinition(e);return!!(t&&t.isInline)}isSelectable(e){const t=this.getDefinition(e);return t?!!(t.isSelectable||t.isObject):!1}isContent(e){const t=this.getDefinition(e);return t?!!(t.isContent||t.isObject):!1}checkChild(e,t){return t?this._checkContextMatch(e,t):!1}checkAttribute(e,t){const i=this.getDefinition(e.last);if(!i)return!1;const o=this._evaluateAttributeChecks(e,t);return o!==void 0?o:i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof C){const i=e.nodeBefore,o=e.nodeAfter;if(!(i instanceof ne))throw new b("schema-check-merge-no-element-before",this);if(!(o instanceof ne))throw new b("schema-check-merge-no-element-after",this);return this.checkMerge(i,o)}if(this.isLimit(e)||this.isLimit(t))return!1;for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e,t){const i=t!==void 0?t:this._genericCheckSymbol,o=this._customChildChecks.get(i)||[];o.push(e),this._customChildChecks.set(i,o)}addAttributeCheck(e,t){const i=t!==void 0?t:this._genericCheckSymbol,o=this._customAttributeChecks.get(i)||[];o.push(e),this._customAttributeChecks.set(i,o)}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||Object.create(null)}getLimitElement(e){let t;for(e instanceof C?t=e.parent:t=(e instanceof y?[e]:Array.from(e.getRanges())).reduce((i,o)=>{const s=o.getCommonAncestor();return i?i.getCommonAncestor(s,{includeSelf:!0}):s},null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Ce("",e.getAttributes())];return this.checkAttribute(i,t)}else{const i=e.getRanges();for(const o of i)for(const s of o)if(this.checkAttribute(s.item,t))return!0}return!1}*getValidRanges(e,t){e=d2(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if(e.root.rootName=="$graveyard")return null;if(this.checkChild(e,"$text"))return new y(e);let i,o;const s=e.getAncestors().reverse().find(r=>this.isLimit(r))||e.root;(t=="both"||t=="backward")&&(i=new yi({boundaries:y._createIn(s),startPosition:e,direction:"backward"})),(t=="both"||t=="forward")&&(o=new yi({boundaries:y._createIn(s),startPosition:e}));for(const r of h2(i,o)){const a=r.walker==i?"elementEnd":"elementStart",l=r.value;if(l.type==a&&this.isObject(l.item))return y._createOn(l.item);if(this.checkChild(l.nextPosition,"$text"))return new y(l.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}setAllowedAttributes(e,t,i){const o=i.model;for(const[s,r]of Object.entries(t))o.schema.checkAttribute(e,s)&&i.setAttribute(s,r,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))Wh(this,i,t);else{const o=y._createIn(i).getPositions();for(const s of o){const r=s.nodeBefore||s.parent;Wh(this,r,t)}}}getAttributesWithProperty(e,t,i){const o={};for(const[s,r]of e.getAttributes()){const a=this.getAttributeProperties(s);a[t]!==void 0&&(i===void 0||i===a[t])&&(o[s]=r)}return o}createContext(e){return new Ui(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const s of i)e[s]=Qk(t[s],s);const o=Object.values(e);for(const s of o)Yk(e,s),Xk(e,s),e2(e,s),t2(e,s);for(const s of o)i2(e,s);for(const s of o)n2(e,s);for(const s of o)o2(e,s);for(const s of o)r2(e,s);for(const s of o)a2(e,s);this._compiledDefinitions=s2(e)}_checkContextMatch(e,t){const i=e.last;let o=this._evaluateChildChecks(e,t);if(o=o!==void 0?o:t.allowIn.includes(i.name),!o)return!1;const s=this.getDefinition(i),r=e.trimLast();return s?r.length==0?!0:this._checkContextMatch(r,s):!1}_evaluateChildChecks(e,t){const i=this._customChildChecks.get(this._genericCheckSymbol)||[],o=this._customChildChecks.get(t.name)||[];for(const s of[...i,...o]){const r=s(e,t);if(r!==void 0)return r}}_evaluateAttributeChecks(e,t){const i=this._customAttributeChecks.get(this._genericCheckSymbol)||[],o=this._customAttributeChecks.get(t)||[];for(const s of[...i,...o]){const r=s(e,t);if(r!==void 0)return r}}*_getValidRangesForRange(e,t){let i=e.start,o=e.start;for(const s of e.getItems({shallow:!0}))s.is("element")&&(yield*this._getValidRangesForRange(y._createIn(s),t)),this.checkAttribute(s,t)||(i.isEqual(o)||(yield new y(i,o)),i=C._createAfter(s)),o=C._createAfter(s);i.isEqual(o)||(yield new y(i,o))}findOptimalInsertionRange(e,t){const i=e.getSelectedElement();if(i&&this.isObject(i)&&!this.isInline(i))return t=="before"||t=="after"?new y(C._createAt(i,t)):y._createOn(i);const o=ae(e.getSelectedBlocks());if(!o)return new y(e.focus);if(o.isEmpty)return new y(C._createAt(o,0));const s=C._createAfter(o);return e.focus.isTouching(s)?new y(s):new y(C._createBefore(o))}}class Ui{constructor(e){if(h(this,"_items"),e instanceof Ui)return e;let t;typeof e=="string"?t=[e]:Array.isArray(e)?t=e:t=e.getAncestors({includeSelf:!0}),this._items=t.map(u2)}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 Ui([e]);return t._items=[...this._items,...t._items],t}trimLast(){const e=new Ui([]);return e._items=this._items.slice(0,-1),e}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function Qk(n,e){const t={name:e,allowIn:new Set,allowChildren:new Set,disallowIn:new Set,disallowChildren:new Set,allowContentOf:new Set,allowWhere:new Set,allowAttributes:new Set,disallowAttributes:new Set,allowAttributesOf:new Set,inheritTypesFrom:new Set};return l2(n,t),Qt(n,t,"allowIn"),Qt(n,t,"allowChildren"),Qt(n,t,"disallowIn"),Qt(n,t,"disallowChildren"),Qt(n,t,"allowContentOf"),Qt(n,t,"allowWhere"),Qt(n,t,"allowAttributes"),Qt(n,t,"disallowAttributes"),Qt(n,t,"allowAttributesOf"),Qt(n,t,"inheritTypesFrom"),c2(n,t),t}function Yk(n,e){for(const t of e.allowIn){const i=n[t];i?i.allowChildren.add(e.name):e.allowIn.delete(t)}}function Xk(n,e){for(const t of e.allowChildren){const i=n[t];i?i.allowIn.add(e.name):e.allowChildren.delete(t)}}function e2(n,e){for(const t of e.disallowIn){const i=n[t];i?i.disallowChildren.add(e.name):e.disallowIn.delete(t)}}function t2(n,e){for(const t of e.disallowChildren){const i=n[t];i?i.disallowIn.add(e.name):e.disallowChildren.delete(t)}}function i2(n,e){for(const t of e.disallowChildren)e.allowChildren.delete(t);for(const t of e.disallowIn)e.allowIn.delete(t);for(const t of e.disallowAttributes)e.allowAttributes.delete(t)}function n2(n,e){for(const t of e.allowContentOf){const i=n[t];i&&(i.disallowChildren.forEach(o=>{e.allowChildren.has(o)||(e.disallowChildren.add(o),n[o].disallowIn.add(e.name))}),i.allowChildren.forEach(o=>{e.disallowChildren.has(o)||(e.allowChildren.add(o),n[o].allowIn.add(e.name))}))}}function o2(n,e){for(const t of e.allowWhere){const i=n[t];i&&(i.disallowIn.forEach(o=>{e.allowIn.has(o)||(e.disallowIn.add(o),n[o].disallowChildren.add(e.name))}),i.allowIn.forEach(o=>{e.disallowIn.has(o)||(e.allowIn.add(o),n[o].allowChildren.add(e.name))}))}}function s2(n){const e={};for(const t of Object.values(n))e[t.name]={name:t.name,isBlock:!!t.isBlock,isContent:!!t.isContent,isInline:!!t.isInline,isLimit:!!t.isLimit,isObject:!!t.isObject,isSelectable:!!t.isSelectable,allowIn:Array.from(t.allowIn).filter(i=>!!n[i]),allowChildren:Array.from(t.allowChildren).filter(i=>!!n[i]),allowAttributes:Array.from(t.allowAttributes)};return e}function r2(n,e){for(const t of e.allowAttributesOf){const i=n[t];if(!i)return;i.allowAttributes.forEach(o=>{e.disallowAttributes.has(o)||e.allowAttributes.add(o)})}}function a2(n,e){for(const t of e.inheritTypesFrom){const i=n[t];if(i){const o=Object.keys(i).filter(s=>s.startsWith("is"));for(const s of o)s in e||(e[s]=i[s])}}}function l2(n,e){for(const t of n){const i=Object.keys(t).filter(o=>o.startsWith("is"));for(const o of i)e[o]=!!t[o]}}function Qt(n,e,t){for(const i of n){let o=i[t];typeof o=="string"&&(o=[o]),Array.isArray(o)&&o.forEach(s=>e[t].add(s))}}function c2(n,e){for(const t of n){const i=t.inheritAllFrom;i&&(e.allowContentOf.add(i),e.allowWhere.add(i),e.allowAttributesOf.add(i),e.inheritTypesFrom.add(i))}}function u2(n){return typeof n=="string"||n.is("documentFragment")?{name:typeof n=="string"?n:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:n.is("element")?n.name:"$text",*getAttributeKeys(){yield*n.getAttributeKeys()},getAttribute(e){return n.getAttribute(e)}}}function*h2(n,e){let t=!1;for(;!t;){if(t=!0,n){const i=n.next();i.done||(t=!1,yield{walker:n,value:i.value})}if(e){const i=e.next();i.done||(t=!1,yield{walker:e,value:i.value})}}}function*d2(n){for(const e of n)yield*e.getMinimalFlatRanges()}function Wh(n,e,t){for(const i of e.getAttributeKeys())n.checkAttribute(e,i)||t.removeAttribute(i,e)}class m2 extends ge(){constructor(e){super(),h(this,"conversionApi"),h(this,"_splitParts",new Map),h(this,"_cursorParents",new Map),h(this,"_modelCursor",null),h(this,"_emptyElementsToKeep",new Set),this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(t,i)=>this._convertItem(t,i),convertChildren:(t,i)=>this._convertChildren(t,i),safeInsert:(t,i)=>this._safeInsert(t,i),updateConversionResult:(t,i)=>this._updateConversionResult(t,i),splitToAllowedParent:(t,i)=>this._splitToAllowedParent(t,i),getSplitParts:t=>this._getSplitParts(t),keepEmptyElement:t=>this._keepEmptyElement(t)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=g2(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=Pr.createFrom(e),this.conversionApi.store={};const{modelRange:o}=this._convertItem(e,this._modelCursor),s=t.createDocumentFragment();if(o){this._removeEmptyElements();const r=this._modelCursor.parent,a=r._removeChildren(0,r.childCount);s._insertChild(0,a),s.markers=f2(s,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,s}_convertItem(e,t){const i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof y))throw new b("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:C._createAt(t,0);const o=new y(i);for(const s of Array.from(e.getChildren())){const r=this._convertItem(s,i);r.modelRange instanceof y&&(o.end=r.modelRange.end,i=r.modelCursor)}return{modelRange:o,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return i?(this.conversionApi.writer.insert(e,i.position),!0):!1}_updateConversionResult(e,t){const i=this._getSplitParts(e),o=this.conversionApi.writer;t.modelRange||(t.modelRange=o.createRange(o.createPositionBefore(e),o.createPositionAfter(i[i.length-1])));const s=this._cursorParents.get(e);s?t.modelCursor=o.createPositionAt(s,0):t.modelCursor=t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:o}=this.conversionApi;let s=i.findAllowedParent(t,e);if(s){if(s===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(s)&&(s=null)}if(!s)return Np(t,e,i)?{position:Dp(t,o)}:null;const r=this.conversionApi.writer.split(t,s),a=[];for(const c of r.range.getWalker())if(c.type=="elementEnd")a.push(c.item);else{const u=a.pop(),d=c.item;this._registerSplitPair(u,d)}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 i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return this._splitParts.has(e)?t=this._splitParts.get(e):t=[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){const e=new Map;for(const t of this._splitParts.keys())if(t.isEmpty&&!this._emptyElementsToKeep.has(t)){const i=e.get(t.parent)||[];i.push(t),this._splitParts.delete(t),e.set(t.parent,i)}for(const[t,i]of e)t._removeChildrenArray(i);e.size&&this._removeEmptyElements()}}function f2(n,e){const t=new Set,i=new Map,o=y._createIn(n).getItems();for(const s of o)s.is("element","$marker")&&t.add(s);for(const s of t){const r=s.getAttribute("data-name"),a=e.createPositionBefore(s);i.has(r)?i.get(r).end=a.clone():i.set(r,new y(a.clone())),e.remove(s)}return i}function g2(n,e){let t;for(const i of new Ui(n)){const o={};for(const r of i.getAttributeKeys())o[r]=i.getAttribute(r);const s=e.createElement(i.name,o);t&&e.insert(s,t),t=C._createAt(s,0)}return t}class p2{getHtml(e){const t=I.document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class jp{constructor(e){h(this,"domParser"),h(this,"domConverter"),h(this,"htmlWriter"),h(this,"skipComments",!0),this.domParser=new DOMParser,this.domConverter=new ca(e,{renderingMode:"data"}),this.htmlWriter=new p2}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode=e=="marked"?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`${e}`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),o=t.body.childNodes;for(;o.length>0;)i.appendChild(o[0]);return i}}class w2 extends ge(){constructor(e,t){super(),h(this,"model"),h(this,"mapper"),h(this,"downcastDispatcher"),h(this,"upcastDispatcher"),h(this,"viewDocument"),h(this,"stylesProcessor"),h(this,"htmlProcessor"),h(this,"processor"),h(this,"_viewWriter"),this.model=e,this.mapper=new xp,this.downcastDispatcher=new Tp({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",Pp(),{priority:"lowest"}),this.downcastDispatcher.on("insert",Ip(),{priority:"lowest"}),this.upcastDispatcher=new m2({schema:e.schema}),this.viewDocument=new aa(t),this.stylesProcessor=t,this.htmlProcessor=new jp(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new gp(this.viewDocument),this.upcastDispatcher.on("text",Ik(),{priority:"lowest"}),this.upcastDispatcher.on("element",Dh(),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",Dh(),{priority:"lowest"}),ue().prototype.decorate.call(this,"init"),ue().prototype.decorate.call(this,"set"),ue().prototype.decorate.call(this,"get"),ue().prototype.decorate.call(this,"toView"),ue().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},Fp)},{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new b("datacontroller-get-non-existent-root",this);const o=this.model.document.getRoot(t);return o.isAttached()||J("datacontroller-get-detached-root",this),i==="empty"&&!this.model.hasContent(o,{ignoreWhitespaces:!0})?"":this.stringify(o,e)}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,o=this._viewWriter;this.mapper.clearBindings();const s=y._createIn(e),r=new vn(i);this.mapper.bindElements(e,r);const a=e.is("documentFragment")?e.markers:b2(e);return this.downcastDispatcher.convert(s,a,o,t),r}init(e){if(this.model.document.version)throw new b("datacontroller-init-document-not-empty",this);let t={};if(typeof e=="string"?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new b("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},i=>{for(const o of Object.keys(t)){const s=this.model.document.getRoot(o);i.insert(this.parse(t[o],s),s,0)}}),Promise.resolve()}set(e,t={}){let i={};if(typeof e=="string"?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new b("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},o=>{o.setSelection(null),o.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const s of Object.keys(i)){const r=this.model.document.getRoot(s);o.remove(o.createRangeIn(r)),o.insert(this.parse(i[s],r),r,0)}})}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change(i=>this.upcastDispatcher.convert(e,i,t))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}}function b2(n){const e=[],t=n.root.document;if(!t)return new Map;const i=y._createIn(n);for(const o of t.model.markers){const s=o.getRange(),r=s.isCollapsed,a=s.start.isEqual(i.start)||s.end.isEqual(i.end);if(r&&a)e.push([o.name,s]);else{const l=i.getIntersection(s);l&&e.push([o.name,l])}}return e.sort(([o,s],[r,a])=>{if(s.end.compareWith(a.start)!=="after")return 1;if(s.start.compareWith(a.end)!=="before")return-1;switch(s.start.compareWith(a.start)){case"before":return 1;case"after":return-1;default:switch(s.end.compareWith(a.end)){case"before":return 1;case"after":return-1;default:return r.localeCompare(o)}}}),new Map(e)}class _2{constructor(e,t){h(this,"_helpers",new Map),h(this,"_downcast"),h(this,"_upcast"),this._downcast=he(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=he(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new b("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new b("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of za(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of za(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of za(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new b("conversion-group-exists",this);const o=i?new Qy(t):new Pk(t);this._helpers.set(e,o)}}function*za(n){if(n.model.values)for(const e of n.model.values){const t={key:n.model.key,value:e},i=n.view[e],o=n.upcastAlso?n.upcastAlso[e]:void 0;yield*jh(t,i,o)}else yield*jh(n.model,n.view,n.upcastAlso)}function*jh(n,e,t){if(yield{model:n,view:e},t)for(const i of he(t))yield{model:n,view:i}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class It{constructor(e){h(this,"baseVersion"),h(this,"isDocumentOperation"),h(this,"batch"),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)}}function Xc(n,e){const t=qp(e),i=t.reduce((r,a)=>r+a.offsetSize,0),o=n.parent;fs(n);const s=n.index;return o._insertChild(s,t),ms(o,s+t.length),ms(o,s),new y(n,n.getShiftedBy(i))}function Up(n){if(!n.isFlat)throw new b("operation-utils-remove-range-not-flat",this);const e=n.start.parent;fs(n.start),fs(n.end);const t=e._removeChildren(n.start.index,n.end.index-n.start.index);return ms(e,n.start.index),t}function ds(n,e){if(!n.isFlat)throw new b("operation-utils-move-range-not-flat",this);const t=Up(n);return e=e._getTransformedByDeletion(n.start,n.end.offset-n.start.offset),Xc(e,t)}function v2(n,e,t){fs(n.start),fs(n.end);for(const i of n.getItems({shallow:!0})){const o=i.is("$textProxy")?i.textNode:i;t!==null?o._setAttribute(e,t):o._removeAttribute(e),ms(o.parent,o.index)}ms(n.end.parent,n.end.index)}function qp(n){const e=[];function t(i){if(typeof i=="string")e.push(new Ce(i));else if(i instanceof Lt)e.push(new Ce(i.data,i.getAttributes()));else if(i instanceof Tn)e.push(i);else if(Pt(i))for(const o of i)t(o)}t(n);for(let i=1;ie.maxOffset)throw new b("move-operation-nodes-do-not-exist",this);if(e===t&&i=i&&this.targetPosition.path[s]i._clone(!0))),t=new je(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new C(e,[0]);return new re(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsett._clone(!0))),Xc(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const i=[];for(const s of e.nodes)s.name?i.push(ne.fromJSON(s)):i.push(Ce.fromJSON(s));const o=new je(C.fromJSON(e.position,t),i,e.baseVersion);return o.shouldReceiveAttributes=e.shouldReceiveAttributes,o}}class we extends It{constructor(e,t,i,o,s){super(s),h(this,"splitPosition"),h(this,"howMany"),h(this,"insertionPosition"),h(this,"graveyardPosition"),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=o?o.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 C(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new y(this.splitPosition,e)}get affectedSelectable(){const e=[y._createFromPositionAndShift(this.splitPosition,0),y._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(y._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new we(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new C(e,[0]);return new Oe(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset0&&(e.sourcePosition.isEqual(t.sourcePosition.getShiftedBy(t.howMany))&&this._setRelation(e,t,"mergeSourceAffected"),e.targetPosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeTargetWasBefore"));else if(e instanceof ot){const i=e.newRange;if(!i)return;if(t instanceof Oe){const o=i.start.isEqual(t.targetPosition),s=i.start.isEqual(t.deletionPosition),r=i.end.isEqual(t.deletionPosition),a=i.end.isEqual(t.sourcePosition);(o||s||r||a)&&this._setRelation(e,t,{wasInLeftElement:o,wasStartBeforeMergedElement:s,wasEndBeforeMergedElement:r,wasInRightElement:a})}}}getContext(e,t,i){return{aIsStrong:i,aWasUndone:this._wasUndone(e),bWasUndone:this._wasUndone(t),abRelation:this._useRelations?this._getRelation(e,t):null,baRelation:this._useRelations?this._getRelation(t,e):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(e){const t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){const i=this.originalOperations.get(t),o=this._history.getUndoneOperation(i);if(!o)return null;const s=this.originalOperations.get(e),r=this._relations.get(s);return r&&r.get(o)||null}_setRelation(e,t,i){const o=this.originalOperations.get(e),s=this.originalOperations.get(t);let r=this._relations.get(o);r||(r=new Map,this._relations.set(o,r)),r.set(s,i)}}function qh(n,e){for(const t of n)t.baseVersion=e++}function Gh(n){const e=new Map;for(let t=0;t{if(n.key===e.key&&n.range.start.hasSameParentAs(e.range.start)){const i=n.range.getDifference(e.range).map(s=>new Le(s,n.key,n.oldValue,n.newValue,0)),o=n.range.getIntersection(e.range);return o&&t.aIsStrong&&i.push(new Le(o,e.key,e.newValue,n.newValue,0)),i.length==0?[new De(0)]:i}else return[n]});ie(Le,je,(n,e)=>{if(n.range.start.hasSameParentAs(e.position)&&n.range.containsPosition(e.position)){const t=n.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map(i=>new Le(i,n.key,n.oldValue,n.newValue,n.baseVersion));if(e.shouldReceiveAttributes){const i=Kp(e,n.key,n.oldValue);i&&t.unshift(i)}return t}return n.range=n.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[n]});function Kp(n,e,t){const i=n.nodes.getNode(0).getAttribute(e);if(i==t)return null;const o=new y(n.position,n.position.getShiftedBy(n.howMany));return new Le(o,e,i,t,0)}ie(Le,Oe,(n,e)=>{const t=[];n.range.start.hasSameParentAs(e.deletionPosition)&&(n.range.containsPosition(e.deletionPosition)||n.range.start.isEqual(e.deletionPosition))&&t.push(y._createFromPositionAndShift(e.graveyardPosition,1));const i=n.range._getTransformedByMergeOperation(e);return i.isCollapsed||t.push(i),t.map(o=>new Le(o,n.key,n.oldValue,n.newValue,n.baseVersion))});ie(Le,re,(n,e)=>T2(n.range,e).map(t=>new Le(t,n.key,n.oldValue,n.newValue,n.baseVersion)));function T2(n,e){const t=y._createFromPositionAndShift(e.sourcePosition,e.howMany);let i=null,o=[];t.containsRange(n,!0)?i=n:n.start.hasSameParentAs(t.start)?(o=n.getDifference(t),i=n.getIntersection(t)):o=[n];const s=[];for(let r of o){r=r._getTransformedByDeletion(e.sourcePosition,e.howMany);const a=e.getMovedRangeStart(),l=r.start.hasSameParentAs(a),c=r._getTransformedByInsertion(a,e.howMany,l);s.push(...c)}return i&&s.push(i._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]),s}ie(Le,we,(n,e)=>{if(n.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||n.range.end.offset++,[n];if(n.range.start.hasSameParentAs(e.splitPosition)&&n.range.containsPosition(e.splitPosition)){const t=n.clone();return t.range=new y(e.moveTargetPosition.clone(),n.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),n.range.end=e.splitPosition.clone(),n.range.end.stickiness="toPrevious",[n,t]}return n.range=n.range._getTransformedBySplitOperation(e),[n]});ie(je,Le,(n,e)=>{const t=[n];if(n.shouldReceiveAttributes&&n.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(n.position)){const i=Kp(n,e.key,e.newValue);i&&t.push(i)}return t});ie(je,je,(n,e,t)=>n.position.isEqual(e.position)&&t.aIsStrong?[n]:(n.position=n.position._getTransformedByInsertOperation(e),[n]));ie(je,re,(n,e)=>(n.position=n.position._getTransformedByMoveOperation(e),[n]));ie(je,we,(n,e)=>(n.position=n.position._getTransformedBySplitOperation(e),[n]));ie(je,Oe,(n,e)=>(n.position=n.position._getTransformedByMergeOperation(e),[n]));ie(ot,je,(n,e)=>(n.oldRange&&(n.oldRange=n.oldRange._getTransformedByInsertOperation(e)[0]),n.newRange&&(n.newRange=n.newRange._getTransformedByInsertOperation(e)[0]),[n]));ie(ot,ot,(n,e,t)=>{if(n.name==e.name)if(t.aIsStrong)n.oldRange=e.newRange?e.newRange.clone():null;else return[new De(0)];return[n]});ie(ot,Oe,(n,e)=>(n.oldRange&&(n.oldRange=n.oldRange._getTransformedByMergeOperation(e)),n.newRange&&(n.newRange=n.newRange._getTransformedByMergeOperation(e)),[n]));ie(ot,re,(n,e)=>{const t=[n];if(n.oldRange&&(n.oldRange=y._createFromRanges(n.oldRange._getTransformedByMoveOperation(e))),n.newRange){const i=n.newRange._getTransformedByMoveOperation(e);n.newRange=i[0];for(let o=1;o{if(n.oldRange&&(n.oldRange=n.oldRange._getTransformedBySplitOperation(e)),n.newRange){if(t.abRelation){const i=n.newRange._getTransformedBySplitOperation(e);return n.newRange.start.isEqual(e.splitPosition)?t.abRelation.wasStartBeforeMergedElement?n.newRange.start=C._createAt(e.insertionPosition):t.abRelation.wasInLeftElement?n.newRange.start=C._createAt(n.newRange.start):n.newRange.start=C._createAt(e.moveTargetPosition):n.newRange.start=i.start,n.newRange.end.isEqual(e.splitPosition)?n.newRange.end.isEqual(e.splitPosition)&&t.abRelation.wasEndBeforeMergedElement?n.newRange.end=C._createAt(e.insertionPosition):t.abRelation.wasInRightElement?n.newRange.end=C._createAt(e.moveTargetPosition):n.newRange.end=C._createAt(n.newRange.end):n.newRange.end=i.end,[n]}n.newRange=n.newRange._getTransformedBySplitOperation(e)}return[n]});ie(Oe,je,(n,e)=>(n.sourcePosition.hasSameParentAs(e.position)&&(n.howMany+=e.howMany),n.sourcePosition=n.sourcePosition._getTransformedByInsertOperation(e),n.targetPosition=n.targetPosition._getTransformedByInsertOperation(e),[n]));ie(Oe,Oe,(n,e,t)=>{if(n.sourcePosition.isEqual(e.sourcePosition)&&n.targetPosition.isEqual(e.targetPosition))if(t.bWasUndone){const i=e.graveyardPosition.path.slice();return i.push(0),n.sourcePosition=new C(e.graveyardPosition.root,i),n.howMany=0,[n]}else return[new De(0)];if(n.sourcePosition.isEqual(e.sourcePosition)&&!n.targetPosition.isEqual(e.targetPosition)&&!t.bWasUndone&&t.abRelation!="splitAtSource"){const i=n.targetPosition.root.rootName=="$graveyard",o=e.targetPosition.root.rootName=="$graveyard";if(o&&!i||!(i&&!o)&&t.aIsStrong){const s=e.targetPosition._getTransformedByMergeOperation(e),r=n.targetPosition._getTransformedByMergeOperation(e);return[new re(s,n.howMany,r,0)]}else return[new De(0)]}return n.sourcePosition.hasSameParentAs(e.targetPosition)&&(n.howMany+=e.howMany),n.sourcePosition=n.sourcePosition._getTransformedByMergeOperation(e),n.targetPosition=n.targetPosition._getTransformedByMergeOperation(e),(!n.graveyardPosition.isEqual(e.graveyardPosition)||!t.aIsStrong)&&(n.graveyardPosition=n.graveyardPosition._getTransformedByMergeOperation(e)),[n]});ie(Oe,re,(n,e,t)=>{const i=y._createFromPositionAndShift(e.sourcePosition,e.howMany);return e.type=="remove"&&!t.bWasUndone&&n.deletionPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(n.sourcePosition)?[new De(0)]:(e.sourcePosition.getShiftedBy(e.howMany).isEqual(n.sourcePosition)?n.sourcePosition.stickiness="toNone":e.targetPosition.isEqual(n.sourcePosition)&&t.abRelation=="mergeSourceAffected"?n.sourcePosition.stickiness="toNext":e.sourcePosition.isEqual(n.targetPosition)?(n.targetPosition.stickiness="toNone",n.howMany-=e.howMany):e.targetPosition.isEqual(n.targetPosition)&&t.abRelation=="mergeTargetWasBefore"?(n.targetPosition.stickiness="toPrevious",n.howMany+=e.howMany):(n.sourcePosition.hasSameParentAs(e.targetPosition)&&(n.howMany+=e.howMany),n.sourcePosition.hasSameParentAs(e.sourcePosition)&&(n.howMany-=e.howMany)),n.sourcePosition=n.sourcePosition._getTransformedByMoveOperation(e),n.targetPosition=n.targetPosition._getTransformedByMoveOperation(e),n.sourcePosition.stickiness="toPrevious",n.targetPosition.stickiness="toNext",n.graveyardPosition.isEqual(e.targetPosition)||(n.graveyardPosition=n.graveyardPosition._getTransformedByMoveOperation(e)),[n])});ie(Oe,we,(n,e,t)=>{if(e.graveyardPosition&&(n.graveyardPosition=n.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),n.deletionPosition.isEqual(e.graveyardPosition)&&(n.howMany=e.howMany)),n.targetPosition.isEqual(e.splitPosition)&&(e.graveyardPosition&&n.deletionPosition.isEqual(e.graveyardPosition)||t.abRelation=="mergeTargetNotMoved"))return n.sourcePosition=n.sourcePosition._getTransformedBySplitOperation(e),[n];if(n.sourcePosition.isEqual(e.splitPosition)){if(t.abRelation=="mergeSourceNotMoved")return n.howMany=0,n.targetPosition=n.targetPosition._getTransformedBySplitOperation(e),[n];if(t.abRelation=="mergeSameElement"||n.sourcePosition.offset>0)return n.sourcePosition=e.moveTargetPosition.clone(),n.targetPosition=n.targetPosition._getTransformedBySplitOperation(e),[n]}return n.sourcePosition.hasSameParentAs(e.splitPosition)&&(n.howMany=e.splitPosition.offset),n.sourcePosition=n.sourcePosition._getTransformedBySplitOperation(e),n.targetPosition=n.targetPosition._getTransformedBySplitOperation(e),[n]});ie(re,je,(n,e)=>{const t=y._createFromPositionAndShift(n.sourcePosition,n.howMany)._getTransformedByInsertOperation(e,!1)[0];return n.sourcePosition=t.start,n.howMany=t.end.offset-t.start.offset,n.targetPosition.isEqual(e.position)||(n.targetPosition=n.targetPosition._getTransformedByInsertOperation(e)),[n]});ie(re,re,(n,e,t)=>{const i=y._createFromPositionAndShift(n.sourcePosition,n.howMany),o=y._createFromPositionAndShift(e.sourcePosition,e.howMany);let s=t.aIsStrong,r=!t.aIsStrong;t.abRelation=="insertBefore"||t.baRelation=="insertAfter"?r=!0:(t.abRelation=="insertAfter"||t.baRelation=="insertBefore")&&(r=!1);let a;if(n.targetPosition.isEqual(e.targetPosition)&&r?a=n.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):a=n.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Kh(n,e)&&Kh(e,n))return[e.getReversed()];if(i.containsPosition(e.targetPosition)&&i.containsRange(o,!0))return i.start=i.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),i.end=i.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),no([i],a);if(o.containsPosition(n.targetPosition)&&o.containsRange(i,!0))return i.start=i.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),i.end=i.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),no([i],a);const l=Xe(n.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if(l=="prefix"||l=="extension")return i.start=i.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),i.end=i.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),no([i],a);n.type=="remove"&&e.type!="remove"&&!t.aWasUndone&&!t.forceWeakRemove?s=!0:n.type!="remove"&&e.type=="remove"&&!t.bWasUndone&&!t.forceWeakRemove&&(s=!1);const c=[],u=i.getDifference(o);for(const m of u){m.start=m.start._getTransformedByDeletion(e.sourcePosition,e.howMany),m.end=m.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const f=Xe(m.start.getParentPath(),e.getMovedRangeStart().getParentPath())=="same",g=m._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,f);c.push(...g)}const d=i.getIntersection(o);return d!==null&&s&&(d.start=d.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),d.end=d.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),c.length===0?c.push(d):c.length==1?o.start.isBefore(i.start)||o.start.isEqual(i.start)?c.unshift(d):c.push(d):c.splice(1,0,d)),c.length===0?[new De(n.baseVersion)]:no(c,a)});ie(re,we,(n,e,t)=>{let i=n.targetPosition.clone();(!n.targetPosition.isEqual(e.insertionPosition)||!e.graveyardPosition||t.abRelation=="moveTargetAfter")&&(i=n.targetPosition._getTransformedBySplitOperation(e));const o=y._createFromPositionAndShift(n.sourcePosition,n.howMany);if(o.end.isEqual(e.insertionPosition))return e.graveyardPosition||n.howMany++,n.targetPosition=i,[n];if(o.start.hasSameParentAs(e.splitPosition)&&o.containsPosition(e.splitPosition)){let r=new y(e.splitPosition,o.end);r=r._getTransformedBySplitOperation(e);const a=[new y(o.start,e.splitPosition),r];return no(a,i)}n.targetPosition.isEqual(e.splitPosition)&&t.abRelation=="insertAtSource"&&(i=e.moveTargetPosition),n.targetPosition.isEqual(e.insertionPosition)&&t.abRelation=="insertBetween"&&(i=n.targetPosition);const s=[o._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const r=o.start.isEqual(e.graveyardPosition)||o.containsPosition(e.graveyardPosition);n.howMany>1&&r&&!t.aWasUndone&&s.push(y._createFromPositionAndShift(e.insertionPosition,1))}return no(s,i)});ie(re,Oe,(n,e,t)=>{const i=y._createFromPositionAndShift(n.sourcePosition,n.howMany);if(e.deletionPosition.hasSameParentAs(n.sourcePosition)&&i.containsPosition(e.sourcePosition)){if(n.type=="remove"&&!t.forceWeakRemove){if(!t.aWasUndone){const s=[];let r=e.graveyardPosition.clone(),a=e.targetPosition._getTransformedByMergeOperation(e);const l=n.targetPosition.getTransformedByOperation(e);n.howMany>1&&(s.push(new re(n.sourcePosition,n.howMany-1,l,0)),r=r._getTransformedByMove(n.sourcePosition,l,n.howMany-1),a=a._getTransformedByMove(n.sourcePosition,l,n.howMany-1));const c=e.deletionPosition._getCombined(n.sourcePosition,l),u=new re(r,1,c,0),d=u.getMovedRangeStart().path.slice();d.push(0);const m=new C(u.targetPosition.root,d);a=a._getTransformedByMove(r,c,1);const f=new re(a,e.howMany,m,0);return s.push(u),s.push(f),s}}else if(n.howMany==1)return t.bWasUndone?(n.sourcePosition=e.graveyardPosition.clone(),n.targetPosition=n.targetPosition._getTransformedByMergeOperation(e),[n]):[new De(0)]}const o=y._createFromPositionAndShift(n.sourcePosition,n.howMany)._getTransformedByMergeOperation(e);return n.sourcePosition=o.start,n.howMany=o.end.offset-o.start.offset,n.targetPosition=n.targetPosition._getTransformedByMergeOperation(e),[n]});ie(dt,je,(n,e)=>(n.position=n.position._getTransformedByInsertOperation(e),[n]));ie(dt,Oe,(n,e)=>n.position.isEqual(e.deletionPosition)?(n.position=e.graveyardPosition.clone(),n.position.stickiness="toNext",[n]):(n.position=n.position._getTransformedByMergeOperation(e),[n]));ie(dt,re,(n,e)=>(n.position=n.position._getTransformedByMoveOperation(e),[n]));ie(dt,dt,(n,e,t)=>{if(n.position.isEqual(e.position))if(t.aIsStrong)n.oldName=e.newName;else return[new De(0)];return[n]});ie(dt,we,(n,e)=>{const t=n.position.path,i=e.splitPosition.getParentPath();if(Xe(t,i)=="same"&&!e.graveyardPosition){const o=new dt(n.position.getShiftedBy(1),n.oldName,n.newName,0);return[n,o]}return n.position=n.position._getTransformedBySplitOperation(e),[n]});ie(Ci,Ci,(n,e,t)=>{if(n.root===e.root&&n.key===e.key){if(!t.aIsStrong||n.newValue===e.newValue)return[new De(0)];n.oldValue=e.newValue}return[n]});ie(ni,ni,(n,e)=>n.rootName===e.rootName&&n.isAdd===e.isAdd?[new De(0)]:[n]);ie(we,je,(n,e)=>(n.splitPosition.hasSameParentAs(e.position)&&n.splitPosition.offset{if(!n.graveyardPosition&&!t.bWasUndone&&n.splitPosition.hasSameParentAs(e.sourcePosition)){const i=e.graveyardPosition.path.slice();i.push(0);const o=new C(e.graveyardPosition.root,i),s=we.getInsertionPosition(new C(e.graveyardPosition.root,i)),r=new we(o,0,s,null,0);return n.splitPosition=n.splitPosition._getTransformedByMergeOperation(e),n.insertionPosition=we.getInsertionPosition(n.splitPosition),n.graveyardPosition=r.insertionPosition.clone(),n.graveyardPosition.stickiness="toNext",[r,n]}return n.splitPosition.hasSameParentAs(e.deletionPosition)&&!n.splitPosition.isAfter(e.deletionPosition)&&n.howMany--,n.splitPosition.hasSameParentAs(e.targetPosition)&&(n.howMany+=e.howMany),n.splitPosition=n.splitPosition._getTransformedByMergeOperation(e),n.insertionPosition=we.getInsertionPosition(n.splitPosition),n.graveyardPosition&&(n.graveyardPosition=n.graveyardPosition._getTransformedByMergeOperation(e)),[n]});ie(we,re,(n,e,t)=>{const i=y._createFromPositionAndShift(e.sourcePosition,e.howMany);if(n.graveyardPosition){const s=i.start.isEqual(n.graveyardPosition)||i.containsPosition(n.graveyardPosition);if(!t.bWasUndone&&s){const r=n.splitPosition._getTransformedByMoveOperation(e),a=n.graveyardPosition._getTransformedByMoveOperation(e),l=a.path.slice();l.push(0);const c=new C(a.root,l);return[new re(r,n.howMany,c,0)]}n.graveyardPosition=n.graveyardPosition._getTransformedByMoveOperation(e)}const o=n.splitPosition.isEqual(e.targetPosition);if(o&&(t.baRelation=="insertAtSource"||t.abRelation=="splitBefore"))return n.howMany+=e.howMany,n.splitPosition=n.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),n.insertionPosition=we.getInsertionPosition(n.splitPosition),[n];if(o&&t.abRelation&&t.abRelation.howMany){const{howMany:s,offset:r}=t.abRelation;return n.howMany+=s,n.splitPosition=n.splitPosition.getShiftedBy(r),[n]}if(n.splitPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(n.splitPosition)){const s=e.howMany-(n.splitPosition.offset-e.sourcePosition.offset);return n.howMany-=s,n.splitPosition.hasSameParentAs(e.targetPosition)&&n.splitPosition.offset{if(n.splitPosition.isEqual(e.splitPosition)){if(!n.graveyardPosition&&!e.graveyardPosition)return[new De(0)];if(n.graveyardPosition&&e.graveyardPosition&&n.graveyardPosition.isEqual(e.graveyardPosition))return[new De(0)];if(t.abRelation=="splitBefore")return n.howMany=0,n.graveyardPosition=n.graveyardPosition._getTransformedBySplitOperation(e),[n]}if(n.graveyardPosition&&e.graveyardPosition&&n.graveyardPosition.isEqual(e.graveyardPosition)){const i=n.splitPosition.root.rootName=="$graveyard",o=e.splitPosition.root.rootName=="$graveyard";if(o&&!i||!(i&&!o)&&t.aIsStrong){const s=[];return e.howMany&&s.push(new re(e.moveTargetPosition,e.howMany,e.splitPosition,0)),n.howMany&&s.push(new re(n.splitPosition,n.howMany,n.moveTargetPosition,0)),s}else return[new De(0)]}if(n.graveyardPosition&&(n.graveyardPosition=n.graveyardPosition._getTransformedBySplitOperation(e)),n.splitPosition.isEqual(e.insertionPosition)&&t.abRelation=="splitBefore")return n.howMany++,[n];if(e.splitPosition.isEqual(n.insertionPosition)&&t.baRelation=="splitBefore"){const i=e.insertionPosition.path.slice();i.push(0);const o=new C(e.insertionPosition.root,i),s=new re(n.insertionPosition,1,o,0);return[n,s]}return n.splitPosition.hasSameParentAs(e.splitPosition)&&n.splitPosition.offset{const t=e[0];t.isDocumentOperation&&S2.call(this,t)},{priority:"low"})}function S2(n){const e=this.getTransformedByOperation(n);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}class Nn{constructor(e={}){h(this,"operations"),h(this,"isUndoable"),h(this,"isLocal"),h(this,"isUndo"),h(this,"isTyping"),typeof e=="string"&&(e=e==="transparent"?{isUndoable:!1}:{},J("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:o=!1,isTyping:s=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=o,this.isTyping=s}get type(){return J("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.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}const Zp=class Kl{constructor(e){h(this,"_markerCollection"),h(this,"_changesInElement",new Map),h(this,"_elementsSnapshots",new Map),h(this,"_elementChildrenSnapshots",new Map),h(this,"_elementState",new Map),h(this,"_changedMarkers",new Map),h(this,"_changedRoots",new Map),h(this,"_changeCount",0),h(this,"_cachedChanges",null),h(this,"_cachedChangesWithGraveyard",null),h(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 i of t.range.getItems({shallow:!0}))this._isInInsertedElement(i.parent)||this._markAttribute(i);break}case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const i=this._isInInsertedElement(t.sourcePosition.parent),o=this._isInInsertedElement(t.targetPosition.parent);i||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),o||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);const s=y._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const r of s.getItems({shallow:!0}))this._setElementState(r,"move");break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const i=y._createFromPositionAndShift(t.position,1);for(const o of this._markerCollection.getMarkersIntersectingRange(i)){const s=o.getData();this.bufferMarkerChange(o.name,s,s)}this._setElementState(t.position.nodeAfter,"rename");break}case"split":{const i=t.splitPosition.parent;if(!this._isInInsertedElement(i)){this._markRemove(i,t.splitPosition.offset,t.howMany);const o=y._createFromPositionAndShift(t.splitPosition,t.howMany);for(const s of o.getItems({shallow:!0}))this._setElementState(s,"move")}this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&(this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1),this._setElementState(t.graveyardPosition.nodeAfter,"move"));break}case"merge":{const i=t.sourcePosition.parent;this._isInInsertedElement(i.parent)||this._markRemove(i.parent,i.startOffset,1);const o=t.graveyardPosition.parent;this._markInsert(o,t.graveyardPosition.offset,1),this._setElementState(i,"move");const s=t.targetPosition.parent;if(!this._isInInsertedElement(s)){this._markInsert(s,t.targetPosition.offset,i.maxOffset);const r=y._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const a of r.getItems({shallow:!0}))this._setElementState(a,"move")}break}case"detachRoot":case"addRoot":{const i=t.affectedSelectable;if(!i._isLoaded||i.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const i=t.root.rootName;this._bufferRootAttributeChange(i,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let o=this._changedMarkers.get(e);o?o.newMarkerData=i:(o={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,o)),o.oldMarkerData.range==null&&i.range==null&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)i.oldMarkerData.range!=null&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)i.newMarkerData.range!=null&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}}))}hasDataChanges(){if(this.getChanges().length||this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const i=e.range&&!t.range,o=!e.range&&t.range,s=e.range&&t.range&&!e.range.isEqual(t.range);if(i||o||s)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const i of this._changesInElement.keys()){const o=this._changesInElement.get(i).sort((u,d)=>u.offset===d.offset?u.type!=d.type?u.type=="remove"?-1:1:0:u.offseti.position.root!=o.position.root?i.position.root.rootNamei);for(const i of t)delete i.changeCount,i.type=="attribute"&&(delete i.position,delete i.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(V2),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{const t={...e};return t.state!==void 0&&delete t.attributes,t})}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementChildrenSnapshots.clear(),this._elementsSnapshots.clear(),this._elementState.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems.clear(),this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e),this._setElementState(e,"refresh");const t=y._createOn(e);for(const i of this._markerCollection.getMarkersIntersectingRange(t)){const o=i.getData();this.bufferMarkerChange(i.name,o,o)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const i=t.getData();this.bufferMarkerChange(t.name,{...i,range:null},i)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e)){this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});return}const i=this._changedRoots.get(e);i.state!==void 0?(delete i.state,i.attributes===void 0&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,o){const s=this._changedRoots.get(e)||{name:e},r=s.attributes||{};if(r[t]){const a=r[t];o===a.oldValue?delete r[t]:a.newValue=o}else r[t]={oldValue:i,newValue:o};Object.entries(r).length===0?(delete s.attributes,s.state===void 0&&this._changedRoots.delete(e)):(s.attributes=r,this._changedRoots.set(e,s))}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const o={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,o)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const o={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,o),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshots(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let o=0;oi&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element")||!this._elementsSnapshots.has(e))return t;const i=this._elementState.get(e);return!i||i=="move"?t:i}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshots(e){if(this._elementChildrenSnapshots.has(e))return;const t=Jh(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(const i of t)this._elementsSnapshots.set(i.node,i)}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const i of t){const o=e.offset+e.howMany,s=i.offset+i.howMany;if(e.type=="insert"&&(i.type=="insert"&&(e.offset<=i.offset?i.offset+=e.howMany:e.offseti.offset){if(o>s){const r={type:"attribute",offset:s,howMany:o-s,count:this._changeCount++};this._handleChange(r,t),t.push(r)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offsets?(e.nodesToHandle=o-s,e.offset=s):e.nodesToHandle=0);if(i.type=="remove"&&e.offseti.offset){const r={type:"attribute",offset:i.offset,howMany:o-i.offset,count:this._changeCount++};this._handleChange(r,t),t.push(r),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}i.type=="attribute"&&(e.offset>=i.offset&&o<=s?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&o>=s&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i,o,s){const r={type:"insert",position:C._createAt(e,t),name:o.name,attributes:new Map(o.attributes),length:1,changeCount:this._changeCount++,action:i};return i!="insert"&&s&&(r.before={name:s.name,attributes:new Map(s.attributes)}),r}_getRemoveDiff(e,t,i,o){return{type:"remove",action:i,position:C._createAt(e,t),name:o.name,attributes:new Map(o.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const o=[];i=new Map(i);for(const[s,r]of t){const a=i.has(s)?i.get(s):null;a!==r&&o.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:r,attributeNewValue:a,changeCount:this._changeCount++}),i.delete(s)}for(const[s,r]of i)o.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:null,attributeNewValue:r,changeCount:this._changeCount++});return o}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),o=e.startOffset;if(i){for(const s of i)if(s.type=="insert"&&o>=s.offset&&oi){for(let r=0;r1500)for(let r=0;rthis._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 b("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const i=this._operations[0];e===void 0&&(e=i.baseVersion);let o=t-1;for(const[a,l]of this._gaps)e>a&&ea&&othis.lastOperation.baseVersion)return[];let s=this._baseVersionToOperationIndex.get(e);s===void 0&&(s=0);let r=this._baseVersionToOperationIndex.get(o);return r===void 0&&(r=this._operations.length-1),this._operations.slice(s,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}}class Rr extends ne{constructor(e,t,i="main"){super(t),h(this,"rootName"),h(this,"_document"),h(this,"_isAttached",!0),h(this,"_isLoaded",!0),this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}Rr.prototype.is=function(n,e){return e?e===this.name&&(n==="rootElement"||n==="model:rootElement"||n==="element"||n==="model:element"):n==="rootElement"||n==="model:rootElement"||n==="element"||n==="model:element"||n==="node"||n==="model:node"};const Qh="$graveyard";class O2 extends ge(){constructor(e){super(),h(this,"model"),h(this,"history"),h(this,"selection"),h(this,"roots"),h(this,"differ"),h(this,"isReadOnly"),h(this,"_postFixers"),h(this,"_hasSelectionChangedFromTheLastChangeBlock"),this.model=e,this.history=new R2,this.selection=new Kt(this),this.roots=new _e({idProperty:"rootName"}),this.differ=new P2(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",Qh),this.listenTo(e,"applyOperation",(t,i)=>{const o=i[0];o.isDocumentOperation&&this.differ.bufferOperation(o)},{priority:"high"}),this.listenTo(e,"applyOperation",(t,i)=>{const o=i[0];o.isDocumentOperation&&this.history.addOperation(o)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(t,i,o,s,r)=>{const a={...i.getData(),range:s};this.differ.bufferMarkerChange(i.name,r,a),o===null&&i.on("change",(l,c)=>{const u=i.getData();this.differ.bufferMarkerChange(i.name,{...u,range:c},u)})}),this.registerPostFixer(t=>{let i=!1;for(const o of this.roots)!o.isAttached()&&!o.isEmpty&&(t.remove(t.createRangeIn(o)),i=!0);for(const o of this.model.markers)o.getRange().root.isAttached()||(t.removeMarker(o),i=!0);return i})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(Qh)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new b("model-document-createroot-name-exists",this,{name:t});const i=new Rr(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(t=>t.rootName)}getRoots(e=!1){return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=Oc(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,o=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(o)||t.createRange(o)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&Yh(e.start)&&Yh(e.end)}_callPostFixers(e){let t=!1;do for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break;while(t)}}function Yh(n){const e=n.textNode;if(e){const t=e.data,i=n.offset-e.startOffset;return!jc(t,i)&&!Uc(t,i)}return!0}class B2 extends ge(){constructor(){super(...arguments),h(this,"_markers",new Map)}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Kn?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,o=!1){const s=e instanceof Kn?e.name:e;if(s.includes(","))throw new b("markercollection-incorrect-marker-name",this);const r=this._markers.get(s);if(r){const c=r.getData(),u=r.getRange();let d=!1;return u.isEqual(t)||(r._attachLiveRange(ht.fromRange(t)),d=!0),i!=r.managedUsingOperations&&(r._managedUsingOperations=i,d=!0),typeof o=="boolean"&&o!=r.affectsData&&(r._affectsData=o,d=!0),d&&this.fire(`update:${s}`,r,u,t,c),r}const a=ht.fromRange(t),l=new Kn(s,a,i,o);return this._markers.set(s,l),this.fire(`update:${s}`,l,null,t,{...l.getData(),range:null}),l}_remove(e){const t=e instanceof Kn?e.name:e,i=this._markers.get(t);return i?(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0):!1}_refresh(e){const t=e instanceof Kn?e.name:e,i=this._markers.get(t);if(!i)throw new b("markercollection-refresh-marker-not-exists",this);const o=i.getRange();this.fire(`update:${t}`,i,o,o,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)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 Kn extends ge(Yi){constructor(e,t,i,o){super(),h(this,"name"),h(this,"_managedUsingOperations"),h(this,"_affectsData"),h(this,"_liveRange"),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=o}get managedUsingOperations(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new b("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}}Kn.prototype.is=function(n){return n==="marker"||n==="model:marker"};class M2 extends It{constructor(e,t){super(null),h(this,"sourcePosition"),h(this,"howMany"),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 b("detach-operation-on-document-node",this)}_execute(){Up(y._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class ti extends Yi{constructor(e){super(),h(this,"markers",new Map),h(this,"_children",new Xo),e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChildAtOffset(i);return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(ne.fromJSON(i)):t.push(Ce.fromJSON(i));return new ti(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=L2(t);for(const o of i)o.parent!==null&&o._remove(),o.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const o of i)o.parent=null;return i}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}}ti.prototype.is=function(n){return n==="documentFragment"||n==="model:documentFragment"};function L2(n){return typeof n=="string"?[new Ce(n)]:(Pt(n)||(n=[n]),Array.from(n).map(e=>typeof e=="string"?new Ce(e):e instanceof Lt?new Ce(e.data,e.getAttributes()):e))}class F2{constructor(e,t){h(this,"model"),h(this,"batch"),this.model=e,this.batch=t}createText(e,t){return new Ce(e,t)}createElement(e,t){return new ne(e,t)}createDocumentFragment(){return new ti}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Ce&&e.data=="")return;const o=C._createAt(t,i);if(e.parent)if(td(e.root,o.root)){this.move(y._createOn(e),o);return}else{if(e.root.document)throw new b("model-writer-insert-forbidden-move",this);this.remove(e)}const s=o.root.document?o.root.document.version:null,r=e instanceof ti?e._removeChildren(0,e.childCount):e,a=new je(o,r,s);if(e instanceof Ce&&(a.shouldReceiveAttributes=!0),this.batch.addOperation(a),this.model.applyOperation(a),e instanceof ti)for(const[l,c]of e.markers){const u=C._createAt(c.root,0),d={range:new y(c.start._getCombined(u,o),c.end._getCombined(u,o)),usingOperation:!0,affectsData:!0};this.model.markers.has(l)?this.updateMarker(l,d):this.addMarker(l,d)}}insertText(e,t,i,o){t instanceof ti||t instanceof ne||t instanceof C?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,o)}insertElement(e,t,i,o){t instanceof ti||t instanceof ne||t instanceof C?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,o)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof ti||t instanceof ne?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof ti||t instanceof ne?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof y){const o=i.getMinimalFlatRanges();for(const s of o)Xh(this,e,t,s)}else ed(this,e,t,i)}setAttributes(e,t){for(const[i,o]of ri(e))this.setAttribute(i,o,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof y){const i=t.getMinimalFlatRanges();for(const o of i)Xh(this,e,null,o)}else ed(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=i=>{for(const o of i.getAttributeKeys())this.removeAttribute(o,i)};if(!(e instanceof y))t(e);else for(const i of e.getItems())t(i)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof y))throw new b("writer-move-invalid-range",this);if(!e.isFlat)throw new b("writer-move-range-not-flat",this);const o=C._createAt(t,i);if(o.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!td(e.root,o.root))throw new b("writer-move-different-document",this);const s=e.root.document?e.root.document.version:null,r=new re(e.start,e.end.offset-e.start.offset,o,s);this.batch.addOperation(r),this.model.applyOperation(r)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof y?e:y._createOn(e)).getMinimalFlatRanges().reverse();for(const i of t)this._addOperationForAffectedMarkers("move",i),N2(i.start,i.end.offset-i.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof ne))throw new b("writer-merge-no-element-before",this);if(!(i instanceof ne))throw new b("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(y._createIn(i),C._createAt(t,"end")),this.remove(i)}_merge(e){const t=C._createAt(e.nodeBefore,"end"),i=C._createAt(e.nodeAfter,0),o=e.root.document.graveyard,s=new C(o,[0]),r=e.root.document.version,a=new Oe(i,e.nodeAfter.maxOffset,t,s,r);this.batch.addOperation(a),this.model.applyOperation(a)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof ne))throw new b("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,o=new dt(C._createBefore(e),e.name,t,i);this.batch.addOperation(o),this.model.applyOperation(o)}split(e,t){this._assertWriterUsedCorrectly();let i=e.parent;if(!i.parent)throw new b("writer-split-element-no-parent",this);if(t||(t=i.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new b("writer-split-invalid-limit-element",this);let o,s;do{const r=i.root.document?i.root.document.version:null,a=i.maxOffset-e.offset,l=we.getInsertionPosition(e),c=new we(e,a,l,null,r);this.batch.addOperation(c),this.model.applyOperation(c),!o&&!s&&(o=i,s=e.parent.nextSibling),e=this.createPositionAfter(e.parent),i=e.parent}while(i!==t);return{position:e,range:new y(C._createAt(o,"end"),C._createAt(s,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new b("writer-wrap-range-not-flat",this);const i=t instanceof ne?t:new ne(t);if(i.childCount>0)throw new b("writer-wrap-element-not-empty",this);if(i.parent!==null)throw new b("writer-wrap-element-attached",this);this.insert(i,e.start);const o=new y(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(o,C._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),e.parent===null)throw new b("writer-unwrap-element-no-parent",this);this.move(y._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||typeof t.usingOperation!="boolean")throw new b("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,o=t.range,s=t.affectsData===void 0?!1:t.affectsData;if(this.model.markers.has(e))throw new b("writer-addmarker-marker-exists",this);if(!o)throw new b("writer-addmarker-no-range",this);return i?(Vo(this,e,null,o,s),this.model.markers.get(e)):this.model.markers._set(e,o,i,s)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i=typeof e=="string"?e:e.name,o=this.model.markers.get(i);if(!o)throw new b("writer-updatemarker-marker-not-exists",this);if(!t){J("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),this.model.markers._refresh(o);return}const s=typeof t.usingOperation=="boolean",r=typeof t.affectsData=="boolean",a=r?t.affectsData:o.affectsData;if(!s&&!t.range&&!r)throw new b("writer-updatemarker-wrong-options",this);const l=o.getRange(),c=t.range?t.range:l;if(s&&t.usingOperation!==o.managedUsingOperations){t.usingOperation?Vo(this,i,null,c,a):(Vo(this,i,l,null,a),this.model.markers._set(i,c,void 0,a));return}o.managedUsingOperations?Vo(this,i,l,c,a):this.model.markers._set(i,c,void 0,a)}removeMarker(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?e:e.name;if(!this.model.markers.has(t))throw new b("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations){this.model.markers._remove(t);return}const o=i.getRange();Vo(this,t,o,null,i.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new b("writer-addroot-root-exists",this);const o=this.model.document,s=new ni(e,t,!0,o,o.version);return this.batch.addOperation(s),this.model.applyOperation(s),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new b("writer-detachroot-no-root",this);for(const s of this.model.markers)s.getRange().root===t&&this.removeMarker(s);for(const s of t.getAttributeKeys())this.removeAttribute(s,t);this.remove(this.createRangeIn(t));const i=this.model.document,o=new ni(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(o),this.model.applyOperation(o)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),typeof e=="string")this._setSelectionAttribute(e,t);else for(const[i,o]of ri(e))this._setSelectionAttribute(i,o)}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 i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const o=Kt._getStoreAttributeKey(e);this.setAttribute(o,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=Kt._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new b("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const o=i.getRange();let s=!1;if(e==="move"){const r=t;s=r.containsPosition(o.start)||r.start.isEqual(o.start)||r.containsPosition(o.end)||r.end.isEqual(o.end)}else{const r=t,a=r.nodeBefore,l=r.nodeAfter,c=o.start.parent==a&&o.start.isAtEnd,u=o.end.parent==l&&o.end.offset==0,d=o.end.nodeAfter==l,m=o.start.nodeAfter==l;s=c||u||d||m}s&&this.updateMarker(i.name,{range:o})}}}function Xh(n,e,t,i){const o=n.model,s=o.document;let r=i.start,a,l,c;for(const d of i.getWalker({shallow:!0}))c=d.item.getAttribute(e),a&&l!=c&&(l!=t&&u(),r=a),a=d.nextPosition,l=c;a instanceof C&&a!=r&&l!=t&&u();function u(){const d=new y(r,a),m=d.root.document?s.version:null,f=new Le(d,e,l,t,m);n.batch.addOperation(f),o.applyOperation(f)}}function ed(n,e,t,i){const o=n.model,s=o.document,r=i.getAttribute(e);let a,l;if(r!=t){if(i.root===i){const c=i.document?s.version:null;l=new Ci(i,e,r,t,c)}else{a=new y(C._createBefore(i),n.createPositionAfter(i));const c=a.root.document?s.version:null;l=new Le(a,e,r,t,c)}n.batch.addOperation(l),o.applyOperation(l)}}function Vo(n,e,t,i,o){const s=n.model,r=s.document,a=new ot(e,t,i,s.markers,!!o,r.version);n.batch.addOperation(a),s.applyOperation(a)}function N2(n,e,t,i){let o;if(n.root.document){const s=i.document,r=new C(s.graveyard,[0]);o=new re(n,e,r,s.version)}else o=new M2(n,e);t.addOperation(o),i.applyOperation(o)}function td(n,e){return n===e||n instanceof Rr&&e instanceof Rr}function D2(n,e,t={}){if(e.isCollapsed)return;const i=e.getFirstRange();if(i.root.rootName=="$graveyard")return;const o=n.schema;n.change(s=>{if(!t.doNotResetEntireContent&&K2(o,e)){G2(s,e);return}const r={};if(!t.doNotAutoparagraph){const c=e.getSelectedElement();c&&Object.assign(r,o.getAttributesWithProperty(c,"copyOnReplace",!0))}let a,l;t.doNotFixSelection?(a=Me.fromPosition(i.start,"toPrevious"),l=Me.fromPosition(i.end,"toNext")):[a,l]=z2(i),a.isTouching(l)||s.remove(s.createRange(a,l)),t.leaveUnmerged||($2(s,a,l),o.removeDisallowedAttributes(a.parent.getChildren(),s)),Xp(s,e,a),!t.doNotAutoparagraph&&U2(o,a)&&Yp(s,a,e,r),a.detach(),l.detach()})}function z2(n){const e=n.root.document.model,t=n.start;let i=n.end;if(e.hasContent(n,{ignoreMarkers:!0})){const o=H2(i);if(o&&i.isTouching(e.createPositionAt(o,0))){const s=e.createSelection(n);e.modifySelection(s,{direction:"backward"});const r=s.getLastPosition(),a=e.createRange(r,i);e.hasContent(a,{ignoreMarkers:!0})||(i=r)}}return[Me.fromPosition(t,"toPrevious"),Me.fromPosition(i,"toNext")]}function H2(n){const e=n.parent,t=e.root.document.model.schema,i=e.getAncestors({parentFirst:!0,includeSelf:!0});for(const o of i){if(t.isLimit(o))return null;if(t.isBlock(o))return o}}function $2(n,e,t){const i=n.model;if(!eu(n.model.schema,e,t))return;const[o,s]=j2(e,t);!o||!s||(!i.hasContent(o,{ignoreMarkers:!0})&&i.hasContent(s,{ignoreMarkers:!0})?Qp(n,e,t,o.parent):Jp(n,e,t,o.parent))}function Jp(n,e,t,i){const o=e.parent,s=t.parent;if(!(o==i||s==i)){for(e=n.createPositionAfter(o),t=n.createPositionBefore(s),t.isEqual(e)||n.insert(s,e),n.merge(e);t.parent.isEmpty;){const r=t.parent;t=n.createPositionBefore(r),n.remove(r)}eu(n.model.schema,e,t)&&Jp(n,e,t,i)}}function Qp(n,e,t,i){const o=e.parent,s=t.parent;if(!(o==i||s==i)){for(e=n.createPositionAfter(o),t=n.createPositionBefore(s),t.isEqual(e)||n.insert(o,t);e.parent.isEmpty;){const r=e.parent;e=n.createPositionBefore(r),n.remove(r)}t=n.createPositionBefore(s),W2(n,t),eu(n.model.schema,e,t)&&Qp(n,e,t,i)}}function W2(n,e){const t=e.nodeBefore,i=e.nodeAfter;t.name!=i.name&&n.rename(t,i.name),n.clearAttributes(t),n.setAttributes(Object.fromEntries(i.getAttributes()),t),n.merge(e)}function eu(n,e,t){const i=e.parent,o=t.parent;return i==o||n.isLimit(i)||n.isLimit(o)?!1:q2(e,t,n)}function j2(n,e){const t=n.getAncestors(),i=e.getAncestors();let o=0;for(;t[o]&&t[o]==i[o];)o++;return[t[o],i[o]]}function U2(n,e){const t=n.checkChild(e,"$text"),i=n.checkChild(e,"paragraph");return!t&&i}function q2(n,e,t){const i=new y(n,e);for(const o of i.getWalker())if(t.isLimit(o.item))return!1;return!0}function Yp(n,e,t,i={}){const o=n.createElement("paragraph");n.model.schema.setAllowedAttributes(o,i,n),n.insert(o,e),Xp(n,t,n.createPositionAt(o,0))}function G2(n,e){const t=n.model.schema.getLimitElement(e);n.remove(n.createRangeIn(t)),Yp(n,n.createPositionAt(t,0),e)}function K2(n,e){const t=n.getLimitElement(e);if(!e.containsEntireContent(t))return!1;const i=e.getFirstRange();return i.start.parent==i.end.parent?!1:n.checkChild(t,"paragraph")}function Xp(n,e,t){e instanceof Kt?n.setSelection(t):e.setTo(t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Z2(n,e){return n.change(t=>{const i=t.createDocumentFragment(),o=e.getFirstRange();if(!o||o.isCollapsed)return i;const s=o.start.root,r=o.start.getCommonPath(o.end),a=s.getNodeByPath(r);let l;o.start.parent==o.end.parent?l=o:l=t.createRange(t.createPositionAt(a,o.start.path[r.length]),t.createPositionAt(a,o.end.path[r.length]+1));const c=l.end.offset-l.start.offset;for(const u of l.getItems({shallow:!0}))u.is("$textProxy")?t.appendText(u.data,u.getAttributes(),i):t.append(t.cloneElement(u,!0),i);if(l!=o){const u=o._getTransformedByMove(l.start,t.createPositionAt(i,0),c)[0],d=t.createRange(t.createPositionAt(i,0),u.start),m=t.createRange(u.end,t.createPositionAt(i,"end"));id(m,t),id(d,t)}return i})}function id(n,e){const t=[];Array.from(n.getItems({direction:"backward"})).map(i=>e.createRangeOn(i)).filter(i=>(i.start.isAfter(n.start)||i.start.isEqual(n.start))&&(i.end.isBefore(n.end)||i.end.isEqual(n.end))).forEach(i=>{t.push(i.start.parent),e.remove(i)}),t.forEach(i=>{let o=i;for(;o.parent&&o.isEmpty;){const s=e.createRangeOn(o);o=o.parent,e.remove(s)}})}function J2(n,e,t){return n.change(i=>{const o=t||n.document.selection;o.isCollapsed||n.deleteContent(o,{doNotAutoparagraph:!0});const s=new Q2(n,i,o.anchor),r=[];let a;if(e.is("documentFragment")){if(e.markers.size){const u=[];for(const[d,m]of e.markers){const{start:f,end:g}=m,p=f.isEqual(g);u.push({position:f,name:d,isCollapsed:p},{position:g,name:d,isCollapsed:p})}u.sort(({position:d},{position:m})=>d.isBefore(m)?1:-1);for(const{position:d,name:m,isCollapsed:f}of u){let g=null,p=null;const _=d.parent===e&&d.isAtStart,v=d.parent===e&&d.isAtEnd;!_&&!v?(g=i.createElement("$marker"),i.insert(g,d)):f&&(p=_?"start":"end"),r.push({name:m,element:g,collapsed:p})}}a=e.getChildren()}else a=[e];s.handleNodes(a);let l=s.getSelectionRange();if(e.is("documentFragment")&&r.length){const u=l?ht.fromRange(l):null,d={};for(let m=r.length-1;m>=0;m--){const{name:f,element:g,collapsed:p}=r[m],_=!d[f];if(_&&(d[f]=[]),g){const v=i.createPositionAt(g,"before");d[f].push(v),i.remove(g)}else{const v=s.getAffectedRange();if(!v){p&&d[f].push(s.position);continue}p?d[f].push(v[p]):d[f].push(_?v.start:v.end)}}for(const[m,[f,g]]of Object.entries(d))f&&g&&f.root===g.root&&f.root.document&&!i.model.markers.has(m)&&i.addMarker(m,{usingOperation:!0,affectsData:!0,range:new y(f,g)});u&&(l=u.toRange(),u.detach())}/* istanbul ignore else -- @preserve */l&&(o instanceof Kt?i.setSelection(l):o.setTo(l));const c=s.getAffectedRange()||n.createRange(o.anchor);return s.destroy(),c})}class Q2{constructor(e,t,i){h(this,"model"),h(this,"writer"),h(this,"position"),h(this,"canMergeWith"),h(this,"schema"),h(this,"_documentFragment"),h(this,"_documentFragmentPosition"),h(this,"_firstNode",null),h(this,"_lastNode",null),h(this,"_lastAutoParagraph",null),h(this,"_filterAttributesOf",[]),h(this,"_affectedStart",null),h(this,"_affectedEnd",null),h(this,"_nodeToSelect",null),this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){this._lastNode=e;/* istanbul ignore if -- @preserve */if(this.position.parent!=e||!this.position.isAtEnd)throw new b("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?y._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new y(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(!this._checkAndSplitToAllowedPosition(e)){this.schema.isObject(e)||this._handleDisallowedNode(e);return}this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=Me.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleDisallowedNode(e){e.is("element")&&this.handleNodes(e.getChildren())}_appendToFragment(e){/* istanbul ignore if -- @preserve */if(!this.schema.checkChild(this.position,e))throw new b("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=Me.fromPosition(e,"toPrevious")),(!this._affectedEnd||this._affectedEnd.isBefore(e))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=Me.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof ne)||!this._canMergeLeft(e))return;const t=Me._createBefore(e);t.stickiness="toNext";const i=Me.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=Me._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=Me._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof ne)||!this._canMergeRight(e))return;const t=Me._createAfter(e);t.stickiness="toNext";/* istanbul ignore if -- @preserve */if(!this.position.isEqual(t))throw new b("insertcontent-invalid-insertion-position",this);this.position=C._createAt(t.nodeBefore,"end");const i=Me.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=Me._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=Me._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof ne&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof ne&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_insertAutoParagraph(){this._insertPartialFragment();const e=this.writer.createElement("paragraph");this.writer.insert(e,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=e,this.position=this.writer.createPositionAt(e,0)}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const i=this.position.parent;this.position=this.writer.createPositionBefore(i),i.isEmpty&&i.parent===t&&this.writer.remove(i)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const i=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=i,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){return this.schema.checkChild(e,t)||this.schema.checkChild(e,"paragraph")&&this.schema.checkChild("paragraph",t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function Y2(n,e,t,i={}){if(!n.schema.isObject(e))throw new b("insertobject-element-not-an-object",n,{object:e});const o=t||n.document.selection;let s=o;i.findOptimalPosition&&n.schema.isBlock(e)&&(s=n.createSelection(n.schema.findOptimalInsertionRange(o,i.findOptimalPosition)));const r=ae(o.getSelectedBlocks()),a={};return r&&Object.assign(a,n.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),n.change(l=>{s.isCollapsed||n.deleteContent(s,{doNotAutoparagraph:!0});let c=e;const u=s.anchor.parent;!n.schema.checkChild(u,e)&&n.schema.checkChild(u,"paragraph")&&n.schema.checkChild("paragraph",e)&&(c=l.createElement("paragraph"),l.insert(e,c)),n.schema.setAllowedAttributes(c,a,l);const d=n.insertContent(c,s);return d.isCollapsed||i.setSelection&&X2(l,e,i.setSelection,a),d})}function X2(n,e,t,i){const o=n.model;if(t=="on"){n.setSelection(e,"on");return}if(t!="after")throw new b("insertobject-invalid-place-parameter-value",o);let s=e.nextSibling;if(o.schema.isInline(e)){n.setSelection(e,"after");return}!(s&&o.schema.checkChild(s,"$text"))&&o.schema.checkChild(e.parent,"paragraph")&&(s=n.createElement("paragraph"),o.schema.setAllowedAttributes(s,i,n),o.insertContent(s,n.createPositionAfter(e))),s&&n.setSelection(s,0)}const e5=' ,.?!:;"-()';function t5(n,e,t={}){const i=n.schema,o=t.direction!="backward",s=t.unit?t.unit:"character",r=!!t.treatEmojiAsSingleUnit,a=e.focus,l=new yi({boundaries:s5(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),c={walker:l,schema:i,isForward:o,unit:s,treatEmojiAsSingleUnit:r};let u;for(;u=l.next();){if(u.done)return;const d=i5(c,u.value);if(d){e instanceof Kt?n.change(m=>{m.setSelectionFocus(d)}):e.setFocus(d);return}}}function i5(n,e){const{isForward:t,walker:i,unit:o,schema:s,treatEmojiAsSingleUnit:r}=n,{type:a,item:l,nextPosition:c}=e;if(a=="text")return n.unit==="word"?o5(i,t):n5(i,o,r);if(a==(t?"elementStart":"elementEnd")){if(s.isSelectable(l))return C._createAt(l,t?"after":"before");if(s.checkChild(c,"$text"))return c}else{if(s.isLimit(l)){i.skip(()=>!0);return}if(s.checkChild(c,"$text"))return c}}function n5(n,e,t){const i=n.position.textNode;if(i){const o=i.data;let s=n.position.offset-i.startOffset;for(;jc(o,s)||e=="character"&&Uc(o,s)||t&&cp(o,s);)n.next(),s=n.position.offset-i.startOffset}return n.position}function o5(n,e){let t=n.position.textNode;for(t||(t=e?n.position.nodeAfter:n.position.nodeBefore);t&&t.is("$text");){const i=n.position.offset-t.startOffset;if(a5(t,i,e))t=e?n.position.nodeAfter:n.position.nodeBefore;else{if(r5(t.data,i,e))break;n.next()}}return n.position}function s5(n,e){const t=n.root,i=C._createAt(t,e?"end":0);return e?new y(n,i):new y(i,n)}function r5(n,e,t){const i=e+(t?0:-1);return e5.includes(n.charAt(i))}function a5(n,e,t){return e===(t?n.offsetSize:0)}let l5=class extends ue(){constructor(){super(),h(this,"markers"),h(this,"document"),h(this,"schema"),h(this,"_pendingChanges"),h(this,"_currentWriter"),this.markers=new B2,this.document=new O2(this),this.schema=new Jk,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(n=>this.decorate(n)),this.on("applyOperation",(n,e)=>{e[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(()=>!0,"$marker"),$k(this),this.document.registerPostFixer(Fp),this.on("insertContent",(n,[e,t])=>{n.return=J2(this,e,t)}),this.on("insertObject",(n,[e,t,i])=>{n.return=Y2(this,e,t,i)}),this.on("canEditAt",n=>{const e=!this.document.isReadOnly;n.return=e,e||n.stop()})}change(n){try{return this._pendingChanges.length===0?(this._pendingChanges.push({batch:new Nn,callback:n}),this._runPendingChanges()[0]):n(this._currentWriter)}catch(e){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(e,this)}}enqueueChange(n,e){try{n?typeof n=="function"?(e=n,n=new Nn):n instanceof Nn||(n=new Nn(n)):n=new Nn,this._pendingChanges.push({batch:n,callback:e}),this._pendingChanges.length==1&&this._runPendingChanges()}catch(t){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(t,this)}}applyOperation(n){n._execute()}insertContent(n,e,t,...i){const o=Ha(e,t);return this.fire("insertContent",[n,o,t,...i])}insertObject(n,e,t,i,...o){const s=Ha(e,t);return this.fire("insertObject",[n,s,i,i,...o])}deleteContent(n,e){D2(this,n,e)}modifySelection(n,e){t5(this,n,e)}getSelectedContent(n){return Z2(this,n)}hasContent(n,e={}){const t=n instanceof y?n:y._createIn(n);if(t.isCollapsed)return!1;const{ignoreWhitespaces:i=!1,ignoreMarkers:o=!1}=e;if(!o){for(const s of this.markers.getMarkersIntersectingRange(t))if(s.affectsData)return!0}for(const s of t.getItems())if(this.schema.isContent(s))if(s.is("$textProxy"))if(i){if(s.data.search(/\S/)!==-1)return!0}else return!0;else return!0;return!1}canEditAt(n){const e=Ha(n);return this.fire("canEditAt",[e])}createPositionFromPath(n,e,t){return new C(n,e,t)}createPositionAt(n,e){return C._createAt(n,e)}createPositionAfter(n){return C._createAfter(n)}createPositionBefore(n){return C._createBefore(n)}createRange(n,e){return new y(n,e)}createRangeIn(n){return y._createIn(n)}createRangeOn(n){return y._createOn(n)}createSelection(...n){return new yt(...n)}createBatch(n){return new Nn(n)}createOperationFromJSON(n){return y2.fromJSON(n,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const n=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const e=this._pendingChanges[0].batch;this._currentWriter=new F2(this,e);const t=this._pendingChanges[0].callback(this._currentWriter);n.push(t),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return n}};function Ha(n,e){if(n)return n instanceof yt||n instanceof Kt?n:n instanceof Tn?e||e===0?new yt(n,e):n.is("rootElement")?new yt(n,"in"):new yt(n,"on"):new yt(n)}class ew extends ui{constructor(){super(...arguments),h(this,"domEventType","click")}onDomEvent(e){this.fire(e.type,e)}}class ua extends ui{constructor(){super(...arguments),h(this,"domEventType",["mousedown","mouseup","mouseover","mouseout"])}onDomEvent(e){this.fire(e.type,e)}}class c5 extends ui{constructor(){super(...arguments),h(this,"domEventType",["touchstart","touchend","touchmove"])}onDomEvent(e){this.fire(e.type,e)}}class Ht{constructor(e){h(this,"document"),this.document=e}createDocumentFragment(e){return new vn(this.document,e)}createElement(e,t,i){return new ai(this.document,e,t,i)}createText(e){return new Ge(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const i=e.parent;if(i){const o=i.getChildIndex(e);return this.removeChildren(o,1,i),this.insertChild(o,t,i),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){const i=new ai(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){Ut(e)&&i===void 0?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return V._createAt(e,t)}createPositionAfter(e){return V._createAfter(e)}createPositionBefore(e){return V._createBefore(e)}createRange(e,t){return new Q(e,t)}createRangeOn(e){return Q._createOn(e)}createRangeIn(e){return Q._createIn(e)}createSelection(...e){return new ki(...e)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const u5=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,h5=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,d5=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,m5=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,f5=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,g5=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,p5=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","activeborder","activecaption","appworkspace","background","buttonface","buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext","inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext","scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window","windowframe","windowtext","rebeccapurple","currentcolor","transparent"]);function tw(n){return n.startsWith("#")?u5.test(n):n.startsWith("rgb")?h5.test(n)||d5.test(n):n.startsWith("hsl")?m5.test(n)||f5.test(n):p5.has(n.toLowerCase())}const w5=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function b5(n){return w5.includes(n)}const _5=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function ha(n){return _5.test(n)}const v5=/^[+-]?[0-9]*([.][0-9]+)?%$/;function iw(n){return v5.test(n)}const y5=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function k5(n){return y5.includes(n)}const C5=["center","top","bottom","left","right"];function A5(n){return C5.includes(n)}const x5=["fixed","scroll","local"];function T5(n){return x5.includes(n)}const E5=/^url\(/;function S5(n){return E5.test(n)}function es(n=""){if(n==="")return{top:void 0,right:void 0,bottom:void 0,left:void 0};const e=tu(n),t=e[0],i=e[2]||t,o=e[1]||t,s=e[3]||o;return{top:t,bottom:i,right:o,left:s}}function ts(n){return e=>{const{top:t,right:i,bottom:o,left:s}=e,r=[];return[t,i,s,o].every(a=>!!a)?r.push([n,P5(e)]):(t&&r.push([n+"-top",t]),i&&r.push([n+"-right",i]),o&&r.push([n+"-bottom",o]),s&&r.push([n+"-left",s])),r}}function P5({top:n,right:e,bottom:t,left:i}){const o=[];return i!==e?o.push(n,e,t,i):t!==n?o.push(n,e,t):e!==n?o.push(n,e):o.push(n),o.join(" ")}function nw(n){return e=>({path:n,value:es(e)})}function tu(n){const e=n.trim().slice(0,1500).matchAll(g5);return Array.from(e).map(t=>t[0])}function iu(n){n.setNormalizer("background",I5()),n.setNormalizer("background-color",V5()),n.setReducer("background",R5()),n.setStyleRelation("background",["background-color"])}function I5(){return n=>{const e={},t=tu(n);for(const i of t)k5(i)?(e.repeat=e.repeat||[],e.repeat.push(i)):A5(i)?(e.position=e.position||[],e.position.push(i)):T5(i)?e.attachment=i:tw(i)?e.color=i:S5(i)&&(e.image=i);return{path:"background",value:e}}}function V5(){return n=>({path:"background.color",value:n})}function R5(){return n=>{const e=[];return e.push(["background-color",n.color]),e}}function ow(n){n.setNormalizer("border",O5()),n.setNormalizer("border-top",$s("top")),n.setNormalizer("border-right",$s("right")),n.setNormalizer("border-bottom",$s("bottom")),n.setNormalizer("border-left",$s("left")),n.setNormalizer("border-color",$a("color")),n.setNormalizer("border-width",$a("width")),n.setNormalizer("border-style",$a("style")),n.setNormalizer("border-top-color",Bt("color","top")),n.setNormalizer("border-top-style",Bt("style","top")),n.setNormalizer("border-top-width",Bt("width","top")),n.setNormalizer("border-right-color",Bt("color","right")),n.setNormalizer("border-right-style",Bt("style","right")),n.setNormalizer("border-right-width",Bt("width","right")),n.setNormalizer("border-bottom-color",Bt("color","bottom")),n.setNormalizer("border-bottom-style",Bt("style","bottom")),n.setNormalizer("border-bottom-width",Bt("width","bottom")),n.setNormalizer("border-left-color",Bt("color","left")),n.setNormalizer("border-left-style",Bt("style","left")),n.setNormalizer("border-left-width",Bt("width","left")),n.setExtractor("border-top",Ws("top")),n.setExtractor("border-right",Ws("right")),n.setExtractor("border-bottom",Ws("bottom")),n.setExtractor("border-left",Ws("left")),n.setExtractor("border-top-color","border.color.top"),n.setExtractor("border-right-color","border.color.right"),n.setExtractor("border-bottom-color","border.color.bottom"),n.setExtractor("border-left-color","border.color.left"),n.setExtractor("border-top-width","border.width.top"),n.setExtractor("border-right-width","border.width.right"),n.setExtractor("border-bottom-width","border.width.bottom"),n.setExtractor("border-left-width","border.width.left"),n.setExtractor("border-top-style","border.style.top"),n.setExtractor("border-right-style","border.style.right"),n.setExtractor("border-bottom-style","border.style.bottom"),n.setExtractor("border-left-style","border.style.left"),n.setReducer("border-color",ts("border-color")),n.setReducer("border-style",ts("border-style")),n.setReducer("border-width",ts("border-width")),n.setReducer("border-top",js("top")),n.setReducer("border-right",js("right")),n.setReducer("border-bottom",js("bottom")),n.setReducer("border-left",js("left")),n.setReducer("border",M5()),n.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),n.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),n.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),n.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),n.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),n.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),n.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),n.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function O5(){return n=>{const{color:e,style:t,width:i}=sw(n);return{path:"border",value:{color:es(e),style:es(t),width:es(i)}}}}function $s(n){return e=>{const{color:t,style:i,width:o}=sw(e),s={};return t!==void 0&&(s.color={[n]:t}),i!==void 0&&(s.style={[n]:i}),o!==void 0&&(s.width={[n]:o}),{path:"border",value:s}}}function $a(n){return e=>({path:"border",value:B5(e,n)})}function B5(n,e){return{[e]:es(n)}}function Bt(n,e){return t=>({path:"border",value:{[n]:{[e]:t}}})}function Ws(n){return(e,t)=>{if(t.border)return Uo(t.border,n)}}function Uo(n,e){const t={};return n.width&&n.width[e]&&(t.width=n.width[e]),n.style&&n.style[e]&&(t.style=n.style[e]),n.color&&n.color[e]&&(t.color=n.color[e]),t}function sw(n){const e={},t=tu(n);for(const i of t)ha(i)||/thin|medium|thick/.test(i)?e.width=i:b5(i)?e.style=i:e.color=i;return e}function M5(){return e=>{const t=Uo(e,"top"),i=Uo(e,"right"),o=Uo(e,"bottom"),s=Uo(e,"left"),r=[t,i,o,s],a={width:n(r,"width"),style:n(r,"style"),color:n(r,"color")},l=Zn(a,"all");return l.length?l:[...Object.entries(a).reduce((c,[u,d])=>(d&&(c.push([`border-${u}`,d]),r.forEach(m=>delete m[u])),c),[]),...Zn(t,"top"),...Zn(i,"right"),...Zn(o,"bottom"),...Zn(s,"left")]};function n(e,t){return e.map(i=>i[t]).reduce((i,o)=>i==o?i:null)}}function js(n){return e=>Zn(e,n)}function Zn(n,e){const t=[];if(n&&n.width&&t.push("width"),n&&n.style&&t.push("style"),n&&n.color&&t.push("color"),t.length==3){const i=t.map(o=>n[o]).join(" ");return[e=="all"?["border",i]:[`border-${e}`,i]]}return e=="all"?[]:t.map(i=>[`border-${e}-${i}`,n[i]])}function L5(n){n.setNormalizer("margin",nw("margin")),n.setNormalizer("margin-top",e=>({path:"margin.top",value:e})),n.setNormalizer("margin-right",e=>({path:"margin.right",value:e})),n.setNormalizer("margin-bottom",e=>({path:"margin.bottom",value:e})),n.setNormalizer("margin-left",e=>({path:"margin.left",value:e})),n.setReducer("margin",ts("margin")),n.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function F5(n){n.setNormalizer("padding",nw("padding")),n.setNormalizer("padding-top",e=>({path:"padding.top",value:e})),n.setNormalizer("padding-right",e=>({path:"padding.right",value:e})),n.setNormalizer("padding-bottom",e=>({path:"padding.bottom",value:e})),n.setNormalizer("padding-left",e=>({path:"padding.left",value:e})),n.setReducer("padding",ts("padding")),n.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class rw{constructor(e){if(h(this,"crashes",[]),h(this,"state","initializing"),h(this,"_crashNumberLimit"),h(this,"_now",Date.now),h(this,"_minimumNonErrorTimePeriod"),h(this,"_boundErrorHandler"),h(this,"_listeners"),this.crashes=[],this._crashNumberLimit=typeof e.crashNumberLimit=="number"?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod=typeof e.minimumNonErrorTimePeriod=="number"?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=t=>{const i="error"in t?t.error:t.reason;i instanceof Error&&this._handleError(i,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(i=>i!==t)}_fire(e,...t){const i=this._listeners[e]||[];for(const o of i)o.apply(this,[null,...t])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const i=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:i}),i?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&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-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Zl(n,e=new Set){const t=[n],i=new Set;let o=0;for(;t.length>o;){const s=t[o++];if(!(i.has(s)||!N5(s)||e.has(s)))if(i.add(s),Symbol.iterator in s)try{for(const r of s)t.push(r)}catch{}else for(const r in s)r!=="defaultValue"&&t.push(s[r])}return i}function N5(n){const e=Object.prototype.toString.call(n),t=typeof n;return!(t==="number"||t==="boolean"||t==="string"||t==="symbol"||t==="function"||e==="[object Date]"||e==="[object RegExp]"||e==="[object Module]"||n===void 0||n===null||n._watchdogExcluded||n instanceof EventTarget||n instanceof Event)}function aw(n,e,t=new Set){if(n===e&&D5(n))return!0;const i=Zl(n,t),o=Zl(e,t);for(const s of i)if(o.has(s))return!0;return!1}function D5(n){return typeof n=="object"&&n!==null}class lw extends rw{constructor(e,t={}){super(t),h(this,"_editor",null),h(this,"_lifecyclePromise",null),h(this,"_throttledSave"),h(this,"_data"),h(this,"_lastDocumentVersion"),h(this,"_elementOrData"),h(this,"_initUsingData",!0),h(this,"_editables",{}),h(this,"_config"),h(this,"_excludedProps"),this._throttledSave=co(this._save.bind(this),typeof t.saveInterval=="number"?t.saveInterval:5e3),e&&(this._creator=(i,o)=>e.create(i,o)),this._destructor=i=>i.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then(()=>(this.state="initializing",this._fire("stateChange"),this._destroy())).catch(e=>{console.error("An error happened during the editor destroying.",e)}).then(()=>{const e={},t=[],i=this._config.rootsAttributes||{},o={};for(const[r,a]of Object.entries(this._data.roots))a.isLoaded?(e[r]="",o[r]=i[r]||{}):t.push(r);const s={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:o,_watchdogInitialData:this._data};return delete s.initialData,s.extraPlugins.push(z5),this._initUsingData?this.create(e,s,s.context):xi(this._elementOrData)?this.create(this._elementOrData,s,s.context):this.create(this._editables,s,s.context)}).then(()=>{this._fire("restart")})}create(e=this._elementOrData,t=this._config,i){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>(super._startErrorHandling(),this._elementOrData=e,this._initUsingData=typeof e=="string"||Object.keys(e).length>0&&typeof Object.values(e)[0]=="string",this._config=this._cloneEditorConfiguration(t)||{},this._config.context=i,this._creator(e,this._config))).then(o=>{this._editor=o,o.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=o.model.document.version,this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this.state="ready",this._fire("stateChange")}).finally(()=>{this._lifecyclePromise=null}),this._lifecyclePromise}destroy(){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())).finally(()=>{this._lifecyclePromise=null}),this._lifecyclePromise}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling(),this._throttledSave.cancel();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)})}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(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=this._editor,t=e.model.document.roots.filter(a=>a.isAttached()&&a.rootName!="$graveyard"),{plugins:i}=e,o=i.has("CommentsRepository")&&i.get("CommentsRepository"),s=i.has("TrackChanges")&&i.get("TrackChanges"),r={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach(a=>{r.roots[a.rootName]={content:JSON.stringify(Array.from(a.getChildren())),attributes:JSON.stringify(Array.from(a.getAttributes())),isLoaded:a._isLoaded}});for(const a of e.model.markers)a._affectsData&&(r.markers[a.name]={rangeJSON:a.getRange().toJSON(),usingOperation:a._managedUsingOperations,affectsData:a._affectsData});return o&&(r.commentThreads=JSON.stringify(o.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),s&&(r.suggestions=JSON.stringify(s.getSuggestions({toJSON:!0,skipNotAttached:!0}))),r}_getEditables(){const e={};for(const t of this.editor.model.document.getRootNames()){const i=this.editor.ui.getEditableElement(t);i&&(e[t]=i)}return e}_isErrorComingFromThisItem(e){return aw(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return Xr(e,(t,i)=>{if(xi(t)||i==="context")return t})}}class z5{constructor(e){h(this,"editor"),h(this,"_data"),this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},t=>{this._restoreCollaborationData(),this._restoreEditorData(t)}),this.editor.data.fire("ready")},{priority:999})}_createNode(e,t){if("name"in t){const i=e.createElement(t.name,t.attributes);if(t.children)for(const o of t.children)i._appendChild(this._createNode(e,o));return i}else return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach(([i,{content:o,attributes:s}])=>{const r=JSON.parse(o),a=JSON.parse(s),l=t.model.document.getRoot(i);for(const[c,u]of a)e.setAttribute(c,u,l);for(const c of r){const u=this._createNode(e,c);e.insert(u,l,"end")}}),Object.entries(this._data.markers).forEach(([i,o])=>{const{document:s}=t.model,{rangeJSON:{start:r,end:a},...l}=o,c=s.getRoot(r.root),u=e.createPositionFromPath(c,r.path,r.stickiness),d=e.createPositionFromPath(c,a.path,a.stickiness),m=e.createRange(u,d);e.addMarker(i,{range:m,...l})})}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach(i=>{const o=this.editor.config.get("collaboration.channelId"),s=this.editor.plugins.get("CommentsRepository");s.hasCommentThread(i.threadId)&&s.getCommentThread(i.threadId).remove(),s.addCommentThread({channelId:o,...i})}),t.forEach(i=>{const o=this.editor.plugins.get("TrackChangesEditing");if(o.hasSuggestion(i.id)){const s=o.getSuggestion(i.id);s.attributes=i.attributes}else o.addSuggestionData(i)})}}const is=Symbol("MainQueueId");class H5 extends rw{constructor(e,t={}){super(t),h(this,"_watchdogs",new Map),h(this,"_watchdogConfig"),h(this,"_context",null),h(this,"_contextProps",new Set),h(this,"_actionQueues",new $5),h(this,"_contextConfig"),h(this,"_item"),this._watchdogConfig=t,this._creator=i=>e.create(i),this._destructor=i=>i.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(is,()=>(this._contextConfig=e,this._create()))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=nd(e);return Promise.all(t.map(i=>this._actionQueues.enqueue(i.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 o;if(this._watchdogs.has(i.id))throw new Error(`Item with the given id is already added: '${i.id}'.`);if(i.type==="editor")return o=new lw(null,this._watchdogConfig),o.setCreator(i.creator),o._setExcludedProperties(this._contextProps),i.destructor&&o.setDestructor(i.destructor),this._watchdogs.set(i.id,o),o.on("error",(s,{error:r,causesRestart:a})=>{this._fire("itemError",{itemId:i.id,error:r}),a&&this._actionQueues.enqueue(i.id,()=>new Promise(l=>{const c=()=>{o.off("restart",c),this._fire("itemRestart",{itemId:i.id}),l()};o.on("restart",c)}))}),o.create(i.sourceElementOrData,i.config,this._context);throw new Error(`Not supported item type: '${i.type}'.`)})))}remove(e){const t=nd(e);return Promise.all(t.map(i=>this._actionQueues.enqueue(i,()=>{const o=this._getWatchdog(i);return this._watchdogs.delete(i),o.destroy()})))}destroy(){return this._actionQueues.enqueue(is,()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))}_restart(){return this._actionQueues.enqueue(is,()=>(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=Zl(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 aw(this._context,e.context)}}class $5{constructor(){h(this,"_onEmptyCallbacks",[]),h(this,"_queues",new Map),h(this,"_activeActions",0)}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===is;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const o=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(is),this._queues.get(e)])).then(t),s=o.catch(()=>{});return this._queues.set(e,s),o.finally(()=>{this._activeActions--,this._queues.get(e)===s&&this._activeActions===0&&this._onEmptyCallbacks.forEach(r=>r())})}}function nd(n){return Array.isArray(n)?n:[n]}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class w extends ue(){constructor(e){super(),h(this,"editor"),h(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",od,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",od),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}function od(n){n.return=!1,n.stop()}class O extends ue(){constructor(e){super(),h(this,"editor"),h(this,"_isEnabledBasedOnSelection"),h(this,"_affectsData"),h(this,"_disableStack"),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.listenTo(e,"change:isReadOnly",()=>{this.refresh()}),this.on("set:isEnabled",t=>{if(!this.affectsData)return;const i=e.model.document.selection,o=i.getFirstPosition().root.rootName!="$graveyard"&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!o)&&(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",sd,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",sd),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function sd(n){n.return=!1,n.stop()}class rd extends O{constructor(){super(...arguments),h(this,"_childCommandsDefinitions",[])}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){Fg(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}}class cw extends ge(){constructor(e,t=[],i=[]){super(),h(this,"_context"),h(this,"_plugins",new Map),h(this,"_availablePlugins"),h(this,"_contextPlugins"),this._context=e,this._availablePlugins=new Map;for(const o of t)o.pluginName&&this._availablePlugins.set(o.pluginName,o);this._contextPlugins=new Map;for(const[o,s]of i)this._contextPlugins.set(o,s),this._contextPlugins.set(s,o),o.pluginName&&this._availablePlugins.set(o.pluginName,o)}*[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 i=e;throw typeof e=="function"&&(i=e.pluginName||e.name),new b("plugincollection-plugin-not-loaded",this._context,{plugin:i})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const o=this,s=this._context;f(e),p(e);const r=e.filter(T=>!d(T,t)),a=[...g(r)];X(a,i);const l=M(a);return G(l,"init").then(()=>G(l,"afterInit")).then(()=>l);function c(T){return typeof T=="function"}function u(T){return c(T)&&!!T.isContextPlugin}function d(T,F){return F.some(x=>x===T||m(T)===x||m(x)===T)}function m(T){return c(T)?T.pluginName||T.name:T}function f(T,F=new Set){T.forEach(x=>{c(x)&&(F.has(x)||(F.add(x),x.pluginName&&!o._availablePlugins.has(x.pluginName)&&o._availablePlugins.set(x.pluginName,x),x.requires&&f(x.requires,F)))})}function g(T,F=new Set){return T.map(x=>c(x)?x:o._availablePlugins.get(x)).reduce((x,q)=>F.has(q)?x:(F.add(q),q.requires&&(p(q.requires,q),g(q.requires,F).forEach(Ve=>x.add(Ve))),x.add(q)),new Set)}function p(T,F=null){T.map(x=>c(x)?x:o._availablePlugins.get(x)||x).forEach(x=>{_(x,F),v(x,F),E(x,F)})}function _(T,F){if(!c(T))throw F?new b("plugincollection-soft-required",s,{missingPlugin:T,requiredBy:m(F)}):new b("plugincollection-plugin-not-found",s,{plugin:T})}function v(T,F){if(u(F)&&!u(T))throw new b("plugincollection-context-required",s,{plugin:m(T),requiredBy:m(F)})}function E(T,F){if(F&&d(T,t))throw new b("plugincollection-required",s,{plugin:m(T),requiredBy:m(F)})}function M(T){return T.map(F=>{let x=o._contextPlugins.get(F);return x=x||new F(s),o._add(F,x),x})}function G(T,F){return T.reduce((x,q)=>!q[F]||o._contextPlugins.has(q)?x:x.then(q[F].bind(q)),Promise.resolve())}function X(T,F){for(const x of F){if(typeof x!="function")throw new b("plugincollection-replace-plugin-invalid-type",null,{pluginItem:x});const q=x.pluginName;if(!q)throw new b("plugincollection-replace-plugin-missing-name",null,{pluginItem:x});if(x.requires&&x.requires.length)throw new b("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:q});const Ve=o._availablePlugins.get(q);if(!Ve)throw new b("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:q});const pe=T.indexOf(Ve);if(pe===-1){if(o._contextPlugins.has(Ve))return;throw new b("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:q})}if(Ve.requires&&Ve.requires.length)throw new b("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:q});T.splice(pe,1,x),o._availablePlugins.set(q,x)}}}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 i=e.pluginName;if(i){if(this._plugins.has(i))throw new b("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class Or{constructor(e){h(this,"config"),h(this,"plugins"),h(this,"locale"),h(this,"t"),h(this,"editors"),h(this,"_contextOwner",null);const{translations:t,...i}=e||{};this.config=new qg(i,this.constructor.defaultConfig);const o=this.constructor.builtinPlugins;this.config.define("plugins",o),this.plugins=new cw(this,o);const s=this.config.get("language")||{};this.locale=new lp({uiLanguage:typeof s=="string"?s:s.ui,contentLanguage:this.config.get("language.content"),translations:t}),this.t=this.locale.t,this.editors=new _e}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if(typeof i!="function")throw new b("context-initplugins-constructor-only",null,{Plugin:i});if(i.isContextPlugin!==!0)throw new b("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,e=>e.destroy())).then(()=>this.plugins.destroy())}_addEditor(e,t){if(this._contextOwner)throw new b("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise(t=>{const i=new this(e);t(i.initPlugins().then(()=>i))})}}h(Or,"defaultConfig"),h(Or,"builtinPlugins");class uw extends ue(){constructor(e){super(),h(this,"context"),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}class W5{constructor(){h(this,"_commands"),this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new b("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class j5 extends te{constructor(e){super(),h(this,"editor"),this.editor=e}set(e,t,i={}){if(typeof t=="string"){const o=t;t=(s,r)=>{this.editor.execute(o),r()}}super.set(e,t,i)}}const Wa="contentEditing",ad="common";class U5{constructor(e){h(this,"keystrokeInfos",new Map),h(this,"_editor"),this._editor=e;const t=e.config.get("menuBar.isVisible"),i=e.locale.t;this.addKeystrokeInfoCategory({id:Wa,label:i("Content editing keystrokes"),description:i("These keyboard shortcuts allow for quick access to content editing features.")});const o=[{label:i("Close contextual balloons, dropdowns, and dialogs"),keystroke:"Esc"},{label:i("Open the accessibility help dialog"),keystroke:"Alt+0"},{label:i("Move focus between form fields (inputs, buttons, etc.)"),keystroke:[["Tab"],["Shift+Tab"]]},{label:i("Move focus to the toolbar, navigate between toolbars"),keystroke:"Alt+F10",mayRequireFn:!0},{label:i("Navigate through the toolbar or menu bar"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]},{label:i("Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content."),keystroke:[["Enter"],["Space"]]}];t&&o.push({label:i("Move focus to the menu bar, navigate between menu bars"),keystroke:"Alt+F9",mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:"navigation",label:i("User interface and content navigation keystrokes"),description:i("Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface."),groups:[{id:"common",keystrokes:o}]})}addKeystrokeInfoCategory({id:e,label:t,description:i,groups:o}){this.keystrokeInfos.set(e,{id:e,label:t,description:i,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:e,id:ad}),o&&o.forEach(s=>{this.addKeystrokeInfoGroup({categoryId:e,...s})})}addKeystrokeInfoGroup({categoryId:e=Wa,id:t,label:i,keystrokes:o}){const s=this.keystrokeInfos.get(e);if(!s)throw new b("accessibility-unknown-keystroke-info-category",this._editor,{groupId:t,categoryId:e});s.groups.set(t,{id:t,label:i,keystrokes:o||[]})}addKeystrokeInfos({categoryId:e=Wa,groupId:t=ad,keystrokes:i}){if(!this.keystrokeInfos.has(e))throw new b("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:e,keystrokes:i});const o=this.keystrokeInfos.get(e);if(!o.groups.has(t))throw new b("accessibility-unknown-keystroke-info-group",this._editor,{groupId:t,categoryId:e,keystrokes:i});o.groups.get(t).keystrokes.push(...i)}}function q5(n){return{sessionId:Q5(),pageSessionId:Y5(),hostname:window.location.hostname,version:globalThis.CKEDITOR_VERSION,type:G5(n),plugins:K5(n.plugins),distribution:Z5(),env:J5(),integration:Object.create(null),menuBar:{isVisible:!!n.config.get("menuBar.isVisible")},language:{ui:n.locale.uiLanguage,content:n.locale.contentLanguage},toolbar:{main:ja(n.config.get("toolbar")),block:ja(n.config.get("blockToolbar")),balloon:ja(n.config.get("balloonToolbar"))}}}function G5(n){return Object.getPrototypeOf(n).constructor.editorName}function K5(n){return Array.from(n).filter(([e])=>!!e.pluginName).map(([e])=>{const{pluginName:t,isContextPlugin:i,isOfficialPlugin:o,isPremiumPlugin:s}=e;return{isContext:!!i,isOfficial:!!o,isPremium:!!s,name:t}})}function ja(n){if(!n)return;const e=Array.isArray(n)?{items:n}:n,t=o(e.items||[]);return{isMultiline:t.includes("-"),shouldNotGroupWhenFull:!!e.shouldNotGroupWhenFull,items:i(t)};function i(s){return s.filter(r=>r!=="|"&&r!=="-")}function o(s){return s.flatMap(r=>typeof r=="string"?[r]:o(r.items))}}function Z5(){return{channel:window[Symbol.for("cke distribution")]||"sh"}}function J5(){let n="unknown",e="unknown";return N.isMac?n="mac":N.isWindows?n="windows":N.isiOS?n="ios":N.isAndroid&&(n="android"),N.isGecko?e="gecko":N.isBlink?e="blink":N.isSafari&&(e="safari"),{os:n,browser:e}}function Q5(){return localStorage.getItem("__ckeditor-session-id")||localStorage.setItem("__ckeditor-session-id",ze()),localStorage.getItem("__ckeditor-session-id")}function Y5(){return I.window.CKEDITOR_PAGE_SESSION_ID=I.window.CKEDITOR_PAGE_SESSION_ID||ze(),I.window.CKEDITOR_PAGE_SESSION_ID}class pn extends ue(){constructor(e={}){if(super(),h(this,"accessibility"),h(this,"commands"),h(this,"config"),h(this,"conversion"),h(this,"data"),h(this,"editing"),h(this,"locale"),h(this,"model"),h(this,"plugins"),h(this,"keystrokes"),h(this,"t"),h(this,"_context"),h(this,"_readOnlyLocks"),"sanitizeHtml"in e)throw new b("editor-config-sanitizehtml-not-supported");const t=this.constructor,{translations:i,...o}=t.defaultConfig||{},{translations:s=i,...r}=e,a=e.language||o.language;this._context=e.context||new Or({language:a,translations:s}),this._context._addEditor(this,!e.context);const l=Array.from(t.builtinPlugins||[]);this.config=new qg(r,o),this.config.define("plugins",l),this.config.define(this._context._getEditorConfig()),u(this.config),this.plugins=new cw(this,l,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new W5,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.model=new l5,this.on("change:isReadOnly",()=>{this.model.document.isReadOnly=this.isReadOnly});const c=new Uv;this.data=new w2(this.model,c),this.editing=new Kk(this.model,c),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new _2([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 j5(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new U5(this),d(this);function u(m){let f=m.get("licenseKey");if(!f&&window.CKEDITOR_GLOBAL_LICENSE_KEY&&(f=window.CKEDITOR_GLOBAL_LICENSE_KEY,m.set("licenseKey",f)),!f)throw new b("license-key-missing")}function d(m){const f=m.config.get("licenseKey"),g=window[Symbol.for("cke distribution")]||"sh";function p(x){m.enableReadOnlyMode(Symbol("invalidLicense")),m._showLicenseError(x)}function _(x){const q=x.split(".");return q.length!=3?null:q[1]}function v(x){return["exp","jti","vc"].every(q=>q in x)}function E(x){return Object.getOwnPropertyNames(x).sort().filter(q=>q!="vc"&&x[q]!=null).map(q=>x[q])}function M(x){const{hostname:q}=new URL(window.location.href);if(x.includes(q))return!0;const Ve=q.split(".");return x.filter(pe=>pe.includes("*")).map(pe=>pe.split(".")).filter(pe=>pe.length<=Ve.length).map(pe=>Array(Ve.length-pe.length).fill(pe[0]==="*"?"*":"").concat(pe)).some(pe=>Ve.every((di,Bn)=>pe[Bn]===di||pe[Bn]==="*"))}function G(x){const q=x[0].toUpperCase()+x.slice(1),Ve=x==="evaluation"?"an":"a";console.info(`%cCKEditor 5 ${q} License`,"color: #ffffff; background: #743CCD; font-size: 14px; padding: 4px 8px; border-radius: 4px;"),console.warn(`⚠️ You are using ${Ve} ${x} license of CKEditor 5${x==="trial"?" which is for evaluation purposes only":""}. For production usage, please obtain a production license at https://portal.ckeditor.com/`)}if(f=="GPL"){g=="cloud"&&p("distributionChannel");return}const X=_(f);if(!X){p("invalid");return}const T=Wc(X);if(!T){p("invalid");return}if(!v(T)){p("invalid");return}if(T.distributionChannel&&!he(T.distributionChannel).includes(g)){p("distributionChannel");return}if(Sv(E(T))!=T.vc.toLowerCase()){p("invalid");return}if(new Date(T.exp*1e3)0&&!M(F)){p("domainLimit");return}if(["evaluation","trial"].includes(T.licenseType)&&T.exp*1e3{p(`${x}Limit`)},6e5);m.on("destroy",()=>{clearTimeout(q)})}T.usageEndpoint&&m.once("ready",()=>{const x={requestId:ze(),requestTime:Math.round(Date.now()/1e3),license:f,editor:X5(m)};m._sendUsageRequest(T.usageEndpoint,x).then(q=>{const{status:Ve,message:pe}=q;pe&&console.warn(pe),Ve!="ok"&&p("usageLimit")},()=>{D_("license-key-validation-endpoint-not-reachable",{url:T.usageEndpoint})})},{priority:"high"})}}static get editorName(){return"Editor"}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new b("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new b("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 b("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))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],o=e.get("extraPlugins")||[],s=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(o),i,s)}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(i){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(i,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}_showLicenseError(e,t){setTimeout(()=>{if(e=="invalid")throw new b("invalid-license-key");if(e=="expired")throw new b("license-key-expired");if(e=="domainLimit")throw new b("license-key-domain-limit");if(e=="featureNotAllowed")throw new b("license-key-plugin-not-allowed",null,{pluginName:t});if(e=="evaluationLimit")throw new b("license-key-evaluation-limit");if(e=="trialLimit")throw new b("license-key-trial-limit");if(e=="developmentLimit")throw new b("license-key-development-limit");if(e=="usageLimit")throw new b("license-key-usage-limit");if(e=="distributionChannel")throw new b("license-key-invalid-distribution-channel")},0),this._showLicenseError=()=>{}}async _sendUsageRequest(e,t){const i=new Headers({"Content-Type":"application/json"}),o=await fetch(new URL(e),{method:"POST",headers:i,body:JSON.stringify(t)});if(!o.ok)throw new Error(`HTTP Response: ${o.status}`);return o.json()}}h(pn,"defaultConfig"),h(pn,"builtinPlugins"),h(pn,"Context",Or),h(pn,"EditorWatchdog",lw),h(pn,"ContextWatchdog",H5);function X5(n){const e=q5(n);function t(i,o){if(Ki(e,i)!==void 0)throw new b("editor-usage-data-path-already-set",{path:i});Ig(e,i,o)}return n.fire("collectUsageData",{setUsageData:t}),e}function eC(n){if(!Tr(n.updateSourceElement))throw new b("attachtoform-missing-elementapi-interface",n);const e=n.sourceElement;if(tC(e)&&e.form){let t;const i=e.form,o=()=>n.updateSourceElement();Tr(i.submit)&&(t=i.submit,i.submit=()=>{o(),t.apply(i)}),i.addEventListener("submit",o),n.on("destroy",()=>{i.removeEventListener("submit",o),t&&(i.submit=t)})}}function tC(n){return!!n&&n.tagName.toLowerCase()==="textarea"}function Br(n){class e extends n{constructor(){super(...arguments),h(this,"sourceElement")}updateSourceElement(i){if(!this.sourceElement)throw new b("editor-missing-sourceelement",this);const o=this.config.get("updateSourceElementOnDestroy"),s=this.sourceElement instanceof HTMLTextAreaElement;if(!o&&!s){hh(this.sourceElement,"");return}const r=typeof i=="string"?i:this.data.get();hh(this.sourceElement,r)}}return e}Br.updateSourceElement=Br(Object).prototype.updateSourceElement;function hw(n,e){if(e.ckeditorInstance)throw new b("editor-source-element-already-used",n);e.ckeditorInstance=n,n.once("destroy",()=>{delete e.ckeditorInstance})}class ld extends uw{constructor(){super(...arguments),h(this,"_actions")}static get pluginName(){return"PendingActions"}static get isOfficialPlugin(){return!0}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 b("pendingactions-add-invalid-message",this);const t=new(ue());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]()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class iC extends ue(){constructor(){super(),h(this,"total"),h(this,"_reader"),h(this,"_data");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((i,o)=>{t.onload=()=>{const s=t.result;this._data=s,i(s)},t.onerror=()=>{o("error")},t.onabort=()=>{o("aborted")},this._reader.readAsDataURL(e)})}abort(){this._reader.abort()}}class At extends w{constructor(){super(...arguments),h(this,"loaders",new _e),h(this,"_loadersMap",new Map),h(this,"_pendingAction",null)}static get pluginName(){return"FileRepository"}static get isOfficialPlugin(){return!0}static get requires(){return[ld]}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 J("filerepository-no-upload-adapter"),null;const t=new cd(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then(i=>{this._loadersMap.set(i,t)}).catch(()=>{}),t.on("change:uploaded",()=>{let i=0;for(const o of this.loaders)i+=o.uploaded;this.uploaded=i}),t.on("change:uploadTotal",()=>{let i=0;for(const o of this.loaders)o.uploadTotal&&(i+=o.uploadTotal);this.uploadTotal=i}),t}destroyLoader(e){const t=e instanceof cd?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach((i,o)=>{i===t&&this._loadersMap.delete(o)})}_updatePendingAction(){const e=this.editor.plugins.get(ld);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=o=>`${t("Upload in progress")} ${parseInt(o)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}class cd extends ue(){constructor(e,t){super(),h(this,"id"),h(this,"_filePromiseWrapper"),h(this,"_adapter"),h(this,"_reader"),this.id=ze(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new iC,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(i,o)=>o?i/o*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 b("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 b("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((i,o)=>{t.rejecter=o,t.isFulfilled=!1,e.then(s=>{t.isFulfilled=!0,i(s)}).catch(s=>{t.isFulfilled=!0,o(s)})}),t}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const ud="ckCsrfToken",hd=40,dd="abcdefghijklmnopqrstuvwxyz0123456789";function nC(){let n=oC(ud);return(!n||n.length!=hd)&&(n=rC(hd),sC(ud,n)),n}function oC(n){n=n.toLowerCase();const e=document.cookie.split(";");for(const t of e){const i=t.split("=");if(decodeURIComponent(i[0].trim().toLowerCase())===n)return decodeURIComponent(i[1])}return null}function sC(n,e){document.cookie=encodeURIComponent(n)+"="+encodeURIComponent(e)+";path=/"}function rC(n){let e="";const t=new Uint8Array(n);window.crypto.getRandomValues(t);for(let i=0;i.5?o.toUpperCase():o}return e}class aC extends w{static get requires(){return[At]}static get pluginName(){return"CKFinderUploadAdapter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(At).createUploadAdapter=t=>new lC(t,e,this.editor.t))}}class lC{constructor(e,t,i){h(this,"loader"),h(this,"url"),h(this,"t"),h(this,"xhr"),this.loader=e,this.url=t,this.t=i}upload(){return this.loader.file.then(e=>new Promise((t,i)=>{this._initRequest(),this._initListeners(t,i,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,i){const o=this.xhr,s=this.loader,r=this.t,a=r("Cannot upload file:")+` ${i.name}.`;o.addEventListener("error",()=>t(a)),o.addEventListener("abort",()=>t()),o.addEventListener("load",()=>{const l=o.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 */o.upload&&o.upload.addEventListener("progress",l=>{l.lengthComputable&&(s.uploadTotal=l.total,s.uploaded=l.loaded)})}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",nC()),this.xhr.send(t)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/var cC='',dw='',mw='',nu='',uC='',fw='',hC='',gw='',dC='',mC='',fC='',gC='',ou='',_o='',pw='',Es='',md='',pC='',wC='',bC='',_C='',vC='',da='',yC='',kC='',fd='',CC='',AC='',gd='',pd='',xC='',TC='',EC='',SC='',PC='',IC='',VC='',RC='',OC='',BC='',wd='',MC='',LC='',FC='',NC='',DC='',zC='',HC='',$C='',WC='',jC='',UC='',qC='',ww='',su='',Mr='',GC='',ru='',Lr='',bw='',_w='',vw='',KC='',ZC='',JC='',QC='',YC='',bd='',XC='',yw='',kw='',eA='',tA='',li='',iA=`
`,nA='',_d='',oA='',sA='',rA='',aA='',lA=`
`,cA='',uA='',hA='',dA='',mA='',fA='',gA='',pA='',wA='',vd='',bA='',_A='',au='',vA='',yA='',yd='',kA='';function lu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var kd,Cd;function Cw(){return Cd||(Cd=1,kd={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),kd}var CA=Cw();const Ad=lu(CA);var xd={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Td(n){var e,t=[],i=1,o;if(typeof n=="string")if(Ad[n])t=Ad[n].slice(),o="rgb";else if(n==="transparent")i=0,o="rgb",t=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(n)){var s=n.slice(1),r=s.length,a=r<=4;i=1,a?(t=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],r===4&&(i=parseInt(s[3]+s[3],16)/255)):(t=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],r===8&&(i=parseInt(s[6]+s[7],16)/255)),t[0]||(t[0]=0),t[1]||(t[1]=0),t[2]||(t[2]=0),o="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(n)){var l=e[1],c=l==="rgb",s=l.replace(/a$/,"");o=s;var r=s==="cmyk"?4:s==="gray"?1:3;t=e[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(m,f){if(/%$/.test(m))return f===r?parseFloat(m)/100:s==="rgb"?parseFloat(m)*255/100:parseFloat(m);if(s[f]==="h"){if(/deg$/.test(m))return parseFloat(m);if(xd[m]!==void 0)return xd[m]}return parseFloat(m)}),l===s&&t.push(1),i=c||t[r]===void 0?1:t[r],t=t.slice(0,r)}else n.length>10&&/[0-9](?:\s|\/)/.test(n)&&(t=n.match(/([0-9]+)/g).map(function(u){return parseFloat(u)}),o=n.match(/([a-z])/ig).join("").toLowerCase());else isNaN(n)?Array.isArray(n)||n.length?(t=[n[0],n[1],n[2]],o="rgb",i=n.length===4?n[3]:1):n instanceof Object&&(n.r!=null||n.red!=null||n.R!=null?(o="rgb",t=[n.r||n.red||n.R||0,n.g||n.green||n.G||0,n.b||n.blue||n.B||0]):(o="hsl",t=[n.h||n.hue||n.H||0,n.s||n.saturation||n.S||0,n.l||n.lightness||n.L||n.b||n.brightness]),i=n.a||n.alpha||n.opacity||1,n.opacity!=null&&(i/=100)):(o="rgb",t=[n>>>16,(n&65280)>>>8,n&255]);return{space:o,values:t,alpha:i}}var Ua,Ed;function Aw(){if(Ed)return Ua;Ed=1;const n=Cw(),e={};for(const o of Object.keys(n))e[n[o]]=o;const t={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};Ua=t;for(const o of Object.keys(t)){if(!("channels"in t[o]))throw new Error("missing channels property: "+o);if(!("labels"in t[o]))throw new Error("missing channel labels property: "+o);if(t[o].labels.length!==t[o].channels)throw new Error("channel and label counts mismatch: "+o);const{channels:s,labels:r}=t[o];delete t[o].channels,delete t[o].labels,Object.defineProperty(t[o],"channels",{value:s}),Object.defineProperty(t[o],"labels",{value:r})}t.rgb.hsl=function(o){const s=o[0]/255,r=o[1]/255,a=o[2]/255,l=Math.min(s,r,a),c=Math.max(s,r,a),u=c-l;let d,m;c===l?d=0:s===c?d=(r-a)/u:r===c?d=2+(a-s)/u:a===c&&(d=4+(s-r)/u),d=Math.min(d*60,360),d<0&&(d+=360);const f=(l+c)/2;return c===l?m=0:f<=.5?m=u/(c+l):m=u/(2-c-l),[d,m*100,f*100]},t.rgb.hsv=function(o){let s,r,a,l,c;const u=o[0]/255,d=o[1]/255,m=o[2]/255,f=Math.max(u,d,m),g=f-Math.min(u,d,m),p=function(_){return(f-_)/6/g+1/2};return g===0?(l=0,c=0):(c=g/f,s=p(u),r=p(d),a=p(m),u===f?l=a-r:d===f?l=1/3+s-a:m===f&&(l=2/3+r-s),l<0?l+=1:l>1&&(l-=1)),[l*360,c*100,f*100]},t.rgb.hwb=function(o){const s=o[0],r=o[1];let a=o[2];const l=t.rgb.hsl(o)[0],c=1/255*Math.min(s,Math.min(r,a));return a=1-1/255*Math.max(s,Math.max(r,a)),[l,c*100,a*100]},t.rgb.cmyk=function(o){const s=o[0]/255,r=o[1]/255,a=o[2]/255,l=Math.min(1-s,1-r,1-a),c=(1-s-l)/(1-l)||0,u=(1-r-l)/(1-l)||0,d=(1-a-l)/(1-l)||0;return[c*100,u*100,d*100,l*100]};function i(o,s){return(o[0]-s[0])**2+(o[1]-s[1])**2+(o[2]-s[2])**2}return t.rgb.keyword=function(o){const s=e[o];if(s)return s;let r=1/0,a;for(const l of Object.keys(n)){const c=n[l],u=i(o,c);u.04045?((s+.055)/1.055)**2.4:s/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,a=a>.04045?((a+.055)/1.055)**2.4:a/12.92;const l=s*.4124+r*.3576+a*.1805,c=s*.2126+r*.7152+a*.0722,u=s*.0193+r*.1192+a*.9505;return[l*100,c*100,u*100]},t.rgb.lab=function(o){const s=t.rgb.xyz(o);let r=s[0],a=s[1],l=s[2];r/=95.047,a/=100,l/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116,l=l>.008856?l**(1/3):7.787*l+16/116;const c=116*a-16,u=500*(r-a),d=200*(a-l);return[c,u,d]},t.hsl.rgb=function(o){const s=o[0]/360,r=o[1]/100,a=o[2]/100;let l,c,u;if(r===0)return u=a*255,[u,u,u];a<.5?l=a*(1+r):l=a+r-a*r;const d=2*a-l,m=[0,0,0];for(let f=0;f<3;f++)c=s+1/3*-(f-1),c<0&&c++,c>1&&c--,6*c<1?u=d+(l-d)*6*c:2*c<1?u=l:3*c<2?u=d+(l-d)*(2/3-c)*6:u=d,m[f]=u*255;return m},t.hsl.hsv=function(o){const s=o[0];let r=o[1]/100,a=o[2]/100,l=r;const c=Math.max(a,.01);a*=2,r*=a<=1?a:2-a,l*=c<=1?c:2-c;const u=(a+r)/2,d=a===0?2*l/(c+l):2*r/(a+r);return[s,d*100,u*100]},t.hsv.rgb=function(o){const s=o[0]/60,r=o[1]/100;let a=o[2]/100;const l=Math.floor(s)%6,c=s-Math.floor(s),u=255*a*(1-r),d=255*a*(1-r*c),m=255*a*(1-r*(1-c));switch(a*=255,l){case 0:return[a,m,u];case 1:return[d,a,u];case 2:return[u,a,m];case 3:return[u,d,a];case 4:return[m,u,a];case 5:return[a,u,d]}},t.hsv.hsl=function(o){const s=o[0],r=o[1]/100,a=o[2]/100,l=Math.max(a,.01);let c,u;u=(2-r)*a;const d=(2-r)*l;return c=r*l,c/=d<=1?d:2-d,c=c||0,u/=2,[s,c*100,u*100]},t.hwb.rgb=function(o){const s=o[0]/360;let r=o[1]/100,a=o[2]/100;const l=r+a;let c;l>1&&(r/=l,a/=l);const u=Math.floor(6*s),d=1-a;c=6*s-u,(u&1)!==0&&(c=1-c);const m=r+c*(d-r);let f,g,p;switch(u){default:case 6:case 0:f=d,g=m,p=r;break;case 1:f=m,g=d,p=r;break;case 2:f=r,g=d,p=m;break;case 3:f=r,g=m,p=d;break;case 4:f=m,g=r,p=d;break;case 5:f=d,g=r,p=m;break}return[f*255,g*255,p*255]},t.cmyk.rgb=function(o){const s=o[0]/100,r=o[1]/100,a=o[2]/100,l=o[3]/100,c=1-Math.min(1,s*(1-l)+l),u=1-Math.min(1,r*(1-l)+l),d=1-Math.min(1,a*(1-l)+l);return[c*255,u*255,d*255]},t.xyz.rgb=function(o){const s=o[0]/100,r=o[1]/100,a=o[2]/100;let l,c,u;return l=s*3.2406+r*-1.5372+a*-.4986,c=s*-.9689+r*1.8758+a*.0415,u=s*.0557+r*-.204+a*1.057,l=l>.0031308?1.055*l**(1/2.4)-.055:l*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,u=u>.0031308?1.055*u**(1/2.4)-.055:u*12.92,l=Math.min(Math.max(0,l),1),c=Math.min(Math.max(0,c),1),u=Math.min(Math.max(0,u),1),[l*255,c*255,u*255]},t.xyz.lab=function(o){let s=o[0],r=o[1],a=o[2];s/=95.047,r/=100,a/=108.883,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;const l=116*r-16,c=500*(s-r),u=200*(r-a);return[l,c,u]},t.lab.xyz=function(o){const s=o[0],r=o[1],a=o[2];let l,c,u;c=(s+16)/116,l=r/500+c,u=c-a/200;const d=c**3,m=l**3,f=u**3;return c=d>.008856?d:(c-16/116)/7.787,l=m>.008856?m:(l-16/116)/7.787,u=f>.008856?f:(u-16/116)/7.787,l*=95.047,c*=100,u*=108.883,[l,c,u]},t.lab.lch=function(o){const s=o[0],r=o[1],a=o[2];let l;l=Math.atan2(a,r)*360/2/Math.PI,l<0&&(l+=360);const c=Math.sqrt(r*r+a*a);return[s,c,l]},t.lch.lab=function(o){const s=o[0],r=o[1],a=o[2]/360*2*Math.PI,l=r*Math.cos(a),c=r*Math.sin(a);return[s,l,c]},t.rgb.ansi16=function(o,s=null){const[r,a,l]=o;let c=s===null?t.rgb.hsv(o)[2]:s;if(c=Math.round(c/50),c===0)return 30;let u=30+(Math.round(l/255)<<2|Math.round(a/255)<<1|Math.round(r/255));return c===2&&(u+=60),u},t.hsv.ansi16=function(o){return t.rgb.ansi16(t.hsv.rgb(o),o[2])},t.rgb.ansi256=function(o){const s=o[0],r=o[1],a=o[2];return s===r&&r===a?s<8?16:s>248?231:Math.round((s-8)/247*24)+232:16+36*Math.round(s/255*5)+6*Math.round(r/255*5)+Math.round(a/255*5)},t.ansi16.rgb=function(o){let s=o%10;if(s===0||s===7)return o>50&&(s+=3.5),s=s/10.5*255,[s,s,s];const r=(~~(o>50)+1)*.5,a=(s&1)*r*255,l=(s>>1&1)*r*255,c=(s>>2&1)*r*255;return[a,l,c]},t.ansi256.rgb=function(o){if(o>=232){const c=(o-232)*10+8;return[c,c,c]}o-=16;let s;const r=Math.floor(o/36)/5*255,a=Math.floor((s=o%36)/6)/5*255,l=s%6/5*255;return[r,a,l]},t.rgb.hex=function(o){const s=(((Math.round(o[0])&255)<<16)+((Math.round(o[1])&255)<<8)+(Math.round(o[2])&255)).toString(16).toUpperCase();return"000000".substring(s.length)+s},t.hex.rgb=function(o){const s=o.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!s)return[0,0,0];let r=s[0];s[0].length===3&&(r=r.split("").map(d=>d+d).join(""));const a=parseInt(r,16),l=a>>16&255,c=a>>8&255,u=a&255;return[l,c,u]},t.rgb.hcg=function(o){const s=o[0]/255,r=o[1]/255,a=o[2]/255,l=Math.max(Math.max(s,r),a),c=Math.min(Math.min(s,r),a),u=l-c;let d,m;return u<1?d=c/(1-u):d=0,u<=0?m=0:l===s?m=(r-a)/u%6:l===r?m=2+(a-s)/u:m=4+(s-r)/u,m/=6,m%=1,[m*360,u*100,d*100]},t.hsl.hcg=function(o){const s=o[1]/100,r=o[2]/100,a=r<.5?2*s*r:2*s*(1-r);let l=0;return a<1&&(l=(r-.5*a)/(1-a)),[o[0],a*100,l*100]},t.hsv.hcg=function(o){const s=o[1]/100,r=o[2]/100,a=s*r;let l=0;return a<1&&(l=(r-a)/(1-a)),[o[0],a*100,l*100]},t.hcg.rgb=function(o){const s=o[0]/360,r=o[1]/100,a=o[2]/100;if(r===0)return[a*255,a*255,a*255];const l=[0,0,0],c=s%1*6,u=c%1,d=1-u;let m=0;switch(Math.floor(c)){case 0:l[0]=1,l[1]=u,l[2]=0;break;case 1:l[0]=d,l[1]=1,l[2]=0;break;case 2:l[0]=0,l[1]=1,l[2]=u;break;case 3:l[0]=0,l[1]=d,l[2]=1;break;case 4:l[0]=u,l[1]=0,l[2]=1;break;default:l[0]=1,l[1]=0,l[2]=d}return m=(1-r)*a,[(r*l[0]+m)*255,(r*l[1]+m)*255,(r*l[2]+m)*255]},t.hcg.hsv=function(o){const s=o[1]/100,r=o[2]/100,a=s+r*(1-s);let l=0;return a>0&&(l=s/a),[o[0],l*100,a*100]},t.hcg.hsl=function(o){const s=o[1]/100,r=o[2]/100*(1-s)+.5*s;let a=0;return r>0&&r<.5?a=s/(2*r):r>=.5&&r<1&&(a=s/(2*(1-r))),[o[0],a*100,r*100]},t.hcg.hwb=function(o){const s=o[1]/100,r=o[2]/100,a=s+r*(1-s);return[o[0],(a-s)*100,(1-a)*100]},t.hwb.hcg=function(o){const s=o[1]/100,r=1-o[2]/100,a=r-s;let l=0;return a<1&&(l=(r-a)/(1-a)),[o[0],a*100,l*100]},t.apple.rgb=function(o){return[o[0]/65535*255,o[1]/65535*255,o[2]/65535*255]},t.rgb.apple=function(o){return[o[0]/255*65535,o[1]/255*65535,o[2]/255*65535]},t.gray.rgb=function(o){return[o[0]/100*255,o[0]/100*255,o[0]/100*255]},t.gray.hsl=function(o){return[0,0,o[0]]},t.gray.hsv=t.gray.hsl,t.gray.hwb=function(o){return[0,100,o[0]]},t.gray.cmyk=function(o){return[0,0,0,o[0]]},t.gray.lab=function(o){return[o[0],0,0]},t.gray.hex=function(o){const s=Math.round(o[0]/100*255)&255,r=((s<<16)+(s<<8)+s).toString(16).toUpperCase();return"000000".substring(r.length)+r},t.rgb.gray=function(o){return[(o[0]+o[1]+o[2])/3/255*100]},Ua}var qa,Sd;function AA(){if(Sd)return qa;Sd=1;const n=Aw();function e(){const s={},r=Object.keys(n);for(let a=r.length,l=0;l1&&(l=c),r(l))};return"conversion"in r&&(a.conversion=r.conversion),a}function s(r){const a=function(...l){const c=l[0];if(c==null)return c;c.length>1&&(l=c);const u=r(l);if(typeof u=="object")for(let d=u.length,m=0;m{t[r]={},Object.defineProperty(t[r],"channels",{value:n[r].channels}),Object.defineProperty(t[r],"labels",{value:n[r].labels});const a=e(r);Object.keys(a).forEach(l=>{const c=a[l];t[r][l]=s(c),t[r][l].raw=o(c)})}),Ga=t,Ga}var xw=xA();const TA=lu(xw),Tw=U0({__proto__:null,default:TA},[xw]),gs=(n,e=0,t=1)=>n>t?t:nMath.round(t*n)/t,EA=n=>RA(Jl(n)),Jl=n=>(n[0]==="#"&&(n=n.substring(1)),n.length<6?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?qe(parseInt(n[3]+n[3],16)/255,2):1}:{r:parseInt(n.substring(0,2),16),g:parseInt(n.substring(2,4),16),b:parseInt(n.substring(4,6),16),a:n.length===8?qe(parseInt(n.substring(6,8),16)/255,2):1}),SA=n=>VA(IA(n)),PA=({h:n,s:e,v:t,a:i})=>{const o=(200-e)*t/100;return{h:qe(n),s:qe(o>0&&o<200?e*t/100/(o<=100?o:200-o)*100:0),l:qe(o/2),a:qe(i,2)}},Ql=n=>{const{h:e,s:t,l:i}=PA(n);return`hsl(${e}, ${t}%, ${i}%)`},IA=({h:n,s:e,v:t,a:i})=>{n=n/360*6,e=e/100,t=t/100;const o=Math.floor(n),s=t*(1-e),r=t*(1-(n-o)*e),a=t*(1-(1-n+o)*e),l=o%6;return{r:qe([t,r,s,s,a,t][l]*255),g:qe([a,t,t,r,s,s][l]*255),b:qe([s,s,a,t,t,r][l]*255),a:qe(i,2)}},Us=n=>{const e=n.toString(16);return e.length<2?"0"+e:e},VA=({r:n,g:e,b:t,a:i})=>{const o=i<1?Us(qe(i*255)):"";return"#"+Us(n)+Us(e)+Us(t)+o},RA=({r:n,g:e,b:t,a:i})=>{const o=Math.max(n,e,t),s=o-Math.min(n,e,t),r=s?o===n?(e-t)/s:o===e?2+(t-n)/s:4+(n-e)/s:0;return{h:qe(60*(r<0?r+6:r)),s:qe(o?s/o*100:0),v:qe(o/255*100),a:i}},Ew=(n,e)=>{if(n===e)return!0;for(const t in n)if(n[t]!==e[t])return!1;return!0},OA=(n,e)=>n.toLowerCase()===e.toLowerCase()?!0:Ew(Jl(n),Jl(e)),Id={},Sw=n=>{let e=Id[n];return e||(e=document.createElement("template"),e.innerHTML=n,Id[n]=e),e},cu=(n,e,t)=>{n.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))};let ro=!1;const Yl=n=>"touches"in n,BA=n=>ro&&!Yl(n)?!1:(ro||(ro=Yl(n)),!0),Vd=(n,e)=>{const t=Yl(e)?e.touches[0]:e,i=n.el.getBoundingClientRect();cu(n.el,"move",n.getMove({x:gs((t.pageX-(i.left+window.pageXOffset))/i.width),y:gs((t.pageY-(i.top+window.pageYOffset))/i.height)}))},MA=(n,e)=>{const t=e.keyCode;t>40||n.xy&&t<37||t<33||(e.preventDefault(),cu(n.el,"move",n.getMove({x:t===39?.01:t===37?-.01:t===34?.05:t===33?-.05:t===35?1:t===36?-1:0,y:t===40?.01:t===38?-.01:0},!0)))};class Pw{constructor(e,t,i,o){const s=Sw(``);e.appendChild(s.content.cloneNode(!0));const r=e.querySelector(`[part=${t}]`);r.addEventListener("mousedown",this),r.addEventListener("touchstart",this),r.addEventListener("keydown",this),this.el=r,this.xy=o,this.nodes=[r.firstChild,r]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(ro?"touchmove":"mousemove",this),t(ro?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!BA(e)||!ro&&e.button!=0)return;this.el.focus(),Vd(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),Vd(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":MA(this,e);break}}style(e){e.forEach((t,i)=>{for(const o in t)this.nodes[i].style.setProperty(o,t[o])})}}class LA extends Pw{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:`${e/360*100}%`,color:Ql({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${qe(e)}`)}getMove(e,t){return{h:t?gs(this.h+e.x*360,0,360):360*e.x}}}class FA extends Pw{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:`${100-e.v}%`,left:`${e.s}%`,color:Ql(e)},{"background-color":Ql({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${qe(e.s)}%, Brightness ${qe(e.v)}%`)}getMove(e,t){return{s:t?gs(this.hsva.s+e.x*100,0,100):e.x*100,v:t?gs(this.hsva.v-e.y*100,0,100):Math.round(100-e.y*100)}}}const NA=':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',DA="[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}",zA="[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}",qs=Symbol("same"),Ka=Symbol("color"),Rd=Symbol("hsva"),Za=Symbol("update"),Od=Symbol("parts"),Bd=Symbol("css"),Md=Symbol("sliders");class HA extends HTMLElement{static get observedAttributes(){return["color"]}get[Bd](){return[NA,DA,zA]}get[Md](){return[FA,LA]}get color(){return this[Ka]}set color(e){if(!this[qs](e)){const t=this.colorModel.toHsva(e);this[Za](t),this[Ka]=e}}constructor(){super();const e=Sw(``),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[Od]=this[Md].map(i=>new i(t))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,i){const o=this.colorModel.fromAttr(i);this[qs](o)||(this.color=o)}handleEvent(e){const t=this[Rd],i={...t,...e.detail};this[Za](i);let o;!Ew(i,t)&&!this[qs](o=this.colorModel.fromHsva(i))&&(this[Ka]=o,cu(this,"color-changed",{value:o}))}[qs](e){return this.color&&this.colorModel.equal(e,this.color)}[Za](e){this[Rd]=e,this[Od].forEach(t=>t.update(e))}}const $A={defaultColor:"#000",toHsva:EA,fromHsva:({h:n,s:e,v:t})=>SA({h:n,s:e,v:t,a:1}),equal:OA,fromAttr:n=>n};class WA extends HA{get colorModel(){return $A}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ie extends _e{constructor(e=[]){super(e,{idProperty:"viewUid"}),h(this,"_parentElement"),this.on("add",(t,i,o)=>{this._renderViewIntoCollectionParent(i,o)}),this.on("remove",(t,i)=>{i.element&&this._parentElement&&i.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||!jA(e))throw new b("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const o of e)i.delegate(o).to(t);this.on("add",(i,o)=>{for(const s of e)o.delegate(s).to(t)}),this.on("remove",(i,o)=>{for(const s of e)o.stopDelegating(s,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 jA(n){return n.every(e=>typeof e=="string")}const UA="http://www.w3.org/1999/xhtml";class qt extends ge(){constructor(e){super(),h(this,"ns"),h(this,"tag"),h(this,"text"),h(this,"attributes"),h(this,"children"),h(this,"eventListeners"),h(this,"_isRendered"),h(this,"_revertData"),Object.assign(this,Fd(Ld(e))),this._isRendered=!1,this._revertData=null}render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData=zd(),this._renderNode({node:e,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new b("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){function*e(t){if(t.children)for(const i of t.children)Fr(i)?yield i:uu(i)&&(yield*e(i))}yield*e(this)}static bind(e,t){return{to(i,o){return new qA({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:o})},if(i,o,s){return new Iw({observable:e,emitter:t,attribute:i,valueIfTrue:o,callback:s})}}}static extend(e,t){if(e._isRendered)throw new b("template-extend-render",[this,e]);Bw(e,Fd(Ld(t)))}_renderNode(e){let t;if(e.node?t=this.tag&&this.text:t=this.tag?this.text:!this.text,t)throw new b("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||UA,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(""),ur(this.text)?this._bindToObservable({schema:this.text,updater:KA(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,i=e.revertData;for(const o in this.attributes){const s=t.getAttribute(o),r=this.attributes[o];i&&(i.attributes[o]=s);const a=Dd(r)?r[0].ns:null;if(ur(r)){const l=Dd(r)?r[0].value:r;i&&Hd(o)&&l.unshift(s),this._bindToObservable({schema:l,updater:ZA(t,o,a),data:e})}else if(o=="style"&&typeof r[0]!="string")this._renderStyleAttribute(r[0],e);else{i&&s&&Hd(o)&&r.unshift(s);const l=r.map(c=>c&&(c.value||c)).reduce((c,u)=>c.concat(u),[]).reduce(Ow,"");uo(l)||t.setAttributeNS(a,o,l)}}}_renderStyleAttribute(e,t){const i=t.node;for(const o in e){const s=e[o];ur(s)?this._bindToObservable({schema:[s],updater:JA(i,o),data:t}):i.style[o]=s}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,o=e.isApplying;let s=0;for(const r of this.children)if(hu(r)){if(!o){r.setParent(t);for(const a of r)i.appendChild(a.element)}}else if(Fr(r))o||(r.isRendered||r.render(),i.appendChild(r.element));else if(Zi(r))i.appendChild(r);else if(o){const a=e.revertData,l=zd();a.children.push(l),r._renderNode({intoFragment:!1,node:i.childNodes[s++],isApplying:!0,revertData:l})}else i.appendChild(r.render());e.intoFragment&&t.appendChild(i)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const i=this.eventListeners[t].map(o=>{const[s,r]=t.split("@");return o.activateDomEventListener(s,r,e)});e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const o=i.revertData;Vw(e,t,i);const s=e.filter(r=>!uo(r)).filter(r=>r.observable).map(r=>r.activateAttributeListener(e,t,i));o&&o.bindings.push(s)}_revertTemplateFromNode(e,t){for(const o of t.bindings)for(const s of o)s();if(t.text){e.textContent=t.text;return}const i=e;for(const o in t.attributes){const s=t.attributes[o];s===null?i.removeAttribute(o):i.setAttribute(o,s)}for(let o=0;oVw(e,t,i);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,o),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,o)}}}class qA extends Ss{constructor(e){super(e),h(this,"eventNameOrFunction"),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,i){const o=(s,r)=>{(!t||r.target.matches(t))&&(typeof this.eventNameOrFunction=="function"?this.eventNameOrFunction(r):this.observable.fire(this.eventNameOrFunction,r))};return this.emitter.listenTo(i.node,e,o),()=>{this.emitter.stopListening(i.node,e,o)}}}class Iw extends Ss{constructor(e){super(e),h(this,"valueIfTrue"),this.valueIfTrue=e.valueIfTrue}getValue(e){const t=super.getValue(e);return uo(t)?!1:this.valueIfTrue||!0}}function ur(n){return n?(n.value&&(n=n.value),Array.isArray(n)?n.some(ur):n instanceof Ss):!1}function GA(n,e){return n.map(t=>t instanceof Ss?t.getValue(e):t)}function Vw(n,e,{node:t}){const i=GA(n,t);let o;n.length==1&&n[0]instanceof Iw?o=i[0]:o=i.reduce(Ow,""),uo(o)?e.remove():e.set(o)}function KA(n){return{set(e){n.textContent=e},remove(){n.textContent=""}}}function ZA(n,e,t){return{set(i){n.setAttributeNS(t,e,i)},remove(){n.removeAttributeNS(t,e)}}}function JA(n,e){return{set(t){n.style[e]=t},remove(){n.style[e]=null}}}function Ld(n){return Xr(n,e=>{if(e&&(e instanceof Ss||uu(e)||Fr(e)||hu(e)))return e})}function Fd(n){if(typeof n=="string"?n=XA(n):n.text&&ex(n),n.on&&(n.eventListeners=YA(n.on),delete n.on),!n.text){n.attributes&&QA(n.attributes);const e=[];if(n.children)if(hu(n.children))e.push(n.children);else for(const t of n.children)uu(t)||Fr(t)||Zi(t)?e.push(t):e.push(new qt(t));n.children=e}return n}function QA(n){for(const e in n)n[e].value&&(n[e].value=he(n[e].value)),Rw(n,e)}function YA(n){for(const e in n)Rw(n,e);return n}function XA(n){return{text:[n]}}function ex(n){n.text=he(n.text)}function Rw(n,e){n[e]=he(n[e])}function Ow(n,e){return uo(e)?n:uo(n)?e:`${n} ${e}`}function Nd(n,e){for(const t in e)n[t]?n[t].push(...e[t]):n[t]=e[t]}function Bw(n,e){if(e.attributes&&(n.attributes||(n.attributes={}),Nd(n.attributes,e.attributes)),e.eventListeners&&(n.eventListeners||(n.eventListeners={}),Nd(n.eventListeners,e.eventListeners)),e.text&&n.text.push(...e.text),e.children&&e.children.length){if(n.children.length!=e.children.length)throw new b("ui-template-extend-children-mismatch",n);let t=0;for(const i of e.children)Bw(n.children[t++],i)}}function uo(n){return!n&&n!==0}function Fr(n){return n instanceof A}function uu(n){return n instanceof qt}function hu(n){return n instanceof Ie}function Dd(n){return Et(n[0])&&n[0].ns}function zd(){return{children:[],bindings:[],attributes:{}}}function Hd(n){return n=="class"||n=="style"}class A extends st(ue()){constructor(e){super(),h(this,"element"),h(this,"isRendered"),h(this,"locale"),h(this,"t"),h(this,"template"),h(this,"_viewCollections"),h(this,"_unboundChildren"),h(this,"_bindTemplate"),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,i)=>{i.locale=e,i.t=e&&e.t}),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=qt.bind(this,this)}createCollection(e){const t=new Ie(e);return this._viewCollections.add(t),t}registerChild(e){Pt(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){Pt(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new qt(e)}extendTemplate(e){qt.extend(this.template,e)}render(){if(this.isRendered)throw new b("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-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function $t({emitter:n,activator:e,callback:t,contextElements:i,listenerOptions:o}){n.listenTo(document,"mousedown",(s,r)=>{if(!e())return;const a=typeof r.composedPath=="function"?r.composedPath():[],l=typeof i=="function"?i():i;for(const c of l)if(c.contains(r.target)||a.includes(c))return;t()},o)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ho(n){class e extends n{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...i){super(...i),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ri({view:n}){n.listenTo(n.element,"submit",(e,t)=>{t.preventDefault(),n.fire("submit")},{useCapture:!0})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function vo({keystrokeHandler:n,focusTracker:e,gridItems:t,numberOfColumns:i,uiLanguageDirection:o}){const s=typeof i=="number"?()=>i:i;n.set("arrowright",r((c,u)=>o==="rtl"?l(c,u.length):a(c,u.length))),n.set("arrowleft",r((c,u)=>o==="rtl"?a(c,u.length):l(c,u.length))),n.set("arrowup",r((c,u)=>{let d=c-s();return d<0&&(d=c+s()*Math.floor(u.length/s()),d>u.length-1&&(d-=s())),d})),n.set("arrowdown",r((c,u)=>{let d=c+s();return d>u.length-1&&(d=c%s()),d}));function r(c){return u=>{const d=t.find(g=>g.element===e.focusedElement),m=t.getIndex(d),f=c(m,t);t.get(f).focus(),u.stopPropagation(),u.preventDefault()}}function a(c,u){return c===u-1?0:c+1}function l(c,u){return c===0?u-1:c-1}}const Mw=class Lw extends A{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.set("isVisible",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon",e.if("isVisible","ck-hidden",t=>!t),"ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox"),"aria-hidden":!0}})}render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",()=>{this._updateXMLContent(),this._colorFillPaths()}),this.on("change:fillColor",()=>{this._colorFillPaths()})}_updateXMLContent(){if(this.content){const e=new DOMParser().parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg");if(!e)throw new b("ui-iconview-invalid-svg",this);const t=e.getAttribute("viewBox");t&&(this.viewBox=t);for(const{name:i,value:o}of Array.from(e.attributes))Lw.presentationalAttributeNames.includes(i)&&this.element.setAttribute(i,o);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;e.childNodes.length>0;)this.element.appendChild(e.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach(e=>{e.style.fill=this.fillColor})}};h(Mw,"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"]);let hi=Mw;class Fw extends A{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:e.to("style"),id:e.to("id")},children:[{text:e.to("text")}]})}}class P extends A{constructor(e,t=new Fw){super(e),h(this,"children"),h(this,"labelView"),h(this,"iconView"),h(this,"keystrokeView"),h(this,"_focusDelayed",null);const i=this.bindTemplate,o=ze();this.set("_ariaPressed",!1),this.set("_ariaChecked",!1),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${o}`),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._setupLabelView(t),this.iconView=new hi,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.iconView.bind("content").to(this,"icon"),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const s={tag:"button",attributes:{class:["ck","ck-button",i.to("class"),i.if("isEnabled","ck-disabled",r=>!r),i.if("isVisible","ck-hidden",r=>!r),i.to("isOn",r=>r?"ck-on":"ck-off"),i.if("withText","ck-button_with-text"),i.if("withKeystroke","ck-button_with-keystroke")],role:i.to("role"),type:i.to("type",r=>r||"button"),tabindex:i.to("tabindex"),"aria-checked":i.to("_ariaChecked"),"aria-pressed":i.to("_ariaPressed"),"aria-label":i.to("ariaLabel"),"aria-labelledby":i.to("ariaLabelledBy"),"aria-disabled":i.if("isEnabled",!0,r=>!r),"data-cke-tooltip-text":i.to("_tooltipString"),"data-cke-tooltip-position":i.to("tooltipPosition")},children:this.children,on:{click:i.to(r=>{this.isEnabled?this.fire("execute"):r.preventDefault()})}};this.bind("_ariaPressed").to(this,"isOn",this,"isToggleable",this,"role",(r,a,l)=>!a||$d(l)?!1:String(!!r)),this.bind("_ariaChecked").to(this,"isOn",this,"isToggleable",this,"role",(r,a,l)=>!a||!$d(l)?!1:String(!!r)),N.isSafari&&(this._focusDelayed||(this._focusDelayed=$c(()=>this.focus(),0)),s.on.mousedown=i.to(()=>{this._focusDelayed()}),s.on.mouseup=i.to(()=>{this._focusDelayed.cancel()})),this.setTemplate(s)}render(){super.render(),this.icon&&this.children.add(this.iconView),this.on("change:icon",(e,t,i,o)=>{i&&!o?this.children.add(this.iconView,0):!i&&o&&this.children.remove(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()}_setupLabelView(e){return e.bind("text","style","id").to(this,"label","labelStyle","ariaLabelledBy"),e}_createKeystrokeView(){const e=new A;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",t=>ph(t))}]}),e}_getTooltipString(e,t,i){return e?typeof e=="string"?e:(i&&(i=ph(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}function $d(n){switch(n){case"radio":case"checkbox":case"option":case"switch":case"menuitemcheckbox":case"menuitemradio":return!0;default:return!1}}class Jt extends A{constructor(e,t={}){super(e),h(this,"children"),h(this,"iconView");const i=this.bindTemplate;this.set("label",t.label||""),this.set("class",t.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",i.to("class")]},children:this.children}),t.icon&&(this.iconView=new hi,this.iconView.content=t.icon,this.children.add(this.iconView));const o=new A(e);o.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"],role:"presentation"},children:[{text:i.to("label")}]}),this.children.add(o)}}class Ae extends ge(){constructor(e){if(super(),h(this,"focusables"),h(this,"focusTracker"),h(this,"keystrokeHandler"),h(this,"actions"),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 i=e.actions[t];typeof i=="string"&&(i=[i]);for(const o of i)e.keystrokeHandler.set(o,(s,r)=>{this[t](),r()},e.keystrokeHandlerOptions)}this.on("forwardCycle",()=>this.focusFirst(),{priority:"low"}),this.on("backwardCycle",()=>this.focusLast(),{priority:"low"})}get first(){return this.focusables.find(Ja)||null}get last(){return this.focusables.filter(Ja).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-1)}get current(){let e=null;return this.focusTracker.focusedElement===null?null:(this.focusables.find((t,i)=>{const o=t.element===this.focusTracker.focusedElement;return o&&(e=i),o}),e)}focusFirst(){this._focus(this.first,1)}focusLast(){this._focus(this.last,-1)}focusNext(){const e=this.next;if(e&&this.focusables.getIndex(e)===this.current){this.fire("forwardCycle");return}e===this.first?this.fire("forwardCycle"):this._focus(e,1)}focusPrevious(){const e=this.previous;if(e&&this.focusables.getIndex(e)===this.current){this.fire("backwardCycle");return}e===this.last?this.fire("backwardCycle"):this._focus(e,-1)}chain(e){const t=()=>this.current===null?null:this.focusables.get(this.current);this.listenTo(e,"forwardCycle",i=>{const o=t();this.focusNext(),o!==t()&&i.stop()},{priority:"low"}),this.listenTo(e,"backwardCycle",i=>{const o=t();this.focusPrevious(),o!==t()&&i.stop()},{priority:"low"})}unchain(e){this.stopListening(e)}_focus(e,t){e&&this.focusTracker.focusedElement!==e.element&&e.focus(t)}_getDomFocusableItem(e){const t=this.focusables.length;if(!t)return null;const i=this.current;if(i===null)return this[e===1?"first":"last"];let o=this.focusables.get(i),s=(i+t+e)%t;do{const r=this.focusables.get(s);if(Ja(r)){o=r;break}s=(s+t+e)%t}while(s!==i);return o}}function Ja(n){return yo(n)&&Gt(n.element)}function yo(n){return"focus"in n&&typeof n.focus=="function"}function Nw(n){return yo(n)&&"focusCycler"in n&&n.focusCycler instanceof Ae}function tx(n){class e extends n{constructor(...i){super(...i),h(this,"_onDragBound",this._onDrag.bind(this)),h(this,"_onDragEndBound",this._onDragEnd.bind(this)),h(this,"_lastDraggingCoordinates",{x:0,y:0}),this.on("render",()=>{this._attachListeners()}),this.set("isDragging",!1)}_attachListeners(){this.listenTo(this.element,"mousedown",this._onDragStart.bind(this)),this.listenTo(this.element,"touchstart",this._onDragStart.bind(this))}_attachDragListeners(){this.listenTo(I.document,"mouseup",this._onDragEndBound),this.listenTo(I.document,"touchend",this._onDragEndBound),this.listenTo(I.document,"mousemove",this._onDragBound),this.listenTo(I.document,"touchmove",this._onDragBound)}_detachDragListeners(){this.stopListening(I.document,"mouseup",this._onDragEndBound),this.stopListening(I.document,"touchend",this._onDragEndBound),this.stopListening(I.document,"mousemove",this._onDragBound),this.stopListening(I.document,"touchmove",this._onDragBound)}_onDragStart(i,o){if(!this._isHandleElementPressed(o))return;this._attachDragListeners();let s=0,r=0;o instanceof MouseEvent?(s=o.clientX,r=o.clientY):(s=o.touches[0].clientX,r=o.touches[0].clientY),this._lastDraggingCoordinates={x:s,y:r},this.isDragging=!0}_onDrag(i,o){if(!this.isDragging){this._detachDragListeners();return}let s=0,r=0;o instanceof MouseEvent?(s=o.clientX,r=o.clientY):(s=o.touches[0].clientX,r=o.touches[0].clientY),o.preventDefault(),this.fire("drag",{deltaX:Math.round(s-this._lastDraggingCoordinates.x),deltaY:Math.round(r-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:s,y:r}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(i){return this.dragHandleElement?this.dragHandleElement===i.target||i.target instanceof HTMLElement&&this.dragHandleElement.contains(i.target):!1}}return e}class ix extends A{constructor(e){super(e),h(this,"children"),h(this,"keystrokes"),h(this,"focusCycler"),h(this,"_focusTracker"),h(this,"_focusables"),this.children=this.createCollection(),this.keystrokes=new te,this._focusTracker=new ee,this._focusables=new Ie,this.focusCycler=new Ae({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__actions"]},children:this.children})}render(){super.render(),this.keystrokes.listenTo(this.element)}setButtons(e){for(const t of e){const i=new P(this.locale);let o;i.on("execute",()=>t.onExecute()),t.onCreate&&t.onCreate(i);for(o in t)o!="onExecute"&&o!="onCreate"&&i.set(o,t[o]);this.children.add(i)}this._updateFocusCyclableItems()}focus(e){e===-1?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}}class nx extends A{constructor(e){super(e),h(this,"children"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__content"]},children:this.children})}reset(){for(;this.children.length;)this.children.remove(0)}}const vt={SCREEN_CENTER:"screen-center",EDITOR_CENTER:"editor-center",EDITOR_TOP_SIDE:"editor-top-side",EDITOR_TOP_CENTER:"editor-top-center",EDITOR_BOTTOM_CENTER:"editor-bottom-center",EDITOR_ABOVE_CENTER:"editor-above-center",EDITOR_BELOW_CENTER:"editor-below-center"},Wd=Vi("px"),Dw=class zw extends tx(A){constructor(e,{getCurrentDomRoot:t,getViewportOffset:i,keystrokeHandlerOptions:o}){super(e),h(this,"parts"),h(this,"headerView"),h(this,"closeButtonView"),h(this,"actionsView"),h(this,"contentView"),h(this,"keystrokes"),h(this,"focusTracker"),h(this,"wasMoved",!1),h(this,"_getCurrentDomRoot"),h(this,"_getViewportOffset"),h(this,"_focusables"),h(this,"_focusCycler");const s=this.bindTemplate,r=e.t;this.set("className",""),this.set("ariaLabel",r("Editor dialog")),this.set("isModal",!1),this.set("position",vt.SCREEN_CENTER),this.set("_isVisible",!1),this.set("_isTransparent",!1),this.set("_top",0),this.set("_left",0),this._getCurrentDomRoot=t,this._getViewportOffset=i,this.decorate("moveTo"),this.parts=this.createCollection(),this.keystrokes=new te,this.focusTracker=new ee,this._focusables=new Ie,this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"},keystrokeHandlerOptions:o}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog-overlay",s.if("isModal","ck-dialog-overlay__transparent",a=>!a),s.if("_isVisible","ck-hidden",a=>!a)],tabindex:"-1"},children:[{tag:"div",attributes:{tabindex:"-1",class:["ck","ck-dialog",s.if("isModal","ck-dialog_modal"),s.to("className")],role:"dialog","aria-label":s.to("ariaLabel"),style:{top:s.to("_top",a=>Wd(a)),left:s.to("_left",a=>Wd(a)),visibility:s.if("_isTransparent","hidden")}},children:this.parts}]})}render(){super.render(),this.keystrokes.set("Esc",(e,t)=>{e.defaultPrevented||(this.fire("close",{source:"escKeyPress"}),t())}),this.on("drag",(e,{deltaX:t,deltaY:i})=>{this.wasMoved=!0,this.moveBy(t,i)}),this.listenTo(I.window,"resize",()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.listenTo(I.document,"scroll",()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.on("change:_isVisible",(e,t,i)=>{i&&(this._isTransparent=!0,setTimeout(()=>{this.updatePosition(),this._isTransparent=!1,this.focus()},10))}),this.keystrokes.listenTo(this.element)}get dragHandleElement(){return this.headerView&&!this.isModal?this.headerView.element:null}setupParts({icon:e,title:t,hasCloseButton:i=!0,content:o,actionButtons:s}){t&&(this.headerView=new Jt(this.locale,{icon:e}),i&&(this.closeButtonView=this._createCloseButton(),this.headerView.children.add(this.closeButtonView)),this.headerView.label=t,this.ariaLabel=t,this.parts.add(this.headerView,0)),o&&(o instanceof A&&(o=[o]),this.contentView=new nx(this.locale),this.contentView.children.addMany(o),this.parts.add(this.contentView)),s&&(this.actionsView=new ix(this.locale),this.actionsView.setButtons(s),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(e,t){const i=this._getViewportRect(),o=this._getDialogRect();e+o.width>i.right&&(e=i.right-o.width),e{this._focusables.add(t),this.focusTracker.add(t.element),Nw(t)&&this._focusCycler.chain(t.focusCycler)})}_createCloseButton(){const e=new P(this.locale),t=this.locale.t;return e.set({label:t("Close"),tooltip:!0,icon:_o}),e.on("execute",()=>this.fire("close",{source:"closeButton"})),e}};h(Dw,"defaultOffset",15);let ox=Dw;const Hw=class wi extends w{constructor(e){super(e),h(this,"view"),h(this,"_onHide");const t=e.t;this._initShowHideListeners(),this._initFocusToggler(),this._initMultiRootIntegration(),this.set({id:null,isOpen:!1}),e.accessibility.addKeystrokeInfos({categoryId:"navigation",keystrokes:[{label:t("Move focus in and out of an active dialog window"),keystroke:"Ctrl+F6",mayRequireFn:!0}]})}static get pluginName(){return"Dialog"}static get isOfficialPlugin(){return!0}destroy(){super.destroy(),wi._visibleDialogPlugin===this&&this._unlockBodyScroll()}_initShowHideListeners(){this.on("show",(e,t)=>{this._show(t)}),this.on("show",(e,t)=>{t.onShow&&t.onShow(this)},{priority:"low"}),this.on("hide",()=>{wi._visibleDialogPlugin&&wi._visibleDialogPlugin._hide()}),this.on("hide",()=>{this._onHide&&(this._onHide(this),this._onHide=void 0)},{priority:"low"})}_initFocusToggler(){const e=this.editor;e.keystrokes.set("Ctrl+F6",(t,i)=>{!this.isOpen||this.view.isModal||(this.view.focusTracker.isFocused?e.editing.view.focus():this.view.focus(),i())})}_initMultiRootIntegration(){const e=this.editor.model;e.document.on("change:data",()=>{if(!this.view)return;const t=e.document.differ.getChangedRoots();for(const i of t)i.state&&this.view.updatePosition()})}show(e){this.hide(),this.fire(`show:${e.id}`,e)}_show({id:e,icon:t,title:i,hasCloseButton:o=!0,content:s,actionButtons:r,className:a,isModal:l,position:c,onHide:u,keystrokeHandlerOptions:d}){const m=this.editor;this.view=new ox(m.locale,{getCurrentDomRoot:()=>m.editing.view.getDomRoot(m.model.document.selection.anchor.root.rootName),getViewportOffset:()=>m.ui.viewportOffset,keystrokeHandlerOptions:d});const f=this.view;f.on("close",()=>{this.hide()}),m.ui.view.body.add(f),m.keystrokes.listenTo(f.element),c||(c=l?vt.SCREEN_CENTER:vt.EDITOR_CENTER),l&&this._lockBodyScroll(),f.set({position:c,_isVisible:!0,className:a,isModal:l}),f.setupParts({icon:t,title:i,hasCloseButton:o,content:s,actionButtons:r}),this.id=e,u&&(this._onHide=u),this.isOpen=!0,wi._visibleDialogPlugin=this}hide(){wi._visibleDialogPlugin&&wi._visibleDialogPlugin.fire(`hide:${wi._visibleDialogPlugin.id}`)}_hide(){if(!this.view)return;const e=this.editor,t=this.view;t.isModal&&this._unlockBodyScroll(),t.contentView&&t.contentView.reset(),e.ui.view.body.remove(t),e.ui.focusTracker.remove(t.element),e.keystrokes.stopListening(t.element),t.destroy(),e.editing.view.focus(),this.id=null,this.isOpen=!1,wi._visibleDialogPlugin=null}_lockBodyScroll(){document.documentElement.classList.add("ck-dialog-scroll-locked")}_unlockBodyScroll(){document.documentElement.classList.remove("ck-dialog-scroll-locked")}};h(Hw,"_visibleDialogPlugin");let du=Hw;class ko extends P{constructor(e,t=new Fw){super(e,t),h(this,"_checkIconHolderView",new sx),this.set({hasCheckSpace:!1,_hasCheck:this.isToggleable});const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-list-item-button",i.if("isToggleable","ck-list-item-button_toggleable")]}}),this.bind("_hasCheck").to(this,"hasCheckSpace",this,"isToggleable",(o,s)=>o||s)}render(){super.render(),this._hasCheck&&this.children.add(this._checkIconHolderView,0),this._watchCheckIconHolderMount()}_watchCheckIconHolderMount(){this._checkIconHolderView.bind("isOn").to(this,"isOn",e=>this.isToggleable&&e),this.on("change:_hasCheck",(e,t,i)=>{const{children:o,_checkIconHolderView:s}=this;i?o.add(s,0):o.remove(s)})}}class sx extends A{constructor(){super(),h(this,"children"),h(this,"_checkIconView",this._createCheckIconView());const e=this.bindTemplate;this.children=this.createCollection(),this.set("isOn",!1),this.setTemplate({tag:"span",children:this.children,attributes:{class:["ck","ck-list-item-button__check-holder",e.to("isOn",t=>t?"ck-on":"ck-off")]}})}render(){super.render(),this.isOn&&this.children.add(this._checkIconView,0),this._watchCheckIconMount()}_watchCheckIconMount(){this.on("change:isOn",(e,t,i)=>{const{children:o,_checkIconView:s}=this;i&&!o.has(s)?o.add(s):!i&&o.has(s)&&o.remove(s)})}_createCheckIconView(){const e=new hi;return e.content=Es,e.extendTemplate({attributes:{class:"ck-list-item-button__check-icon"}}),e}}class ve extends ko{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}class xt extends A{constructor(e){super(e),h(this,"id"),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${ze()}`;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")}]})}}const $w=class ei extends Ie{constructor(e,t=[]){super(t),h(this,"locale"),h(this,"_bodyCollectionContainer"),this.locale=e}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new qt({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection,role:"application"},children:this}).render(),(!ei._bodyWrapper||!ei._bodyWrapper.isConnected)&&(ei._bodyWrapper=Ll(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(ei._bodyWrapper)),ei._bodyWrapper.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove(),ei._bodyWrapper&&!ei._bodyWrapper.childElementCount&&(ei._bodyWrapper.remove(),delete ei._bodyWrapper)}};h($w,"_bodyWrapper");let rx=$w;class Ji extends P{constructor(e){super(e),h(this,"toggleSwitchView"),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 A;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}class jd extends Ww(P){}class ax extends Ww(ko){}function Ww(n){class e extends n{constructor(...i){super(...i),h(this,"buttonView"),h(this,"_fileInputView"),this.buttonView=this,this._fileInputView=new lx(this.locale),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.on("execute",()=>{this._fileInputView.open()}),this.extendTemplate({attributes:{class:"ck-file-dialog-button"}})}render(){super.render(),this.children.add(this._fileInputView)}}return e}class lx extends A{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(()=>{var i,o;(o=(i=this.element)==null?void 0:i.files)!=null&&o.length&&this.fire("done",this.element.files),this.element.value=""})}})}open(){this.element.click()}}class mu extends A{constructor(e,t){super(e),h(this,"buttonView"),h(this,"children");const i=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid",void 0),t&&this.children.addMany(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",i.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:i.if("isCollapsed","hidden"),"aria-labelledby":i.to("_collapsibleAriaLabelUid")},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}focus(){this.buttonView.focus()}_createButtonView(){const e=new P(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:da}),e.extendTemplate({attributes:{"aria-expanded":t.to("isOn",i=>String(i))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",i=>!i),e.on("execute",()=>{this.isCollapsed=!this.isCollapsed}),e}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ps(n,e){const t=n.t,i={Black:t("Black"),"Dim grey":t("Dim grey"),Grey:t("Grey"),"Light grey":t("Light grey"),White:t("White"),Red:t("Red"),Orange:t("Orange"),Yellow:t("Yellow"),"Light green":t("Light green"),Green:t("Green"),Aquamarine:t("Aquamarine"),Turquoise:t("Turquoise"),"Light blue":t("Light blue"),Blue:t("Blue"),Purple:t("Purple")};return e.map(o=>{const s=i[o.label];return s&&s!=o.label&&(o.label=s),o})}function ws(n){return n.map(cx).filter(e=>!!e)}function cx(n){return typeof n=="string"?{model:n,label:n,hasBorder:!1,view:{name:"span",styles:{color:n}}}:{model:n.color,label:n.label||n.color,hasBorder:n.hasBorder===void 0?!1:n.hasBorder,view:{name:"span",styles:{color:`${n.color}`}}}}class jw extends P{constructor(e){super(e);const t=this.bindTemplate;this.set("color",void 0),this.set("hasBorder",!1),this.icon=bC,this.extendTemplate({attributes:{style:{backgroundColor:t.to("color",i=>N.isMediaForcedColors?null:i)},class:["ck","ck-color-grid__tile",t.if("hasBorder","ck-color-selector__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}class Ud extends A{constructor(e,t){super(e),h(this,"columns"),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes");const i=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t?.columns||5;const o={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this.items.on("add",(s,r)=>{r.isOn=r.color===this.selectedColor}),i.forEach(s=>{const r=new jw;r.set({color:s.color,label:s.label,tooltip:!0,hasBorder:s.options.hasBorder}),r.on("execute",()=>{this.fire("execute",{value:s.color,hasBorder:s.options.hasBorder,label:s.label})}),this.items.add(r)}),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:o}}),this.on("change:selectedColor",(s,r,a)=>{for(const l of this.items)l.isOn=l.color===a})}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){var e;super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",(t,i)=>{this.focusTracker.add(i.element)}),this.items.on("remove",(t,i)=>{this.focusTracker.remove(i.element)}),this.keystrokes.listenTo(this.element),vo({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:(e=this.locale)==null?void 0:e.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Uw(n,e){if(!n)return"";const t=qw(n);if(!t)return"";if(t.space===e)return n;if(!mx(t))return"";const i=Tw[t.space][e];if(!i)return"";const o=i(t.space==="hex"?t.hexValue:t.values);return dx(o,e)}function ux(n){if(!n)return"";const e=qw(n);return e?e.space==="hex"?e.hexValue:Uw(n,"hex"):"#000"}function hx(n,e){customElements.get(n)===void 0&&customElements.define(n,e)}function dx(n,e){switch(e){case"hex":return`#${n}`;case"rgb":return`rgb(${n[0]}, ${n[1]}, ${n[2]})`;case"hsl":return`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`;case"hwb":return`hwb(${n[0]}, ${n[1]}, ${n[2]})`;case"lab":return`lab(${n[0]}% ${n[1]} ${n[2]})`;case"lch":return`lch(${n[0]}% ${n[1]} ${n[2]})`;default:return""}}function qw(n){if(n.startsWith("#")){const t=Td(n);return{space:"hex",values:t.values,hexValue:n,alpha:t.alpha}}const e=Td(n);return e.space?e:null}function mx(n){return Object.keys(Tw).includes(n.space)}class Te extends A{constructor(e,t){super(e),h(this,"fieldView"),h(this,"labelView"),h(this,"statusView"),h(this,"fieldWrapperChildren");const i=`ck-labeled-field-view-${ze()}`,o=`ck-labeled-field-view-status-${ze()}`;this.fieldView=t(this,i,o),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(i),this.statusView=this._createStatusView(o),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",(r,a)=>r||a);const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",s.to("class"),s.if("isEnabled","ck-disabled",r=>!r),s.if("isEmpty","ck-labeled-field-view_empty"),s.if("isFocused","ck-labeled-field-view_focused"),s.if("placeholder","ck-labeled-field-view_placeholder"),s.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 xt(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new A(this.locale),i=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",i.if("errorText","ck-labeled-field-view__status_error"),i.if("_statusText","ck-hidden",o=>!o)],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}focus(e){this.fieldView.focus(e)}}class Gw extends A{constructor(e){super(e),h(this,"focusTracker"),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("tabIndex",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.set("ariaLabel",void 0),this.focusTracker=new ee,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);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"),tabindex:t.to("tabIndex"),readonly:t.to("isReadOnly"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById"),"aria-label":t.to("ariaLabel")},on:{input:t.to((...i)=>{this.fire("input",...i),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,i)=>{this._setDomElementValue(i),this._updateIsEmpty()})}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}reset(){this.value=this.element.value="",this._updateIsEmpty()}_updateIsEmpty(){this.isEmpty=fx(this.element)}_setDomElementValue(e){this.element.value=!e&&e!==0?"":e}}function fx(n){return!n.value}class Kw extends Gw{constructor(e){super(e),this.set("inputMode","text");const t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to("inputMode")}})}}class Zw extends Kw{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class gx extends Kw{constructor(e,{min:t,max:i,step:o}={}){super(e);const s=this.bindTemplate;this.set("min",t),this.set("max",i),this.set("step",o),this.extendTemplate({attributes:{type:"number",class:["ck-input-number"],min:s.to("min"),max:s.to("max"),step:s.to("step")}})}}class px extends Gw{constructor(e){super(e),h(this,"_resizeObserver"),h(this,"_isUpdateAutoGrowHeightPending",!1);const t=Vi("px");this.set("minRows",2),this.set("maxRows",5),this.set("_height",null),this.set("resize","none"),this._resizeObserver=null,this.on("change:minRows",this._validateMinMaxRows.bind(this)),this.on("change:maxRows",this._validateMinMaxRows.bind(this));const i=this.bindTemplate;this.template.tag="textarea",this.extendTemplate({attributes:{class:["ck-textarea"],style:{height:i.to("_height",o=>o?t(o):null),resize:i.to("resize")},rows:i.to("minRows")}})}render(){super.render();let e=!1;this.on("input",()=>{this._updateAutoGrowHeight(!0),this.fire("update")}),this.on("change:value",()=>{I.window.requestAnimationFrame(()=>{if(!Gt(this.element)){this._isUpdateAutoGrowHeightPending=!0;return}this._updateAutoGrowHeight(),this.fire("update")})}),this._resizeObserver=new bo(this.element,t=>{const i=!!t.contentRect.width&&!!t.contentRect.height;!e&&i&&this._isUpdateAutoGrowHeightPending&&I.window.requestAnimationFrame(()=>{this._updateAutoGrowHeight(),this.fire("update")}),e=i})}destroy(){this._resizeObserver&&this._resizeObserver.destroy()}reset(){super.reset(),this._updateAutoGrowHeight(),this.fire("update")}_updateAutoGrowHeight(e){const t=this.element;if(!t.offsetParent){this._isUpdateAutoGrowHeightPending=!0;return}this._isUpdateAutoGrowHeightPending=!1;const i=qd(t,"1"),o=qd(t,t.value),s=i.ownerDocument.defaultView.getComputedStyle(i),r=parseFloat(s.paddingTop)+parseFloat(s.paddingBottom),a=Dc(i),l=parseFloat(s.lineHeight),c=a.top+a.bottom,u=new z(i).height,d=Math.round((o.scrollHeight-r)/l),m=this.maxRows*l+r+c,f=d===1?u:this.minRows*l+r+c;this._height=Math.min(Math.max(Math.max(d,this.minRows)*l+r+c,f),m),e&&(t.scrollTop=t.scrollHeight),i.remove(),o.remove()}_validateMinMaxRows(){if(this.minRows>this.maxRows)throw new b("ui-textarea-view-min-rows-greater-than-max-rows",{textareaView:this,minRows:this.minRows,maxRows:this.maxRows})}}function qd(n,e){const t=n.cloneNode();return t.style.position="absolute",t.style.top="-99999px",t.style.left="-99999px",t.style.height="auto",t.style.overflow="hidden",t.style.width=n.ownerDocument.defaultView.getComputedStyle(n).width,t.tabIndex=-1,t.rows=1,t.value=e,n.parentNode.insertBefore(t,n),t}class wx extends A{constructor(e){super(e),h(this,"children");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",i=>`ck-dropdown__panel_${i}`),t.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:t.to(i=>{i.target.tagName.toLocaleLowerCase()!=="input"&&i.preventDefault()})}})}focus(){if(this.children.length){const e=this.children.first;typeof e.focus=="function"?e.focus():J("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()}}}const Xl=class ec extends A{constructor(e,t,i){super(e),h(this,"buttonView"),h(this,"panelView"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"listView"),h(this,"toolbarView"),h(this,"menuView");const o=this.bindTemplate;this.buttonView=t,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new te,this.focusTracker=new ee,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",o.to("class"),o.if("isEnabled","ck-disabled",s=>!s)],id:o.to("id"),"aria-describedby":o.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":o.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.on("change:isOpen",(t,i,o)=>{if(o)if(this.panelPosition==="auto"){const s=ec._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=s?s.name:this._defaultPanelPositionName}else this.panelView.position=this.panelPosition}),this.keystrokes.listenTo(this.element);const e=(t,i)=>{this.isOpen&&(this.isOpen=!1,i())};this.keystrokes.set("arrowdown",(t,i)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,i())}),this.keystrokes.set("arrowright",(t,i)=>{this.isOpen&&i()}),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:i,southWest:o,northEast:s,northWest:r,southMiddleEast:a,southMiddleWest:l,northMiddleEast:c,northMiddleWest:u}=ec.defaultPanelPositions;return this.locale.uiLanguageDirection!=="rtl"?[i,o,a,l,e,s,r,c,u,t]:[o,i,l,a,e,r,s,u,c,t]}get _defaultPanelPositionName(){return this.locale.uiLanguageDirection==="rtl"?"sw":"se"}};h(Xl,"defaultPanelPositions",{south:(n,e)=>({top:n.bottom,left:n.left-(e.width-n.width)/2,name:"s"}),southEast:n=>({top:n.bottom,left:n.left,name:"se"}),southWest:(n,e)=>({top:n.bottom,left:n.left-e.width+n.width,name:"sw"}),southMiddleEast:(n,e)=>({top:n.bottom,left:n.left-(e.width-n.width)/4,name:"sme"}),southMiddleWest:(n,e)=>({top:n.bottom,left:n.left-(e.width-n.width)*3/4,name:"smw"}),north:(n,e)=>({top:n.top-e.height,left:n.left-(e.width-n.width)/2,name:"n"}),northEast:(n,e)=>({top:n.top-e.height,left:n.left,name:"ne"}),northWest:(n,e)=>({top:n.top-e.height,left:n.left-e.width+n.width,name:"nw"}),northMiddleEast:(n,e)=>({top:n.top-e.height,left:n.left-(e.width-n.width)/4,name:"nme"}),northMiddleWest:(n,e)=>({top:n.top-e.height,left:n.left-(e.width-n.width)*3/4,name:"nmw"})}),h(Xl,"_getOptimalPosition",zc);let Jw=Xl;class fu extends P{constructor(e){super(e),h(this,"arrowView"),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 hi;return e.content=da,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class Nt extends A{constructor(e){super(e),h(this,"children");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",i=>!i)],role:"presentation"},children:this.children})}focus(){this.children.first&&this.children.first.focus()}}class ma extends A{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class hr extends A{constructor(e,t=new xt){super(e),h(this,"labelView"),h(this,"items"),h(this,"children");const i=this.bindTemplate,o=new En(e);this.set({label:"",isVisible:!0}),this.labelView=t,this.labelView.bind("text").to(this,"label"),this.children=this.createCollection(),this.children.addMany([this.labelView,o]),o.set({role:"group",ariaLabelledBy:t.id}),o.focusTracker.destroy(),o.keystrokes.destroy(),this.items=o.items,this.setTemplate({tag:"li",attributes:{role:"presentation",class:["ck","ck-list__group",i.if("isVisible","ck-hidden",s=>!s)]},children:this.children})}focus(){if(this.items){const e=this.items.find(t=>!(t instanceof ma));e&&e.focus()}}}class En extends A{constructor(e){super(e),h(this,"focusables"),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"_focusCycler"),h(this,"_listItemGroupToChangeListeners",new WeakMap);const t=this.bindTemplate;this.focusables=new Ie,this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this._focusCycler=new Ae({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",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"),"aria-labelledby":t.to("ariaLabelledBy")},children:this.items})}render(){super.render();for(const e of this.items)e instanceof hr?this._registerFocusableItemsGroup(e):e instanceof Nt&&this._registerFocusableListItem(e);this.items.on("change",(e,t)=>{for(const i of t.removed)i instanceof hr?this._deregisterFocusableItemsGroup(i):i instanceof Nt&&this._deregisterFocusableListItem(i);for(const i of Array.from(t.added).reverse())i instanceof hr?this._registerFocusableItemsGroup(i,t.index):this._registerFocusableListItem(i,t.index)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_registerFocusableListItem(e,t){this.focusTracker.add(e.element),this.focusables.add(e,t)}_deregisterFocusableListItem(e){this.focusTracker.remove(e.element),this.focusables.remove(e)}_getOnGroupItemsChangeCallback(e){return(t,i)=>{for(const o of i.removed)this._deregisterFocusableListItem(o);for(const o of Array.from(i.added).reverse())this._registerFocusableListItem(o,this.items.getIndex(e)+i.index)}}_registerFocusableItemsGroup(e,t){Array.from(e.items).forEach((o,s)=>{const r=typeof t<"u"?t+s:void 0;this._registerFocusableListItem(o,r)});const i=this._getOnGroupItemsChangeCallback(e);this._listItemGroupToChangeListeners.set(e,i),e.items.on("change",i)}_deregisterFocusableItemsGroup(e){for(const t of e.items)this._deregisterFocusableListItem(t);e.items.off("change",this._listItemGroupToChangeListeners.get(e)),this._listItemGroupToChangeListeners.delete(e)}}const Gd=Vi("px"),bx={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}},dn=class Jn extends A{constructor(e){super(e),h(this,"content"),h(this,"_pinWhenIsVisibleCallback"),h(this,"_resizeObserver");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._resizeObserver=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",i=>`ck-balloon-panel_${i}`),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Gd),left:t.to("left",Gd)}},children:this.content})}destroy(){this.hide(),super.destroy()}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){const t=dr(e.target);if(t&&!Gt(t))return!1;this.show();const i=Jn.defaultPositions,o=Object.assign({},{element:this.element,positions:[i.southArrowNorth,i.southArrowNorthMiddleWest,i.southArrowNorthMiddleEast,i.southArrowNorthWest,i.southArrowNorthEast,i.northArrowSouth,i.northArrowSouthMiddleWest,i.northArrowSouthMiddleEast,i.northArrowSouthWest,i.northArrowSouthEast,i.viewportStickyNorth],limiter:I.document.body,fitInViewport:!0},e),s=Jn._getOptimalPosition(o)||bx,r=parseInt(s.left),a=parseInt(s.top),l=s.name,c=s.config||{},{withArrow:u=!0}=c;return this.top=a,this.left=r,this.position=l,this.withArrow=u,!0}pin(e){this.unpin(),this._startPinning(e)&&(this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},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){if(!this.attachTo(e))return!1;let t=dr(e.target);const i=e.limiter?dr(e.limiter):I.document.body;if(this.listenTo(I.document,"scroll",(o,s)=>{const r=s.target,a=t&&r.contains(t),l=i&&r.contains(i);(a||l||!t||!i)&&this.attachTo(e)},{useCapture:!0}),this.listenTo(I.window,"resize",()=>{this.attachTo(e)}),!this._resizeObserver&&(t&&xe(t)&&(t=t.parentElement),t)){const o=()=>{Gt(t)||this.unpin()};this._resizeObserver=new bo(t,o)}return!0}_stopPinning(){this.stopListening(I.document,"scroll"),this.stopListening(I.window,"resize"),this._resizeObserver&&(this._resizeObserver.destroy(),this._resizeObserver=null)}static generatePositions(e={}){const{sideOffset:t=Jn.arrowSideOffset,heightOffset:i=Jn.arrowHeightOffset,stickyVerticalOffset:o=Jn.stickyVerticalOffset,config:s}=e;return{northWestArrowSouthWest:(l,c)=>({top:r(l,c),left:l.left-t,name:"arrow_sw",...s&&{config:s}}),northWestArrowSouthMiddleWest:(l,c)=>({top:r(l,c),left:l.left-c.width*.25-t,name:"arrow_smw",...s&&{config:s}}),northWestArrowSouth:(l,c)=>({top:r(l,c),left:l.left-c.width/2,name:"arrow_s",...s&&{config:s}}),northWestArrowSouthMiddleEast:(l,c)=>({top:r(l,c),left:l.left-c.width*.75+t,name:"arrow_sme",...s&&{config:s}}),northWestArrowSouthEast:(l,c)=>({top:r(l,c),left:l.left-c.width+t,name:"arrow_se",...s&&{config:s}}),northArrowSouthWest:(l,c)=>({top:r(l,c),left:l.left+l.width/2-t,name:"arrow_sw",...s&&{config:s}}),northArrowSouthMiddleWest:(l,c)=>({top:r(l,c),left:l.left+l.width/2-c.width*.25-t,name:"arrow_smw",...s&&{config:s}}),northArrowSouth:(l,c)=>({top:r(l,c),left:l.left+l.width/2-c.width/2,name:"arrow_s",...s&&{config:s}}),northArrowSouthMiddleEast:(l,c)=>({top:r(l,c),left:l.left+l.width/2-c.width*.75+t,name:"arrow_sme",...s&&{config:s}}),northArrowSouthEast:(l,c)=>({top:r(l,c),left:l.left+l.width/2-c.width+t,name:"arrow_se",...s&&{config:s}}),northEastArrowSouthWest:(l,c)=>({top:r(l,c),left:l.right-t,name:"arrow_sw",...s&&{config:s}}),northEastArrowSouthMiddleWest:(l,c)=>({top:r(l,c),left:l.right-c.width*.25-t,name:"arrow_smw",...s&&{config:s}}),northEastArrowSouth:(l,c)=>({top:r(l,c),left:l.right-c.width/2,name:"arrow_s",...s&&{config:s}}),northEastArrowSouthMiddleEast:(l,c)=>({top:r(l,c),left:l.right-c.width*.75+t,name:"arrow_sme",...s&&{config:s}}),northEastArrowSouthEast:(l,c)=>({top:r(l,c),left:l.right-c.width+t,name:"arrow_se",...s&&{config:s}}),southWestArrowNorthWest:l=>({top:a(l),left:l.left-t,name:"arrow_nw",...s&&{config:s}}),southWestArrowNorthMiddleWest:(l,c)=>({top:a(l),left:l.left-c.width*.25-t,name:"arrow_nmw",...s&&{config:s}}),southWestArrowNorth:(l,c)=>({top:a(l),left:l.left-c.width/2,name:"arrow_n",...s&&{config:s}}),southWestArrowNorthMiddleEast:(l,c)=>({top:a(l),left:l.left-c.width*.75+t,name:"arrow_nme",...s&&{config:s}}),southWestArrowNorthEast:(l,c)=>({top:a(l),left:l.left-c.width+t,name:"arrow_ne",...s&&{config:s}}),southArrowNorthWest:l=>({top:a(l),left:l.left+l.width/2-t,name:"arrow_nw",...s&&{config:s}}),southArrowNorthMiddleWest:(l,c)=>({top:a(l),left:l.left+l.width/2-c.width*.25-t,name:"arrow_nmw",...s&&{config:s}}),southArrowNorth:(l,c)=>({top:a(l),left:l.left+l.width/2-c.width/2,name:"arrow_n",...s&&{config:s}}),southArrowNorthMiddleEast:(l,c)=>({top:a(l),left:l.left+l.width/2-c.width*.75+t,name:"arrow_nme",...s&&{config:s}}),southArrowNorthEast:(l,c)=>({top:a(l),left:l.left+l.width/2-c.width+t,name:"arrow_ne",...s&&{config:s}}),southEastArrowNorthWest:l=>({top:a(l),left:l.right-t,name:"arrow_nw",...s&&{config:s}}),southEastArrowNorthMiddleWest:(l,c)=>({top:a(l),left:l.right-c.width*.25-t,name:"arrow_nmw",...s&&{config:s}}),southEastArrowNorth:(l,c)=>({top:a(l),left:l.right-c.width/2,name:"arrow_n",...s&&{config:s}}),southEastArrowNorthMiddleEast:(l,c)=>({top:a(l),left:l.right-c.width*.75+t,name:"arrow_nme",...s&&{config:s}}),southEastArrowNorthEast:(l,c)=>({top:a(l),left:l.right-c.width+t,name:"arrow_ne",...s&&{config:s}}),westArrowEast:(l,c)=>({top:l.top+l.height/2-c.height/2,left:l.left-c.width-i,name:"arrow_e",...s&&{config:s}}),eastArrowWest:(l,c)=>({top:l.top+l.height/2-c.height/2,left:l.right+i,name:"arrow_w",...s&&{config:s}}),viewportStickyNorth:(l,c,u)=>{const d=new z(I.document.body).getIntersection(u.getVisible());if(!d)return null;const m=d.getVisible();return!l.getIntersection(m)||!(m.top-l.top-o{e.target===n.element&&e.preventDefault()})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function gu(n){if(Array.isArray(n))return{items:n,removeItems:[]};const e={items:[],removeItems:[]};return n?{...e,...n}:e}const tc={alignLeft:nu,bold:gw,importExport:BC,paragraph:yw,plus:tA,text:_A,threeVerticalDots:au,pilcrow:eA,dragIndicator:vC};class Ei extends A{constructor(e,t){super(e),h(this,"options"),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"itemsView"),h(this,"children"),h(this,"focusables"),h(this,"_focusCycler"),h(this,"_behavior");const i=this.bindTemplate,o=this.t;this.options=t||{},this.set("ariaLabel",o("Editor toolbar")),this.set("maxWidth","auto"),this.set("role","toolbar"),this.set("isGrouping",!!this.options.shouldGroupWhenFull),this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this.set("class",void 0),this.set("isCompact",!1),this.set("isVertical",!1),this.itemsView=new yx(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const s=e.uiLanguageDirection==="rtl";this._focusCycler=new Ae({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[s?"arrowright":"arrowleft","arrowup"],focusNext:[s?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact"),i.if("isGrouping","ck-toolbar_grouping"),i.if("isVertical","ck-toolbar_vertical")];this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:i.to("role"),"aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:vx(this)}}),this._behavior=this.options.shouldGroupWhenFull?new Zd(this):new Kd(this)}render(){super.render(),this.focusTracker.add(this.element);for(const e of this.items)this.focusTracker.add(e);this.items.on("add",(e,t)=>{this.focusTracker.add(t)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t)}),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,i){this.items.addMany(this._buildItemsFromConfig(e,t,i))}switchBehavior(e){this._behavior.type!==e&&(this._behavior.destroy(),this.itemsView.children.clear(),this.focusables.clear(),e==="dynamic"?(this._behavior=new Zd(this),this._behavior.render(this),this._behavior.refreshItems()):(this._behavior=new Kd(this),this._behavior.render(this)))}_buildItemsFromConfig(e,t,i){const o=gu(e),s=i||o.removeItems;return this._cleanItemsConfiguration(o.items,t,s).map(r=>Et(r)?this._createNestedToolbarDropdown(r,t,s):r==="|"?new Qw:r==="-"?new _x:t.create(r)).filter(r=>!!r)}_cleanItemsConfiguration(e,t,i){const o=e.filter((s,r,a)=>s==="|"?!0:i.indexOf(s)!==-1?!1:s==="-"?this.options.shouldGroupWhenFull?(J("toolbarview-line-break-ignored-when-grouping-items",a),!1):!0:!Et(s)&&!t.has(s)?(J("toolbarview-item-unavailable",{item:s}),!1):!0);return this._cleanSeparatorsAndLineBreaks(o)}_cleanSeparatorsAndLineBreaks(e){const t=r=>r!=="-"&&r!=="|",i=e.length,o=e.findIndex(t);if(o===-1)return[];const s=i-e.slice().reverse().findIndex(t);return e.slice(o,s).filter((r,a,l)=>t(r)?!0:!(a>0&&l[a-1]===r))}_createNestedToolbarDropdown(e,t,i){let{label:o,icon:s,items:r,tooltip:a=!0,withText:l=!1}=e;if(r=this._cleanItemsConfiguration(r,t,i),!r.length)return null;const c=this.locale,u=Ee(c);return o||J("toolbarview-nested-toolbar-dropdown-missing-label",e),u.class="ck-toolbar__nested-toolbar-dropdown",u.buttonView.set({label:o,tooltip:a,withText:!!l}),s!==!1?u.buttonView.icon=tc[s]||s||au:u.buttonView.withText=!0,fa(u,()=>u.toolbarView._buildItemsFromConfig(r,t,i)),u}}class yx extends A{constructor(e){super(e),h(this,"children"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Kd{constructor(e){h(this,"type","static"),e.isGrouping=!1,e.itemsView.children.bindTo(e.items).using(t=>t),e.focusables.bindTo(e.items).using(t=>yo(t)?t:null)}render(){}destroy(){}}class Zd{constructor(e){h(this,"type","dynamic"),h(this,"view"),h(this,"viewChildren"),h(this,"viewFocusables"),h(this,"viewItemsView"),h(this,"viewFocusTracker"),h(this,"viewLocale"),h(this,"ungroupedItems"),h(this,"groupedItems"),h(this,"groupedItemsDropdown"),h(this,"resizeObserver",null),h(this,"cachedPadding",null),h(this,"shouldUpdateGroupingOnNextResize",!1),h(this,"viewElement"),this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.view.isGrouping=!0,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._updateFocusCyclableItems.bind(this)),e.children.on("change",this._updateFocusCyclableItems.bind(this)),e.items.on("change",(t,i)=>{const o=i.index,s=Array.from(i.added);for(const r of i.removed)o>=this.ungroupedItems.length?this.groupedItems.remove(r):this.ungroupedItems.remove(r);for(let r=o;rthis.ungroupedItems.length?this.groupedItems.add(a,r-this.ungroupedItems.length):this.ungroupedItems.add(a,r)}this._updateGrouping()})}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.viewChildren.length>1&&(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last)),this.resizeObserver.destroy()}refreshItems(){const e=this.view;if(e.items.length){for(let t=0;to.right-this.cachedPadding:i.left{(!e||e!==t.contentRect.width||this.shouldUpdateGroupingOnNextResize)&&(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)}),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",()=>{this._updateGrouping()})}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new Qw),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,i=Ee(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition=e.uiLanguageDirection==="ltr"?"sw":"se",fa(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:e.uiLanguageDirection==="rtl"?"se":"sw",icon:au}),i}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map(e=>{yo(e)&&this.viewFocusables.add(e)}),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class Xi extends A{constructor(e,t){super(e),h(this,"children"),h(this,"actionView"),h(this,"arrowView"),h(this,"keystrokes"),h(this,"focusTracker");const i=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(t),this.arrowView=this._createArrowView(),this.keystrokes=new te,this.focusTracker=new ee,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",i.to("class"),i.if("isVisible","ck-hidden",o=>!o),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(e){const t=e||new P;return e||t.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),t.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),t.delegate("execute").to(this),t}_createArrowView(){const e=new P,t=e.bindTemplate;return e.icon=da,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",i=>String(i))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}}function Ee(n,e=fu){const t=typeof e=="function"?new e(n):e,i=new wx(n),o=new Jw(n,t,i);return t.bind("isEnabled").to(o),t instanceof Xi?t.arrowView.bind("isOn").to(o,"isOpen"):t.bind("isOn").to(o,"isOpen"),kx(o),o}function fa(n,e,t={}){n.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),n.isOpen?Jd(n,e,t):n.once("change:isOpen",()=>Jd(n,e,t),{priority:"highest"}),t.enableActiveItemFocusOnDropdownOpen&&ga(n,()=>n.toolbarView.items.find(i=>i.isOn))}function Jd(n,e,t){const i=n.locale,o=i.t,s=n.toolbarView=new Ei(i),r=typeof e=="function"?e():e;s.ariaLabel=t.ariaLabel||o("Dropdown toolbar"),t.maxWidth&&(s.maxWidth=t.maxWidth),t.class&&(s.class=t.class),t.isCompact&&(s.isCompact=t.isCompact),t.isVertical&&(s.isVertical=!0),r instanceof Ie?s.items.bindTo(r).using(a=>a):s.items.addMany(r),n.panelView.children.add(s),n.focusTracker.add(s),s.items.delegate("execute").to(n)}function wt(n,e,t={}){n.isOpen?Qd(n,e,t):n.once("change:isOpen",()=>Qd(n,e,t),{priority:"highest"}),ga(n,()=>n.listView.items.find(i=>i instanceof Nt?i.children.first.isOn:!1))}function Qd(n,e,t){const i=n.locale,o=n.listView=new En(i),s=typeof e=="function"?e():e;o.ariaLabel=t.ariaLabel,o.role=t.role,Xw(n,o.items,s,i),n.panelView.children.add(o),o.items.delegate("execute").to(n)}function ga(n,e){n.on("change:isOpen",()=>{if(!n.isOpen)return;const t=e();t&&(typeof t.focus=="function"?t.focus():J("ui-dropdown-focus-child-on-open-child-missing-focus",{view:t}))},{priority:kt.low-10})}function kx(n){Cx(n),Ax(n),xx(n),Tx(n),Ex(n),Sx(n)}function Cx(n){$t({emitter:n,activator:()=>n.isRendered&&n.isOpen,callback:()=>{n.isOpen=!1},contextElements:()=>[n.element,...Yw(n.focusTracker).filter(e=>!n.element.contains(e))]})}function Yw(n){return[...n.elements,...n.externalViews.flatMap(e=>Yw(e.focusTracker))]}function Ax(n){n.on("execute",e=>{e.source instanceof Ji||(n.isOpen=!1)})}function xx(n){n.focusTracker.on("change:isFocused",(e,t,i)=>{i||!n.isOpen||(n.isOpen=!1)})}function Tx(n){n.keystrokes.set("arrowdown",(e,t)=>{n.isOpen&&(n.panelView.focus(),t())}),n.keystrokes.set("arrowup",(e,t)=>{n.isOpen&&(n.panelView.focusLast(),t())})}function Ex(n){n.on("change:isOpen",(e,t,i)=>{i||n.focusTracker.elements.some(o=>o.contains(I.document.activeElement))&&n.buttonView.focus()})}function Sx(n){n.on("change:isOpen",(e,t,i)=>{i&&n.panelView.focus()},{priority:"low"})}function Xw(n,e,t,i){Px(e),e.bindTo(t).using(o=>{if(o.type==="separator")return new ma(i);if(o.type==="group"){const s=new hr(i);return s.set({label:o.label}),Xw(n,s.items,o.items,i),s.items.delegate("execute").to(n),s}else if(o.type==="button"||o.type==="switchbutton"){const s=o.model.role==="menuitemcheckbox"||o.model.role==="menuitemradio",r=new Nt(i);let a;return o.type==="button"?(a=new ko(i),a.set({isToggleable:s})):a=new Ji(i),a.bind(...Object.keys(o.model)).to(o.model),a.delegate("execute").to(r),r.children.add(a),r}return null})}function Px(n){let e=0;const t=s=>!(s instanceof Nt)||!(s.children.first instanceof ko)?null:s.children.first,i=s=>{const r=t(s);return!r||!r.isToggleable?null:r},o=s=>{for(const r of n){const a=t(r);a&&(a.hasCheckSpace=s)}};n.on("change",(s,r)=>{const a=e>0;for(const c of r.removed)i(c)&&e--;for(const c of r.added){const u=t(c);u&&(u.isToggleable&&e++,u.hasCheckSpace=e>0)}const l=e>0;a!==l&&o(l)})}const nt=(n,e,t)=>{const i=new Zw(n.locale);return i.set({id:e,ariaDescribedById:t}),i.bind("isReadOnly").to(n,"isEnabled",o=>!o),i.bind("hasError").to(n,"errorText",o=>!!o),i.on("input",()=>{n.errorText=null}),n.bind("isEmpty","isFocused","placeholder").to(i),i},eb=(n,e,t)=>{const i=new gx(n.locale);return i.set({id:e,ariaDescribedById:t,inputMode:"numeric"}),i.bind("isReadOnly").to(n,"isEnabled",o=>!o),i.bind("hasError").to(n,"errorText",o=>!!o),i.on("input",()=>{n.errorText=null}),n.bind("isEmpty","isFocused","placeholder").to(i),i},Ix=(n,e,t)=>{const i=new px(n.locale);return i.set({id:e,ariaDescribedById:t}),i.bind("isReadOnly").to(n,"isEnabled",o=>!o),i.bind("hasError").to(n,"errorText",o=>!!o),i.on("input",()=>{n.errorText=null}),n.bind("isEmpty","isFocused","placeholder").to(i),i},pu=(n,e,t)=>{const i=Ee(n.locale);return i.set({id:e,ariaDescribedById:t}),i.bind("isEnabled").to(n),i},Vx=150;class Rx extends A{constructor(e,t={}){super(e),h(this,"hexInputRow"),h(this,"_debounceColorPickerEvent"),h(this,"_config"),this.set({color:"",_hexColor:""}),this.hexInputRow=this._createInputRow();const i=this.createCollection();t.hideInput||i.add(this.hexInputRow),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker"],tabindex:-1},children:i}),this._config=t,this._debounceColorPickerEvent=St(o=>{this.set("color",o),this.fire("colorSelected",{color:this.color})},Vx,{leading:!0}),this.on("set:color",(o,s,r)=>{o.return=Uw(r,this._config.format||"hsl")}),this.on("change:color",()=>{this._hexColor=Qa(this.color)}),this.on("change:_hexColor",()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Qa(this.color)!=Qa(this._hexColor)&&(this.color=this._hexColor)})}render(){if(super.render(),hx("hex-color-picker",WA),this.picker=I.document.createElement("hex-color-picker"),this.picker.setAttribute("class","hex-color-picker"),this.picker.setAttribute("tabindex","-1"),this._createSlidersView(),this.element){this.hexInputRow.element?this.element.insertBefore(this.picker,this.hexInputRow.element):this.element.appendChild(this.picker);const e=document.createElement("style");e.textContent='[role="slider"]:focus [part$="pointer"] {border: 1px solid #fff;outline: 1px solid var(--ck-color-focus-border);box-shadow: 0 0 0 2px #fff;}',this.picker.shadowRoot.appendChild(e)}this.picker.addEventListener("color-changed",e=>{const t=e.detail.value;this._debounceColorPickerEvent(t)})}focus(){/* istanbul ignore next -- @preserve */!this._config.hideInput&&(N.isGecko||N.isiOS||N.isSafari||N.isBlink)&&this.hexInputRow.children.get(1).focus(),this.slidersView.first.focus()}_createSlidersView(){const e=[...this.picker.shadowRoot.children].filter(t=>t.getAttribute("role")==="slider").map(t=>new Ox(t));this.slidersView=this.createCollection(),e.forEach(t=>{this.slidersView.add(t)})}_createInputRow(){const e=this._createColorInput();return new Mx(this.locale,e)}_createColorInput(){const e=new Te(this.locale,nt),{t}=this.locale;return e.set({label:t("HEX"),class:"color-picker-hex-input"}),e.fieldView.bind("value").to(this,"_hexColor",i=>e.isFocused?e.fieldView.value:i.startsWith("#")?i.substring(1):i),e.fieldView.on("input",()=>{const i=e.fieldView.element.value;if(i){const o=tb(i);o&&this._debounceColorPickerEvent(o)}}),e}isValid(){const{t:e}=this.locale;return this._config.hideInput?!0:(this.resetValidationStatus(),this.hexInputRow.getParsedColor()?!0:(this.hexInputRow.inputView.errorText=e('Please enter a valid color (e.g. "ff0000").'),!1))}resetValidationStatus(){this.hexInputRow.inputView.errorText=null}}function Qa(n){let e=ux(n);return e||(e="#000"),e.length===4&&(e="#"+[e[1],e[1],e[2],e[2],e[3],e[3]].join("")),e.toLowerCase()}class Ox extends A{constructor(e){super(),this.element=e}focus(){this.element.focus()}}class Bx extends A{constructor(e){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class Mx extends A{constructor(e,t){super(e),h(this,"children"),h(this,"inputView"),this.inputView=t,this.children=this.createCollection([new Bx,this.inputView]),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}getParsedColor(){return tb(this.inputView.fieldView.element.value)}}function tb(n){if(!n)return null;const e=n.trim().replace(/^#/,"");return![3,4,6,8].includes(e.length)||!/^(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})$/.test(e)?null:`#${e}`}class Lx extends ue(_e){constructor(e){super(e),this.set("isEmpty",!0),this.on("change",()=>{this.set("isEmpty",this.length===0)})}add(e,t){return this.find(i=>i.color===e.color)?this:super.add(e,t)}hasColor(e){return!!this.find(t=>t.color===e)}}class Fx extends A{constructor(e,{colors:t,columns:i,removeButtonLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerLabel:a,focusTracker:l,focusables:c}){super(e),h(this,"items"),h(this,"colorDefinitions"),h(this,"focusTracker"),h(this,"columns"),h(this,"documentColors"),h(this,"documentColorsCount"),h(this,"staticColorsGrid"),h(this,"documentColorsGrid"),h(this,"colorPickerButtonView"),h(this,"removeColorButtonView"),h(this,"_focusables"),h(this,"_documentColorsLabel"),h(this,"_removeButtonLabel"),h(this,"_colorPickerLabel");const u=this.bindTemplate;this.set("isVisible",!0),this.focusTracker=l,this.items=this.createCollection(),this.colorDefinitions=t,this.columns=i,this.documentColors=new Lx,this.documentColorsCount=r,this._focusables=c,this._removeButtonLabel=o,this._colorPickerLabel=a,this._documentColorsLabel=s,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-fragment",u.if("isVisible","ck-hidden",d=>!d)]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}updateDocumentColors(e,t){const i=e.document,o=this.documentColorsCount;this.documentColors.clear();for(const s of i.getRoots()){const r=e.createRangeIn(s);for(const a of r.getItems())if(a.is("$textProxy")&&a.hasAttribute(t)&&(this._addColorToDocumentColors(a.getAttribute(t)),this.documentColors.length>=o))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,i=this.selectedColor;t.selectedColor=i,e&&(e.selectedColor=i)}render(){if(super.render(),this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount){const e=qt.bind(this.documentColors,this.documentColors),t=new A(this.locale);t.setTemplate({tag:"span",attributes:{class:["ck","ck-color-grid__label",e.if("isEmpty","ck-hidden")]},children:[{text:this._documentColorsLabel}]}),this.items.add(t),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}this._createColorPickerButton(),this._addColorSelectorElementsToFocusTracker()}focus(){this.removeColorButtonView.focus()}destroy(){super.destroy()}addColorPickerButton(){this.colorPickerButtonView&&(this.items.add(this.colorPickerButtonView),this.focusTracker.add(this.colorPickerButtonView.element),this._focusables.add(this.colorPickerButtonView))}_addColorSelectorElementsToFocusTracker(){this.focusTracker.add(this.removeColorButtonView.element),this._focusables.add(this.removeColorButtonView),this.staticColorsGrid&&(this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid)),this.documentColorsGrid&&(this.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid))}_createColorPickerButton(){this.colorPickerButtonView=new P,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:wC,class:"ck-color-selector__color-picker"}),this.colorPickerButtonView.on("execute",()=>{this.fire("colorPicker:show")})}_createRemoveColorButton(){const e=new P;return e.set({withText:!0,icon:kC,label:this._removeButtonLabel}),e.class="ck-color-selector__remove-color",e.on("execute",()=>{this.fire("execute",{value:null,source:"removeColorButton"})}),e.render(),e}_createStaticColorsGrid(){const e=new Ud(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.on("execute",(t,i)=>{this.fire("execute",{value:i.value,source:"staticColorsGrid"})}),e}_createDocumentColorsGrid(){const e=qt.bind(this.documentColors,this.documentColors),t=new Ud(this.locale,{columns:this.columns});return t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using(i=>{var o;const s=new jw;return s.set({color:i.color,hasBorder:(o=i.options)==null?void 0:o.hasBorder}),i.label&&s.set({label:i.label,tooltip:!0}),s.on("execute",()=>{this.fire("execute",{value:i.color,source:"documentColorsGrid"})}),s}),this.documentColors.on("change:isEmpty",(i,o,s)=>{s&&(t.selectedColor=null)}),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find(i=>i.color===e);t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}}class Nx extends A{constructor(e,{focusTracker:t,focusables:i,keystrokes:o,colorPickerViewConfig:s}){super(e),h(this,"items"),h(this,"colorPickerView"),h(this,"saveButtonView"),h(this,"cancelButtonView"),h(this,"actionBarView"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"_focusables"),h(this,"_colorPickerViewConfig"),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=o,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=i,this._colorPickerViewConfig=s;const r=this.bindTemplate,{saveButtonView:a,cancelButtonView:l}=this._createActionButtons();this.saveButtonView=a,this.cancelButtonView=l,this.actionBarView=this._createActionBarView({saveButtonView:a,cancelButtonView:l}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-fragment",r.if("isVisible","ck-hidden",c=>!c)]},children:this.items})}render(){super.render();const e=new Rx(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=e,this.colorPickerView.render(),this.selectedColor&&(e.color=this.selectedColor),this.listenTo(this,"change:selectedColor",(t,i,o)=>{e.color=o}),this.items.add(this.colorPickerView),this.items.add(this.actionBarView),this._addColorPickersElementsToFocusTracker(),this._stopPropagationOnArrowsKeys(),this._executeOnEnterPress(),this._executeUponColorChange()}destroy(){super.destroy()}focus(){this.colorPickerView.focus()}resetValidationStatus(){this.colorPickerView.resetValidationStatus()}_executeOnEnterPress(){this.keystrokes.set("enter",e=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&this.colorPickerView.isValid()&&(this.fire("execute",{value:this.selectedColor}),e.stopPropagation(),e.preventDefault())})}_stopPropagationOnArrowsKeys(){const e=t=>t.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}_addColorPickersElementsToFocusTracker(){for(const t of this.colorPickerView.slidersView)this.focusTracker.add(t.element),this._focusables.add(t);const e=this.colorPickerView.hexInputRow.children.get(1);e.element&&(this.focusTracker.add(e.element),this._focusables.add(e)),this.focusTracker.add(this.saveButtonView.element),this._focusables.add(this.saveButtonView),this.focusTracker.add(this.cancelButtonView.element),this._focusables.add(this.cancelButtonView)}_createActionBarView({saveButtonView:e,cancelButtonView:t}){const i=new A,o=this.createCollection();return o.add(e),o.add(t),i.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector_action-bar"]},children:o}),i}_createActionButtons(){const e=this.locale,t=e.t,i=new P(e),o=new P(e);return i.set({icon:Es,class:"ck-button-save",type:"button",withText:!1,label:t("Accept")}),o.set({icon:_o,class:"ck-button-cancel",type:"button",withText:!1,label:t("Cancel")}),i.on("execute",()=>{this.colorPickerView.isValid()&&this.fire("execute",{source:"colorPickerSaveButton",value:this.selectedColor})}),o.on("execute",()=>{this.fire("colorPicker:cancel")}),{saveButtonView:i,cancelButtonView:o}}_executeUponColorChange(){this.colorPickerView.on("colorSelected",(e,t)=>{this.fire("execute",{value:t.color,source:"colorPicker"}),this.set("selectedColor",t.color)})}}class wu extends A{constructor(e,{colors:t,columns:i,removeButtonLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerLabel:a,colorPickerViewConfig:l}){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"items"),h(this,"colorGridsFragmentView"),h(this,"colorPickerFragmentView"),h(this,"_focusCycler"),h(this,"_focusables"),h(this,"_colorPickerViewConfig"),this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this._focusables=new Ie,this._colorPickerViewConfig=l,this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsFragmentView=new Fx(e,{colors:t,columns:i,removeButtonLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerLabel:a,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new Nx(e,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerViewConfig:l}),this.set("_isColorGridsFragmentVisible",!0),this.set("_isColorPickerFragmentVisible",!1),this.set("selectedColor",void 0),this.colorGridsFragmentView.bind("isVisible").to(this,"_isColorGridsFragmentVisible"),this.colorPickerFragmentView.bind("isVisible").to(this,"_isColorPickerFragmentVisible"),this.on("change:selectedColor",(c,u,d)=>{this.colorGridsFragmentView.set("selectedColor",d),this.colorPickerFragmentView.set("selectedColor",d)}),this.colorGridsFragmentView.on("change:selectedColor",(c,u,d)=>{this.set("selectedColor",d)}),this.colorPickerFragmentView.on("change:selectedColor",(c,u,d)=>{this.set("selectedColor",d)}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector"]},children:this.items})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendUI(){this._appendColorGridsFragment(),this._colorPickerViewConfig&&this._appendColorPickerFragment()}showColorPickerFragment(){!this.colorPickerFragmentView.colorPickerView||this._isColorPickerFragmentVisible||(this._isColorPickerFragmentVisible=!0,this.colorPickerFragmentView.focus(),this.colorPickerFragmentView.resetValidationStatus(),this._isColorGridsFragmentVisible=!1)}showColorGridsFragment(){this._isColorGridsFragmentVisible||(this._isColorGridsFragmentVisible=!0,this.colorGridsFragmentView.focus(),this._isColorPickerFragmentVisible=!1)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}updateDocumentColors(e,t){this.colorGridsFragmentView.updateDocumentColors(e,t)}updateSelectedColors(){this.colorGridsFragmentView.updateSelectedColors()}_appendColorGridsFragment(){this.items.length||(this.items.add(this.colorGridsFragmentView),this.colorGridsFragmentView.delegate("execute").to(this),this.colorGridsFragmentView.delegate("colorPicker:show").to(this))}_appendColorPickerFragment(){this.items.length!==2&&(this.items.add(this.colorPickerFragmentView),this.colorGridsFragmentView.colorPickerButtonView&&this.colorGridsFragmentView.colorPickerButtonView.on("execute",()=>{this.showColorPickerFragment()}),this.colorGridsFragmentView.addColorPickerButton(),this.colorPickerFragmentView.delegate("execute").to(this),this.colorPickerFragmentView.delegate("colorPicker:cancel").to(this))}}class Dx{constructor(e){h(this,"editor"),h(this,"_components",new Map),this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(Ya(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new b("componentfactory-item-missing",this,{name:e});return this._components.get(Ya(e)).callback(this.editor.locale)}has(e){return this._components.has(Ya(e))}}function Ya(n){return String(n).toLowerCase()}const Yd="ck-tooltip",mr=class at extends st(){constructor(e){if(super(),h(this,"tooltipTextView"),h(this,"balloonPanelView"),h(this,"_currentElementWithTooltip",null),h(this,"_currentTooltipPosition",null),h(this,"_mutationObserver",null),h(this,"_pinTooltipDebounced"),h(this,"_unpinTooltipDebounced"),h(this,"_watchdogExcluded"),at._editors.add(e),at._instance)return at._instance;at._instance=this,this.tooltipTextView=new A(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 Ne(e.locale),this.balloonPanelView.class=Yd,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=Hx(()=>{this._updateTooltipPosition()}),this._pinTooltipDebounced=St(this._pinTooltip,600),this._unpinTooltipDebounced=St(this._unpinTooltip,400),this.listenTo(I.document,"keydown",this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(I.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(I.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(I.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(I.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(I.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;at._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),at._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),at._instance=null)}static getPositioningFunctions(e){const t=at.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]}_onKeyDown(e,t){t.key==="Escape"&&this._currentElementWithTooltip&&(this._unpinTooltip(),t.stopPropagation())}_onEnterOrFocus(e,{target:t}){const i=Xa(t);if(!i){e.name==="focus"&&this._unpinTooltip();return}if(i===this._currentElementWithTooltip){this._unpinTooltipDebounced.cancel();return}this._unpinTooltip(),e.name==="focus"&&!i.matches(":hover")||i.matches("[data-cke-tooltip-instant]")?this._pinTooltip(i,el(i)):this._pinTooltipDebounced(i,el(i))}_onLeaveOrBlur(e,{target:t,relatedTarget:i}){if(e.name==="mouseleave"){if(!xi(t))return;const o=this.balloonPanelView.element,s=o&&(o===i||o.contains(i)),r=!s&&t===o;if(s){this._unpinTooltipDebounced.cancel();return}if(!r&&this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const a=Xa(t),l=Xa(i);(r||a&&a!==l)&&(this._pinTooltipDebounced.cancel(),this._currentElementWithTooltip&&this._currentElementWithTooltip.matches("[data-cke-tooltip-instant]")||a&&a.matches("[data-cke-tooltip-instant]")?this._unpinTooltip():this._unpinTooltipDebounced())}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._pinTooltipDebounced.cancel(),this._unpinTooltipDebounced()}}_onScroll(e,{target:t}){this._currentElementWithTooltip&&(t.contains(this.balloonPanelView.element)&&t.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(e,{text:t,position:i,cssClass:o}){this._unpinTooltip();const s=ae(at._editors.values()).ui.view.body;s.has(this.balloonPanelView)||s.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.class=[Yd,o].filter(r=>r).join(" "),this.balloonPanelView.pin({target:e,positions:at.getPositioningFunctions(i)}),this._mutationObserver.attach(e);for(const r of at._editors)this.listenTo(r.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=i}_unpinTooltip(){this._unpinTooltipDebounced.cancel(),this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of at._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this.tooltipTextView.text="",this._mutationObserver.detach()}_updateTooltipPosition(){if(!this._currentElementWithTooltip)return;const e=el(this._currentElementWithTooltip);if(!Gt(this._currentElementWithTooltip)||!e.text){this._unpinTooltip();return}this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:at.getPositioningFunctions(e.position)})}};h(mr,"defaultBalloonPositions",Ne.generatePositions({heightOffset:5,sideOffset:13})),h(mr,"_editors",new Set),h(mr,"_instance",null);let zx=mr;function Xa(n){return xi(n)?n.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function el(n){return{text:n.dataset.ckeTooltipText,position:n.dataset.ckeTooltipPosition||"s",cssClass:n.dataset.ckeTooltipClass||""}}function Hx(n){const e=new MutationObserver(()=>{n()});return{attach(t){e.observe(t,{attributes:!0,attributeFilter:["data-cke-tooltip-text","data-cke-tooltip-position"]})},detach(){e.disconnect()}}}const $x=50,Wx=350;class ib extends st(){constructor(e,t={}){super(),h(this,"editor"),h(this,"_balloonView",null),h(this,"_showBalloonThrottled",co(()=>this._showBalloon(),50,{leading:!0})),h(this,"_lastFocusedEditableElement",null),h(this,"_balloonClass"),this.editor=e,this._balloonClass=t.balloonClass,e.on("ready",()=>this._handleEditorReady())}destroy(){const e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const e=this.editor;this._isEnabled()&&e.ui.view&&(e.ui.focusTracker.on("change:isFocused",(t,i,o)=>{this._updateLastFocusedEditableElement(),o?this._showBalloon():this._hideBalloon()}),e.ui.focusTracker.on("change:focusedElement",(t,i,o)=>{this._updateLastFocusedEditableElement(),o&&this._showBalloon()}),e.ui.on("update",()=>{this._showBalloonThrottled()}))}_getNormalizedConfig(){return{side:this.editor.locale.contentLanguageDirection==="ltr"?"right":"left",position:"border",verticalOffset:0,horizontalOffset:5}}_showBalloon(){const e=this._getBalloonAttachOptions();e&&(this._balloonView||(this._balloonView=this._createBalloonView()),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_createBalloonView(){const e=this.editor,t=new Ne,i=this._createBadgeContent();return t.content.add(i),this._balloonClass&&(t.class=this._balloonClass),e.ui.view.body.add(t),t}_getBalloonAttachOptions(){if(!this._lastFocusedEditableElement)return null;const e=this._getNormalizedConfig(),t=e.side==="right"?jx(this._lastFocusedEditableElement,e):Ux(this._lastFocusedEditableElement,e);return{target:this._lastFocusedEditableElement,positions:[t]}}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,i=e.ui.focusTracker.focusedElement;if(!t||!i){this._lastFocusedEditableElement=null;return}const o=Array.from(e.ui.getEditableElementsNames()).map(s=>e.ui.getEditableElement(s));o.includes(i)?this._lastFocusedEditableElement=i:this._lastFocusedEditableElement=o[0]}}function jx(n,e){return nb(n,e,(t,i)=>t.left+t.width-i.width-e.horizontalOffset)}function Ux(n,e){return nb(n,e,t=>t.left+e.horizontalOffset)}function nb(n,e,t){return(i,o)=>{const s=new z(n);if(s.widths.preventDefault())}}]})}}class Zx extends ib{constructor(e){super(e,{balloonClass:"ck-evaluation-badge-balloon"}),h(this,"licenseTypeMessage",{evaluation:"For evaluation purposes only",trial:"For evaluation purposes only",development:"For development purposes only"})}_isEnabled(){const e=this.editor.config.get("licenseKey"),t=Xd(e);return!!(t&&this.licenseTypeMessage[t])}_createBadgeContent(){const e=this.editor.config.get("licenseKey"),t=Xd(e);return new Jx(this.editor.locale,this.licenseTypeMessage[t])}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{},i=t.position||e.position,o=t.side||e.side;return{position:i,side:o==="left"?"right":"left",verticalOffset:e.verticalOffset,horizontalOffset:e.horizontalOffset}}}class Jx extends A{constructor(e,t){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-evaluation-badge"],"aria-hidden":!0},children:[{tag:"span",attributes:{class:["ck","ck-evaluation-badge__label"]},children:[t]}]})}}function Xd(n){if(n=="GPL")return"GPL";const e=Wc(n.split(".")[1]);return e?e.licenseType||"production":null}const em={POLITE:"polite",ASSERTIVE:"assertive"};class Qx{constructor(e){h(this,"editor"),h(this,"view"),this.editor=e,e.once("ready",()=>{for(const t of Object.values(em))this.announce("",t)})}announce(e,t=em.POLITE){const i=this.editor;if(!i.ui.view)return;this.view||(this.view=new Yx(i.locale),i.ui.view.body.add(this.view));const{politeness:o,isUnsafeHTML:s}=typeof t=="string"?{politeness:t}:t;let r=this.view.regionViews.find(a=>a.politeness===o);r||(r=new Xx(i,o),this.view.regionViews.add(r)),r.announce({announcement:e,isUnsafeHTML:s})}}class Yx extends A{constructor(e){super(e),h(this,"regionViews"),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class Xx extends A{constructor(e,t){super(e.locale),h(this,"politeness"),h(this,"_domConverter"),h(this,"_pruneAnnouncementsInterval"),this.setTemplate({tag:"div",attributes:{"aria-live":t,"aria-relevant":"additions"},children:[{tag:"ul",attributes:{class:["ck","ck-aria-live-region-list"]}}]}),e.on("destroy",()=>{this._pruneAnnouncementsInterval!==null&&(clearInterval(this._pruneAnnouncementsInterval),this._pruneAnnouncementsInterval=null)}),this.politeness=t,this._domConverter=e.data.htmlProcessor.domConverter,this._pruneAnnouncementsInterval=setInterval(()=>{this.element&&this._listElement.firstChild&&this._listElement.firstChild.remove()},5e3)}announce({announcement:e,isUnsafeHTML:t}){if(!e.trim().length)return;const i=document.createElement("li");t?this._domConverter.setContentOf(i,e):i.innerText=e,this._listElement.appendChild(i)}get _listElement(){return this.element.querySelector("ul")}}class Oi extends Nt{constructor(e,t){super(e);const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item"]},on:{mouseenter:i.to("mouseenter")}}),this.delegate("mouseenter").to(t)}}const Gs=5,Dn={toggleMenusAndFocusItemsOnHover(n){n.on("menu:mouseenter",e=>{if(!(!n.isFocusBorderEnabled&&!n.isOpen)){if(n.isOpen)for(const t of n.menus){const i=e.path[0],o=i instanceof Oi&&i.children.first===t;t.isOpen=(e.path.includes(t)||o)&&t.isEnabled}e.source.focus()}})},focusCycleMenusOnArrows(n){const e=n.locale.uiLanguageDirection==="rtl";n.on("menu:arrowright",i=>{t(i.source,e?-1:1)}),n.on("menu:arrowleft",i=>{t(i.source,e?1:-1)});function t(i,o){const s=n.children.getIndex(i),r=i.isOpen,a=n.children.length,l=n.children.get((s+a+o)%a);i.isOpen=!1,r&&(l.isOpen=!0),l.buttonView.focus()}},closeMenusWhenTheBarCloses(n){n.on("change:isOpen",()=>{n.isOpen||n.menus.forEach(e=>{e.isOpen=!1})})},closeMenuWhenAnotherOnTheSameLevelOpens(n){n.on("menu:change:isOpen",(e,t,i)=>{i&&n.menus.filter(o=>e.source.parentMenuView===o.parentMenuView&&e.source!==o&&o.isOpen).forEach(o=>{o.isOpen=!1})})},closeOnClickOutside(n){$t({emitter:n,activator:()=>n.isOpen,callback:()=>n.close(),contextElements:()=>n.children.map(e=>e.element)})},enableFocusHighlightOnInteraction(n){let e=!1;n.on("change:isOpen",(t,i,o)=>{o||(e||(n.isFocusBorderEnabled=!1),e=!1)}),n.listenTo(n.element,"keydown",()=>{e=!0},{useCapture:!0}),n.listenTo(n.element,"keyup",()=>{e=!1},{useCapture:!0}),n.listenTo(n.element,"focus",()=>{e&&(n.isFocusBorderEnabled=!0)},{useCapture:!0})}},Fi={openAndFocusPanelOnArrowDownKey(n){n.keystrokes.set("arrowdown",(e,t)=>{n.isEnabled&&n.focusTracker.focusedElement===n.buttonView.element&&(n.isOpen||(n.isOpen=!0),n.panelView.focus(),t())})},openOnArrowRightKey(n){const e=n.locale.uiLanguageDirection==="rtl"?"arrowleft":"arrowright";n.keystrokes.set(e,(t,i)=>{n.focusTracker.focusedElement!==n.buttonView.element||!n.isEnabled||(n.isOpen||(n.isOpen=!0),n.panelView.focus(),i())})},openOnButtonClick(n){n.buttonView.on("execute",()=>{n.isOpen=!0})},toggleOnButtonClick(n){n.buttonView.on("execute",()=>{n.isOpen=!n.isOpen})},openAndFocusOnEnterKeyPress(n){n.keystrokes.set("enter",(e,t)=>{n.focusTracker.focusedElement===n.buttonView.element&&(n.isOpen=!0,n.panelView.focus(),t())})},closeOnArrowLeftKey(n){const e=n.locale.uiLanguageDirection==="rtl"?"arrowright":"arrowleft";n.keystrokes.set(e,(t,i)=>{n.isOpen&&(n.isOpen=!1,n.focus(),i())})},closeOnEscKey(n){n.keystrokes.set("esc",(e,t)=>{n.isOpen&&(n.isOpen=!1,n.focus(),t())})},closeOnParentClose(n){n.parentMenuView.on("change:isOpen",(e,t,i)=>{!i&&e.source===n.parentMenuView&&(n.isOpen=!1)})}},eT={southEast:n=>({top:n.bottom,left:n.left,name:"se"}),southWest:(n,e)=>({top:n.bottom,left:n.left-e.width+n.width,name:"sw"}),northEast:(n,e)=>({top:n.top-e.height,left:n.left,name:"ne"}),northWest:(n,e)=>({top:n.top-e.height,left:n.left-e.width+n.width,name:"nw"}),eastSouth:n=>({top:n.top,left:n.right-Gs,name:"es"}),eastNorth:(n,e)=>({top:n.top-e.height,left:n.right-Gs,name:"en"}),westSouth:(n,e)=>({top:n.top,left:n.left-e.width+Gs,name:"ws"}),westNorth:(n,e)=>({top:n.top-e.height,left:n.left-e.width+Gs,name:"wn"})},tT=[{menuId:"file",label:"File",groups:[{groupId:"export",items:["menuBar:exportPdf","menuBar:exportWord"]},{groupId:"import",items:["menuBar:importWord"]},{groupId:"revisionHistory",items:["menuBar:revisionHistory"]}]},{menuId:"edit",label:"Edit",groups:[{groupId:"undo",items:["menuBar:undo","menuBar:redo"]},{groupId:"selectAll",items:["menuBar:selectAll"]},{groupId:"findAndReplace",items:["menuBar:findAndReplace"]}]},{menuId:"view",label:"View",groups:[{groupId:"sourceEditingEnhanced",items:["menuBar:sourceEditingEnhanced"]},{groupId:"sourceEditing",items:["menuBar:sourceEditing"]},{groupId:"showBlocks",items:["menuBar:showBlocks"]},{groupId:"previewMergeFields",items:["menuBar:previewMergeFields"]},{groupId:"fullscreen",items:["menuBar:fullscreen"]},{groupId:"restrictedEditing",items:["menuBar:restrictedEditing"]}]},{menuId:"insert",label:"Insert",groups:[{groupId:"insertMainWidgets",items:["menuBar:insertImage","menuBar:ckbox","menuBar:ckfinder","menuBar:insertTable","menuBar:insertTableLayout"]},{groupId:"insertInline",items:["menuBar:link","menuBar:bookmark","menuBar:comment","menuBar:insertMergeField","menuBar:emoji"]},{groupId:"insertMinorWidgets",items:["menuBar:mediaEmbed","menuBar:insertTemplate","menuBar:specialCharacters","menuBar:blockQuote","menuBar:codeBlock","menuBar:htmlEmbed"]},{groupId:"insertStructureWidgets",items:["menuBar:horizontalLine","menuBar:pageBreak","menuBar:tableOfContents"]},{groupId:"restrictedEditingException",items:["menuBar:restrictedEditingException"]}]},{menuId:"format",label:"Format",groups:[{groupId:"textAndFont",items:[{menuId:"text",label:"Text",groups:[{groupId:"basicStyles",items:["menuBar:bold","menuBar:italic","menuBar:underline","menuBar:strikethrough","menuBar:superscript","menuBar:subscript","menuBar:code"]},{groupId:"textPartLanguage",items:["menuBar:textPartLanguage"]}]},{menuId:"font",label:"Font",groups:[{groupId:"fontProperties",items:["menuBar:fontSize","menuBar:fontFamily"]},{groupId:"fontColors",items:["menuBar:fontColor","menuBar:fontBackgroundColor"]},{groupId:"highlight",items:["menuBar:highlight"]}]},"menuBar:heading"]},{groupId:"list",items:["menuBar:bulletedList","menuBar:numberedList","menuBar:multiLevelList","menuBar:todoList"]},{groupId:"indent",items:["menuBar:alignment","menuBar:indent","menuBar:outdent"]},{groupId:"caseChange",items:["menuBar:caseChange"]},{groupId:"removeFormat",items:["menuBar:removeFormat"]}]},{menuId:"tools",label:"Tools",groups:[{groupId:"aiTools",items:["menuBar:aiAssistant","menuBar:aiCommands"]},{groupId:"tools",items:["menuBar:trackChanges","menuBar:commentsArchive"]}]},{menuId:"help",label:"Help",groups:[{groupId:"help",items:["menuBar:accessibilityHelp"]}]}];function iT(n){let e;return!("items"in n)||!n.items?e={items:mt(tT),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0,...n}:e={items:n.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1,...n},e}function nT({normalizedConfig:n,locale:e,componentFactory:t,extraItems:i}){const o=mt(n);return tm(n,o,i),oT(n,o),tm(n,o,o.addItems),sT(n,o,t),ob(n,o),rT(o,e),o}function oT(n,e){const t=e.removeItems,i=[];e.items=e.items.filter(({menuId:o})=>t.includes(o)?(i.push(o),!1):!0),Co(e.items,o=>{o.groups=o.groups.filter(({groupId:s})=>t.includes(s)?(i.push(s),!1):!0);for(const s of o.groups)s.items=s.items.filter(r=>{const a=sb(r);return t.includes(a)?(i.push(a),!1):!0})});for(const o of t)i.includes(o)||J("menu-bar-item-could-not-be-removed",{menuBarConfig:n,itemName:o})}function tm(n,e,t){const i=[];if(t.length!=0){for(const o of t){const s=cT(o.position),r=uT(o.position);if(aT(o))if(!r)s==="start"?(e.items.unshift(o.menu),i.push(o)):s==="end"&&(e.items.push(o.menu),i.push(o));else{const a=e.items.findIndex(l=>l.menuId===r);a!=-1?s==="before"?(e.items.splice(a,0,o.menu),i.push(o)):s==="after"&&(e.items.splice(a+1,0,o.menu),i.push(o)):im(e,o.menu,r,s)&&i.push(o)}else lT(o)?Co(e.items,a=>{if(a.menuId===r)s==="start"?(a.groups.unshift(o.group),i.push(o)):s==="end"&&(a.groups.push(o.group),i.push(o));else{const l=a.groups.findIndex(c=>c.groupId===r);l!==-1&&(s==="before"?(a.groups.splice(l,0,o.group),i.push(o)):s==="after"&&(a.groups.splice(l+1,0,o.group),i.push(o)))}}):im(e,o.item,r,s)&&i.push(o)}for(const o of t)i.includes(o)||J("menu-bar-item-could-not-be-added",{menuBarConfig:n,addedItemConfig:o})}}function im(n,e,t,i){let o=!1;return Co(n.items,s=>{for(const{groupId:r,items:a}of s.groups){if(o)return;if(r===t)i==="start"?(a.unshift(e),o=!0):i==="end"&&(a.push(e),o=!0);else{const l=a.findIndex(c=>sb(c)===t);l!==-1&&(i==="before"?(a.splice(l,0,e),o=!0):i==="after"&&(a.splice(l+1,0,e),o=!0))}}}),o}function sT(n,e,t){Co(e.items,i=>{for(const o of i.groups)o.items=o.items.filter(s=>{const r=typeof s=="string"&&!t.has(s);return r&&!e.isUsingDefaultConfig&&J("menu-bar-item-unavailable",{menuBarConfig:n,parentMenuConfig:mt(i),componentName:s}),!r})})}function ob(n,e){const t=e.isUsingDefaultConfig;let i=!1;if(e.items=e.items.filter(o=>o.groups.length?!0:(tl(n,o,t),!1)),!e.items.length){tl(n,n,t);return}Co(e.items,o=>{o.groups=o.groups.filter(s=>s.items.length?!0:(i=!0,!1));for(const s of o.groups)s.items=s.items.filter(r=>rb(r)&&!r.groups.length?(tl(n,r,t),i=!0,!1):!0)}),i&&ob(n,e)}function tl(n,e,t){t||J("menu-bar-menu-empty",{menuBarConfig:n,emptyMenuConfig:e})}function rT(n,e){const t=e.t,i={File:t({string:"File",id:"MENU_BAR_MENU_FILE"}),Edit:t({string:"Edit",id:"MENU_BAR_MENU_EDIT"}),View:t({string:"View",id:"MENU_BAR_MENU_VIEW"}),Insert:t({string:"Insert",id:"MENU_BAR_MENU_INSERT"}),Format:t({string:"Format",id:"MENU_BAR_MENU_FORMAT"}),Tools:t({string:"Tools",id:"MENU_BAR_MENU_TOOLS"}),Help:t({string:"Help",id:"MENU_BAR_MENU_HELP"}),Text:t({string:"Text",id:"MENU_BAR_MENU_TEXT"}),Font:t({string:"Font",id:"MENU_BAR_MENU_FONT"})};Co(n.items,o=>{o.label in i&&(o.label=i[o.label])})}function Co(n,e){if(Array.isArray(n))for(const i of n)t(i);function t(i){e(i);for(const o of i.groups)for(const s of o.items)rb(s)&&t(s)}}function aT(n){return typeof n=="object"&&"menu"in n}function lT(n){return typeof n=="object"&&"group"in n}function cT(n){return n.startsWith("start")?"start":n.startsWith("end")?"end":n.startsWith("after")?"after":"before"}function uT(n){const e=n.match(/^[^:]+:(.+)/);return e?e[1]:null}function sb(n){return typeof n=="string"?n:n.menuId}function rb(n){return typeof n=="object"&&"menuId"in n}class ab extends ue(){constructor(e){super(),h(this,"editor"),h(this,"componentFactory"),h(this,"focusTracker"),h(this,"tooltipManager"),h(this,"poweredBy"),h(this,"evaluationBadge"),h(this,"ariaLiveAnnouncer"),h(this,"isReady",!1),h(this,"_editableElementsMap",new Map),h(this,"_focusableToolbarDefinitions",[]),h(this,"_extraMenuBarElements",[]),h(this,"_lastFocusedForeignElement",null),h(this,"_domEmitter");const t=e.editing.view;this.editor=e,this.componentFactory=new Dx(e),this.focusTracker=new ee,this.tooltipManager=new zx(e),this.poweredBy=new Gx(e),this.evaluationBadge=new Zx(e),this.ariaLiveAnnouncer=new Qx(e),this._initViewportOffset(this._readViewportOffsetFromConfig()),this.once("ready",()=>{this._bindBodyCollectionWithFocusTracker(),this.isReady=!0}),this.listenTo(t.document,"layoutChanged",this.update.bind(this)),this.listenTo(t,"scrollToTheSelection",this._handleScrollToTheSelection.bind(this)),this._initFocusTracking(),this._initVisualViewportSupport()}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy(),this.evaluationBadge.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[],this._domEmitter&&this._domEmitter.stopListening()}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor),this.focusTracker.add(t);const i=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?i():this.once("ready",i)}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),this.editor.keystrokes.listenTo(e.element)):e.once("render",()=>{this.focusTracker.add(e),this.editor.keystrokes.listenTo(e.element)}),this._focusableToolbarDefinitions.push({toolbarView:e,options:t})}extendMenuBar(e){this._extraMenuBarElements.push(e)}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}initMenuBar(e){const t=e.element;this.focusTracker.add(t),this.editor.keystrokes.listenTo(t);const i=iT(this.editor.config.get("menuBar")||{});e.fillFromConfig(i,this.componentFactory,this._extraMenuBarElements),this.editor.keystrokes.set("Esc",(o,s)=>{t.contains(this.editor.ui.focusTracker.focusedElement)&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):this.editor.editing.view.focus(),s())}),this.editor.keystrokes.set("Alt+F9",(o,s)=>{t.contains(this.editor.ui.focusTracker.focusedElement)||(this._saveLastFocusedForeignElement(),e.isFocusBorderEnabled=!0,e.focus(),s())})}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const i=e.config.get("toolbar.viewportTopOffset");return i?(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:i}):{top:0}}_initFocusTracking(){const e=this.editor;let t;e.keystrokes.set("Alt+F10",(i,o)=>{this._saveLastFocusedForeignElement();const s=this._getCurrentFocusedToolbarDefinition();(!s||!t)&&(t=this._getFocusableCandidateToolbarDefinitions());for(let r=0;r{const s=this._getCurrentFocusedToolbarDefinition();s&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):e.editing.view.focus(),s.options.afterBlur&&s.options.afterBlur(),o())})}_saveLastFocusedForeignElement(){const e=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(e)&&!Array.from(this.editor.editing.view.domRoots.values()).includes(e)&&(this._lastFocusedForeignElement=e)}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:i,options:o}=t;(Gt(i.element)||o.beforeFocus)&&e.push(t)}return e.sort((t,i)=>nm(t)-nm(i)),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:i}}=e;return i&&i(),Gt(t.element)?(t.focus(),!0):!1}_handleScrollToTheSelection(e,t){const i={top:0,bottom:0,left:0,right:0,...this.viewportOffset};t.viewportOffset.top+=i.top,t.viewportOffset.bottom+=i.bottom,t.viewportOffset.left+=i.left,t.viewportOffset.right+=i.right}_bindBodyCollectionWithFocusTracker(){const e=this.view.body;for(const t of e)this.focusTracker.add(t.element);e.on("add",(t,i)=>{this.focusTracker.add(i.element)}),e.on("remove",(t,i)=>{this.focusTracker.remove(i.element)})}_initViewportOffset(e){this.on("set:viewportOffset",(t,i,o)=>{const s=this._getVisualViewportTopOffset(o);o.visualTop!==s&&(t.return={...o,visualTop:s})}),this.set("viewportOffset",e)}_initVisualViewportSupport(){if(!I.window.visualViewport)return;const e=()=>{const t=this._getVisualViewportTopOffset(this.viewportOffset);this.viewportOffset.visualTop!==t&&(this.viewportOffset={...this.viewportOffset,visualTop:t})};this._domEmitter=new(st()),this._domEmitter.listenTo(I.window.visualViewport,"scroll",e),this._domEmitter.listenTo(I.window.visualViewport,"resize",e)}_getVisualViewportTopOffset(e){const t=av().top,i=e.top||0;return t>i?0:i-t}}function nm(n){const{toolbarView:e,options:t}=n;let i=10;return Gt(e.element)&&i--,t.isContextual&&(i-=2),i}class lb extends A{constructor(e){super(e),h(this,"body"),h(this,"menuBarView"),h(this,"toolbar"),this.body=new rx(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class hT extends A{constructor(e,t,i){super(e),h(this,"name",null),h(this,"_editingView"),h(this,"_editableElement"),h(this,"_hasExternalElement"),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=i,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?i(this):t(this);function t(o){e.change(s=>{const r=e.document.getRoot(o.name);s.addClass(o.isFocused?"ck-focused":"ck-blurred",r),s.removeClass(o.isFocused?"ck-blurred":"ck-focused",r)})}function i(o){e.once("change:isRenderingInProgress",(s,r,a)=>{a?i(o):t(o)})}}}class cb extends hT{constructor(e,t,i,o={}){super(e,t,i),h(this,"_options"),this._options=o,this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const e=this._editingView;e.change(t=>{const i=e.document.getRoot(this.name);t.setAttribute("aria-label",this.getEditableAriaLabel(),i)})}getEditableAriaLabel(){const e=this.locale.t,t=this._options.label,i=this._editableElement,o=this.name;if(typeof t=="string")return t;if(typeof t=="object")return t[o];if(typeof t=="function")return t(this);if(i){const s=i.getAttribute("aria-label");if(s)return s}return e("Rich Text Editor. Editing area: %0",o)}}class $e extends A{constructor(e,t={}){super(e),h(this,"children");const i=this.bindTemplate;this.set("class",["ck","ck-form__row",...he(t.class||[])]),this.children=this.createCollection(),t.children&&t.children.forEach(o=>this.children.add(o)),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:i.to("class",o=>o.join(" ")),role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}class Nr extends uw{static get pluginName(){return"Notification"}static get isOfficialPlugin(){return!0}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||""})}}class et extends ue(){constructor(e,t){super(),t&&Rg(this,t),e&&this.set(e)}}const Ks=Vi("px");class Ue extends w{constructor(e){super(e),h(this,"positionLimiter"),h(this,"visibleStack"),h(this,"_viewToStack",new Map),h(this,"_idToStack",new Map),h(this,"_view",null),h(this,"_rotatorView",null),h(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.decorate("getPositionOptions"),this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}static get pluginName(){return"ContextualBalloon"}static get isOfficialPlugin(){return!0}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 b("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 i=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),i.set(e.view,e),this._viewToStack.set(e.view,i),i===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new b("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.getPositionOptions()),this._fakePanelsView.updatePosition()}getPositionOptions(){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,top:this.editor.ui.viewportOffset.visualTop}})),e}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new b("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new Ne(this.editor.locale),this.editor.ui.view.body.add(this._view),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(t=>t[1]===e)[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new dT(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",(i,o)=>!o&&i>1),e.on("change:isNavigationVisible",()=>this.updatePosition(),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",(i,o)=>{if(o<2)return"";const s=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[s,o])}),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 mT(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",(t,i)=>!i&&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:i=!0,singleViewMode:o=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition(),o&&(this._singleViewMode=!0)}}class dT extends A{constructor(e){super(e),h(this,"focusTracker"),h(this,"buttonPrevView"),h(this,"buttonNextView"),h(this,"content");const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new ee,this.buttonPrevView=this._createButtonView(t("Previous"),li),this.buttonNextView=this._createButtonView(t("Next"),ww),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",i.to("isNavigationVisible",o=>o?"":"ck-hidden")]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:i.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 i=new P(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class mT extends A{constructor(e,t){super(e),h(this,"content"),h(this,"_balloonPanelView");const i=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",i.to("numberOfPanels",o=>o?"":"ck-hidden")],style:{top:i.to("top",Ks),left:i.to("left",Ks),width:i.to("width",Ks),height:i.to("height",Ks)}},children:this.content}),this.on("change:numberOfPanels",(o,s,r,a)=>{r>a?this._addPanels(r-a):this._removePanels(a-r),this.updatePosition()})}_addPanels(e){for(;e--;){const t=new A;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:i,height:o}=new z(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:o})}}}class fT extends Te{constructor(e,t){const i=e.t,o=Object.assign({},{showResetButton:!0,showIcon:!0,creator:nt},t);super(e,o.creator),h(this,"iconView"),h(this,"resetButtonView"),h(this,"_viewConfig"),this.label=t.label,this._viewConfig=o,this._viewConfig.showIcon&&(this.iconView=new hi,this.iconView.content=qC,this.fieldWrapperChildren.add(this.iconView,0),this.extendTemplate({attributes:{class:"ck-search__query_with-icon"}})),this._viewConfig.showResetButton&&(this.resetButtonView=new P(e),this.resetButtonView.set({label:i("Clear"),icon:_o,class:"ck-search__reset",isVisible:!1,tooltip:!0}),this.resetButtonView.on("execute",()=>{this.reset(),this.focus(),this.fire("reset")}),this.resetButtonView.bind("isVisible").to(this.fieldView,"isEmpty",s=>!s),this.fieldWrapperChildren.add(this.resetButtonView),this.extendTemplate({attributes:{class:"ck-search__query_with-reset"}}))}reset(){this.fieldView.reset(),this._viewConfig.showResetButton&&(this.resetButtonView.isVisible=!1)}}class ub extends A{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,primaryText:"",secondaryText:""}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__info",e.if("isVisible","ck-hidden",t=>!t)],tabindex:-1},children:[{tag:"span",children:[{text:[e.to("primaryText")]}]},{tag:"span",children:[{text:[e.to("secondaryText")]}]}]})}focus(){this.element.focus()}}class gT extends A{constructor(e){super(e),h(this,"focusTracker"),h(this,"children"),h(this,"_focusCycler"),this.children=this.createCollection(),this.focusTracker=new ee,this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__results"],tabindex:-1},children:this.children}),this._focusCycler=new Ae({focusables:this.children,focusTracker:this.focusTracker})}render(){super.render();for(const e of this.children)this.focusTracker.add(e.element)}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}class pT extends A{constructor(e,t){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"resultsView"),h(this,"filteredView"),h(this,"infoView"),h(this,"queryView"),h(this,"focusCycler"),h(this,"_config"),this._config=t,this.filteredView=t.filteredView,this.queryView=this._createSearchTextQueryView(),this.focusTracker=new ee,this.keystrokes=new te,this.resultsView=new gT(e),this.children=this.createCollection(),this.focusableChildren=this.createCollection([this.queryView,this.resultsView]),this.set("isEnabled",!0),this.set("resultsCount",0),this.set("totalItemsCount",0),t.infoView&&t.infoView.instance?this.infoView=t.infoView.instance:(this.infoView=new ub,this._enableDefaultInfoViewBehavior(),this.on("render",()=>{this.search("")})),this.resultsView.children.addMany([this.infoView,this.filteredView]),this.focusCycler=new Ae({focusables:this.focusableChildren,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.on("search",(i,{resultsCount:o,totalItemsCount:s})=>{this.resultsCount=o,this.totalItemsCount=s}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search",t.class||null],tabindex:"-1"},children:this.children})}render(){super.render(),this.children.addMany([this.queryView,this.resultsView]);const e=t=>t.stopPropagation();for(const t of this.focusableChildren)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}focus(){this.queryView.focus()}reset(){this.queryView.reset(),this.search(""),this.filteredView.element.scrollTo(0,0)}search(e){const t=e?new RegExp(ta(e),"ig"):null,i=this.filteredView.filter(t);this.fire("search",{query:e,...i})}_createSearchTextQueryView(){const e=new fT(this.locale,this._config.queryView);return this.listenTo(e.fieldView,"input",()=>{this.search(e.fieldView.element.value)}),e.on("reset",()=>this.reset()),e.bind("isEnabled").to(this),e}_enableDefaultInfoViewBehavior(){const e=this.locale.t,t=this.infoView;this.on("search",(o,s)=>{if(s.resultsCount)t.set({isVisible:!1});else{const r=this._config.infoView&&this._config.infoView.text;let a,l;s.totalItemsCount?r!=null&&r.notFound?(a=r.notFound.primary,l=r.notFound.secondary):(a=e("No results found"),l=""):r!=null&&r.noSearchableItems?(a=r.noSearchableItems.primary,l=r.noSearchableItems.secondary):(a=e("No searchable items"),l=""),t.set({primaryText:i(a,s),secondaryText:i(l,s),isVisible:!0})}});function i(o,{query:s,resultsCount:r,totalItemsCount:a}){return typeof o=="function"?o(s,r,a):o}}}const wT=Vi("px");class bT extends w{constructor(e){super(e),h(this,"toolbarView"),h(this,"focusTracker"),h(this,"_balloonConfig"),h(this,"_resizeObserver",null),h(this,"_balloon"),h(this,"_fireSelectionChangeDebounced"),this._balloonConfig=gu(e.config.get("balloonToolbar")),this.toolbarView=this._createToolbarView(),this.focusTracker=new ee,this._trackFocusableEditableElements(),this.focusTracker.add(this.toolbarView),e.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this.show(!0),afterBlur:()=>this.hide(),isContextual:!0}),this._balloon=e.plugins.get(Ue),this._fireSelectionChangeDebounced=St(()=>this.fire("_selectionChangeDebounced"),200),this.decorate("show")}static get pluginName(){return"BalloonToolbar"}static get isOfficialPlugin(){return!0}static get requires(){return[Ue]}init(){const e=this.editor,t=e.model.document.selection;this.listenTo(this.focusTracker,"change:isFocused",(i,o,s)=>{const r=this._balloon.visibleView===this.toolbarView;!s&&r?this.hide():s&&this.show()}),this.listenTo(t,"change:range",(i,o)=>{(o.directChange||t.isCollapsed)&&this.hide(),this._fireSelectionChangeDebounced()}),this.listenTo(this,"_selectionChangeDebounced",()=>{this.editor.editing.view.document.isFocused&&this.show()}),this._balloonConfig.shouldNotGroupWhenFull||this.listenTo(e,"ready",()=>{const i=e.ui.view.editable.element;this._resizeObserver=new bo(i,o=>{this.toolbarView.maxWidth=wT(o.contentRect.width*.9)})}),this.listenTo(this.toolbarView,"groupedItemsUpdate",()=>{this._updatePosition()}),e.ui.once("ready",()=>{this.toolbarView.fillFromConfig(this._balloonConfig,this.editor.ui.componentFactory)})}_createToolbarView(){const e=this.editor.locale.t,t=!this._balloonConfig.shouldNotGroupWhenFull,i=new Ei(this.editor.locale,{shouldGroupWhenFull:t,isFloating:!0});return i.ariaLabel=e("Editor contextual toolbar"),i.render(),i}show(e=!1){const t=this.editor,i=t.model.document.selection,o=t.model.schema;this._balloon.hasView(this.toolbarView)||i.isCollapsed&&!e||_T(i,o)||Array.from(this.toolbarView.items).every(s=>s.isEnabled!==void 0&&!s.isEnabled)||(this.listenTo(this.editor.ui,"update",()=>{this._updatePosition()}),this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"}))}hide(){this._balloon.hasView(this.toolbarView)&&(this.stopListening(this.editor.ui,"update"),this._balloon.remove(this.toolbarView))}_trackFocusableEditableElements(){const{editor:e,focusTracker:t}=this,{editing:i}=e;i.view.addObserver(class extends Zt{observe(o){t.add(o)}stopObserving(o){t.remove(o)}})}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document,i=t.selection,o=t.selection.isBackward;return{target:()=>{const s=o?i.getFirstRange():i.getLastRange(),r=z.getDomRangeRects(e.domConverter.viewRangeToDom(s));return o?r[0]:(r.length>1&&r[r.length-1].width===0&&r.pop(),r[r.length-1])},positions:this._getBalloonPositions(o)}}_updatePosition(){this._balloon.updatePosition(this._getBalloonPositionData())}destroy(){super.destroy(),this.stopListening(),this._fireSelectionChangeDebounced.cancel(),this.toolbarView.destroy(),this.focusTracker.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_getBalloonPositions(e){const t=N.isSafari&&N.isiOS?Ne.generatePositions({heightOffset:Math.max(Ne.arrowHeightOffset,Math.round(20/I.window.visualViewport.scale))}):Ne.defaultPositions;return e?[t.northWestArrowSouth,t.northWestArrowSouthWest,t.northWestArrowSouthEast,t.northWestArrowSouthMiddleEast,t.northWestArrowSouthMiddleWest,t.southWestArrowNorth,t.southWestArrowNorthWest,t.southWestArrowNorthEast,t.southWestArrowNorthMiddleWest,t.southWestArrowNorthMiddleEast]:[t.southEastArrowNorth,t.southEastArrowNorthEast,t.southEastArrowNorthWest,t.southEastArrowNorthMiddleEast,t.southEastArrowNorthMiddleWest,t.northEastArrowSouth,t.northEastArrowSouthEast,t.northEastArrowSouthWest,t.northEastArrowSouthMiddleEast,t.northEastArrowSouthMiddleWest]}}function _T(n,e){return n.rangeCount===1?!1:[...n.getRanges()].every(t=>{const i=t.getContainedElement();return i&&e.isSelectable(i)})}const om=Vi("px");class vT extends P{constructor(e){super(e);const t=this.bindTemplate;this.isVisible=!1,this.isToggleable=!0,this.set("top",0),this.set("left",0),this.extendTemplate({attributes:{class:"ck-block-toolbar-button",style:{top:t.to("top",i=>om(i)),left:t.to("left",i=>om(i))}}})}}const Ro=Vi("px");class yT extends w{constructor(e){super(e),h(this,"toolbarView"),h(this,"panelView"),h(this,"buttonView"),h(this,"_resizeObserver",null),h(this,"_blockToolbarConfig"),this._blockToolbarConfig=gu(this.editor.config.get("blockToolbar")),this.toolbarView=this._createToolbarView(),this.panelView=this._createPanelView(),this.buttonView=this._createButtonView(),$t({emitter:this.panelView,contextElements:[this.panelView.element,this.buttonView.element],activator:()=>this.panelView.isVisible,callback:()=>this._hidePanel()})}static get pluginName(){return"BlockToolbar"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=t("Click to edit block"),o=t("Drag to move"),s=t("Edit block"),r=e.plugins.has("DragDropBlockToolbar"),a=r?`${i}
${o}`:s;this.buttonView.label=a,r&&(this.buttonView.element.dataset.ckeTooltipClass="ck-tooltip_multi-line"),this.listenTo(e.model.document.selection,"change:range",(l,c)=>{c.directChange&&this._hidePanel()}),this.listenTo(e.ui,"update",()=>this._updateButton()),this.listenTo(e,"change:isReadOnly",()=>this._updateButton(),{priority:"low"}),this.listenTo(e.ui.focusTracker,"change:isFocused",()=>this._updateButton()),this.listenTo(this.buttonView,"change:isVisible",(l,c,u)=>{u?this.buttonView.listenTo(window,"resize",()=>this._updateButton()):(this.buttonView.stopListening(window,"resize"),this._hidePanel())}),this._repositionButtonOnScroll(),e.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this._showPanel(),afterBlur:()=>this._hidePanel()}),e.ui.once("ready",()=>{this.toolbarView.fillFromConfig(this._blockToolbarConfig,this.editor.ui.componentFactory);for(const l of this.toolbarView.items)l.on("execute",()=>this._hidePanel(!0),{priority:"high"})})}destroy(){super.destroy(),this.panelView.destroy(),this.buttonView.destroy(),this.toolbarView.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_createToolbarView(){const e=this.editor.locale.t,t=!this._blockToolbarConfig.shouldNotGroupWhenFull,i=new Ei(this.editor.locale,{shouldGroupWhenFull:t,isFloating:!0});return i.ariaLabel=e("Editor block content toolbar"),i}_createPanelView(){const e=this.editor,t=new Ne(e.locale);return t.content.add(this.toolbarView),t.class="ck-toolbar-container",e.ui.view.body.add(t),this.toolbarView.keystrokes.set("Esc",(i,o)=>{this._hidePanel(!0),o()}),t}_createButtonView(){const e=this.editor,t=e.t,i=new vT(e.locale),o=this._blockToolbarConfig.icon,s=tc[o]||o||tc.dragIndicator;return i.set({label:t("Edit block"),icon:s,withText:!1}),i.bind("isOn").to(this.panelView,"isVisible"),i.bind("tooltip").to(this.panelView,"isVisible",r=>!r),this.listenTo(i,"execute",()=>{this.panelView.isVisible?this._hidePanel(!0):this._showPanel()}),this.listenTo(i,"change:isEnabled",(r,a,l)=>{!l&&this.panelView.isVisible&&this._hidePanel(!1)}),e.ui.view.body.add(i),i}_updateButton(){const e=this.editor,t=e.model,i=e.editing.view;if(!e.ui.focusTracker.isFocused){this._hideButton();return}if(!e.model.canEditAt(e.model.document.selection)){this._hideButton();return}const o=Array.from(t.document.selection.getSelectedBlocks())[0];if(!o||Array.from(this.toolbarView.items).every(r=>!r.isEnabled)){this._hideButton();return}const s=i.domConverter.mapViewToDom(e.editing.mapper.toViewElement(o));this.buttonView.isVisible=!0,this._setupToolbarResize(),this._attachButtonToElement(s),this.panelView.isVisible&&this._showPanel()}_hideButton(){this.buttonView.isVisible=!1}_showPanel(){if(!this.buttonView.isVisible)return;const e=this.panelView.isVisible;this.panelView.show();const t=this._getSelectedEditableElement();this.toolbarView.maxWidth=this._getToolbarMaxWidth(t),this.panelView.pin({target:this.buttonView.element,limiter:t}),e||this.toolbarView.items.get(0).focus()}_getSelectedEditableElement(){const e=this.editor.model.document.selection.getFirstRange().root.rootName;return this.editor.ui.getEditableElement(e)}_hidePanel(e){this.panelView.isVisible=!1,e&&this.editor.editing.view.focus()}_repositionButtonOnScroll(){const{buttonView:e}=this;let t=!1;const i=(o,s)=>{if(t)return;const r=this._getSelectedEditableElement();s.target!==I.document&&!Zg(r).includes(s.target)||(t=!0,I.window.requestAnimationFrame(()=>{this._updateButton(),t=!1}))};e.on("change:isVisible",(o,s,r)=>{r?e.listenTo(I.document,"scroll",i,{useCapture:!0,usePassive:!0}):e.stopListening(I.document,"scroll",i)})}_attachButtonToElement(e){const t=this.buttonView.element,i=this._getSelectedEditableElement(),o=window.getComputedStyle(e),s=new z(i),r=parseInt(o.paddingTop,10),a=parseInt(o.lineHeight,10)||parseInt(o.fontSize,10)*1.2,l=new z(t),c=new z(e);let u;this.editor.locale.uiLanguageDirection==="ltr"?u=s.left-l.width:u=s.right;const d=c.top+r+(a-l.height)/2;l.moveTo(u,d);const m=l.toAbsoluteRect();this.buttonView.top=m.top,this.buttonView.left=m.left,this._clipButtonToViewport(this.buttonView,i)}_clipButtonToViewport(e,t){const i=new z(e.element),o=new z(t).getVisible(),s=(...a)=>{e.element.style.clipPath=a.length?`polygon(${a.join(",")})`:""},r=a=>{e.isEnabled=!a,e.element.style.pointerEvents=a?"none":""};if(o&&o.bottom=i.height),s("0 0","100% 0",`100% calc(100% - ${Ro(a)})`,`0 calc(100% - ${Ro(a)}`)}else if(o&&o.top>i.top){const a=Math.min(i.height,o.top-i.top);r(a>=i.height),s(`0 ${Ro(a)}`,`100% ${Ro(a)}`,"100% 100%","0 100%")}else r(!1),s()}_setupToolbarResize(){const e=this._getSelectedEditableElement();this._blockToolbarConfig.shouldNotGroupWhenFull||(this._resizeObserver&&this._resizeObserver.element!==e&&(this._resizeObserver.destroy(),this._resizeObserver=null),this._resizeObserver||(this._resizeObserver=new bo(e,()=>{this.toolbarView.maxWidth=this._getToolbarMaxWidth(e)})))}_getToolbarMaxWidth(e){const t=new z(e),i=new z(this.buttonView.element),o=this.editor.locale.uiLanguageDirection==="rtl"?i.left-t.right+i.width:t.left-i.left;return Ro(t.width+o)}}class kT extends ko{constructor(e){super(e),h(this,"arrowView");const t=this.bindTemplate;this.set({withText:!0,role:"menuitem"}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__button"],"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",i=>String(i)),"data-cke-tooltip-disabled":t.to("isOn")},on:{mouseenter:t.to("mouseenter")}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new hi;return e.content=da,e.extendTemplate({attributes:{class:"ck-menu-bar__menu__button__arrow"}}),e}}class CT extends A{constructor(e){super(e),h(this,"children");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-menu-bar__menu__panel",t.to("position",i=>`ck-menu-bar__menu__panel_position_${i}`),t.if("isVisible","ck-hidden",i=>!i)],tabindex:"-1"},children:this.children,on:{selectstart:t.to(i=>{i.target.tagName.toLocaleLowerCase()!=="input"&&i.preventDefault()})}})}focus(e=1){this.children.length&&(e===1?this.children.first.focus():this.children.last.focus())}}const hb=class db extends A{constructor(e){super(e),h(this,"buttonView"),h(this,"panelView"),h(this,"focusTracker"),h(this,"keystrokes");const t=this.bindTemplate;this.buttonView=new kT(e),this.buttonView.delegate("mouseenter").to(this),this.buttonView.bind("isOn","isEnabled").to(this,"isOpen","isEnabled"),this.panelView=new CT(e),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new te,this.focusTracker=new ee,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("panelPosition","w"),this.set("class",void 0),this.set("parentMenuView",null),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar__menu",t.to("class"),t.if("isEnabled","ck-disabled",i=>!i),t.if("parentMenuView","ck-menu-bar__menu_top-level",i=>!i)]},children:[this.buttonView,this.panelView]})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.keystrokes.listenTo(this.element),Fi.closeOnEscKey(this),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(Fi.openOnButtonClick(this),Fi.openOnArrowRightKey(this),Fi.closeOnArrowLeftKey(this),Fi.openAndFocusOnEnterKeyPress(this),Fi.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),Fi.openAndFocusPanelOnArrowDownKey(this),Fi.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set("arrowright",(e,t)=>{this.fire("arrowright"),t()}),this.keystrokes.set("arrowleft",(e,t)=>{this.fire("arrowleft"),t()})}_repositionPanelOnOpen(){this.on("change:isOpen",(e,t,i)=>{if(!i)return;const o=db._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=o?o.name:this._defaultMenuPositionName})}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:e,southWest:t,northEast:i,northWest:o,westSouth:s,eastSouth:r,westNorth:a,eastNorth:l}=eT;return this.locale.uiLanguageDirection==="ltr"?this.parentMenuView?[r,l,s,a]:[e,t,i,o]:this.parentMenuView?[s,a,r,l]:[t,e,o,i]}get _defaultMenuPositionName(){return this.locale.uiLanguageDirection==="ltr"?this.parentMenuView?"es":"se":this.parentMenuView?"ws":"sw"}};h(hb,"_getOptimalPosition",zc);let Tt=hb;class Si extends En{constructor(e){super(e),this.role="menu",this.items.on("change",this._setItemsCheckSpace.bind(this))}_setItemsCheckSpace(){const e=Array.from(this.items).some(t=>{const i=sm(t);return i&&i.isToggleable});this.items.forEach(t=>{const i=sm(t);i&&(i.hasCheckSpace=e)})}}function sm(n){return n instanceof Nt?n.children.map(e=>AT(e)?e.buttonView:e).find(e=>e instanceof ko):null}function AT(n){return typeof n=="object"&&"buttonView"in n&&n.buttonView instanceof P}class mb extends ax{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}const rm=["mouseenter","arrowleft","arrowright","change:isOpen"];class fb extends A{constructor(e){super(e),h(this,"children"),h(this,"menus",[]);const t=e.t,i=this.bindTemplate;this.set({isOpen:!1,isFocusBorderEnabled:!1}),this._setupIsOpenUpdater(),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar",i.if("isFocusBorderEnabled","ck-menu-bar_focus-border-enabled")],"aria-label":t("Editor menu bar"),role:"menubar"},children:this.children})}fillFromConfig(e,t,i=[]){const o=this.locale,s=nT({normalizedConfig:e,locale:o,componentFactory:t,extraItems:i}).items.map(r=>this._createMenu({componentFactory:t,menuDefinition:r}));this.children.addMany(s)}render(){super.render(),Dn.toggleMenusAndFocusItemsOnHover(this),Dn.closeMenusWhenTheBarCloses(this),Dn.closeMenuWhenAnotherOnTheSameLevelOpens(this),Dn.focusCycleMenusOnArrows(this),Dn.closeOnClickOutside(this),Dn.enableFocusHighlightOnInteraction(this)}focus(){this.children.first&&this.children.first.focus()}close(){for(const e of this.children)e.isOpen=!1}disable(){for(const e of this.children)e.isEnabled=!1}enable(){for(const e of this.children)e.isEnabled=!0}registerMenu(e,t=null){t?(e.delegate(...rm).to(t),e.parentMenuView=t):e.delegate(...rm).to(this,i=>"menu:"+i),e._attachBehaviors(),this.menus.push(e)}_createMenu({componentFactory:e,menuDefinition:t,parentMenuView:i}){const o=this.locale,s=new Tt(o);return this.registerMenu(s,i),s.buttonView.set({label:t.label}),s.once("change:isOpen",()=>{const r=new Si(o);r.ariaLabel=t.label,s.panelView.children.add(r),r.items.addMany(this._createMenuItems({menuDefinition:t,parentMenuView:s,componentFactory:e}))}),s}_createMenuItems({menuDefinition:e,parentMenuView:t,componentFactory:i}){const o=this.locale,s=[];for(const r of e.groups){for(const a of r.items){const l=new Oi(o,t);if(Et(a))l.children.add(this._createMenu({componentFactory:i,menuDefinition:a,parentMenuView:t}));else{const c=this._createMenuItemContentFromFactory({componentName:a,componentFactory:i,parentMenuView:t});if(!c)continue;l.children.add(c)}s.push(l)}r!==e.groups[e.groups.length-1]&&s.push(new ma(o))}return s}_createMenuItemContentFromFactory({componentName:e,parentMenuView:t,componentFactory:i}){const o=i.create(e);return o instanceof Tt||o instanceof ve||o instanceof mb?(this._registerMenuTree(o,t),o.on("execute",()=>{this.close()}),o):(J("menu-bar-component-unsupported",{componentName:e,componentView:o}),null)}_registerMenuTree(e,t){if(!(e instanceof Tt)){e.delegate("mouseenter").to(t);return}this.registerMenu(e,t);const i=e.panelView.children.filter(s=>s instanceof Si)[0];if(!i){e.delegate("mouseenter").to(t);return}const o=i.items.filter(s=>s instanceof Nt);for(const s of o)this._registerMenuTree(s.children.get(0),e)}_setupIsOpenUpdater(){let e;this.on("menu:change:isOpen",(t,i,o)=>{clearTimeout(e),o?this.isOpen=!0:e=setTimeout(()=>{this.isOpen=Array.from(this.children).some(s=>s.isOpen)},0)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const bu=["left","right","center","justify"];function gb(n){return bu.includes(n)}function pb(n,e){return e.contentLanguageDirection=="rtl"?n==="right":n==="left"}function wb(n){const e=n.map(i=>{let o;return typeof i=="string"?o={name:i}:o=i,o}).filter(i=>{const o=bu.includes(i.name);return o||J("alignment-config-name-not-recognized",{option:i}),o}),t=e.filter(i=>!!i.className).length;if(t&&t{const r=s.slice(o+1);if(r.some(a=>a.name==i.name))throw new b("alignment-config-name-already-defined",{option:i,configuredOptions:n});if(i.className&&r.some(a=>a.className==i.className))throw new b("alignment-config-classname-already-defined",{option:i,configuredOptions:n})}),e}const _u="alignment";class xT extends O{refresh(){const e=this.editor.locale,t=ae(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=!!t&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value=e.contentLanguageDirection==="rtl"?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,o=t.model,s=o.document,r=e.value;o.change(a=>{const l=Array.from(s.selection.getSelectedBlocks()).filter(u=>this._canBeAligned(u)),c=l[0].getAttribute("alignment");pb(r,i)||c===r||!r?TT(l,a):ET(l,a,r)})}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,_u)}}function TT(n,e){for(const t of n)e.removeAttribute(_u,t)}function ET(n,e,t){for(const i of n)e.setAttribute(_u,t,i)}class ST extends w{static get pluginName(){return"AlignmentEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("alignment",{options:bu.map(t=>({name:t}))})}init(){const e=this.editor,t=e.locale,i=e.model.schema,o=wb(e.config.get("alignment.options")).filter(l=>gb(l.name)&&!pb(l.name,t)),s=o.some(l=>!!l.className);i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),s?e.conversion.attributeToAttribute(RT(o)):e.conversion.for("downcast").attributeToAttribute(PT(o));const r=IT(o);for(const l of r)e.conversion.for("upcast").attributeToAttribute(l);const a=VT(o);for(const l of a)e.conversion.for("upcast").attributeToAttribute(l);e.commands.add("alignment",new xT(e))}}function PT(n){const e={};for(const{name:t}of n)e[t]={key:"style",value:{"text-align":t}};return{model:{key:"alignment",values:n.map(t=>t.name)},view:e}}function IT(n){const e=[];for(const{name:t}of n)e.push({view:{key:"style",value:{"text-align":t}},model:{key:"alignment",value:t}});return e}function VT(n){const e=[];for(const{name:t}of n)e.push({view:{key:"align",value:t},model:{key:"alignment",value:t}});return e}function RT(n){const e={};for(const t of n)e[t.name]={key:"class",value:t.className};return{model:{key:"alignment",values:n.map(t=>t.name)},view:e}}const Oo=new Map([["left",nu],["right",fw],["center",dw],["justify",mw]]);class OT extends w{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=wb(e.config.get("alignment.options"));t.map(i=>i.name).filter(gb).forEach(i=>this._addButton(i)),this._addToolbarDropdown(t),this._addMenuBarMenu(t)}_addButton(e){this.editor.ui.componentFactory.add(`alignment:${e}`,t=>this._createButton(t,e))}_createButton(e,t,i={}){const o=this.editor,s=o.commands.get("alignment"),r=new P(e);return r.set({label:this.localizedOptionTitles[t],icon:Oo.get(t),tooltip:!0,isToggleable:!0,...i}),r.bind("isEnabled").to(s),r.bind("isOn").to(s,"value",a=>a===t),this.listenTo(r,"execute",()=>{o.execute("alignment",{value:t}),o.editing.view.focus()}),r}_addToolbarDropdown(e){const t=this.editor;t.ui.componentFactory.add("alignment",i=>{const o=Ee(i),s=i.uiLanguageDirection==="rtl"?"w":"e",r=i.t;fa(o,()=>e.map(c=>this._createButton(i,c.name,{tooltipPosition:s})),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:r("Text alignment toolbar")}),o.buttonView.set({label:r("Text alignment"),tooltip:!0}),o.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const a=i.contentLanguageDirection==="rtl"?Oo.get("right"):Oo.get("left"),l=t.commands.get("alignment");return o.buttonView.bind("icon").to(l,"value",c=>Oo.get(c)||a),o.bind("isEnabled").to(l,"isEnabled"),this.listenTo(o,"execute",()=>{t.editing.view.focus()}),o})}_addMenuBarMenu(e){const t=this.editor;t.ui.componentFactory.add("menuBar:alignment",i=>{const o=t.commands.get("alignment"),s=i.t,r=new Tt(i),a=new Si(i);r.bind("isEnabled").to(o),a.set({ariaLabel:s("Text alignment"),role:"menu"}),r.buttonView.set({label:s("Text alignment")});for(const l of e){const c=new Oi(i,r),u=new ve(i);u.delegate("execute").to(r),u.set({label:this.localizedOptionTitles[l.name],icon:Oo.get(l.name),role:"menuitemcheckbox",isToggleable:!0}),u.on("execute",()=>{t.execute("alignment",{value:l.name}),t.editing.view.focus()}),u.bind("isOn").to(o,"value",d=>d===l.name),u.bind("isEnabled").to(o,"isEnabled"),c.children.add(u),a.items.add(c)}return r.panelView.children.add(a),r})}}class BT extends w{static get requires(){return[ST,OT]}static get pluginName(){return"Alignment"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bb{constructor(e,t=20){h(this,"model"),h(this,"limit"),h(this,"_isLocked"),h(this,"_size"),h(this,"_batch",null),h(this,"_changeCallback"),h(this,"_selectionChangeCallback"),this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(i,o)=>{o.isLocal&&o.isUndoable&&o!==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)}}class MT extends O{constructor(e,t){super(e),h(this,"_buffer"),this._buffer=new bb(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,i=t.document,o=e.text||"",s=o.length;let r=i.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();const c=Array.from(i.selection.getAttributes());t.deleteContent(r),o&&t.insertContent(l.createText(o,c),r),a?l.setSelection(a):r.is("documentSelection")||l.setSelection(r),this._buffer.unlock(),this._buffer.input(s)})}}const _b=["insertText","insertReplacementText"],LT=[..._b,"insertCompositionText"];class FT extends Zt{constructor(e){super(e),h(this,"focusObserver"),this.focusObserver=e.getObserver(Vr);const t=N.isAndroid?LT:_b,i=e.document;i.on("beforeinput",(o,s)=>{if(!this.isEnabled)return;const{data:r,targetRanges:a,inputType:l,domEvent:c,isComposing:u}=s;if(!t.includes(l))return;this.focusObserver.flush();const d=new Ti(i,"insertText");i.fire(d,new kn(e,c,{text:r,selection:e.createSelection(a),isComposing:u})),d.stop.called&&o.stop()}),N.isAndroid||i.on("compositionend",(o,{data:s,domEvent:r})=>{this.isEnabled&&s&&i.fire("insertText",new kn(e,r,{text:s,isComposing:!0}))},{priority:"low"})}observe(){}stopObserving(){}}class vb extends w{constructor(){super(...arguments),h(this,"_typingQueue")}static get pluginName(){return"Input"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=e.editing.view,o=e.editing.mapper,s=t.document.selection;this._typingQueue=new NT(e),i.addObserver(FT);const r=new MT(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",r),e.commands.add("input",r),this.listenTo(i.document,"beforeinput",()=>{this._typingQueue.flush("next beforeinput")},{priority:"high"}),this.listenTo(i.document,"insertText",(a,l)=>{const{text:c,selection:u}=l;if(i.document.selection.isFake&&u&&i.document.selection.isSimilar(u)&&l.preventDefault(),!r.isEnabled){l.preventDefault();return}let d;u?d=Array.from(u.getRanges()).map(g=>o.toModelRange(g)):d=Array.from(s.getRanges());let m=c;if(N.isAndroid){const g=Array.from(d[0].getItems()).reduce((p,_)=>p+(_.is("$textProxy")?_.data:""),"");if(g&&(g.length<=m.length?m.startsWith(g)&&(m=m.substring(g.length),d[0].start=d[0].start.getShiftedBy(g.length)):g.startsWith(m)&&(d[0].start=d[0].start.getShiftedBy(m.length),m="")),m.length==0&&d[0].isCollapsed)return}const f={text:m,selection:t.createSelection(d)};this._typingQueue.push(f,!!l.isComposing),l.domEvent.defaultPrevented&&this._typingQueue.flush("beforeinput default prevented")}),N.isAndroid?this.listenTo(i.document,"keydown",(a,l)=>{s.isCollapsed||l.keyCode!=229||!i.document.isComposing||am(t,r)}):this.listenTo(i.document,"compositionstart",()=>{s.isCollapsed||am(t,r)},{priority:"high"}),this.listenTo(i.document,"mutations",(a,{mutations:l})=>{if(this._typingQueue.hasAffectedElements())for(const{node:c}of l){const u=zT(c,o),d=o.toModelElement(u);if(this._typingQueue.isElementAffected(d)){this._typingQueue.flush("mutations");return}}}),this.listenTo(i.document,"compositionend",()=>{this._typingQueue.flush("before composition end")},{priority:"high"}),this.listenTo(i.document,"compositionend",()=>{this._typingQueue.flush("after composition end");const a=[];if(this._typingQueue.hasAffectedElements())for(const l of this._typingQueue.flushAffectedElements()){const c=o.toViewElement(l);c&&a.push({type:"children",node:c})}(a.length||!N.isAndroid)&&i.document.fire("mutations",{mutations:a})},{priority:"lowest"})}destroy(){super.destroy(),this._typingQueue.destroy()}}class NT{constructor(e){h(this,"editor"),h(this,"flushDebounced",St(()=>this.flush("timeout"),50)),h(this,"_queue",[]),h(this,"_isComposing",!1),h(this,"_affectedElements",new Set),this.editor=e}destroy(){for(this.flushDebounced.cancel(),this._affectedElements.clear();this._queue.length;)this.shift()}get length(){return this._queue.length}push(e,t){const i={text:e.text};if(e.selection){i.selectionRanges=[];for(const o of e.selection.getRanges())i.selectionRanges.push(ht.fromRange(o)),this._affectedElements.add(o.start.parent)}this._queue.push(i),this._isComposing||(this._isComposing=t),this.flushDebounced()}shift(){const e=this._queue.shift(),t={text:e.text};if(e.selectionRanges){const i=e.selectionRanges.map(o=>DT(o)).filter(o=>!!o);i.length&&(t.selection=this.editor.model.createSelection(i))}return t}flush(e){const t=this.editor,i=t.model,o=t.editing.view;if(this.flushDebounced.cancel(),!this._queue.length)return;const s=t.commands.get("insertText").buffer;i.enqueueChange(s.batch,()=>{for(s.lock();this._queue.length;){const r=this.shift();t.execute("insertText",r)}s.unlock(),this._isComposing||this._affectedElements.clear(),this._isComposing=!1}),o.scrollToTheSelection()}isElementAffected(e){return this._affectedElements.has(e)}hasAffectedElements(){return this._affectedElements.size>0}flushAffectedElements(){const e=Array.from(this._affectedElements);return this._affectedElements.clear(),e}}function am(n,e){if(!e.isEnabled)return;const t=e.buffer;t.lock(),n.enqueueChange(t.batch,()=>{n.deleteContent(n.document.selection)}),t.unlock()}function DT(n){const e=n.toRange();return n.detach(),e.root.rootName=="$graveyard"?null:e}function zT(n,e){let t=n.is("$text")?n.parent:n;for(;!e.toModelElement(t);)t=t.parent;return t}class lm extends O{constructor(e,t){super(e),h(this,"direction"),h(this,"_buffer"),this.direction=t,this._buffer=new bb(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,i=t.document;t.enqueueChange(this._buffer.batch,o=>{this._buffer.lock();const s=o.createSelection(e.selection||i.selection);if(!t.canEditAt(s))return;const r=e.sequence||1,a=s.isCollapsed;if(s.isCollapsed&&t.modifySelection(s,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(r)){this._replaceEntireContentWithParagraph(o);return}if(this._shouldReplaceFirstBlockWithParagraph(s,r)){this.editor.execute("paragraph",{selection:s});return}if(s.isCollapsed)return;let l=0;s.getFirstRange().getMinimalFlatRanges().forEach(c=>{l+=Ml(c.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))}),t.deleteContent(s,{doNotResetEntireContent:a,direction:this.direction}),this._buffer.input(l),o.setSelection(s),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 s=o.getChild(0);return!(s&&s.is("element","paragraph"))}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,o=t.schema.getLimitElement(i),s=e.createElement("paragraph");e.remove(e.createRangeIn(o)),e.insert(s,o),e.setSelection(s,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||this.direction!="backward"||!e.isCollapsed)return!1;const o=e.getFirstPosition(),s=i.schema.getLimitElement(o),r=s.getChild(0);return!(o.parent!=r||!e.containsEntireContent(r)||!i.schema.checkChild(s,"paragraph")||r.name=="paragraph")}}const HT="character",cm="word",$T="codePoint",$i="selection",Qn="backward",qo="forward",yb={deleteContent:{unit:$i,direction:Qn},deleteContentBackward:{unit:$T,direction:Qn},deleteWordBackward:{unit:cm,direction:Qn},deleteHardLineBackward:{unit:$i,direction:Qn},deleteSoftLineBackward:{unit:$i,direction:Qn},deleteContentForward:{unit:HT,direction:qo},deleteWordForward:{unit:cm,direction:qo},deleteHardLineForward:{unit:$i,direction:qo},deleteSoftLineForward:{unit:$i,direction:qo}};class WT extends Zt{constructor(e){super(e);const t=e.document;let i=0;t.on("keydown",()=>{i++}),t.on("keyup",()=>{i=0}),t.on("beforeinput",(o,s)=>{if(!this.isEnabled)return;const{targetRanges:r,domEvent:a,inputType:l}=s,c=yb[l];if(!c)return;const u={direction:c.direction,unit:c.unit,sequence:i};u.unit==$i&&(u.selectionToRemove=e.createSelection(r[0])),l==="deleteContentBackward"&&(N.isAndroid&&(u.sequence=1),UT(r)&&(u.unit=$i,u.selectionToRemove=e.createSelection(r)));const d=new xn(t,"delete",r[0]);t.fire(d,new kn(e,a,u)),d.stop.called&&o.stop()}),N.isBlink&&jT(this)}observe(){}stopObserving(){}}function jT(n){const e=n.view,t=e.document;let i=null,o=!1;t.on("keydown",(a,{keyCode:l})=>{i=l,o=!1}),t.on("keyup",(a,{keyCode:l,domEvent:c})=>{const u=t.selection,d=n.isEnabled&&l==i&&s(l)&&!u.isCollapsed&&!o;if(i=null,d){const m=u.getFirstRange(),f=new xn(t,"delete",m),g={unit:$i,direction:r(l),selectionToRemove:u};t.fire(f,new kn(e,c,g))}}),t.on("beforeinput",(a,{inputType:l})=>{const c=yb[l];s(i)&&c&&c.direction==r(i)&&(o=!0)},{priority:"high"}),t.on("beforeinput",(a,{inputType:l,data:c})=>{i==Z.delete&&l=="insertText"&&c==""&&a.stop()},{priority:"high"});function s(a){return a==Z.backspace||a==Z.delete}function r(a){return a==Z.backspace?Qn:qo}}function UT(n){if(n.length!=1||n[0].isCollapsed)return!1;const e=n[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let t=0;for(const{nextPosition:i,item:o}of e){if(i.parent.is("$text")){const s=i.parent.data,r=i.offset;if(jc(s,r)||Uc(s,r)||cp(s,r))continue;t++}else(o.is("containerElement")||o.is("emptyElement"))&&t++;if(t>1)return!0}return!1}class en extends w{constructor(){super(...arguments),h(this,"_undoOnBackspace")}static get pluginName(){return"Delete"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,o=e.model.document;t.addObserver(WT),this._undoOnBackspace=!1;const s=new lm(e,"forward");e.commands.add("deleteForward",s),e.commands.add("forwardDelete",s),e.commands.add("delete",new lm(e,"backward")),this.listenTo(i,"delete",(r,a)=>{i.isComposing||a.preventDefault();const{direction:l,sequence:c,selectionToRemove:u,unit:d}=a,m=l==="forward"?"deleteForward":"delete",f={sequence:c};if(d=="selection"){const g=Array.from(u.getRanges()).map(p=>e.editing.mapper.toModelRange(p));f.selection=e.model.createSelection(g)}else f.unit=d;e.execute(m,f),t.scrollToTheSelection()},{priority:"low"}),this.listenTo(i,"keydown",(r,a)=>{if(i.isComposing||a.keyCode!=Z.backspace||!o.selection.isCollapsed)return;const l=e.model.schema.getLimitElement(o.selection),c=e.model.createPositionAt(l,0);if(c.isTouching(o.selection.getFirstPosition())){a.preventDefault();const u=e.model.schema.getNearestSelectionRange(c,"forward");if(!u)return;const d=t.createSelection(e.editing.mapper.toViewRange(u)),m=d.getFirstRange(),f=new xn(document,"delete",m),g={unit:"selection",direction:"backward",selectionToRemove:d};i.fire(f,new kn(t,a.domEvent,g))}}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(i,"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(o,"change",()=>{this._undoOnBackspace=!1}))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class pa extends w{static get requires(){return[vb,en]}static get pluginName(){return"Typing"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function kb(n,e){let t=n.start;return{text:Array.from(n.getWalker({ignoreElementEnd:!1})).reduce((i,{item:o})=>o.is("$text")||o.is("$textProxy")?i+o.data:(t=e.createPositionAfter(o),""),""),range:e.createRange(t,n.end)}}class vu extends ue(){constructor(e,t){super(),h(this,"model"),h(this,"testCallback"),h(this,"_hasMatch"),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 e=this.model.document;this.listenTo(e.selection,"change:range",(t,{directChange:i})=>{if(i){if(!e.selection.isCollapsed){this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1);return}this._evaluateTextBeforeSelection("selection")}}),this.listenTo(e,"change:data",(t,i)=>{i.isUndo||!i.isLocal||this._evaluateTextBeforeSelection("data",{batch:i})})}_evaluateTextBeforeSelection(e,t={}){const i=this.model,o=i.document.selection,s=i.createRange(i.createPositionAt(o.focus.parent,0),o.focus),{text:r,range:a}=kb(s,i),l=this.testCallback(r);if(!l&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!l,l){const c=Object.assign(t,{text:r,range:a});typeof l=="object"&&Object.assign(c,l),this.fire(`matched:${e}`,c)}}}class Dr extends w{constructor(e){super(e),h(this,"attributes"),h(this,"_overrideUid"),h(this,"_isNextGravityRestorationSkipped",!1),this.attributes=new Set,this._overrideUid=null}static get pluginName(){return"TwoStepCaretMovement"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=e.editing.view,o=e.locale,s=t.document.selection;this.listenTo(i.document,"arrowKey",(r,a)=>{if(!s.isCollapsed||a.shiftKey||a.altKey||a.ctrlKey)return;const l=a.keyCode==Z.arrowright,c=a.keyCode==Z.arrowleft;if(!l&&!c)return;const u=o.contentLanguageDirection;let d=!1;u==="ltr"&&l||u==="rtl"&&c?d=this._handleForwardMovement(a):d=this._handleBackwardMovement(a),d===!0&&r.stop()},{context:"$text",priority:"highest"}),this.listenTo(s,"change:range",(r,a)=>{if(this._isNextGravityRestorationSkipped){this._isNextGravityRestorationSkipped=!1;return}this._isGravityOverridden&&(!a.directChange&&Mt(s.getFirstPosition(),this.attributes)||this._restoreGravity())}),this._enableClickingAfterNode(),this._enableInsertContentSelectionAttributesFixer(),this._handleDeleteContentAfterNode()}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model,o=i.document.selection,s=o.getFirstPosition();return this._isGravityOverridden||s.isAtStart&&gi(o,t)?!1:Mt(s,t)?(e&&Mo(e),gi(o,t)&&Mt(s,t,!0)?Bo(i,t):this._overrideGravity(),!0):!1}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,o=i.document.selection,s=o.getFirstPosition();return this._isGravityOverridden?(e&&Mo(e),this._restoreGravity(),Mt(s,t,!0)?Bo(i,t):Zs(i,t,s),!0):s.isAtStart?gi(o,t)?(e&&Mo(e),Zs(i,t,s),!0):!1:!gi(o,t)&&Mt(s,t,!0)?(e&&Mo(e),Zs(i,t,s),!0):um(s,t)?s.isAtEnd&&!gi(o,t)&&Mt(s,t)?(e&&Mo(e),Zs(i,t,s),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):!1}_enableClickingAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,o=e.editing.view.document;e.editing.view.addObserver(ua),e.editing.view.addObserver(c5);let s=!1,r=!1;this.listenTo(o,"touchstart",()=>{r=!1,s=!0}),this.listenTo(o,"mousedown",()=>{r=!0}),this.listenTo(o,"selectionChange",()=>{const a=this.attributes;if(!r&&!s||(r=!1,s=!1,!i.isCollapsed)||!gi(i,a))return;const l=i.getFirstPosition();Mt(l,a)&&(l.isAtStart||Mt(l,a,!0)?Bo(t,a):this._isGravityOverridden||this._overrideGravity())})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection,i=this.attributes;this.listenTo(e,"insertContent",()=>{const o=t.getFirstPosition();gi(t,i)&&Mt(o,i)&&Bo(e,i)},{priority:"low"})}_handleDeleteContentAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,o=e.editing.view;let s=!1,r=!1;this.listenTo(o.document,"delete",(a,l)=>{s=l.direction==="backward"},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{if(!s)return;const a=i.getFirstPosition();r=gi(i,this.attributes)&&!um(a,this.attributes)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{s&&(s=!1,!r&&e.model.enqueueChange(()=>{const a=i.getFirstPosition();gi(i,this.attributes)&&Mt(a,this.attributes)&&(a.isAtStart||Mt(a,this.attributes,!0)?Bo(t,this.attributes):this._isGravityOverridden||this._overrideGravity())}))},{priority:"low"})}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 gi(n,e){for(const t of e)if(n.hasAttribute(t))return!0;return!1}function Zs(n,e,t){const i=t.nodeBefore;n.change(o=>{if(i){const s=[],r=n.schema.isObject(i)&&n.schema.isInline(i);for(const[a,l]of i.getAttributes())n.schema.checkAttribute("$text",a)&&(!r||n.schema.getAttributeProperties(a).copyFromObject!==!1)&&s.push([a,l]);o.setSelectionAttribute(s)}else o.removeSelectionAttribute(e)})}function Bo(n,e){n.change(t=>{t.removeSelectionAttribute(e)})}function Mo(n){n.preventDefault()}function um(n,e){const t=n.getShiftedBy(-1);return Mt(t,e)}function Mt(n,e,t=!1){const{nodeBefore:i,nodeAfter:o}=n;for(const s of e){const r=i?i.getAttribute(s):void 0,a=o?o.getAttribute(s):void 0;if(!(t&&(r===void 0||a===void 0))&&a!==r)return!0}return!1}const hm={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:zn('"'),to:[null,"“",null,"”"]},quotesSecondary:{from:zn("'"),to:[null,"‘",null,"’"]},quotesPrimaryEnGb:{from:zn("'"),to:[null,"‘",null,"’"]},quotesSecondaryEnGb:{from:zn('"'),to:[null,"“",null,"”"]},quotesPrimaryPl:{from:zn('"'),to:[null,"„",null,"”"]},quotesSecondaryPl:{from:zn("'"),to:[null,"‚",null,"’"]}},dm={symbols:["copyright","registeredTrademark","trademark"],mathematical:["oneHalf","oneThird","twoThirds","oneForth","threeQuarters","lessThanOrEqual","greaterThanOrEqual","notEqual","arrowLeft","arrowRight"],typography:["horizontalEllipsis","enDash","emDash"],quotes:["quotesPrimary","quotesSecondary"]},qT=["symbols","mathematical","typography","quotes"];class GT extends w{static get requires(){return["Delete","Input"]}static get pluginName(){return"TextTransformation"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("typing",{transformations:{include:qT}})}init(){const e=this.editor.model.document.selection;e.on("change:range",()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}),this._enableTransformationWatchers()}_enableTransformationWatchers(){const e=this.editor,t=e.model,i=e.plugins.get("Delete"),o=QT(e.config.get("typing.transformations")),s=a=>{for(const l of o)if(l.from.test(a))return{normalizedTransformation:l}},r=new vu(e.model,s);r.on("matched:data",(a,l)=>{if(!l.batch.isTyping)return;const{from:c,to:u}=l.normalizedTransformation,d=c.exec(l.text),m=u(d.slice(1)),f=l.range;let g=d.index;t.enqueueChange(p=>{for(let _=1;_{i.requestUndoOnBackspace()})})}),r.bind("isEnabled").to(this)}}function KT(n){return typeof n=="string"?new RegExp(`(${ta(n)})$`):n}function ZT(n){return typeof n=="string"?()=>[n]:n instanceof Array?()=>n:n}function JT(n){return(n.textNode?n.textNode:n.nodeAfter).getAttributes()}function zn(n){return new RegExp(`(^|\\s)(${n})([^${n}]*)(${n})$`)}function QT(n){const e=n.extra||[],t=n.remove||[],i=s=>!t.includes(s),o=n.include.concat(e).filter(i);return YT(o).filter(i).map(s=>typeof s=="string"&&hm[s]?hm[s]:s).filter(s=>typeof s=="object").map(s=>({from:KT(s.from),to:ZT(s.to)}))}function YT(n){const e=new Set;for(const t of n)if(typeof t=="string"&&dm[t])for(const i of dm[t])e.add(i);else e.add(t);return Array.from(e)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ps(n,e,t,i){return i.createRange(ic(n,e,t,!0,i),ic(n,e,t,!1,i))}function ic(n,e,t,i,o){let s=n.textNode||(i?n.nodeBefore:n.nodeAfter),r=null;for(;s&&s.getAttribute(e)==t;)r=s,s=i?s.previousSibling:s.nextSibling;return r?o.createPositionAt(r,i?"before":"after"):n}function Cb(n,e,t,i){const o=n.editing.view,s=new Set;o.document.registerPostFixer(r=>{const a=n.model.document.selection;let l=!1;if(a.hasAttribute(e)){const c=Ps(a.getFirstPosition(),e,a.getAttribute(e),n.model),u=n.editing.mapper.toViewRange(c);for(const d of u.getItems())d.is("element",t)&&!d.hasClass(i)&&(r.addClass(i,d),s.add(d),l=!0)}return l}),n.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(){o.change(l=>{for(const c of s.values())l.removeClass(i,c),s.delete(c)})}})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Wt(n,e,t,i){let o,s=null;typeof i=="function"?o=i:(s=n.commands.get(i),o=()=>{n.execute(i)}),n.model.document.on("change:data",(r,a)=>{if(s&&!s.isEnabled||!e.isEnabled)return;const l=ae(n.model.document.selection.getRanges());if(!l.isCollapsed||a.isUndo||!a.isLocal)return;const c=Array.from(n.model.document.differ.getChanges()),u=c[0];if(c.length!=1||u.type!=="insert"||u.name!="$text"||u.length!=1)return;const d=u.position.parent;if(d.is("element","codeBlock")||d.is("element","listItem")&&typeof i!="function"&&!["numberedList","bulletedList","todoList"].includes(i)||s&&s.value===!0)return;const m=d.getChild(0),f=n.model.createRangeOn(m);if(!f.containsRange(l)&&!l.end.isEqual(f.end))return;const g=t.exec(m.data.substr(0,l.end.offset));g&&n.model.enqueueChange(p=>{const _=p.createPositionAt(d,0),v=p.createPositionAt(d,g[0].length),E=new ht(_,v);if(o({match:g})!==!1){p.remove(E);const M=n.model.document.selection.getFirstRange(),G=p.createRangeIn(d);d.isEmpty&&!G.isEqual(M)&&!G.containsRange(M,!0)&&p.remove(d)}E.detach(),n.model.enqueueChange(()=>{n.plugins.get("Delete").requestUndoOnBackspace()})})})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function mn(n,e,t,i){let o,s;t instanceof RegExp?o=t:s=t,s=s||(r=>{let a;const l=[],c=[];for(;(a=o.exec(r))!==null&&!(a&&a.length<4);){let{index:u,"1":d,"2":m,"3":f}=a;const g=d+m+f;u+=a[0].length-g.length;const p=[u,u+d.length],_=[u+d.length+m.length,u+d.length+m.length+f.length];l.push(p),l.push(_),c.push([u+d.length,u+d.length+m.length])}return{remove:l,format:c}}),n.model.document.on("change:data",(r,a)=>{if(a.isUndo||!a.isLocal||!e.isEnabled)return;const l=n.model,c=l.document.selection;if(!c.isCollapsed)return;const u=Array.from(l.document.differ.getChanges()),d=u[0];if(u.length!=1||d.type!=="insert"||d.name!="$text"||d.length!=1)return;const m=c.focus,f=m.parent,{text:g,range:p}=XT(l.createRange(l.createPositionAt(f,0),m),l),_=s(g),v=mm(p.start,_.format,l),E=mm(p.start,_.remove,l);v.length&&E.length&&l.enqueueChange(M=>{if(i(M,v)!==!1){for(const G of E.reverse())M.remove(G);l.enqueueChange(()=>{n.plugins.get("Delete").requestUndoOnBackspace()})}})})}function mm(n,e,t){return e.filter(i=>i[0]!==void 0&&i[1]!==void 0).map(i=>t.createRange(n.getShiftedBy(i[0]),n.getShiftedBy(i[1])))}function XT(n,e){let t=n.start;return{text:Array.from(n.getItems()).reduce((i,o)=>!(o.is("$text")||o.is("$textProxy"))||o.getAttribute("code")?(t=e.createPositionAfter(o),""):i+o.data,""),range:e.createRange(t,n.end)}}class yu extends w{static get requires(){return[en]}static get pluginName(){return"Autoformat"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=this.editor.t;this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats(),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Revert autoformatting action"),keystroke:"Backspace"}]})}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&Wt(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&Wt(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&Wt(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&Wt(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=Js(this.editor,"bold");mn(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),mn(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(e.get("italic")){const t=Js(this.editor,"italic");mn(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),mn(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(e.get("code")){const t=Js(this.editor,"code");mn(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(e.get("strikethrough")){const t=Js(this.editor,"strikethrough");mn(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 i=t[7],o=new RegExp(`^(#{${i}})\\s$`);Wt(this.editor,this,o,()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&Wt(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&Wt(e,this,/^```$/,()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})})}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&Wt(this.editor,this,/^---$/,"horizontalLine")}}function Js(n,e){return(t,i)=>{if(!n.commands.get(e).isEnabled)return!1;const o=n.model.schema.getValidRanges(i,e);for(const s of o)t.setAttribute(e,!0,s);t.removeSelectionAttribute(e)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class tn extends O{constructor(e,t){super(e),h(this,"attributeKey"),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(s=>{if(i.isCollapsed)o?s.setSelectionAttribute(this.attributeKey,!0):s.removeSelectionAttribute(this.attributeKey);else{const r=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const a of r)o?s.setAttribute(this.attributeKey,o,a):s.removeAttribute(this.attributeKey,a)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const o of i.getRanges())for(const s of o.getItems())if(t.checkAttribute(s,this.attributeKey))return s.hasAttribute(this.attributeKey);return!1}}const Hn="bold";class eE extends w{static get pluginName(){return"BoldEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Hn}),e.model.schema.setAttributeProperties(Hn,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Hn,view:"strong",upcastAlso:["b",i=>{const o=i.getStyle("font-weight");return o&&(o=="bold"||Number(o)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(Hn,new tn(e,Hn)),e.keystrokes.set("CTRL+B",Hn),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Bold text"),keystroke:"CTRL+B"}]})}}function Sn({editor:n,commandName:e,plugin:t,icon:i,label:o,keystroke:s}){return r=>{const a=n.commands.get(e),l=new r(n.locale);return l.set({label:o,icon:i,keystroke:s,isToggleable:!0}),l.bind("isEnabled").to(a,"isEnabled"),l.bind("isOn").to(a,"value"),l instanceof ve?l.set({role:"menuitemcheckbox"}):l.set({tooltip:!0}),t.listenTo(l,"execute",()=>{n.execute(e),n.editing.view.focus()}),l}}const il="bold";class tE extends w{static get pluginName(){return"BoldUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:il,plugin:this,icon:gw,label:t("Bold"),keystroke:"CTRL+B"});e.ui.componentFactory.add(il,()=>i(P)),e.ui.componentFactory.add("menuBar:"+il,()=>i(ve))}}class iE extends w{static get requires(){return[eE,tE]}static get pluginName(){return"Bold"}static get isOfficialPlugin(){return!0}}const ln="code",nE="ck-code_selected";class oE extends w{static get pluginName(){return"CodeEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Dr]}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:ln}),e.model.schema.setAttributeProperties(ln,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:ln,view:"code"}),e.commands.add(ln,new tn(e,ln)),e.plugins.get(Dr).registerAttribute(ln),Cb(e,ln,"code",nE),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Move out of an inline code style"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}}const nl="code";class sE extends w{static get pluginName(){return"CodeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:nl,plugin:this,icon:pC,label:t("Code")});e.ui.componentFactory.add(nl,()=>i(P)),e.ui.componentFactory.add("menuBar:"+nl,()=>i(ve))}}class rE extends w{static get requires(){return[oE,sE]}static get pluginName(){return"Code"}static get isOfficialPlugin(){return!0}}const $n="italic";class aE extends w{static get pluginName(){return"ItalicEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:$n}),e.model.schema.setAttributeProperties($n,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:$n,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add($n,new tn(e,$n)),e.keystrokes.set("CTRL+I",$n),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Italic text"),keystroke:"CTRL+I"}]})}}const ol="italic";class lE extends w{static get pluginName(){return"ItalicUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:ol,plugin:this,icon:MC,keystroke:"CTRL+I",label:t("Italic")});e.ui.componentFactory.add(ol,()=>i(P)),e.ui.componentFactory.add("menuBar:"+ol,()=>i(ve))}}class cE extends w{static get requires(){return[aE,lE]}static get pluginName(){return"Italic"}static get isOfficialPlugin(){return!0}}const Lo="strikethrough";class uE extends w{static get pluginName(){return"StrikethroughEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Lo}),e.model.schema.setAttributeProperties(Lo,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Lo,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(Lo,new tn(e,Lo)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Strikethrough text"),keystroke:"CTRL+SHIFT+X"}]})}}const sl="strikethrough";class hE extends w{static get pluginName(){return"StrikethroughUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:sl,plugin:this,icon:uA,keystroke:"CTRL+SHIFT+X",label:t("Strikethrough")});e.ui.componentFactory.add(sl,()=>i(P)),e.ui.componentFactory.add("menuBar:"+sl,()=>i(ve))}}class dE extends w{static get requires(){return[uE,hE]}static get pluginName(){return"Strikethrough"}static get isOfficialPlugin(){return!0}}const Fo="subscript";class mE extends w{static get pluginName(){return"SubscriptEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Fo}),e.model.schema.setAttributeProperties(Fo,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Fo,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),e.commands.add(Fo,new tn(e,Fo))}}const rl="subscript";class fE extends w{static get pluginName(){return"SubscriptUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:rl,plugin:this,icon:hA,label:t("Subscript")});e.ui.componentFactory.add(rl,()=>i(P)),e.ui.componentFactory.add("menuBar:"+rl,()=>i(ve))}}class gE extends w{static get requires(){return[mE,fE]}static get pluginName(){return"Subscript"}static get isOfficialPlugin(){return!0}}const No="superscript";class pE extends w{static get pluginName(){return"SuperscriptEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:No}),e.model.schema.setAttributeProperties(No,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:No,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),e.commands.add(No,new tn(e,No))}}const al="superscript";class wE extends w{static get pluginName(){return"SuperscriptUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:al,plugin:this,icon:dA,label:t("Superscript")});e.ui.componentFactory.add(al,()=>i(P)),e.ui.componentFactory.add("menuBar:"+al,()=>i(ve))}}class bE extends w{static get requires(){return[pE,wE]}static get pluginName(){return"Superscript"}static get isOfficialPlugin(){return!0}}const Do="underline";class _E extends w{static get pluginName(){return"UnderlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Do}),e.model.schema.setAttributeProperties(Do,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Do,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(Do,new tn(e,Do)),e.keystrokes.set("CTRL+U","underline"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Underline text"),keystroke:"CTRL+U"}]})}}const ll="underline";class vE extends w{static get pluginName(){return"UnderlineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:ll,plugin:this,icon:yA,label:t("Underline"),keystroke:"CTRL+U"});e.ui.componentFactory.add(ll,()=>i(P)),e.ui.componentFactory.add("menuBar:"+ll,()=>i(ve))}}class yE extends w{static get requires(){return[_E,vE]}static get pluginName(){return"Underline"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function*Ab(n,e){for(const t of e)t&&n.getAttributeProperties(t[0]).copyOnEnter&&(yield t)}class kE extends O{execute(){this.editor.model.change(e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})})}enterBlock(e){const t=this.editor.model,i=t.document.selection,o=t.schema,s=i.isCollapsed,r=i.getFirstRange(),a=r.start.parent,l=r.end.parent;if(o.isLimit(a)||o.isLimit(l))return!s&&a==l&&t.deleteContent(i),!1;if(s){const c=Ab(e.model.schema,i.getAttributes());return fm(e,r.start),e.setSelectionAttribute(c),!0}else{const c=!(r.start.isAtStart&&r.end.isAtEnd),u=a==l;if(t.deleteContent(i,{leaveUnmerged:c}),c){if(u)return fm(e,i.focus),!0;e.setSelection(l,0)}}return!1}}function fm(n,e){n.split(e),n.setSelection(e.parent.nextSibling,0)}const CE={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class xb extends Zt{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",(o,s)=>{i=s.shiftKey}),t.on("beforeinput",(o,s)=>{if(!this.isEnabled)return;let r=s.inputType;N.isSafari&&i&&r=="insertParagraph"&&(r="insertLineBreak");const a=s.domEvent,l=CE[r];if(!l)return;const c=new xn(t,"enter",s.targetRanges[0]);t.fire(c,new kn(e,a,{isSoft:l.isSoft})),c.stop.called&&o.stop()})}observe(){}stopObserving(){}}class Ao extends w{static get pluginName(){return"Enter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,o=this.editor.t;t.addObserver(xb),e.commands.add("enter",new kE(e)),this.listenTo(i,"enter",(s,r)=>{i.isComposing||r.preventDefault(),!r.isSoft&&(e.execute("enter"),t.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class AE extends O{execute(){const e=this.editor.model,t=e.document;e.change(i=>{TE(e,i,t.selection),this.fire("afterExecute",{writer:i})})}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=xE(e.schema,t.selection)}}function xE(n,e){if(e.rangeCount>1)return!1;const t=e.anchor;if(!t||!n.checkChild(t,"softBreak"))return!1;const i=e.getFirstRange(),o=i.start.parent,s=i.end.parent;return!((nc(o,n)||nc(s,n))&&o!==s)}function TE(n,e,t){const i=t.isCollapsed,o=t.getFirstRange(),s=o.start.parent,r=o.end.parent,a=s==r;if(i){const l=Ab(n.schema,t.getAttributes());gm(n,e,o.end),e.removeSelectionAttribute(t.getAttributeKeys()),e.setSelectionAttribute(l)}else{const l=!(o.start.isAtStart&&o.end.isAtEnd);n.deleteContent(t,{leaveUnmerged:l}),a?gm(n,e,t.focus):l&&e.setSelection(r,0)}}function gm(n,e,t){const i=e.createElement("softBreak");n.insertContent(i,t),e.setSelection(i,"after")}function nc(n,e){return n.is("rootElement")?!1:e.isLimit(n)||nc(n.parent,e)}class Tb extends w{static get pluginName(){return"ShiftEnter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.conversion,o=e.editing.view,s=o.document,r=this.editor.t;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(a,{writer:l})=>l.createEmptyElement("br")}),o.addObserver(xb),e.commands.add("shiftEnter",new AE(e)),this.listenTo(s,"enter",(a,l)=>{s.isComposing||l.preventDefault(),l.isSoft&&(e.execute("shiftEnter"),o.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:r("Insert a soft break (a <br> element)"),keystroke:"Shift+Enter"}]})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class EE extends O{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,o=t.document.selection,s=Array.from(o.getSelectedBlocks()),r=e.forceValue===void 0?!this.value:e.forceValue;t.change(a=>{if(!r)this._removeQuote(a,s.filter(Qs));else{const l=s.filter(c=>Qs(c)||wm(i,c));this._applyQuote(a,l)}})}_getValue(){const e=this.editor.model.document.selection,t=ae(e.getSelectedBlocks());return!!(t&&Qs(t))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=ae(e.getSelectedBlocks());return i?wm(t,i):!1}_removeQuote(e,t){pm(e,t).reverse().forEach(i=>{if(i.start.isAtStart&&i.end.isAtEnd){e.unwrap(i.start.parent);return}if(i.start.isAtStart){const s=e.createPositionBefore(i.start.parent);e.move(i,s);return}i.end.isAtEnd||e.split(i.end);const o=e.createPositionAfter(i.end.parent);e.move(i,o)})}_applyQuote(e,t){const i=[];pm(e,t).reverse().forEach(o=>{let s=Qs(o.start);s||(s=e.createElement("blockQuote"),e.wrap(o,s)),i.push(s)}),i.reverse().reduce((o,s)=>o.nextSibling==s?(e.merge(e.createPositionAfter(o)),o):s)}}function Qs(n){return n.parent.name=="blockQuote"?n.parent:null}function pm(n,e){let t,i=0;const o=[];for(;i{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 u=r.createRangeIn(c);for(const d of u.getItems())if(d.is("element","blockQuote")&&!t.checkChild(r.createPositionBefore(d),d))return r.unwrap(d),!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 i=this.editor.editing.view.document,o=e.model.document.selection,s=e.commands.get("blockQuote");this.listenTo(i,"enter",(r,a)=>{!o.isCollapsed||!s.value||o.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"blockquote"}),this.listenTo(i,"delete",(r,a)=>{if(a.direction!="backward"||!o.isCollapsed||!s.value)return;const l=o.getLastPosition().parent;l.isEmpty&&!l.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"blockquote"})}}class PE extends w{static get pluginName(){return"BlockQuoteUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("blockQuote",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:blockQuote",()=>{const t=this._createButton(ve);return t.set({role:"menuitemcheckbox"}),t})}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("blockQuote"),s=new e(t.locale),r=i.t;return s.set({label:r("Block quote"),icon:nA,isToggleable:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value"),this.listenTo(s,"execute",()=>{t.execute("blockQuote"),t.editing.view.focus()}),s}}class IE extends w{static get requires(){return[SE,PE]}static get pluginName(){return"BlockQuote"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class VE extends ge(){constructor(){super(...arguments),h(this,"_stack",[])}add(e,t){const i=this._stack,o=i[0];this._insertDescriptor(e);const s=i[0];o!==s&&!cl(o,s)&&this.fire("change:top",{oldDescriptor:o,newDescriptor:s,writer:t})}remove(e,t){const i=this._stack,o=i[0];this._removeDescriptor(e);const s=i[0];o!==s&&!cl(o,s)&&this.fire("change:top",{oldDescriptor:o,newDescriptor:s,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex(s=>s.id===e.id);if(cl(e,t[i]))return;i>-1&&t.splice(i,1);let o=0;for(;t[o]&&RE(t[o],e);)o++;t.splice(o,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex(o=>o.id===e);i>-1&&t.splice(i,1)}}function cl(n,e){return n&&e&&n.priority==e.priority&&zr(n.classes)==zr(e.classes)}function RE(n,e){return n.priority>e.priority?!0:n.priorityzr(e.classes)}function zr(n){return Array.isArray(n)?n.sort().join(","):n}const OE="ck-widget",bm="ck-widget_selected";function Se(n){return n.is("element")?!!n.getCustomProperty("widget"):!1}function gt(n,e,t={}){if(!n.is("containerElement"))throw new b("widget-to-widget-wrong-element-type",null,{element:n});return e.setAttribute("contenteditable","false",n),e.addClass(OE,n),e.setCustomProperty("widget",!0,n),n.getFillerOffset=NE,e.setCustomProperty("widgetLabel",[],n),t.label&&LE(n,t.label),t.hasSelectionHandle&&DE(n,e),Eb(n,e),n}function BE(n,e,t){if(e.classes&&t.addClass(he(e.classes),n),e.attributes)for(const i in e.attributes)t.setAttribute(i,e.attributes[i],n)}function ME(n,e,t){if(e.classes&&t.removeClass(he(e.classes),n),e.attributes)for(const i in e.attributes)t.removeAttribute(i,n)}function Eb(n,e,t=BE,i=ME){const o=new VE;o.on("change:top",(a,l)=>{l.oldDescriptor&&i(n,l.oldDescriptor,l.writer),l.newDescriptor&&t(n,l.newDescriptor,l.writer)});const s=(a,l,c)=>o.add(l,c),r=(a,l,c)=>o.remove(l,c);e.setCustomProperty("addHighlight",s,n),e.setCustomProperty("removeHighlight",r,n)}function LE(n,e){n.getCustomProperty("widgetLabel").push(e)}function FE(n){return n.getCustomProperty("widgetLabel").reduce((e,t)=>typeof t=="function"?e?e+". "+t():t():e?e+". "+t:t,"")}function wa(n,e,t={}){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],n),t.withAriaRole!==!1&&e.setAttribute("role","textbox",n),e.setAttribute("tabindex","-1",n),t.label&&e.setAttribute("aria-label",t.label,n),e.setAttribute("contenteditable",n.isReadOnly?"false":"true",n),n.on("change:isReadOnly",(i,o,s)=>{e.setAttribute("contenteditable",s?"false":"true",n)}),n.on("change:isFocused",(i,o,s)=>{s?e.addClass("ck-editor__nested-editable_focused",n):e.removeClass("ck-editor__nested-editable_focused",n)}),Eb(n,e),n}function ku(n,e){const t=n.getSelectedElement();if(t){const i=zi(n);if(i)return e.createRange(e.createPositionAt(t,i))}return e.schema.findOptimalInsertionRange(n)}function Cu(n,e){return(t,i)=>{const{mapper:o,viewPosition:s}=i,r=o.findMappedViewAncestor(s);if(!e(r))return;const a=o.toModelElement(r);i.modelPosition=n.createPositionAt(a,s.isAtStart?"before":"after")}}function NE(){return null}function DE(n,e){const t=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},function(i){const o=this.toDomElement(i),s=new hi;return s.set("content",_C),s.render(),o.appendChild(s.element),o});e.insert(e.createPositionAt(n,0),t),e.addClass(["ck-widget_with-selection-handle"],n)}function Au(n){const e=a=>{const{width:l,paddingLeft:c,paddingRight:u}=a.ownerDocument.defaultView.getComputedStyle(a);return parseFloat(l)-(parseFloat(c)||0)-(parseFloat(u)||0)},t=n.parentElement;if(!t)return 0;let i=e(t);const o=5;let s=0,r=t;for(;isNaN(i);){if(r=r.parentElement,++s>o)return 0;i=e(r)}return i}function zE(n,e=new z(n)){const t=Au(n);return t?e.width/t*100:0}const bi="widget-type-around";function cn(n,e,t){return!!n&&Se(n)&&!t.isInline(e)}function HE(n){return n.closest(".ck-widget__type-around__button")}function $E(n){return n.classList.contains("ck-widget__type-around__button_before")?"before":"after"}function WE(n,e){const t=n.closest(".ck-widget");return e.mapDomToView(t)}function zi(n){return n.getAttribute(bi)}const Sb=["before","after"],jE=new DOMParser().parseFromString(rA,"image/svg+xml").firstChild,_m="ck-widget__type-around_disabled";class UE extends w{constructor(){super(...arguments),h(this,"_currentFakeCaretModelElement",null)}static get pluginName(){return"WidgetTypeAround"}static get isOfficialPlugin(){return!0}static get requires(){return[Ao,en]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",(i,o,s)=>{t.change(r=>{for(const a of t.document.roots)s?r.removeClass(_m,a):r.addClass(_m,a)}),s||e.model.change(r=>{r.removeSelectionAttribute(bi)})}),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 i=this.editor,o=i.editing.view,s=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:s}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(e,t,i,o){this.listenTo(e,t,(...s)=>{this.isEnabled&&i(...s)},o)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=zi(e);if(!t)return!1;const i=e.getSelectedElement();return this._insertParagraph(i,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,o={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",(s,r,a)=>{const l=a.mapper.toViewElement(r.item);l&&cn(l,r.item,t)&&(qE(a.writer,o,l),l.getCustomProperty("widgetLabel").push(()=>this.isEnabled?i("Press Enter to type after or press Shift + Enter to type before the widget"):""))},{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,i=t.document.selection,o=t.schema,s=e.editing.view;this._listenToIfEnabled(s.document,"arrowKey",(a,l)=>{this._handleArrowKeyPress(a,l)},{context:[Se,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",(a,l)=>{l.directChange&&e.model.change(c=>{c.removeSelectionAttribute(bi)})}),this._listenToIfEnabled(t.document,"change:data",()=>{const a=i.getSelectedElement();if(a){const l=e.editing.mapper.toViewElement(a);if(cn(l,a,o))return}e.model.change(l=>{l.removeSelectionAttribute(bi)})}),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",(a,l,c)=>{const u=c.writer;if(this._currentFakeCaretModelElement){const g=c.mapper.toViewElement(this._currentFakeCaretModelElement);g&&(u.removeClass(Sb.map(r),g),this._currentFakeCaretModelElement=null)}const d=l.selection.getSelectedElement();if(!d)return;const m=c.mapper.toViewElement(d);if(!cn(m,d,o))return;const f=zi(l.selection);f&&(u.addClass(r(f),m),this._currentFakeCaretModelElement=d)}),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",(a,l,c)=>{c||e.model.change(u=>{u.removeSelectionAttribute(bi)})});function r(a){return`ck-widget_type-around_show-fake-caret_${a}`}}_handleArrowKeyPress(e,t){const i=this.editor,o=i.model,s=o.document.selection,r=o.schema,a=i.editing.view,l=t.keyCode,c=pv(l,i.locale.contentLanguageDirection),u=a.document.selection.getSelectedElement(),d=i.editing.mapper.toModelElement(u);let m;cn(u,d,r)?m=this._handleArrowKeyPressOnSelectedWidget(c):s.isCollapsed?m=this._handleArrowKeyPressWhenSelectionNextToAWidget(c):t.shiftKey||(m=this._handleArrowKeyPressWhenNonCollapsedSelection(c)),m&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=t.document.selection,o=zi(i);return t.change(s=>{if(o){if(o!==(e?"after":"before"))return s.removeSelectionAttribute(bi),!0}else return s.setSelectionAttribute(bi,e?"after":"before"),!0;return!1})}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,o=i.schema,s=t.plugins.get("Widget"),r=s._getObjectElementNextToSelection(e),a=t.editing.mapper.toViewElement(r);return cn(a,r,o)?(i.change(l=>{s._setSelectionOverElement(r),l.setSelectionAttribute(bi,e?"before":"after")}),!0):!1}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,o=i.schema,s=t.editing.mapper,r=i.document.selection,a=e?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter,l=s.toViewElement(a);return cn(l,a,o)?(i.change(c=>{c.setSelection(a,"on"),c.setSelectionAttribute(bi,e?"after":"before")}),!0):!1}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",(i,o)=>{const s=HE(o.domTarget);if(!s)return;const r=$E(s),a=WE(s,t.domConverter),l=e.editing.mapper.toModelElement(a);this._insertParagraph(l,r),o.preventDefault(),i.stop()})}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",(o,s)=>{if(o.eventPhase!="atTarget")return;const r=t.getSelectedElement(),a=e.editing.mapper.toViewElement(r),l=e.model.schema;let c;this._insertParagraphAccordingToFakeCaretPosition()?c=!0:cn(a,r,l)&&(this._insertParagraph(r,s.isSoft?"before":"after"),c=!0),c&&(s.preventDefault(),o.stop())},{context:Se})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",(t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)},{priority:"high"}),N.isAndroid?this._listenToIfEnabled(e,"keydown",(t,i)=>{i.keyCode==229&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(e,"compositionstart",()=>{this._insertParagraphAccordingToFakeCaretPosition()},{priority:"highest"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,o=i.schema;this._listenToIfEnabled(t.document,"delete",(s,r)=>{if(s.eventPhase!="atTarget")return;const a=zi(i.document.selection);if(!a)return;const l=r.direction,c=i.document.selection.getSelectedElement(),u=a==="before",d=l=="forward";if(u===d)e.execute("delete",{selection:i.createSelection(c,"on")});else{const m=o.getNearestSelectionRange(i.createPositionAt(c,a),l);if(m)if(!m.isCollapsed)i.change(f=>{f.setSelection(m),e.execute(d?"deleteForward":"delete")});else{const f=i.createSelection(m.start);if(i.modifySelection(f,{direction:l}),!f.focus.isEqual(m.start))i.change(g=>{g.setSelection(m),e.execute(d?"deleteForward":"delete")});else{const g=ZE(o,m.start.parent);i.deleteContent(i.createSelection(g,"on"),{doNotAutoparagraph:!0})}}}r.preventDefault(),s.stop()},{context:Se})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",(o,[s,r])=>{if(r&&!r.is("documentSelection"))return;const a=zi(i);if(a)return o.stop(),t.change(l=>{const c=i.getSelectedElement(),u=t.createPositionAt(c,a),d=l.createSelection(u),m=t.insertContent(s,d);return l.setSelection(d),m})},{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",(i,o)=>{const[,s,r={}]=o;if(s&&!s.is("documentSelection"))return;const a=zi(t);a&&(r.findOptimalPosition=a,o[3]=r)},{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",(i,[o])=>{o&&!o.is("documentSelection")||zi(t)&&i.stop()},{priority:"high"})}}function qE(n,e,t){const i=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},function(o){const s=this.toDomElement(o);return GE(s,e),KE(s),s});n.insert(n.createPositionAt(t,"end"),i)}function GE(n,e){for(const t of Sb){const i=new qt({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${t}`],title:e[t],"aria-hidden":"true"},children:[n.ownerDocument.importNode(jE,!0)]});n.appendChild(i.render())}}function KE(n){const e=new qt({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});n.appendChild(e.render())}function ZE(n,e){let t=e;for(const i of e.getAncestors({parentFirst:!0})){if(i.childCount>1||n.isLimit(i))break;t=i}return t}function JE(n){const e=n.model;return(t,i)=>{const o=i.keyCode==Z.arrowup,s=i.keyCode==Z.arrowdown,r=i.shiftKey,a=e.document.selection;if(!o&&!s)return;const l=s;if(r&&XE(a,l))return;const c=QE(n,a,l);if(c){if(c.isCollapsed&&(a.isCollapsed||r))return;(c.isCollapsed||YE(n,c,l))&&(e.change(u=>{const d=l?c.end:c.start;if(r){const m=e.createSelection(a.anchor);m.setFocus(d),u.setSelection(m)}else u.setSelection(d)}),t.stop(),i.preventDefault(),i.stopPropagation())}}}function QE(n,e,t){const i=n.model;if(t){const o=e.isCollapsed?e.focus:e.getLastPosition(),s=vm(i,o,"forward");if(!s)return null;const r=i.createRange(o,s),a=ym(i.schema,r,"backward");return a?i.createRange(o,a):null}else{const o=e.isCollapsed?e.focus:e.getFirstPosition(),s=vm(i,o,"backward");if(!s)return null;const r=i.createRange(s,o),a=ym(i.schema,r,"forward");return a?i.createRange(a,o):null}}function vm(n,e,t){const i=n.schema,o=n.createRangeIn(e.root),s=t=="forward"?"elementStart":"elementEnd";for(const{previousPosition:r,item:a,type:l}of o.getWalker({startPosition:e,direction:t})){if(i.isLimit(a)&&!i.isInline(a))return r;if(l==s&&i.isBlock(a))return null}return null}function ym(n,e,t){const i=t=="backward"?e.end:e.start;if(n.checkChild(i,"$text"))return i;for(const{nextPosition:o}of e.getWalker({direction:t}))if(n.checkChild(o,"$text"))return o;return null}function YE(n,e,t){const i=n.model,o=n.view.domConverter;if(t){const c=i.createSelection(e.start);i.modifySelection(c),!c.focus.isAtEnd&&!e.start.isEqual(c.focus)&&(e=i.createRange(c.focus,e.end))}const s=n.mapper.toViewRange(e),r=o.viewRangeToDom(s),a=z.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 XE(n,e){return!n.isCollapsed&&n.isBackward==e}class Vt extends w{constructor(){super(...arguments),h(this,"_previouslySelected",new Set)}static get pluginName(){return"Widget"}static get isOfficialPlugin(){return!0}static get requires(){return[UE,en]}init(){const e=this.editor,t=e.editing.view,i=t.document,o=e.t;this.editor.editing.downcastDispatcher.on("selection",(s,r,a)=>{const l=a.writer,c=r.selection;if(c.isCollapsed)return;const u=c.getSelectedElement();if(!u)return;const d=e.editing.mapper.toViewElement(u);Se(d)&&a.consumable.consume(c,"selection")&&l.setSelection(l.createRangeOn(d),{fake:!0,label:FE(d)})}),this.editor.editing.downcastDispatcher.on("selection",(s,r,a)=>{this._clearPreviouslySelectedWidgets(a.writer);const l=a.writer,c=l.document.selection;let u=null;for(const d of c.getRanges())for(const m of d){const f=m.item;Se(f)&&!i3(f,u)&&(l.addClass(bm,f),this._previouslySelected.add(f),u=f)}},{priority:"low"}),t.addObserver(ua),this.listenTo(i,"mousedown",(...s)=>this._onMousedown(...s)),this.listenTo(i,"arrowKey",(...s)=>{this._handleSelectionChangeOnArrowKeyPress(...s)},{context:[Se,"$text"]}),this.listenTo(i,"arrowKey",(...s)=>{this._preventDefaultOnArrowKeyPress(...s)},{context:"$root"}),this.listenTo(i,"arrowKey",JE(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",(s,r)=>{this._handleDelete(r.direction=="forward")&&(r.preventDefault(),s.stop())},{context:"$root"}),this.listenTo(i,"tab",(s,r)=>{s.eventPhase=="atTarget"&&(r.shiftKey||this._selectFirstNestedEditable()&&(r.preventDefault(),s.stop()))},{context:Se,priority:"low"}),this.listenTo(i,"tab",(s,r)=>{r.shiftKey&&this._selectAncestorWidget()&&(r.preventDefault(),s.stop())},{priority:"low"}),this.listenTo(i,"keydown",(s,r)=>{r.keystroke==Z.esc&&this._selectAncestorWidget()&&(r.preventDefault(),s.stop())},{priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:o("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:o("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:o("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:o("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:o("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:o("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=this.editor,o=i.editing.view,s=o.document;let r=t.target;if(!r)return;if(t.domEvent.detail>=3){this._selectBlockContent(r)&&t.preventDefault();return}if(!Se(r)){const l=e3(r);if(!l)return;if(Se(l))r=l;else{const c=t3(o,t);if(c&&Se(c))r=c;else return}}N.isAndroid&&t.preventDefault(),s.isFocused||o.focus();const a=i.editing.mapper.toModelElement(r);this._setSelectionOverElement(a)}_selectBlockContent(e){const t=this.editor,i=t.model,o=t.editing.mapper,s=i.schema,r=o.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),a=n3(o.toModelElement(r),i.schema);return a?(i.change(l=>{const c=s.isLimit(a)?null:o3(l.createPositionAfter(a),s),u=l.createPositionAt(a,0),d=c?l.createPositionAt(c,0):l.createPositionAt(a,"end");l.setSelection(l.createRange(u,d))}),!0):!1}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,o=this.editor.model,s=o.schema,r=o.document.selection,a=r.getSelectedElement(),l=oa(i,this.editor.locale.contentLanguageDirection),c=l=="down"||l=="right",u=l=="up"||l=="down";if(a&&s.isObject(a)){const m=c?r.getLastPosition():r.getFirstPosition(),f=s.getNearestSelectionRange(m,c?"forward":"backward");f&&(o.change(g=>{g.setSelection(f)}),t.preventDefault(),e.stop());return}if(!r.isCollapsed&&!t.shiftKey){const m=r.getFirstPosition(),f=r.getLastPosition(),g=m.nodeAfter,p=f.nodeBefore;(g&&s.isObject(g)||p&&s.isObject(p))&&(o.change(_=>{_.setSelection(c?f:m)}),t.preventDefault(),e.stop());return}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(c);if(d&&s.isObject(d)){if(s.isInline(d)&&u)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,o=i.schema,s=i.document.selection.getSelectedElement();s&&o.isObject(s)&&(t.preventDefault(),e.stop())}_handleDelete(e){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t)||!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);if(i)return this.editor.model.change(o=>{let s=t.anchor.parent;for(;s.isEmpty;){const r=s;s=r.parent,o.remove(r)}this._setSelectionOverElement(i)}),!0}_setSelectionOverElement(e){this.editor.model.change(t=>{t.setSelection(t.createRangeOn(e))})}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,o=t.document.selection,s=t.createSelection(o);if(t.modifySelection(s,{direction:e?"forward":"backward"}),s.isEqual(o))return null;const r=e?s.focus.nodeBefore:s.focus.nodeAfter;return r&&i.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(bm,t);this._previouslySelected.clear()}_selectFirstNestedEditable(){const e=this.editor,t=this.editor.editing.view.document;for(const i of t.selection.getFirstRange().getItems())if(i.is("editableElement")){const o=e.editing.mapper.toModelElement(i);/* istanbul ignore next -- @preserve */if(!o)continue;const s=e.model.createPositionAt(o,0),r=e.model.schema.getNearestSelectionRange(s,"forward");return e.model.change(a=>{a.setSelection(r)}),!0}return!1}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,i=e.editing.view.document.selection.getFirstPosition().parent,o=(i.is("$text")?i.parent:i).findAncestor(Se);if(!o)return!1;const s=t.toModelElement(o);/* istanbul ignore next -- @preserve */return s?(e.model.change(r=>{r.setSelection(s,"on")}),!0):!1}}function e3(n){let e=n;for(;e;){if(e.is("editableElement")||Se(e))return e;e=e.parent}return null}function t3(n,e){const t=Qg(e.domEvent);let i=null;if(t?i=n.domConverter.domRangeToView(t):i=n.createRange(n.createPositionAt(e.target,0)),!i)return null;const o=i.start;if(!o.parent)return null;let s=o.parent;return o.parent.is("editableElement")&&(o.isAtEnd&&o.nodeBefore?s=o.nodeBefore:o.isAtStart&&o.nodeAfter&&(s=o.nodeAfter)),s.is("$text")?s.parent:s}function i3(n,e){return e?Array.from(n.getAncestors()).includes(e):!1}function n3(n,e){for(const t of n.getAncestors({includeSelf:!0,parentFirst:!0})){if(e.checkChild(t,"$text"))return t;if(e.isLimit(t)&&!e.isObject(t))break}return null}function o3(n,e){const t=new yi({startPosition:n});for(const{item:i}of t){if(e.isLimit(i)||!i.is("element"))return null;if(e.checkChild(i,"$text"))return i}return null}class ci extends w{constructor(){super(...arguments),h(this,"_toolbarDefinitions",new Map),h(this,"_balloon")}static get requires(){return[Ue]}static get pluginName(){return"WidgetToolbarRepository"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",i=>{s3(e.editing.view.document.selection)&&i.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:i,getRelatedElement:o,balloonClassName:s="ck-toolbar-container",positions:r}){if(!i.length){J("widget-toolbar-no-items",{toolbarId:e});return}const a=this.editor,l=a.t,c=new Ei(a.locale);if(c.ariaLabel=t||l("Widget toolbar"),this._toolbarDefinitions.has(e))throw new b("widget-toolbar-duplicated",this,{toolbarId:e});const u={view:c,getRelatedElement:o,balloonClassName:s,itemsConfig:i,positions:r,initialized:!1};a.ui.addToolbar(c,{isContextual:!0,beforeFocus:()=>{const d=o(a.editing.view.document.selection);d&&this._showToolbar(u,d)},afterBlur:()=>{this._hideToolbar(u)}}),this._toolbarDefinitions.set(e,u)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const o of this._toolbarDefinitions.values()){const s=o.getRelatedElement(this.editor.editing.view.document.selection);if(!this.isEnabled||!s)this._isToolbarInBalloon(o)&&this._hideToolbar(o);else if(!this.editor.ui.focusTracker.isFocused)this._isToolbarVisible(o)&&this._hideToolbar(o);else{const r=s.getAncestors().length;r>e&&(e=r,t=s,i=o)}}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?km(this.editor,t,e.positions):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:Pb(this.editor,t,e.positions),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const i of this._toolbarDefinitions.values())if(this._isToolbarVisible(i)){const o=i.getRelatedElement(this.editor.editing.view.document.selection);km(this.editor,o,e.positions)}}))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function km(n,e,t){const i=n.plugins.get("ContextualBalloon"),o=Pb(n,e,t);i.updatePosition(o)}function Pb(n,e,t){const i=n.editing.view,o=Ne.defaultPositions;return{target:i.domConverter.mapViewToDom(e),positions:t||[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}function s3(n){const e=n.getSelectedElement();return!!(e&&Se(e))}class r3 extends ue(){constructor(e){super(),h(this,"_referenceCoordinates"),h(this,"_options"),h(this,"_originalWidth"),h(this,"_originalHeight"),h(this,"_originalWidthPercents"),h(this,"_aspectRatio"),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,i){const o=new z(t);this.activeHandlePosition=c3(e),this._referenceCoordinates=a3(t,u3(this.activeHandlePosition)),this._originalWidth=o.width,this._originalHeight=o.height,this._aspectRatio=o.width/o.height;const s=i.style.width;s&&s.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(s):this._originalWidthPercents=zE(i,o)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function a3(n,e){const t=new z(n),i=e.split("-"),o={x:i[1]=="right"?t.right:t.left,y:i[0]=="bottom"?t.bottom:t.top};return o.x+=n.ownerDocument.defaultView.scrollX,o.y+=n.ownerDocument.defaultView.scrollY,o}function l3(n){return`ck-widget__resizer__handle-${n}`}function c3(n){const e=["top-left","top-right","bottom-right","bottom-left"];for(const t of e)if(n.classList.contains(l3(t)))return t}function u3(n){const e=n.split("-"),t={top:"bottom",bottom:"top",left:"right",right:"left"};return`${t[e[0]]}-${t[e[1]]}`}class h3 extends A{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",(i,o)=>i!==null&&o!==null),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",(i,o,s)=>e.unit==="px"?`${i}×${o}`:`${s}%`),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",(i,o,s)=>o<50||s<50?"above-center":i)}_dismiss(){this.unbind(),this._isVisible=!1}}class Cm extends ue(){constructor(e){super(),h(this,"_state"),h(this,"_sizeView"),h(this,"_options"),h(this,"_viewResizerWrapper",null),h(this,"_initialViewWidth"),this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",(t,i)=>t&&i),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(e=>{e.removeClass("ck-hidden",this._viewResizerWrapper)})}hide(){this._options.editor.editing.view.change(e=>{e.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(s){const r=this.toDomElement(s);return e._appendHandles(r),e._appendSizeUI(r),r});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 r3(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(l=>{const c=this._options.unit||"%",u=(c==="%"?t.widthPercents:t.width)+c;l.setStyle("width",u,this._options.viewElement)});const i=this._getHandleHost(),o=new z(i),s=Math.round(o.width),r=Math.round(o.height),a=new z(i);t.width=Math.round(a.width),t.height=Math.round(a.height),this.redraw(o),this.state.update({...t,handleHostWidth:s,handleHostHeight:r})}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(!f3(t))return;const i=t.parentElement,o=this._getHandleHost(),s=this._viewResizerWrapper,r=[s.getStyle("width"),s.getStyle("height"),s.getStyle("left"),s.getStyle("top")];let a;if(i.isSameNode(o)){const l=e||new z(o);a=[l.width+"px",l.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];Xe(r,a)!=="same"&&this._options.editor.editing.view.change(l=>{l.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},s)})}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss(),this._options.editor.editing.view.change(e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){const t=this.state,i=m3(e),o=this._options.isCentered?this._options.isCentered(this):!0,s={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(s.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(s.x*=2);let r=Math.abs(t.originalWidth+s.x),a=Math.abs(t.originalHeight+s.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 i of t)e.appendChild(new qt({tag:"div",attributes:{class:`ck-widget__resizer__handle ${d3(i)}`}}).render())}_appendSizeUI(e){this._sizeView=new h3,this._sizeView.render(),e.appendChild(this._sizeView.element)}}function d3(n){return`ck-widget__resizer__handle-${n}`}function m3(n){return{x:n.pageX,y:n.pageY}}function f3(n){return n&&n.ownerDocument&&n.ownerDocument.contains(n)}class ul extends w{constructor(){super(...arguments),h(this,"_resizers",new Map),h(this,"_observer"),h(this,"_redrawSelectedResizerThrottled")}static get pluginName(){return"WidgetResize"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.editing,t=I.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(ua),this._observer=new(st()),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=co(()=>this.redrawSelectedResizer(),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",()=>{for(const[o,s]of this._resizers)o.isAttached()||(this._resizers.delete(o),s.destroy())},{priority:"lowest"}),this._observer.listenTo(I.window,"resize",this._redrawSelectedResizerThrottled);const i=this.editor.editing.view.document.selection;i.on("change",()=>{const o=i.getSelectedElement(),s=this.getResizerByViewElement(o)||null;s?this.select(s):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 Cm(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const s=i.get("WidgetToolbarRepository");t.on("begin",()=>{s.forceDisabled("resize")},{priority:"lowest"}),t.on("cancel",()=>{s.clearForceDisabled("resize")},{priority:"highest"}),t.on("commit",()=>{s.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 i=t.domTarget;Cm.isResizeHandle(i)&&(this._activeResizer=this._getResizerByHandle(i)||null,this._activeResizer&&(this._activeResizer.begin(i),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-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class g3 extends A{constructor(e,t){super(e),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"idInputView"),h(this,"backButtonView"),h(this,"saveButtonView"),h(this,"children"),h(this,"_validators"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.idInputView=this._createIdInput(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new $e(e,{children:[this.idInputView,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this.keystrokes.set("Esc",(i,o)=>{this.fire("cancel"),o()}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-bookmark-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),[this.backButtonView,this.idInputView,this.saveButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.idInputView.focus()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.idInputView.errorText=t,!1}return!0}resetFormStatus(){this.idInputView.errorText=null}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new P(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Bookmark")});return t.children.add(this.backButtonView,0),t}_createIdInput(){const e=this.locale.t,t=new Te(this.locale,nt);return t.label=e("Bookmark name"),t.infoText=e("Enter the bookmark name without spaces."),t.class="ck-labeled-field-view_full-width",t}get id(){const{element:e}=this.idInputView.fieldView;return e?e.value.trim():null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ib(n){return!(!n||typeof n!="string"||/\s/.test(n))}class p3 extends O{refresh(){const e=this.editor.model.document.selection,t=this._getPositionToInsertBookmark(e);this.isEnabled=!!t}execute(e){if(!e)return;const{bookmarkId:t}=e;if(!Ib(t)){J("insert-bookmark-command-executed-with-invalid-name");return}const i=this.editor,o=i.model,s=o.document.selection;o.change(r=>{let a=this._getPositionToInsertBookmark(s);if(!o.schema.checkChild(a,"bookmark")){const c=i.execute("insertParagraph",{position:a});if(!c)return;a=c}const l=r.createElement("bookmark",{...Object.fromEntries(s.getAttributes()),bookmarkId:t});o.insertObject(l,a,null,{setSelection:"on"})})}_getPositionToInsertBookmark(e){const t=this.editor.model,i=t.schema,o=e.getFirstRange(),s=o.start;if(hl(s,i))return s;for(const{previousPosition:r,item:a}of o){if(a.is("element")&&i.checkChild(a,"$text")&&hl(a,i))return t.createPositionAt(a,0);if(hl(r,i))return r}return null}}function hl(n,e){return e.checkChild(n,"bookmark")?!0:e.checkChild(n,"paragraph")?e.checkChild("paragraph","bookmark"):!1}class w3 extends O{refresh(){const e=this.editor.model.document.selection,t=Am(e);this.isEnabled=!!t,this.value=t?t.getAttribute("bookmarkId"):void 0}execute(e){if(!e)return;const{bookmarkId:t}=e;if(!Ib(t)){J("update-bookmark-command-executed-with-invalid-name");return}const i=this.editor.model,o=i.document.selection,s=Am(o);s&&i.change(r=>{r.setAttribute("bookmarkId",t,s)})}}function Am(n){const e=n.getSelectedElement();return e&&e.is("element","bookmark")?e:null}class ns extends w{constructor(e){super(e),h(this,"_bookmarkElements",new Map),e.config.define("bookmark",{toolbar:["bookmarkPreview","|","editBookmark","removeBookmark"]})}static get pluginName(){return"BookmarkEditing"}static get isOfficialPlugin(){return!0}init(){const{editor:e}=this;this._defineSchema(),this._defineConverters(),e.commands.add("insertBookmark",new p3(e)),e.commands.add("updateBookmark",new w3(e)),this.listenTo(e.model.document,"change:data",()=>{this._trackBookmarkElements()})}getElementForBookmarkId(e){for(const[t,i]of this._bookmarkElements)if(i==e)return t;return null}getAllBookmarkNames(){return new Set(this._bookmarkElements.values())}_defineSchema(){this.editor.model.schema.register("bookmark",{inheritAllFrom:"$inlineObject",allowAttributes:"bookmarkId",disallowAttributes:["linkHref","htmlA"]})}_defineConverters(){const{editor:e}=this,{conversion:t,t:i}=e;e.data.htmlProcessor.domConverter.registerInlineObjectMatcher(o=>oc(o)),e.editing.view.domConverter.registerInlineObjectMatcher(o=>oc(o,!1)),t.for("dataDowncast").elementToElement({model:{name:"bookmark",attributes:["bookmarkId"]},view:(o,{writer:s})=>s.createEmptyElement("a",{id:o.getAttribute("bookmarkId")})}),t.for("editingDowncast").elementToElement({model:{name:"bookmark",attributes:["bookmarkId"]},view:(o,{writer:s})=>{const r=o.getAttribute("bookmarkId"),a=s.createContainerElement("a",{id:r,class:"ck-bookmark"},[this._createBookmarkUIElement(s)]);return s.setCustomProperty("bookmark",!0,a),this._bookmarkElements.set(o,r),gt(a,s,{label:()=>`${r} ${i("bookmark widget")}`})}}),t.for("upcast").add(o=>o.on("element:a",b3(e)))}_createBookmarkUIElement(e){return e.createUIElement("span",{class:"ck-bookmark__icon"},function(t){const i=this.toDomElement(t),o=new hi;return o.set({content:dC,isColorInherited:!1}),o.render(),i.appendChild(o.element),i})}_trackBookmarkElements(){this._bookmarkElements.forEach((e,t)=>{t.root.rootName==="$graveyard"&&this._bookmarkElements.delete(t)})}}function oc(n,e=!0){if(n.name!=="a"||e&&!n.isEmpty)return null;const t=n.hasAttribute("id"),i=n.hasAttribute("name"),o=n.hasAttribute("href");return t&&!o?{name:!0,attributes:["id"]}:i&&!o?{name:!0,attributes:["name"]}:null}function b3(n){return(e,t,i)=>{const o=t.viewItem,s=oc(o,!1);if(!s||!i.consumable.test(o,s)||!_3(n)&&!o.isEmpty)return;const r=i.writer,a=o.getAttribute("id"),l=o.getAttribute("name"),c=a||l,u=r.createElement("bookmark",{bookmarkId:c});if(!i.safeInsert(u,t.modelCursor))return;i.consumable.consume(o,s),a===l&&i.consumable.consume(o,{attributes:["name"]}),i.updateConversionResult(u,t);const{modelCursor:d,modelRange:m}=i.convertChildren(o,t.modelCursor);t.modelCursor=d,t.modelRange=r.createRange(t.modelRange.start,m.end)}}function _3(n){const e=n.config.get("bookmark.enableNonEmptyAnchorConversion");return e!==void 0?e:!0}const Yt="bookmark-ui";class v3 extends w{constructor(){super(...arguments),h(this,"formView",null),h(this,"_balloon")}static get requires(){return[ns,Ue,ci]}static get pluginName(){return"BookmarkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;this._balloon=e.plugins.get(Ue),e.plugins.has("LinkUI")&&this._registerLinkProvider(),this._registerComponents(),e.conversion.for("editingDowncast").markerToHighlight({model:Yt,view:{classes:["ck-fake-bookmark-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Yt,view:(t,{writer:i})=>{if(!t.markerRange.isCollapsed)return null;const o=i.createUIElement("span");return i.addClass(["ck-fake-bookmark-selection","ck-fake-bookmark-selection_collapsed"],o),o}})}afterInit(){const e=this.editor,t=e.locale.t,i=this.editor.plugins.get(ci),o=Ne.defaultPositions;i.register("bookmark",{ariaLabel:t("Bookmark toolbar"),items:e.config.get("bookmark.toolbar"),getRelatedElement:k3,balloonClassName:"ck-bookmark-balloon ck-toolbar-container",positions:[o.southArrowNorth,o.southArrowNorthMiddleWest,o.southArrowNorthMiddleEast,o.southArrowNorthWest,o.southArrowNorthEast,o.northArrowSouth,o.northArrowSouthMiddleWest,o.northArrowSouthMiddleEast,o.northArrowSouthWest,o.northArrowSouthEast,o.viewportStickyNorth]})}destroy(){super.destroy(),this.formView&&this.formView.destroy()}_createViews(){this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createFormView(){const e=this.editor,t=e.locale,i=t.t,o=e.commands.get("insertBookmark"),s=e.commands.get("updateBookmark"),r=[o,s],a=new(ho(g3))(t,y3(e));return a.idInputView.fieldView.bind("value").to(s,"value"),a.saveButtonView.bind("label").to(s,"value",l=>i(l?"Save":"Insert")),a.idInputView.bind("isEnabled").toMany(r,"isEnabled",(...l)=>l.some(c=>c)),a.saveButtonView.bind("isEnabled").toMany(r,"isEnabled",(...l)=>l.some(c=>c)),this.listenTo(a,"cancel",()=>{this._hideFormView()}),this.listenTo(a,"submit",()=>{if(a.isValid()){const l=a.id;this._getSelectedBookmarkElement()?e.execute("updateBookmark",{bookmarkId:l}):e.execute("insertBookmark",{bookmarkId:l}),this._hideFormView()}}),this.listenTo(a.idInputView,"change:errorText",()=>{e.ui.update()}),a}_registerLinkProvider(){const e=this.editor.locale.t,t=this.editor.plugins.get("LinkUI"),i=this.editor.plugins.get(ns),o=()=>Array.from(i.getAllBookmarkNames()).sort((r,a)=>r.localeCompare(a)).map(r=>({id:r,href:`#${r}`,label:r,icon:fC})),s=r=>{const a=[...i.getAllBookmarkNames()].find(l=>`#${l}`===r);return a?{href:r,label:a,icon:gC,tooltip:e("Scroll to bookmark")}:null};t.registerLinksListProvider({label:e("Bookmarks"),emptyListPlaceholder:e("No bookmarks available."),navigate:({href:r})=>this._scrollToBookmark(r),getListItems:o,getItem:s})}_scrollToBookmark(e){const t=this.editor.plugins.get(ns).getElementForBookmarkId(e.slice(1));return t?(this.editor.model.change(i=>{i.setSelection(t,"on")}),this.editor.editing.view.scrollToTheSelection({alignToTop:!0,forceScroll:!0}),!0):!1}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("bookmark",()=>{const t=this._createBookmarkButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:bookmark",()=>this._createBookmarkButton(ve)),e.ui.componentFactory.add("bookmarkPreview",t=>{const i=e.commands.get("updateBookmark"),o=new xt(t);return o.extendTemplate({attributes:{class:["ck-bookmark-toolbar__preview"]}}),o.bind("text").to(i,"value"),o}),e.ui.componentFactory.add("editBookmark",t=>{const i=e.commands.get("updateBookmark"),o=new P(t),s=t.t;return o.set({label:s("Edit bookmark"),icon:kw,tooltip:!0}),o.bind("isEnabled").to(i),this.listenTo(o,"execute",()=>{this._showFormView()}),o}),e.ui.componentFactory.add("removeBookmark",t=>{const i=e.commands.get("delete"),o=new P(t),s=t.t;return o.set({label:s("Remove bookmark"),icon:sA,tooltip:!0}),o.bind("isEnabled").to(i),this.listenTo(o,"execute",()=>{e.execute("delete"),e.editing.view.focus()}),o})}_createBookmarkButton(e){const t=this.editor,i=t.locale,o=new e(i),s=t.commands.get("insertBookmark"),r=t.commands.get("updateBookmark"),a=i.t;return o.set({label:a("Bookmark"),icon:mC}),this.listenTo(o,"execute",()=>{t.editing.view.scrollToTheSelection(),this._showFormView()}),o.bind("isEnabled").toMany([s,r],"isEnabled",(...l)=>l.some(c=>c)),o.bind("isOn").to(r,"value",l=>!!l),o}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Esc",(e,t)=>{this._isFormVisible&&(this._hideFormView(),t())}),$t({emitter:this.formView,activator:()=>this._isFormInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideFormView(!1)}})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("updateBookmark");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.backButtonView.isVisible=e.isEnabled,this.formView.idInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.idInputView.fieldView.select(),this.formView.enableCssTransitions()}_removeFormView(e=!0){this.formView.saveButtonView.focus(),this.formView.idInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection()}_showFormView(){this.formView||this._createViews(),this._getSelectedBookmarkElement()||this._showFakeVisualSelection(),this._addFormView(),this._balloon.showStack("main"),this._startUpdatingUI()}_hideFormView(e=!0){if(!this._isFormInPanel)return;const t=this.editor;this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e&&t.editing.view.focus(),this._removeFormView(e),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedBookmarkElement(),o=r();const s=()=>{const a=this._getSelectedBookmarkElement(),l=r();i&&!a||!i&&l!==o?this._hideFormView():this._isFormVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=a,o=l};function r(){return t.selection.focus.getAncestors().reverse().find(a=>a.is("element"))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model;let i;const o=this._getSelectedBookmarkElement();if(t.markers.has(Yt)){const s=Array.from(this.editor.editing.mapper.markerNameToElements(Yt)),r=e.createRange(e.createPositionBefore(s[0]),e.createPositionAfter(s[s.length-1]));i=e.domConverter.viewRangeToDom(r)}else o&&(i=()=>{const s=this.editor.editing.mapper,r=e.domConverter,a=s.toViewElement(o);return r.mapViewToDom(a)});if(i)return{target:i}}_getSelectedBookmarkElement(){const e=this.editor.model.document.selection.getSelectedElement();return e&&e.is("element","bookmark")?e:null}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(Yt))t.updateMarker(Yt,{range:i});else if(i.start.isAtEnd){const o=i.start.getLastMatchingPosition(({item:s})=>!e.schema.isContent(s),{boundaries:i});t.addMarker(Yt,{usingOperation:!1,affectsData:!1,range:t.createRange(o,i.end)})}else t.addMarker(Yt,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Yt)&&e.change(t=>{t.removeMarker(Yt)})}}function y3(n){const{t:e}=n,t=n.plugins.get(ns);return[i=>{if(!i.id)return e("Bookmark must not be empty.")},i=>{if(i.id&&/\s/.test(i.id))return e("Bookmark name cannot contain space characters.")},i=>{const o=n.model.document.selection.getSelectedElement(),s=t.getElementForBookmarkId(i.id);if(o!==s&&s)return e("Bookmark name already exists.")}]}function k3(n){const e=n.getSelectedElement();return!e||!Se(e)||!e.getCustomProperty("bookmark")?null:e}class C3 extends w{static get pluginName(){return"Bookmark"}static get requires(){return[ns,v3,Vt]}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bs extends ui{constructor(e){super(e),h(this,"domEventType",["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"]);const t=this.document;this.listenTo(t,"paste",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",i("dragging"),{priority:"low"});function i(o){return(s,r)=>{r.preventDefault();const a=r.dropRange?[r.dropRange]:null,l=new Ti(t,o);t.fire(l,{dataTransfer:r.dataTransfer,method:s.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,i=e.type=="drop"||e.type=="paste",o={dataTransfer:new kp(t,{cacheFiles:i})};if(e.type=="drop"||e.type=="dragover"){const s=Qg(e);o.dropRange=s&&this.view.domConverter.domRangeToView(s)}this.fire(e.type,e,o)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function A3(n){return n=n.replace(/&/g,"&").replace(//g,">").replace(/\r?\n\r?\n/g,"
").replace(/\r?\n/g,"
").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," "),(n.includes("
")||n.includes("
"))&&(n=`
${n}
`),n}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function x3(n){return n.replace(/(\s+)<\/span>/g,(e,t)=>t.length==1?" ":t).replace(//g,"")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const xm=["figcaption","li"],Tm=["ol","ul"];function Vb(n,e){if(e.is("$text")||e.is("$textProxy"))return e.data;if(e.is("element","img")&&e.hasAttribute("alt"))return e.getAttribute("alt");if(e.is("element","br"))return`
`;let t="",i=null;for(const o of e.getChildren())t+=T3(o,i)+Vb(n,o),i=o;if(e.is("rawElement")){const o=document.createElement("div");e.render(o,n),t+=Rb(o)}return t}function Rb(n){let e="";if(n.nodeType===Node.TEXT_NODE)return n.textContent;if(n.tagName==="BR")return`
`;for(const t of n.childNodes)e+=Rb(t);return e}function T3(n,e){return e?n.is("element","li")&&!n.isEmpty&&n.getChild(0).is("containerElement")||Tm.includes(n.name)&&Tm.includes(e.name)?`
`:!n.is("containerElement")&&!e.is("containerElement")?"":xm.includes(n.name)||xm.includes(e.name)?`
`:n.is("element")&&n.getCustomProperty("dataPipeline:transparentRendering")||e.is("element")&&e.getCustomProperty("dataPipeline:transparentRendering")?"":`
`:""}class os extends w{constructor(){super(...arguments),h(this,"_markersToCopy",new Map)}static get pluginName(){return"ClipboardMarkersUtils"}static get isOfficialPlugin(){return!0}_registerMarkerToCopy(e,t){this._markersToCopy.set(e,t)}_copySelectedFragmentWithMarkers(e,t,i=o=>o.model.getSelectedContent(o.model.document.selection)){return this.editor.model.change(o=>{const s=o.model.document.selection;o.setSelection(t);const r=this._insertFakeMarkersIntoSelection(o,o.model.document.selection,e),a=i(o),l=this._removeFakeMarkersInsideElement(o,a);for(const[c,u]of Object.entries(r)){l[c]||(l[c]=o.createRangeIn(a));for(const d of u)o.remove(d)}a.markers.clear();for(const[c,u]of Object.entries(l))a.markers.set(c,u);return o.setSelection(s),a})}_pasteMarkersIntoTransformedElement(e,t){const i=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change(o=>{const s=this._insertFakeMarkersElements(o,i),r=t(o),a=this._removeFakeMarkersInsideElement(o,r);for(const l of Object.values(s).flat())o.remove(l);for(const[l,c]of Object.entries(a))o.model.markers.has(l)||o.addMarker(l,{usingOperation:!0,affectsData:!0,range:c});return r})}_pasteFragmentWithMarkers(e){const t=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const i of t)e.markers.set(i.name,i.range);return this.editor.model.insertContent(e)}_forceMarkersCopy(e,t,i={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const o=this._markersToCopy.get(e);this._markersToCopy.set(e,i),t(),o?this._markersToCopy.set(e,o):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const i=this._getMarkerClipboardConfig(e);if(!i)return!1;if(!t)return!0;const{allowedActions:o}=i;return o==="all"||o.includes(t)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[t]=e.split(":");return this._markersToCopy.get(t)||null}_insertFakeMarkersIntoSelection(e,t,i){const o=this._getCopyableMarkersFromSelection(e,t,i);return this._insertFakeMarkersElements(e,o)}_getCopyableMarkersFromSelection(e,t,i){const o=Array.from(t.getRanges()),s=new Set(o.flatMap(a=>Array.from(e.model.markers.getMarkersIntersectingRange(a)))),r=a=>{if(!this._isMarkerCopyable(a.name,i))return!1;const{copyPartiallySelected:l}=this._getMarkerClipboardConfig(a.name);if(!l){const c=a.getRange();return o.some(u=>u.containsRange(c,!0))}return!0};return Array.from(s).filter(r).map(a=>({name:i==="dragstart"?this._getUniqueMarkerName(a.name):a.name,range:a.getRange()}))}_getPasteMarkersFromRangeMap(e,t=null){const{model:i}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap(([o,s])=>{if(!this._hasMarkerConfiguration(o))return[{name:o,range:s}];if(this._isMarkerCopyable(o,t)){const r=this._getMarkerClipboardConfig(o),a=i.markers.has(o)&&i.markers.get(o).getRange().root.rootName==="$graveyard";return(r.duplicateOnPaste||a)&&(o=this._getUniqueMarkerName(o)),[{name:o,range:s}]}return[]})}_insertFakeMarkersElements(e,t){const i={},o=t.flatMap(s=>{const{start:r,end:a}=s.range;return[{position:r,marker:s,type:"start"},{position:a,marker:s,type:"end"}]}).sort(({position:s},{position:r})=>s.isBefore(r)?1:-1);for(const{position:s,marker:r,type:a}of o){const l=e.createElement("$marker",{"data-name":r.name,"data-type":a});i[r.name]||(i[r.name]=[]),i[r.name].push(l),e.insert(l,s)}return i}_removeFakeMarkersInsideElement(e,t){const i=this._getAllFakeMarkersFromElement(e,t).reduce((o,s)=>{const r=s.markerElement&&e.createPositionBefore(s.markerElement);let a=o[s.name],l=!1;return a!=null&&a.start&&a!=null&&a.end&&(this._getMarkerClipboardConfig(s.name).duplicateOnPaste?o[this._getUniqueMarkerName(s.name)]=o[s.name]:l=!0,a=null),l||(o[s.name]={...a,[s.type]:r}),s.markerElement&&e.remove(s.markerElement),o},{});return __(i,o=>new y(o.start||e.createPositionFromPath(t,[0]),o.end||e.createPositionAt(t,"end")))}_getAllFakeMarkersFromElement(e,t){const i=Array.from(e.createRangeIn(t)).flatMap(({item:r})=>{if(!r.is("element","$marker"))return[];const a=r.getAttribute("data-name"),l=r.getAttribute("data-type");return[{markerElement:r,name:a,type:l}]}),o=[],s=[];for(const r of i)r.type==="end"&&(i.some(a=>a.name===r.name&&a.type==="start")||o.push({markerElement:null,name:r.name,type:"start"})),r.type==="start"&&(i.some(a=>a.name===r.name&&a.type==="end")||s.unshift({markerElement:null,name:r.name,type:"end"}));return[...o,...i,...s]}_getUniqueMarkerName(e){const t=e.split(":"),i=ze().substring(1,6);return t.length===3?`${t.slice(0,2).join(":")}:${i}`:`${t.join(":")}:${i}`}}class pt extends w{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[os]}init(){this.editor.editing.view.addObserver(bs),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const o=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:i==="cut"},()=>{const s=o._copySelectedFragmentWithMarkers(i,t);this.fire("outputTransformation",{dataTransfer:e,content:s,method:i})})}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,o=i.document,s=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(o,"clipboardInput",(r,a)=>{a.method=="paste"&&!e.model.canEditAt(e.model.document.selection)&&r.stop()},{priority:"highest"}),this.listenTo(o,"clipboardInput",(r,a)=>{const l=a.dataTransfer;let c;if(a.content)c=a.content;else{let m="";l.getData("text/html")?m=x3(l.getData("text/html")):l.getData("text/plain")&&(m=A3(l.getData("text/plain"))),c=this.editor.data.htmlProcessor.toView(m)}const u=new Ti(this,"inputTransformation"),d=l.getData("application/ckeditor5-editor-id")||null;this.fire(u,{content:c,dataTransfer:l,sourceEditorId:d,targetRanges:a.targetRanges,method:a.method}),u.stop.called&&r.stop(),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(r,a)=>{if(a.content.isEmpty)return;const l=this.editor.data.toModel(a.content,"$clipboardHolder");l.childCount!=0&&(r.stop(),t.change(()=>{this.fire("contentInsertion",{content:l,method:a.method,sourceEditorId:a.sourceEditorId,dataTransfer:a.dataTransfer,targetRanges:a.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(r,a)=>{a.resultRange=s._pasteFragmentWithMarkers(a.content)},{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,o=(s,r)=>{const a=r.dataTransfer;r.preventDefault(),this._fireOutputTransformationEvent(a,t.selection,s.name)};this.listenTo(i,"copy",o,{priority:"low"}),this.listenTo(i,"cut",(s,r)=>{e.model.canEditAt(e.model.document.selection)?o(s,r):r.preventDefault()},{priority:"low"}),this.listenTo(this,"outputTransformation",(s,r)=>{const a=e.data.toView(r.content,{isClipboardPipeline:!0});i.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:a,method:r.method})},{priority:"low"}),this.listenTo(i,"clipboardOutput",(s,r)=>{r.content.isEmpty||(r.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(r.content)),r.dataTransfer.setData("text/plain",Vb(e.data.htmlProcessor.domConverter,r.content)),r.dataTransfer.setData("application/ckeditor5-editor-id",this.editor.id)),r.method=="cut"&&e.model.deleteContent(t.selection)},{priority:"low"})}}const dl=Vi("px");class E3 extends A{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",t=>!t)],style:{left:e.to("left",t=>dl(t)),top:e.to("top",t=>dl(t)),width:e.to("width",t=>dl(t))}}})}}class Ys extends w{constructor(){super(...arguments),h(this,"removeDropMarkerDelayed",$c(()=>this.removeDropMarker(),40)),h(this,"_updateDropMarkerThrottled",co(e=>this._updateDropMarker(e),40)),h(this,"_reconvertMarkerThrottled",co(()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")},0)),h(this,"_dropTargetLineView",new E3),h(this,"_domEmitter",new(st())),h(this,"_scrollables",new Map)}static get pluginName(){return"DragDropTarget"}static get isOfficialPlugin(){return!0}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,i,o,s,r){this.removeDropMarkerDelayed.cancel();const a=Em(this.editor,e,t,i,o,s,r);/* istanbul ignore next -- @preserve */if(a){if(r&&r.containsRange(a))return this.removeDropMarker();this._updateDropMarkerThrottled(a)}}getFinalDropRange(e,t,i,o,s,r){const a=Em(this.editor,e,t,i,o,s,r);return this.removeDropMarker(),a}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change(t=>{t.removeMarker("drop-target")})}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(i);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const t=this.editor,i=t.model.markers;t.model.change(o=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||o.updateMarker("drop-target",{range:e}):o.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})})}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},function(t){const i=this.toDomElement(t);return i.append("",t.createElement("span"),""),i})}_updateDropTargetLine(e){const t=this.editor.editing,i=e.start.nodeBefore,o=e.start.nodeAfter,s=e.start.parent,r=i?t.mapper.toViewElement(i):null,a=r?t.view.domConverter.mapViewToDom(r):null,l=o?t.mapper.toViewElement(o):null,c=l?t.view.domConverter.mapViewToDom(l):null,u=t.mapper.toViewElement(s);if(!u)return;const d=t.view.domConverter.mapViewToDom(u),m=this._getScrollableRect(u),{scrollX:f,scrollY:g}=I.window,p=a?new z(a):null,_=c?new z(c):null,v=new z(d).excludeScrollbarsAndBorders(),E=p?p.bottom:v.top,M=_?_.top:v.bottom,G=I.window.getComputedStyle(d),X=E<=M?(E+M)/2:M;if(m.topa.schema.checkChild(d,m))){if(a.schema.checkChild(d,"$text"))return a.createRange(d);if(u)return Xs(n,Sm(n,u.parent),i,o)}}}else if(a.schema.isInline(c))return Xs(n,c,i,o)}if(a.schema.isBlock(c))return Xs(n,c,i,o);if(a.schema.checkChild(c,"$block")){const u=Array.from(c.getChildren()).filter(f=>f.is("element")&&!S3(n,f));let d=0,m=u.length;if(m==0)return a.createRange(a.createPositionAt(c,"end"));for(;d{o?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")}),N.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const t=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(t,"dragstart",(i,o)=>this._handleBlockDragStart(o)),this._domEmitter.listenTo(I.document,"dragover",(i,o)=>this._handleBlockDragging(o)),this._domEmitter.listenTo(I.document,"drop",(i,o)=>this._handleBlockDragging(o)),this._domEmitter.listenTo(I.document,"dragend",()=>this._handleBlockDragEnd(),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",(i,o,s)=>{t.setAttribute("draggable",s?"true":"false")})}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,o=this.editor.editing.view,s=Array.from(i.getSelectedBlocks()),r=t.createRange(t.createPositionBefore(s[0]),t.createPositionAfter(s[s.length-1]));t.change(a=>a.setSelection(r)),this._isBlockDragging=!0,o.focus(),o.getObserver(bs).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+(this.editor.locale.contentLanguageDirection=="ltr"?100:-100),i=e.clientY,o=document.elementFromPoint(t,i),s=this.editor.editing.view;!o||!o.closest(".ck-editor__editable")||s.getObserver(bs).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:o,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class V3 extends w{constructor(){super(...arguments),h(this,"_draggedRange"),h(this,"_draggingUid"),h(this,"_draggableElement"),h(this,"_clearDraggableAttributesDelayed",$c(()=>this._clearDraggableAttributes(),40)),h(this,"_blockMode",!1),h(this,"_domEmitter",new(st())),h(this,"_previewContainer")}static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[pt,Vt,Ys,I3]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(bs),t.addObserver(ua),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",(i,o,s)=>{s?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(i,o,s)=>{s||this._finalizeDragging(!1)}),N.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,i=e.editing.view,o=i.document,s=e.plugins.get(Ys);this.listenTo(o,"dragstart",(r,a)=>{var l;if((l=a.target)!=null&&l.is("editableElement")){a.preventDefault();return}if(this._prepareDraggedRange(a.target),!this._draggedRange){a.preventDefault();return}this._draggingUid=ze(),a.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",a.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(a.dataTransfer,c,"dragstart");const{dataTransfer:u,domTarget:d,domEvent:m}=a,{clientX:f}=m;this._updatePreview({dataTransfer:u,domTarget:d,clientX:f}),a.stopPropagation(),this.isEnabled||(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._domEmitter.listenTo(I.document,"dragend",()=>{this._blockMode=!1},{useCapture:!0}),this.listenTo(o,"dragenter",()=>{this.isEnabled&&i.focus()}),this.listenTo(o,"dragleave",()=>{s.removeDropMarkerDelayed()}),this.listenTo(o,"dragging",(r,a)=>{if(!this.isEnabled){a.dataTransfer.dropEffect="none";return}const{clientX:l,clientY:c}=a.domEvent;s.updateDropMarker(a.target,a.targetRanges,l,c,this._blockMode,this._draggedRange),this._draggedRange||(a.dataTransfer.dropEffect="copy"),N.isGecko||(a.dataTransfer.effectAllowed=="copy"?a.dataTransfer.dropEffect="copy":["all","copyMove"].includes(a.dataTransfer.effectAllowed)&&(a.dataTransfer.dropEffect="move")),r.stop()},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(Ys);this.listenTo(t,"clipboardInput",(o,s)=>{if(s.method!="drop")return;const{clientX:r,clientY:a}=s.domEvent,l=i.getFinalDropRange(s.target,s.targetRanges,r,a,this._blockMode,this._draggedRange);if(!l){this._finalizeDragging(!1),o.stop();return}if(this._draggedRange&&this._draggingUid!=s.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),Pm(s.dataTransfer)=="move"&&this._draggedRange&&this._draggedRange.containsRange(l,!0)){this._finalizeDragging(!1),o.stop();return}s.targetRanges=[e.editing.mapper.toViewRange(l)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(pt);e.on("contentInsertion",(t,i)=>{if(!this.isEnabled||i.method!=="drop")return;const o=i.targetRanges.map(s=>this.editor.editing.mapper.toModelRange(s));this.editor.model.change(s=>s.setSelection(o))},{priority:"high"}),e.on("contentInsertion",(t,i)=>{if(!this.isEnabled||i.method!=="drop")return;const o=Pm(i.dataTransfer)=="move",s=!i.resultRange||!i.resultRange.isCollapsed;this._finalizeDragging(s&&o)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",(o,s)=>{if(N.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let r=Im(s.target);if(N.isBlink&&!e.isReadOnly&&!r&&!i.selection.isCollapsed){const a=i.selection.getSelectedElement();(!a||!Se(a))&&(r=i.selection.editableElement)}r&&(t.change(a=>{a.setAttribute("draggable","true",r)}),this._draggableElement=e.editing.mapper.toModelElement(r))}),this.listenTo(i,"mouseup",()=>{N.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})}_finalizeDragging(e){const t=this.editor,i=t.model;t.plugins.get(Ys).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&i.change(o=>{const s=i.createSelection(this._draggedRange);i.deleteContent(s,{doNotAutoparagraph:!0});const r=s.getFirstPosition().parent;r.isEmpty&&!i.schema.checkChild(r,"$text")&&i.schema.checkChild(r,"paragraph")&&o.insertElement("paragraph",r,0)}),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,o=i.document.selection,s=e?Im(e):null;if(s){const c=t.editing.mapper.toModelElement(s);this._draggedRange=ht.fromRange(i.createRangeOn(c)),this._blockMode=i.schema.isBlock(c),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop");return}if(o.isCollapsed&&!o.getFirstPosition().parent.isEmpty)return;const r=Array.from(o.getSelectedBlocks()),a=o.getFirstRange();if(r.length==0){this._draggedRange=ht.fromRange(a);return}const l=Bb(i,r);if(r.length>1)this._draggedRange=ht.fromRange(l),this._blockMode=!0;else if(r.length==1){const c=a.start.isTouching(l.start)&&a.end.isTouching(l.end);this._draggedRange=ht.fromRange(c?l:a),this._blockMode=c}i.change(c=>c.setSelection(this._draggedRange.toRange()))}_updatePreview({dataTransfer:e,domTarget:t,clientX:i}){const o=this.editor.editing.view,s=o.document.selection.editableElement,r=o.domConverter.mapViewToDom(s),a=I.window.getComputedStyle(r);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=Ll(I.document,"div",{style:"position: fixed; left: -999999px;"}),I.document.body.appendChild(this._previewContainer));const l=new z(r);if(r.contains(t))return;const c=parseFloat(a.paddingLeft),u=Ll(I.document,"div");u.className="ck ck-content",u.style.width=a.width,u.style.paddingLeft=`${l.left-i+c}px`,N.isiOS&&(u.style.backgroundColor="white"),o.domConverter.setContentOf(u,e.getData("text/html")),e.setDragImage(u,0,0),this._previewContainer.appendChild(u)}}function Pm(n){return N.isGecko?n.dropEffect:["all","copyMove"].includes(n.effectAllowed)?"move":"copy"}function Im(n){if(n.is("editableElement"))return null;if(n.hasClass("ck-widget__selection-handle"))return n.findAncestor(Se);if(Se(n))return n;const e=n.findAncestor(t=>Se(t)||t.is("editableElement"));return Se(e)?e:null}function Bb(n,e){const t=e[0],i=e[e.length-1],o=t.getCommonAncestor(i),s=n.createPositionBefore(t),r=n.createPositionAfter(i);if(o&&o.is("element")&&!n.schema.isLimit(o)){const a=n.createRangeOn(o),l=s.isTouching(a.start),c=r.isTouching(a.end);if(l&&c)return Bb(n,[o])}return n.createRange(s,r)}class R3 extends w{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[pt]}init(){const e=this.editor,t=e.model,i=e.editing.view,o=t.document.selection;i.addObserver(bs),e.plugins.get(pt).on("contentInsertion",(s,r)=>{O3(r.content,t)&&t.change(a=>{const l=Array.from(o.getAttributes()).filter(([u])=>t.schema.getAttributeProperties(u).isFormatting);o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),l.push(...o.getAttributes());const c=a.createRangeIn(r.content);for(const u of c.getItems())for(const d of l)t.schema.checkAttribute(u,d[0])&&a.setAttribute(d[0],d[1],u)})})}}function O3(n,e){let t=e.createRangeIn(n);if(n.childCount==1){const i=n.getChild(0);i.is("element")&&e.schema.isBlock(i)&&!e.schema.isObject(i)&&!e.schema.isLimit(i)&&(t=e.createRangeIn(i))}for(const i of t.getItems())if(!e.schema.isInline(i)||Array.from(i.getAttributeKeys()).find(o=>e.schema.getAttributeProperties(o).isFormatting))return!1;return!0}class _s extends w{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[os,pt,V3,R3]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Hr(n){const e=n.t,t=n.config.get("codeBlock.languages");for(const i of t)i.label==="Plain text"&&(i.label=e("Plain text")),i.class===void 0&&(i.class=`language-${i.language}`);return t}function $r(n,e,t){const i={};for(const o of n)if(e==="class"){const s=o[e].split(" ").shift();i[s]=o[t]}else i[o[e]]=o[t];return i}function xu(n){return n.data.match(/^(\s*)/)[0]}function B3(n,e){const t=n.createDocumentFragment(),i=e.split(`
`),o=i.reduce((s,r,a)=>(s.push(r),a!c.isEqual(l))&&t.push(l)}return t}function Mb(n){const e=ae(n.getSelectedBlocks());return!!e&&e.is("element","codeBlock")}function Vm(n,e){return e.is("rootElement")||n.isLimit(e)?!1:n.checkChild(e.parent,"codeBlock")}function Rm(n,e,t,i){const o=$r(e,"language","label"),s=t.getAttribute("language");if(s in o){const r=o[s];return n(i==="enter"?"Entering %0 code snippet":"Leaving %0 code snippet",r)}return n(i==="enter"?"Entering code snippet":"Leaving code snippet")}function Lb(n,e){for(n.textNode&&(n=e.createPositionBefore(n.textNode));n.nodeBefore&&!n.nodeBefore.is("element","softBreak");)n=e.createPositionBefore(n.nodeBefore);const t=n.nodeAfter;return t&&t.is("$text")?t:null}class M3 extends O{constructor(e){super(e),h(this,"_lastLanguage"),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,o=i.document.selection,s=Hr(t)[0],r=Array.from(o.getSelectedBlocks()),a=e.forceValue==null?!this.value:e.forceValue,l=L3(e,this._lastLanguage,s.language);i.change(c=>{a?this._applyCodeBlock(c,r,l):this._removeCodeBlock(c,r)})}_getValue(){const e=this.editor.model.document.selection,t=ae(e.getSelectedBlocks());return t!=null&&t.is("element","codeBlock")?t.getAttribute("language"):!1}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=ae(e.getSelectedBlocks());return i?Vm(t,i):!1}_applyCodeBlock(e,t,i){this._lastLanguage=i;const o=this.editor.model.schema,s=t.filter(r=>Vm(o,r));for(const r of s)e.rename(r,"codeBlock"),e.setAttribute("language",i,r),o.removeDisallowedAttributes([r],e),Array.from(r.getChildren()).filter(a=>!o.checkChild(r,a)).forEach(a=>e.remove(a));s.reverse().forEach((r,a)=>{const l=s[a+1];r.previousSibling===l&&(e.appendElement("softBreak",l),e.merge(e.createPositionBefore(r)))})}_removeCodeBlock(e,t){const i=t.filter(o=>o.is("element","codeBlock"));for(const o of i){const s=e.createRangeOn(o);for(const r of Array.from(s.getItems()).reverse())if(r.is("element","softBreak")&&r.parent.is("element","codeBlock")){const{position:a}=e.split(e.createPositionBefore(r)),l=a.nodeAfter;e.rename(l,"paragraph"),e.removeAttribute("language",l),e.remove(r)}e.rename(o,"paragraph"),e.removeAttribute("language",o)}}}function L3(n,e,t){return n.language?n.language:n.usePreviousLanguageChoice&&e?e:t}class F3 extends O{constructor(e){super(e),h(this,"_indentSequence"),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(t=>{const i=sc(e);for(const o of i){const s=t.createText(this._indentSequence);e.insertContent(s,o)}})}_checkEnabled(){return this._indentSequence?Mb(this.editor.model.document.selection):!1}}class N3 extends O{constructor(e){super(e),h(this,"_indentSequence"),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(()=>{const t=sc(e);for(const i of t){const o=Om(e,i,this._indentSequence);o&&e.deleteContent(e.createSelection(o))}})}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return Mb(e.document.selection)?sc(e).some(t=>Om(e,t,this._indentSequence)):!1}}function Om(n,e,t){const i=Lb(e,n);if(!i)return null;const o=xu(i),s=o.lastIndexOf(t);if(s+t.length!==o.length||s===-1)return null;const{parent:r,startOffset:a}=i;return n.createRange(n.createPositionAt(r,a+s),n.createPositionAt(r,a+s+t.length))}function Bm(n,e,t=!1){const i=$r(e,"language","class"),o=$r(e,"language","label");return(s,r,a)=>{const{writer:l,mapper:c,consumable:u}=a;if(!u.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),m=c.toViewPosition(n.createPositionBefore(r.item)),f={};t&&(f["data-language"]=o[d],f.class="hljs",f.spellcheck="false");const g=i[d]?{class:i[d]}:void 0,p=l.createContainerElement("code",g),_=l.createContainerElement("pre",f,p);l.insert(m,_),c.bindElements(r.item,p)}}function D3(n){return(e,t,i)=>{if(t.item.parent.name!=="codeBlock")return;const{writer:o,mapper:s,consumable:r}=i;if(!r.consume(t.item,"insert"))return;const a=s.toViewPosition(n.createPositionBefore(t.item));o.insert(a,o.createText(`
`))}}function z3(n,e){const t=$r(e,"class","language"),i=e[0].language;return(o,s,r)=>{const a=s.viewItem,l=a.parent;if(!l||!l.is("element","pre")||s.modelCursor.findAncestor("codeBlock"))return;const{consumable:c,writer:u}=r;if(!c.test(a,{name:!0}))return;const d=u.createElement("codeBlock"),m=[...a.getClassNames()];m.length||m.push("");for(const f of m){const g=t[f];if(g){u.setAttribute("language",g,d);break}}d.hasAttribute("language")||u.setAttribute("language",i,d),r.convertChildren(a,d),r.safeInsert(d,s.modelCursor)&&(c.consume(a,{name:!0}),r.updateConversionResult(d,s))}}function H3(){return(n,e,{consumable:t,writer:i})=>{let o=e.modelCursor;if(!t.test(e.viewItem)||!o.findAncestor("codeBlock"))return;t.consume(e.viewItem);const s=e.viewItem.data.split(`
`).map(a=>i.createText(a)),r=s[s.length-1];for(const a of s)if(i.insert(a,o),o=o.getShiftedBy(a.offsetSize),a!==r){const l=i.createElement("softBreak");i.insert(l,o),o=i.createPositionAfter(l)}e.modelRange=i.createRange(e.modelCursor,o),e.modelCursor=o}}function $3(){return(n,e,{consumable:t})=>{const i=e.viewItem;if(i.findAncestor("pre"))return;const o=Array.from(i.getChildren()),s=o.find(r=>r.is("element","code"));if(s)for(const r of o)r===s||!r.is("$text")||t.consume(r,{name:!0})}}const Fb="paragraph";class W3 extends w{static get pluginName(){return"CodeBlockEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Tb]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"go",label:"Go"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:" "})}init(){const e=this.editor,t=e.model.schema,i=e.model,o=e.editing.view,s=Hr(e);e.commands.add("codeBlock",new M3(e)),e.commands.add("indentCodeBlock",new F3(e)),e.commands.add("outdentCodeBlock",new N3(e)),this.listenTo(o.document,"tab",(r,a)=>{const l=a.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(l).isEnabled&&(e.execute(l),a.stopPropagation(),a.preventDefault(),r.stop())},{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",disallowChildren:"$inlineObject",allowAttributes:["language"],allowAttributesOf:"$listItem",isBlock:!0}),t.addAttributeCheck((r,a)=>{const l=r.getItem(r.length-2);if(t.getAttributeProperties(a).isFormatting&&l&&l.name=="codeBlock")return!1}),e.editing.downcastDispatcher.on("insert:codeBlock",Bm(i,s,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Bm(i,s)),e.data.downcastDispatcher.on("insert:softBreak",D3(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",z3(o,s)),e.data.upcastDispatcher.on("text",H3()),e.data.upcastDispatcher.on("element:pre",$3(),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",(r,a)=>{let l=i.createRange(i.document.selection.anchor);if(a.targetRanges&&(l=e.editing.mapper.toModelRange(a.targetRanges[0])),!l.start.parent.is("element","codeBlock"))return;const c=a.dataTransfer.getData("text/plain"),u=new Ht(e.editing.view.document);a.content=B3(u,c)}),e.plugins.has("ClipboardPipeline")&&e.plugins.get(pt).on("contentInsertion",(r,a)=>{const l=e.model,c=l.document.selection;c.anchor.parent.is("element","codeBlock")&&l.change(u=>{const d=u.createRangeIn(a.content);for(const m of[...d.getItems()])m.is("node")&&!t.checkChild(c.anchor,m)&&u.remove(m)})}),this.listenTo(i,"getSelectedContent",(r,[a])=>{const l=a.anchor;a.isCollapsed||!l.parent.is("element","codeBlock")||!l.hasSameParentAs(a.focus)||i.change(c=>{const u=r.return;if(l.parent.is("element")&&(u.childCount>1||a.containsEntireContent(l.parent))){const m=c.createElement("codeBlock",l.parent.getAttributes());c.append(u,m);const f=c.createDocumentFragment();c.append(m,f),r.return=f;return}const d=u.getChild(0);t.checkAttribute(d,"code")&&c.setAttribute("code",!0,d)})})}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),o=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),o&&o.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",(s,r)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(!U3(e,r.isSoft)&&!q3(e,r.isSoft)&&j3(e),r.preventDefault(),s.stop())},{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor,o=Hr(this.editor);let s=null;e.document.selection.on("change:range",()=>{const r=e.document.selection.focus.parent;!t||s===r||!r.is("element")||(s&&s.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(Rm(i,o,s,"leave")),r.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(Rm(i,o,r,"enter")),s=r)})}}function j3(n){const e=n.model,t=e.document,i=t.selection.getLastPosition();let o;const s=Lb(i,e);s&&s.is("$text")&&(o=xu(s)),n.model.change(r=>{n.execute("shiftEnter"),o&&r.insertText(o,t.selection.anchor)})}function U3(n,e){const t=n.model.document,i=n.editing.view,o=t.selection.getLastPosition(),s=o.nodeAfter;return e||!t.selection.isCollapsed||!o.isAtStart||!fn(s)?!1:(n.model.change(r=>{n.execute("enter");const a=t.selection.anchor.parent.previousSibling;r.rename(a,Fb),r.setSelection(a,"in"),n.model.schema.removeDisallowedAttributes([a],r),r.remove(s)}),i.scrollToTheSelection(),!0)}function q3(n,e){const t=n.model,i=t.document,o=n.editing.view,s=i.selection.getLastPosition(),r=s.nodeBefore;let a;if(e||!i.selection.isCollapsed||!s.isAtEnd||!r||!r.previousSibling)return!1;if(fn(r)&&fn(r.previousSibling))a=t.createRange(t.createPositionBefore(r.previousSibling),t.createPositionAfter(r));else if(ml(r)&&fn(r.previousSibling)&&fn(r.previousSibling.previousSibling))a=t.createRange(t.createPositionBefore(r.previousSibling.previousSibling),t.createPositionAfter(r));else if(ml(r)&&fn(r.previousSibling)&&ml(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&fn(r.previousSibling.previousSibling.previousSibling))a=t.createRange(t.createPositionBefore(r.previousSibling.previousSibling.previousSibling),t.createPositionAfter(r));else return!1;return n.model.change(l=>{l.remove(a),n.execute("enter");const c=i.selection.anchor.parent;l.rename(c,Fb),n.model.schema.removeDisallowedAttributes([c],l)}),o.scrollToTheSelection(),!0}function ml(n){return n&&n.is("$text")&&!n.data.match(/\S/)}function fn(n){return n&&n.is("element","softBreak")}class G3 extends w{static get pluginName(){return"CodeBlockUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,o=Hr(e),s=this._getLanguageListItemDefinitions(o),r=e.commands.get("codeBlock");i.add("codeBlock",a=>{const l=Ee(a,Xi),c=l.buttonView,u=t("Insert code block");return c.set({label:u,tooltip:!0,icon:md,isToggleable:!0}),c.bind("isOn").to(r,"value",d=>!!d),c.on("execute",()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()}),l.on("execute",d=>{e.execute("codeBlock",{language:d.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),l.class="ck-code-block-dropdown",l.bind("isEnabled").to(r),wt(l,s,{role:"menu",ariaLabel:u}),l}),i.add("menuBar:codeBlock",a=>{const l=new Tt(a);l.buttonView.set({role:"menuitem",label:t("Code block"),icon:md}),l.bind("isEnabled").to(r);const c=new Si(a);c.set({ariaLabel:t("Insert code block")});for(const u of s){const d=new Oi(a,l),m=new ve(a);m.bind(...Object.keys(u.model)).to(u.model),m.set({isToggleable:!0,role:"menuitemcheckbox"}),m.delegate("execute").to(l),m.on("execute",()=>{e.execute("codeBlock",{language:u.model._codeBlockLanguage,forceValue:r.value!=u.model._codeBlockLanguage}),e.editing.view.focus()}),d.children.add(m),c.items.add(d)}return l.panelView.children.add(c),l})}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new _e;for(const o of e){const s={type:"button",model:new et({_codeBlockLanguage:o.language,label:o.label,role:"menuitemradio",withText:!0})};s.model.bind("isOn").to(t,"value",r=>r===s.model._codeBlockLanguage),i.add(s)}return i}}class Tu extends w{static get requires(){return[W3,G3]}static get pluginName(){return"CodeBlock"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class K3 extends ab{constructor(e,t){super(e),h(this,"view"),this.view=t}get element(){return this.view.editable.element}init(){const e=this.editor,t=this.view,i=e.editing.view,o=t.editable,s=i.document.getRoot();o.name=s.rootName,t.render();const r=o.element;this.setEditableElement(o.name,r),o.bind("isFocused").to(this.focusTracker),i.attachDomRoot(r),this._initPlaceholder(),this.initMenuBar(this.view.menuBarView),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),o=e.config.get("placeholder");if(o){const s=typeof o=="string"?o:o[i.rootName];s&&(i.placeholder=s)}sa({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}}class Z3 extends lb{constructor(e,t,i,o){super(e),h(this,"editable"),h(this,"menuBarView"),this.editable=new cb(e,t,i,{label:o}),this.menuBarView=new fb(e),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}render(){super.render(),this.registerChild(this.editable),this.registerChild(this.menuBarView)}}class Nb extends Br(pn){constructor(e,t={}){if(!fr(e)&&t.initialData!==void 0)throw new b("editor-create-initial-data",null);super(t),h(this,"ui"),this.config.get("initialData")===void 0&&this.config.set("initialData",J3(e)),fr(e)&&(this.sourceElement=e,hw(this,e));const i=this.config.get("plugins");i.push(bT),this.config.set("plugins",i),this.config.define("balloonToolbar",this.config.get("toolbar")),this.model.document.createRoot();const o=new Z3(this.locale,this.editing.view,this.sourceElement,this.config.get("label"));this.ui=new K3(this,o),eC(this)}static get editorName(){return"BalloonEditor"}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,t={}){return new Promise(i=>{if(fr(e)&&e.tagName==="TEXTAREA")throw new b("editor-wrong-element",null);const o=new this(e,t);i(o.initPlugins().then(()=>o.ui.init()).then(()=>o.data.init(o.config.get("initialData"))).then(()=>o.fire("ready")).then(()=>o))})}}function J3(n){return fr(n)?Jg(n):n}function fr(n){return xi(n)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Q3 extends ab{constructor(e,t){super(e),h(this,"view"),this.view=t}init(){const e=this.editor,t=this.view,i=e.editing.view,o=t.editable,s=i.document.getRoot();o.name=s.rootName,t.render();const r=o.element;this.setEditableElement(o.name,r),t.editable.bind("isFocused").to(this.focusTracker),i.attachDomRoot(r),this._initPlaceholder(),this._initToolbar(),this.initMenuBar(this.view.menuBarView),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;t.getDomRoot(e.editable.name)&&t.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,i=t.document.getRoot(),o=e.config.get("placeholder");if(o){const s=typeof o=="string"?o:o[i.rootName];s&&(i.placeholder=s)}sa({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}}class Y3 extends lb{constructor(e,t,i={}){super(e),h(this,"toolbar"),h(this,"editable"),h(this,"menuBarView"),this.toolbar=new Ei(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.menuBarView=new fb(e),this.editable=new cb(e,t,i.editableElement,{label:i.label}),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}}),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.menuBarView,this.toolbar,this.editable])}}class X3 extends Br(pn){constructor(e,t={}){if(!gr(e)&&t.initialData!==void 0)throw new b("editor-create-initial-data",null);super(t),h(this,"ui"),this.config.get("initialData")===void 0&&this.config.set("initialData",eS(e)),gr(e)&&(this.sourceElement=e,hw(this,e)),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),o=new Y3(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:i,label:this.config.get("label")});this.ui=new Q3(this,o)}static get editorName(){return"DecoupledEditor"}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,t={}){return new Promise(i=>{if(gr(e)&&e.tagName==="TEXTAREA")throw new b("editor-wrong-element",null);const o=new this(e,t);i(o.initPlugins().then(()=>o.ui.init()).then(()=>o.data.init(o.config.get("initialData"))).then(()=>o.fire("ready")).then(()=>o))})}}function eS(n){return gr(n)?Jg(n):n}function gr(n){return xi(n)}var rc={exports:{}},tS=rc.exports,Mm;function iS(){return Mm||(Mm=1,function(n){((e,t)=>{n.exports?n.exports=t():e.fuzzysort=t()})(tS,e=>{var t=(S,k)=>{if(!S||!k)return He;var R=g(S);nn(k)||(k=f(k));var H=R.bitflags;return(H&k._bitflags)!==H?He:_(R,k)},i=(S,k,R)=>{if(!S)return R!=null&&R.all?p(k,R):Ta;var H=g(S),W=H.bitflags,D=H.containsSpace,B=d(R?.threshold||0),K=R?.limit||Zu,j=0,le=0,oe=k.length;function rt(on){jLs.peek()._score&&Ls.replaceTop(on))}if(R!=null&&R.key)for(var Ze=R.key,ce=0;ce-1e3&&pe[ke]>bt){var Ot=(pe[ke]+di[ke])/4;Ot>pe[ke]&&(pe[ke]=Ot)}di[ke]>pe[ke]&&(pe[ke]=di[ke])}}if(D){for(let fe=0;fe-1e3&&Fe>bt){var Ot=(Fe+ye._score)/4;Ot>Fe&&(Fe=Ot)}ye._score>Fe&&(Fe=ye._score)}}if(_t.obj=tt,_t._score=Fe,R!=null&&R.scoreFn){if(Fe=R.scoreFn(_t),!Fe)continue;Fe=d(Fe),_t._score=Fe}Fe=0;--ce)Li[ce]=Ls.poll();return Li.total=j+le,Li},o=(S,k="",R="")=>{for(var H=typeof k=="function"?k:void 0,W=S.target,D=W.length,B=S.indexes,K="",j=0,le=0,oe=!1,rt=[],Ze=0;Ze{typeof S=="number"?S=""+S:typeof S!="string"&&(S="");var k=M(S);return c(S,{_targetLower:k._lower,_targetLowerCodes:k.lowerCodes,_bitflags:k.bitflags})},r=()=>{T.clear(),F.clear()};class a{get indexes(){return this._indexes.slice(0,this._indexes.len).sort((k,R)=>k-R)}set indexes(k){return this._indexes=k}highlight(k,R){return o(this,k,R)}get score(){return u(this._score)}set score(k){this._score=d(k)}}class l extends Array{get score(){return u(this._score)}set score(k){this._score=d(k)}}var c=(S,k)=>{const R=new a;return R.target=S,R.obj=k.obj??He,R._score=k._score??bt,R._indexes=k._indexes??[],R._targetLower=k._targetLower??"",R._targetLowerCodes=k._targetLowerCodes??He,R._nextBeginningIndexes=k._nextBeginningIndexes??He,R._bitflags=k._bitflags??0,R},u=S=>S===bt?0:S>1?S:Math.E**(((-S+1)**.04307-1)*-2),d=S=>S===0?bt:S>1?S:1-Math.pow(Math.log(S)/-2+1,1/.04307),m=S=>{typeof S=="number"?S=""+S:typeof S!="string"&&(S=""),S=S.trim();var k=M(S),R=[];if(k.containsSpace){var H=S.split(/\s+/);H=[...new Set(H)];for(var W=0;W{if(S.length>999)return s(S);var k=T.get(S);return k!==void 0||(k=s(S),T.set(S,k)),k},g=S=>{if(S.length>999)return m(S);var k=F.get(S);return k!==void 0||(k=m(S),F.set(S,k)),k},p=(S,k)=>{var R=[];R.total=S.length;var H=k?.limit||Zu;if(k!=null&&k.key)for(var W=0;W=H)return R}}else if(k!=null&&k.keys)for(var W=0;W=0;--le){var B=Ms(D,k.keys[le]);if(!B){j[le]=xo;continue}nn(B)||(B=f(B)),B._score=bt,B._indexes.len=0,j[le]=B}if(j.obj=D,j._score=bt,R.push(j),R.length>=H)return R}else for(var W=0;W=H))return R}return R},_=(S,k,R=!1,H=!1)=>{if(R===!1&&S.containsSpace)return v(S,k,H);for(var W=S._lower,D=S.lowerCodes,B=D[0],K=k._targetLowerCodes,j=D.length,le=K.length,ce=0,oe=0,rt=0;;){var Ze=B===K[oe];if(Ze){if(x[rt++]=oe,++ce,ce===j)break;B=D[ce]}if(++oe,oe>=le)return He}var ce=0,tt=!1,me=0,ye=k._nextBeginningIndexes;ye===He&&(ye=k._nextBeginningIndexes=X(k.target)),oe=x[0]===0?0:ye[x[0]-1];var Mi=0;if(oe!==le)for(;;)if(oe>=le){if(ce<=0||(++Mi,Mi>200))break;--ce;var Rt=q[--me];oe=ye[Rt]}else{var Ze=D[ce]===K[oe];if(Ze){if(q[me++]=oe,++ce,ce===j){tt=!0;break}++oe}else oe=ye[oe]}var Je=j<=1?-1:k._targetLower.indexOf(W,x[0]),se=!!~Je,Ot=se?Je===0||k._nextBeginningIndexes[Je-1]===Je:!1;if(se&&!Ot){for(var Y=0;Y{for(var ke=0,Ju=0,mi=1;mi24&&(ke*=(Ea-24)*10)}return ke-=(le-j)/2,se&&(ke/=1+j*j*1),Ot&&(ke/=1+j*j*1),ke-=(le-j)/2,ke};if(tt)if(Ot){for(var Y=0;Y{for(var H=new Set,W=0,D=He,B=0,K=S.spaceSearches,j=K.length,le=0,oe=()=>{for(let Y=le-1;Y>=0;Y--)k._nextBeginningIndexes[Ve[Y*2+0]]=Ve[Y*2+1]},rt=!1,se=0;se=0&&Mi===k._nextBeginningIndexes[Y];Y--)k._nextBeginningIndexes[Y]=ye,Ve[le*2+0]=Y,Ve[le*2+1]=Mi,le++}}W+=D._score/j,di[se]=D._score/j,D._indexes[0]W){if(R)for(var se=0;seS.replace(new RegExp("\\p{Script=Latin}+","gu"),k=>k.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),M=S=>{S=E(S);for(var k=S.length,R=S.toLowerCase(),H=[],W=0,D=!1,B=0;B=97&&K<=122?K-97:K>=48&&K<=57?26:K<=127?30:31;W|=1<{for(var k=S.length,R=[],H=0,W=!1,D=!1,B=0;B=65&&K<=90,le=j||K>=97&&K<=122||K>=48&&K<=57,oe=j&&!W||!D||!le;W=j,D=le,oe&&(R[H++]=B)}return R},X=S=>{S=E(S);for(var k=S.length,R=G(S),H=[],W=R[0],D=0,B=0;BB?H[B]=W:(W=R[++D],H[B]=W===void 0?k:W);return H},T=new Map,F=new Map,x=[],q=[],Ve=[],pe=[],di=[],Bn=[],Mn=[],Ms=(S,k)=>{var R=S[k];if(R!==void 0)return R;if(typeof k=="function")return k(S);var H=k;Array.isArray(k)||(H=k.split("."));for(var W=H.length,D=-1;S&&++Dtypeof S=="object"&&typeof S._bitflags=="number",Zu=1/0,bt=-1/0,Ta=[];Ta.total=0;var He=null,xo=s(""),H0=S=>{var k=[],R=0,H={},W=D=>{for(var B=0,K=k[B],j=1;j>1]=k[B],j=1+(B<<1)}for(var oe=B-1>>1;B>0&&K._score>1)k[B]=k[oe];k[B]=K};return H.add=D=>{var B=R;k[R++]=D;for(var K=B-1>>1;B>0&&D._score>1)k[B]=k[K];k[B]=D},H.poll=D=>{if(R!==0){var B=k[0];return k[0]=k[--R],W(),B}},H.peek=D=>{if(R!==0)return k[0]},H.replaceTop=D=>{k[0]=D,W()},H},Ls=H0();return{single:t,go:i,prepare:s,cleanup:r}})}(rc)),rc.exports}var nS=iS();const oS=lu(nS);/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2023, Koala Interactive SAS
* For licensing, see https://github.com/koala-interactive/is-emoji-supported/blob/master/LICENSE.md
*/function sS(n){const e=rS();/* istanbul ignore next -- @preserve */if(!e)return!1;const t=25,i=20,o=Math.floor(t/2);e.font=o+"px Arial, Sans-Serif",e.textBaseline="top",e.canvas.width=i*2,e.canvas.height=t,e.clearRect(0,0,i*2,t),e.fillStyle="#FF0000",e.fillText(n,0,22),e.fillStyle="#0000FF",e.fillText(n,i,22);const s=e.getImageData(0,0,i,t).data,r=s.length;let a=0;for(;a=r)return!1;const l=i+a/4%i,c=Math.floor(a/4/i),u=e.getImageData(l,c,1,1).data;/* istanbul ignore next -- @preserve */if(s[a]!==u[0]||s[a+2]!==u[2])return!1;/* istanbul ignore next -- @preserve */return!(e.measureText(n).width>=i)}function rS(){try{return document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{/* istanbul ignore next -- @preserve */return null}}const aS={0:"default",1:"light",2:"medium-light",3:"medium",4:"medium-dark",5:"dark"},lS={"":16,"🫨":15.1,"🫠":14,"😶🌫️":13.1,"🧑💻":12.1,"🥰":11,"🤪":5,"⚕️":4,"🤣":3,"👋🏽":2,"😀":1,"😐":.7,"😂":.6},Lm=24,Db=class zb extends w{static get pluginName(){return"EmojiUtils"}static get isOfficialPlugin(){return!0}isEmojiSupported(e,t,i){return e.version<=t?this.hasZwj(e.emoji)?this.isEmojiZwjSupported(e,i):!0:!1}getEmojiSupportedVersionByOs(){for(const[e,t]of Object.entries(lS))if(zb._isEmojiSupported(e))return t;return 0}hasZwj(e){return e.includes("")}isEmojiZwjSupported(e,t){return this.getNodeWidth(t,e.emoji){const o=aS[i.tone];t.skins[o]=i.emoji}),t}isEmojiCategoryAllowed(e){return e.group!==2}};h(Db,"_isEmojiSupported",sS);let cS=Db;const uS="https://cdn.ckeditor.com/ckeditor5/data/emoji/{version}/en.json",hS=16,Hb=class pr extends w{constructor(e){super(e),h(this,"_items"),h(this,"_url"),h(this,"_repositoryPromise"),e.config.define("emoji",{version:void 0,skinTone:"default",definitionsUrl:void 0,useCustomFont:!1}),this._url=this._getUrl(),this._repositoryPromise=new Promise(t=>{this._repositoryPromiseResolveCallback=t}),this._items=null}static get requires(){return[cS]}static get pluginName(){return"EmojiRepository"}static get isOfficialPlugin(){return!0}async init(){return this._warnAboutCdnUse(),await this._loadAndCacheEmoji(),this._items=this._getItems(),this._items?this._repositoryPromiseResolveCallback(!0):(J("emoji-repository-empty"),this._repositoryPromiseResolveCallback(!1))}getEmojiByQuery(e){return this._items?e.split(/\s/).filter(Boolean).some(t=>t.length>=2)?oS.go(e,this._items,{threshold:.6,keys:["emoticon","annotation",t=>e.split(/\s/).filter(Boolean).flatMap(i=>{var o;return(o=t.tags)==null?void 0:o.filter(s=>s.startsWith(i))}).join()]}).map(t=>t.obj):[]:[]}getEmojiCategories(){const e=this._getItems();if(!e)return[];const{t}=this.editor.locale,i=[{title:t("Smileys & Expressions"),icon:"😄",groupId:0},{title:t("Gestures & People"),icon:"👋",groupId:1},{title:t("Animals & Nature"),icon:"🐻",groupId:3},{title:t("Food & Drinks"),icon:"🍎",groupId:4},{title:t("Travel & Places"),icon:"🚘",groupId:5},{title:t("Activities"),icon:"🏀",groupId:6},{title:t("Objects"),icon:"💡",groupId:7},{title:t("Symbols"),icon:"🔵",groupId:8},{title:t("Flags"),icon:"🏁",groupId:9}],o=q0(e,s=>s.group);return i.map(s=>({...s,items:o[s.groupId]}))}getSkinTones(){const{t:e}=this.editor.locale;return[{id:"default",icon:"👋",tooltip:e("Default skin tone")},{id:"light",icon:"👋🏻",tooltip:e("Light skin tone")},{id:"medium-light",icon:"👋🏼",tooltip:e("Medium Light skin tone")},{id:"medium",icon:"👋🏽",tooltip:e("Medium skin tone")},{id:"medium-dark",icon:"👋🏾",tooltip:e("Medium Dark skin tone")},{id:"dark",icon:"👋🏿",tooltip:e("Dark skin tone")}]}isReady(){return this._repositoryPromise}_getUrl(){const{definitionsUrl:e,version:t}=this.editor.config.get("emoji");if(!e||e==="cdn"){const i=t||hS,o=new URL(uS.replace("{version}",i.toString()));return o.searchParams.set("editorVersion",zg),o}return t&&J("emoji-repository-redundant-version"),new URL(e)}_warnAboutCdnUse(){const e=this.editor,t=e.config.get("emoji"),i=e.config.get("licenseKey"),o=window[Symbol.for("cke distribution")];i!=="GPL"&&o!=="cloud"&&(t&&t.definitionsUrl||J("emoji-repository-cdn-use"))}_getItems(){const e=pr._results[this._url.href];return e&&e.length?e:null}async _loadAndCacheEmoji(){if(pr._results[this._url.href])return;const e=await fetch(this._url,{cache:"force-cache"}).then(t=>t.ok?t.json():[]).catch(()=>[]);pr._results[this._url.href]=this._normalizeEmoji(e)}_normalizeEmoji(e){const t=this.editor,i=t.config.get("emoji.useCustomFont"),o=t.plugins.get("EmojiUtils"),s=e.filter(c=>o.isEmojiCategoryAllowed(c));if(i)return s.map(c=>o.normalizeEmojiSkinTone(c));const r=o.getEmojiSupportedVersionByOs(),a=o.createEmojiWidthTestingContainer();document.body.appendChild(a);const l=s.filter(c=>o.isEmojiSupported(c,r,a)).map(c=>o.normalizeEmojiSkinTone(c));return a.remove(),l}};h(Hb,"_results",{});let $b=Hb;const Wn=":",fl=":__EMOJI_SHOW_ALL:",gl=":__EMOJI_HINT:";class dS extends w{constructor(e){super(e),h(this,"_emojiDropdownLimit"),h(this,"_skinTone"),this.editor.config.define("emoji",{dropdownLimit:6}),this._emojiDropdownLimit=e.config.get("emoji.dropdownLimit"),this._skinTone=e.config.get("emoji.skinTone"),this._setupMentionConfiguration(e)}static get requires(){return[$b,pa,"Mention"]}static get pluginName(){return"EmojiMention"}static get isOfficialPlugin(){return!0}_setupMentionConfiguration(e){const t=e.config.get("mergeFields.prefix"),i=e.config.get("mention.feeds"),o=t?t[0]===Wn:!1;if(i.filter(r=>!r._isEmojiMarker).some(r=>r.marker===Wn)||o){J("emoji-config-marker-already-used",{marker:Wn});return}if(i.some(r=>r._isEmojiMarker))return;const s={_isEmojiMarker:!0,marker:Wn,dropdownLimit:this._emojiDropdownLimit,itemRenderer:this._customItemRendererFactory(this.editor.t),feed:this._queryEmojiCallbackFactory()};this.editor.config.set("mention.feeds",[...i,s])}async init(){const e=this.editor;this.emojiPickerPlugin=e.plugins.has("EmojiPicker")?e.plugins.get("EmojiPicker"):null,this.emojiRepositoryPlugin=e.plugins.get("EmojiRepository"),this._isEmojiRepositoryAvailable=await this.emojiRepositoryPlugin.isReady(),this._isEmojiRepositoryAvailable&&e.once("ready",this._overrideMentionExecuteListener.bind(this))}_customItemRendererFactory(e){return t=>{const i=document.createElement("button");i.classList.add("ck"),i.classList.add("ck-button"),i.classList.add("ck-button_with-text"),i.id=`mention-list-item-id${t.id.slice(0,-1)}`,i.type="button",i.tabIndex=-1;const o=document.createElement("span");return o.classList.add("ck"),o.classList.add("ck-button__label"),i.appendChild(o),t.id===gl?(i.classList.add("ck-list-item-button"),i.classList.add("ck-disabled"),o.textContent=e("Keep on typing to see the emoji.")):t.id===fl?o.textContent=e("Show all emoji..."):o.textContent=`${t.text} ${t.id}`,i}}_overrideMentionExecuteListener(){const e=this.editor;e.commands.get("mention").on("execute",(t,i)=>{const o=i[0];if(o.marker===Wn&&(t.stop(),o.mention.id!==gl))if(o.mention.id===fl){const s=[...o.range.getItems()].filter(a=>a.is("$textProxy")).map(a=>a.data).reduce((a,l)=>a+l,"");e.model.change(a=>{e.model.deleteContent(a.createSelection(o.range))});const r=this.emojiPickerPlugin;r.showUI(s.slice(1)),setTimeout(()=>{r.emojiPickerView.focus()})}else e.execute("insertText",{text:o.mention.text,range:o.range})},{priority:"high"})}_queryEmojiCallbackFactory(){return e=>{if(e.startsWith(" "))return[];if(e.startsWith(Wn))return[];if(!this._isEmojiRepositoryAvailable)return[];const t=this.emojiRepositoryPlugin.getEmojiByQuery(e).map(o=>{let s=o.skins[this._skinTone]||o.skins.default;return this.emojiPickerPlugin&&(s=o.skins[this.emojiPickerPlugin.skinTone]||o.skins.default),{id:`:${o.annotation}:`,text:s}});if(!this.emojiPickerPlugin)return t.slice(0,this._emojiDropdownLimit);const i={id:e.length>1?fl:gl};return[...t.slice(0,this._emojiDropdownLimit-1),i]}}}class mS extends O{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=t.checkChild(i.getFirstPosition(),"$text")}execute(e=""){this.editor.plugins.get("EmojiPicker").showUI(e)}}class fS extends A{constructor(e,{categoryName:t,emojiCategories:i,getEmojiByQuery:o,skinTone:s}){super(e),h(this,"tiles"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"emojiCategories"),h(this,"cachedTiles"),h(this,"_getEmojiByQuery"),this.set("isEmpty",!0),this.set("categoryName",t),this.set("skinTone",s),this.tiles=this.createCollection(),this.cachedTiles=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this._getEmojiByQuery=o,this.emojiCategories=i;const r=this.bindTemplate;this.setTemplate({tag:"div",children:[{tag:"div",attributes:{role:"grid",class:["ck","ck-emoji__grid"]},children:this.tiles}],attributes:{role:"tabpanel",class:["ck","ck-emoji__tiles",r.if("isEmpty","ck-hidden",a=>a)]}}),vo({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.tiles,numberOfColumns:()=>I.window.getComputedStyle(this.element.firstChild).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy(),this.focusTracker.destroy()}focus(){const e=this.tiles.first;e&&e.focus()}filter(e){const{matchingItems:t,allItems:i}=e?this._getItemsByQuery(e.source):this._getItemsByCategory();return this._updateGrid(t),this.set("isEmpty",t.length===0),{resultsCount:t.length,totalItemsCount:i.length}}_getItemsByQuery(e){return{matchingItems:this._getEmojiByQuery(e),allItems:this.emojiCategories.flatMap(t=>t.items)}}_getItemsByCategory(){const e=this.emojiCategories.find(i=>i.title===this.categoryName),{items:t}=e;return{matchingItems:t,allItems:t}}_updateGrid(e){[...this.tiles].forEach(t=>{this.focusTracker.remove(t),this.tiles.remove(t)}),e.map(t=>{const i=t.skins[this.skinTone]||t.skins.default;return this.cachedTiles.get(i)||this._createTile(i,t.annotation)}).forEach(t=>{this.tiles.add(t),this.focusTracker.add(t)})}_createTile(e,t){const i=new P(this.locale);return i.viewUid=e,i.extendTemplate({attributes:{class:["ck-emoji__tile"]}}),i.set({label:e,tooltip:t,withText:!0,ariaLabel:t,ariaLabelledBy:void 0}),i.on("execute",()=>{this.fire("execute",{name:t,emoji:e})}),this.cachedTiles.add(i),i}}class gS extends A{constructor(e,{emojiCategories:t,categoryName:i}){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"focusCycler"),h(this,"buttonViews"),this.buttonViews=this.createCollection(t.map(o=>this._createCategoryButton(o))),this.focusTracker=new ee,this.keystrokes=new te,this.focusCycler=new Ae({focusables:this.buttonViews,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-emoji__categories-list"],role:"tablist"},children:this.buttonViews}),this.on("change:categoryName",(o,s,r,a)=>{const l=this.buttonViews.find(u=>u.tooltip===a);l&&(l.isOn=!1);const c=this.buttonViews.find(u=>u.tooltip===r);c.isOn=!0}),this.set("categoryName",i)}render(){super.render(),this.buttonViews.forEach(e=>{this.focusTracker.add(e)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),this.buttonViews.destroy()}focus(){this.buttonViews.first.focus()}enableCategories(){this.buttonViews.forEach(e=>{e.isEnabled=!0})}disableCategories(){this.buttonViews.forEach(e=>{e.set({class:"",isEnabled:!1,isOn:!1})})}_createCategoryButton(e){const t=new P,i=t.bindTemplate;return t.extendTemplate({attributes:{"aria-selected":i.to("isOn",o=>o.toString()),class:["ck-emoji__category-item"]}}),t.set({ariaLabel:e.title,label:e.icon,role:"tab",tooltip:e.title,withText:!0,ariaLabelledBy:void 0}),t.on("execute",()=>{this.categoryName=e.title}),t.on("change:isEnabled",()=>{t.isEnabled&&t.tooltip===this.categoryName&&(t.isOn=!0)}),t}}class pS extends A{constructor(e,{gridView:t,resultsView:i}){super(e),h(this,"inputView"),h(this,"gridView"),this.gridView=t;const o=e.t;this.inputView=new pT(this.locale,{queryView:{label:o("Find an emoji (min. 2 characters)"),creator:nt},filteredView:this.gridView,infoView:{instance:i}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search"],tabindex:"-1"},children:[this.inputView.queryView]}),this.inputView.delegate("search").to(this)}destroy(){super.destroy(),this.inputView.destroy()}search(e){const t=e?new RegExp(ta(e),"ig"):null,i=this.gridView.filter(t);this.inputView.fire("search",{query:e,...i})}setInputValue(e){e?this.inputView.queryView.fieldView.value=e:this.inputView.queryView.fieldView.reset()}getInputValue(){return this.inputView.queryView.fieldView.element.value}focus(){this.inputView.focus()}}class wS extends A{constructor(e,{skinTone:t,skinTones:i}){super(e),h(this,"dropdownView"),h(this,"_skinTones"),this.set("skinTone",t),this._skinTones=i;const o=e.t,s=o("Select skin tone"),r=Ee(e),a=new _e;for(const{id:l,icon:c,tooltip:u}of this._skinTones){const d={type:"button",model:new et({value:l,label:c,ariaLabel:u,tooltip:u,tooltipPosition:"e",role:"menuitemradio",withText:!0,ariaLabelledBy:void 0})};d.model.bind("isOn").to(this,"skinTone",m=>m===l),a.add(d)}wt(r,a,{ariaLabel:s,role:"menu"}),r.buttonView.set({label:this._getSkinTone().icon,ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),this.dropdownView=r,this.listenTo(r,"execute",l=>{this.skinTone=l.source.value}),r.buttonView.bind("label").to(this,"skinTone",()=>this._getSkinTone().icon),r.buttonView.bind("ariaLabel").to(this,"skinTone",()=>`${this._getSkinTone().tooltip}, ${s}`),this.setTemplate({tag:"div",attributes:{class:["ck","ck-emoji__skin-tone"]},children:[r]})}focus(){this.dropdownView.buttonView.focus()}_getSkinTone(){return this._skinTones.find(e=>e.id===this.skinTone)}}class bS extends A{constructor(e,{emojiCategories:t,getEmojiByQuery:i,skinTone:o,skinTones:s}){super(e),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"focusCycler"),h(this,"searchView"),h(this,"toneView"),h(this,"categoriesView"),h(this,"gridView"),h(this,"infoView");const r=t[0].title;this.gridView=new fS(e,{categoryName:r,emojiCategories:t,getEmojiByQuery:i,skinTone:o}),this.infoView=new ub,this.searchView=new pS(e,{gridView:this.gridView,resultsView:this.infoView}),this.categoriesView=new gS(e,{emojiCategories:t,categoryName:r}),this.toneView=new wS(e,{skinTone:o,skinTones:s}),this.items=this.createCollection([this.searchView,this.toneView,this.categoriesView,this.gridView,this.infoView]),this.focusTracker=new ee,this.keystrokes=new te,this.focusCycler=new Ae({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",children:[{tag:"div",children:[this.searchView,this.toneView],attributes:{class:["ck","ck-emoji__search"]}},this.categoriesView,this.gridView,{tag:"div",children:[this.infoView],attributes:{class:["ck","ck-search__results"]}}],attributes:{tabindex:"-1",class:["ck","ck-emoji","ck-search"]}}),this._setupEventListeners()}render(){super.render(),this.focusTracker.add(this.searchView.element),this.focusTracker.add(this.toneView.element),this.focusTracker.add(this.categoriesView.element),this.focusTracker.add(this.gridView.element),this.focusTracker.add(this.infoView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.searchView.focus()}_setupEventListeners(){const e=this.locale.t;this.searchView.on("search",(t,i)=>{i.query?this.categoriesView.disableCategories():this.categoriesView.enableCategories()}),this.searchView.on("search",(t,i)=>{i.query.length===1?this.infoView.set({primaryText:e("Keep on typing to see the emoji."),secondaryText:e("The query must contain at least two characters."),isVisible:!0}):i.resultsCount?this.infoView.set({isVisible:!1}):this.infoView.set({primaryText:e('No emojis were found matching "%0".',i.query),secondaryText:e("Please try a different phrase or check the spelling."),isVisible:!0})}),this.searchView.on("search",()=>{this.fire("update"),this.gridView.element.scrollTo(0,0)}),this.categoriesView.on("change:categoryName",(t,i,o)=>{this.gridView.categoryName=o,this.searchView.search("")}),this.toneView.on("change:skinTone",(t,i,o)=>{this.gridView.skinTone=o,this.searchView.search(this.searchView.getInputValue())})}}class _S extends A{constructor(e){super(e),h(this,"backButtonView"),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"children"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this.backButtonView=this._createBackButton(),this.children=this.createCollection([this._createHeaderView()]),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form","ck-emoji-picker-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),[...this.children.filter(yo),this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element),Nw(e)&&this._focusCycler.chain(e.focusCycler)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Emoji picker")});return t.children.add(this.backButtonView,0),t}}const Ni="emoji-picker";class vS extends w{static get requires(){return[$b,Ue,du,pa]}static get pluginName(){return"EmojiPicker"}static get isOfficialPlugin(){return!0}async init(){const e=this.editor;if(this.balloonPlugin=e.plugins.get("ContextualBalloon"),this.emojiRepositoryPlugin=e.plugins.get("EmojiRepository"),!await this.emojiRepositoryPlugin.isReady())return;const t=new mS(e);e.commands.add("emoji",t),e.ui.componentFactory.add("emoji",()=>{const i=this._createButton(P,t);return i.set({tooltip:!0}),i}),e.ui.componentFactory.add("menuBar:emoji",()=>this._createButton(ve,t)),this._setupConversion()}destroy(){super.destroy(),this.emojiPickerView&&this.emojiPickerView.destroy()}get skinTone(){return this.emojiPickerView?this.emojiPickerView.gridView.skinTone:this.editor.config.get("emoji.skinTone")}showUI(e=""){this._showFakeVisualSelection(),this.emojiPickerView||(this.emojiPickerView=this._createEmojiPickerView()),e&&this.emojiPickerView.searchView.setInputValue(e),this.emojiPickerView.searchView.search(e),this.emojiPickerFormView||(this.emojiPickerFormView=this._createEmojiPickerFormView()),this.balloonPlugin.hasView(this.emojiPickerFormView)||(this.emojiPickerFormView.backButtonView.isVisible=!!this.balloonPlugin.visibleView,this.balloonPlugin.add({view:this.emojiPickerFormView,position:this._getBalloonPositionData(),balloonClassName:"ck-emoji-picker-balloon"})),this.emojiPickerView.focus()}_createButton(e,t){const i=new e(this.editor.locale),o=this.editor.locale.t;return i.bind("isEnabled").to(t,"isEnabled"),i.set({label:o("Emoji"),icon:yC,isToggleable:!0}),i.on("execute",()=>{this.editor.editing.view.scrollToTheSelection(),this.showUI()}),i}_createEmojiPickerView(){const e=new bS(this.editor.locale,{emojiCategories:this.emojiRepositoryPlugin.getEmojiCategories(),skinTone:this.editor.config.get("emoji.skinTone"),skinTones:this.emojiRepositoryPlugin.getSkinTones(),getEmojiByQuery:t=>this.emojiRepositoryPlugin.getEmojiByQuery(t)});return this.listenTo(e.gridView,"execute",(t,i)=>{const o=this.editor,s=i.emoji;this._hideUI(),o.execute("insertText",{text:s})}),e}_createEmojiPickerFormView(){const e=new _S(this.editor.locale);return e.children.add(this.emojiPickerView),this.listenTo(this.emojiPickerView,"update",()=>{this.balloonPlugin.visibleView===e&&this.balloonPlugin.updatePosition()}),this.listenTo(e,"cancel",()=>{this._hideUI()}),e.keystrokes.set("Esc",(t,i)=>{this._hideUI(),i()}),$t({emitter:e,contextElements:[this.balloonPlugin.view.element],callback:()=>{this._hideUI(!1)},activator:()=>this.balloonPlugin.visibleView===e}),e}_hideUI(e=!0){this.balloonPlugin.remove(this.emojiPickerFormView),this.emojiPickerView.searchView.setInputValue(""),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection()}_setupConversion(){const e=this.editor;e.conversion.for("editingDowncast").markerToHighlight({model:Ni,view:{classes:["ck-fake-emoji-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Ni,view:(t,{writer:i})=>{if(!t.markerRange.isCollapsed)return null;const o=i.createUIElement("span");return i.addClass(["ck-fake-emoji-selection","ck-fake-emoji-selection_collapsed"],o),o}})}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;return{target:()=>e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(Ni))t.updateMarker(Ni,{range:i});else if(i.start.isAtEnd){const o=i.start.getLastMatchingPosition(({item:s})=>!e.schema.isContent(s),{boundaries:i});t.addMarker(Ni,{usingOperation:!1,affectsData:!1,range:t.createRange(o,i.end)})}else t.addMarker(Ni,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Ni)&&e.change(t=>{t.removeMarker(Ni)})}}class yS extends w{static get requires(){return[dS,vS]}static get pluginName(){return"Emoji"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class kS extends O{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!Fm(e.schema,i))do if(i=i.parent,!i)return;while(!Fm(e.schema,i));e.change(o=>{o.setSelection(i,"in")})}}function Fm(n,e){return n.isLimit(e)&&(n.checkChild(e,"$text")||n.checkChild(e,"paragraph"))}const CS=na("Ctrl+A");class AS extends w{static get pluginName(){return"SelectAllEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.editing.view.document;e.commands.add("selectAll",new kS(e)),this.listenTo(i,"keydown",(o,s)=>{yn(s)===CS&&(e.execute("selectAll"),s.preventDefault())}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class xS extends w{static get pluginName(){return"SelectAllUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:selectAll",()=>this._createButton(ve))}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("selectAll"),s=new e(t.locale),r=i.t;return s.set({label:r("Select all"),icon:aA,keystroke:"Ctrl+A"}),s.bind("isEnabled").to(o,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("selectAll"),t.editing.view.focus()}),s}}class Wb extends w{static get requires(){return[AS,xS]}static get pluginName(){return"SelectAll"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class jb extends O{constructor(e){super(e),h(this,"_stack",[]),h(this,"_createdBatches",new WeakSet),this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",(t,i)=>{i[1]={...i[1]};const o=i[1];o.batchType||(o.batchType={isUndoable:!1})},{priority:"high"}),this.listenTo(e.data,"set",(t,i)=>{i[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,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const o=this.editor.model,s=o.document,r=[],a=e.map(c=>c.getTransformedByOperations(i)),l=a.flat();for(const c of a){const u=c.filter(d=>d.root!=s.graveyard).filter(d=>!ES(d,l));u.length&&(TS(u),r.push(u[0]))}r.length&&o.change(c=>{c.setSelection(r,{backward:t})})}_undo(e,t){const i=this.editor.model,o=i.document;this._createdBatches.add(t);const s=e.operations.slice().filter(r=>r.isDocumentOperation);s.reverse();for(const r of s){const a=r.baseVersion+1,l=Array.from(o.history.getOperations(a)),c=A2([r.getReversed()],l,{useRelations:!0,document:this.editor.model.document,forceWeakRemove:!0}).operationsA;for(let u of c){const d=u.affectedSelectable;d&&!i.canEditAt(d)&&(u=new De(u.baseVersion)),t.addOperation(u),i.applyOperation(u),o.history.setOperationAsUndone(r,u)}}}}function TS(n){n.sort((e,t)=>e.start.isBefore(t.start)?-1:1);for(let e=1;et!==n&&t.containsRange(n,!0))}class SS extends jb{execute(e=null){const t=e?this._stack.findIndex(s=>s.batch==e):this._stack.length-1,i=this._stack.splice(t,1)[0],o=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(o,()=>{this._undo(i.batch,o);const s=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,s)}),this.fire("revert",i.batch,o),this.refresh()}}class PS extends jb{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()}}class IS extends w{constructor(){super(...arguments),h(this,"_undoCommand"),h(this,"_redoCommand"),h(this,"_batchRegistry",new WeakSet)}static get pluginName(){return"UndoEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;this._undoCommand=new SS(e),this._redoCommand=new PS(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",(i,o)=>{const s=o[0];if(!s.isDocumentOperation)return;const r=s.batch,a=this._redoCommand.createdBatches.has(r),l=this._undoCommand.createdBatches.has(r);this._batchRegistry.has(r)||(this._batchRegistry.add(r),r.isUndoable&&(a?this._undoCommand.addBatch(r):l||(this._undoCommand.addBatch(r),this._redoCommand.clearStack())))},{priority:"highest"}),this.listenTo(this._undoCommand,"revert",(i,o,s)=>{this._redoCommand.addBatch(s)}),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Undo"),keystroke:"CTRL+Z"},{label:t("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}class VS extends w{static get pluginName(){return"UndoUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,o=t.uiLanguageDirection=="ltr"?yd:_d,s=t.uiLanguageDirection=="ltr"?_d:yd;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",o),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",s)}_addButtonsToFactory(e,t,i,o){const s=this.editor;s.ui.componentFactory.add(e,()=>{const r=this._createButton(P,e,t,i,o);return r.set({tooltip:!0}),r}),s.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(ve,e,t,i,o))}_createButton(e,t,i,o,s){const r=this.editor,a=r.locale,l=r.commands.get(t),c=new e(a);return c.set({label:i,icon:s,keystroke:o}),c.bind("isEnabled").to(l,"isEnabled"),this.listenTo(c,"execute",()=>{r.execute(t),r.editing.view.focus()}),c}}class Ub extends w{static get requires(){return[IS,VS]}static get pluginName(){return"Undo"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class RS extends A{constructor(e){super(e),h(this,"children"),h(this,"_findInputView"),h(this,"_replaceInputView"),h(this,"_findButtonView"),h(this,"_findPrevButtonView"),h(this,"_findNextButtonView"),h(this,"_advancedOptionsCollapsibleView"),h(this,"_matchCaseSwitchView"),h(this,"_wholeWordsOnlySwitchView"),h(this,"_replaceButtonView"),h(this,"_replaceAllButtonView"),h(this,"_inputsDivView"),h(this,"_actionButtonsDivView"),h(this,"_focusTracker"),h(this,"_keystrokes"),h(this,"_focusables"),h(this,"focusCycler");const t=e.t;this.children=this.createCollection(),this.set("matchCount",0),this.set("highlightOffset",0),this.set("isDirty",!1),this.set("_areCommandsEnabled",{}),this.set("_resultsCounterText",""),this.set("_matchCase",!1),this.set("_wholeWordsOnly",!1),this.bind("_searchResultsFound").to(this,"matchCount",this,"isDirty",(i,o)=>i>0&&!o),this._findInputView=this._createInputField(t("Find in text…")),this._findPrevButtonView=this._createButton({label:t("Previous result"),class:"ck-button-prev",icon:li,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:t("Next result"),class:"ck-button-next",icon:li,keystroke:"F3",tooltip:!0}),this._replaceInputView=this._createInputField(t("Replace with…"),"ck-labeled-field-replace"),this._inputsDivView=this._createInputsDiv(),this._matchCaseSwitchView=this._createMatchCaseSwitch(),this._wholeWordsOnlySwitchView=this._createWholeWordsOnlySwitch(),this._advancedOptionsCollapsibleView=this._createAdvancedOptionsCollapsible(),this._replaceAllButtonView=this._createButton({label:t("Replace all"),class:"ck-button-replaceall",withText:!0}),this._replaceButtonView=this._createButton({label:t("Replace"),class:"ck-button-replace",withText:!0}),this._findButtonView=this._createButton({label:t("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._actionButtonsDivView=this._createActionButtonsDiv(),this._focusTracker=new ee,this._keystrokes=new te,this._focusables=new Ie,this.focusCycler=new Ae({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.addMany([this._inputsDivView,this._advancedOptionsCollapsibleView,this._actionButtonsDivView]),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(e){e===-1?this.focusCycler.focusLast():this.focusCycler.focusFirst()}reset(){this._findInputView.errorText=null,this.isDirty=!0}get _textToFind(){return this._findInputView.fieldView.element.value}get _textToReplace(){return this._replaceInputView.fieldView.element.value}_createInputsDiv(){const e=this.locale,t=e.t,i=new A(e);return this._findInputView.fieldView.on("input",()=>{this.isDirty=!0}),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findPrevious:o})=>o),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findNext:o})=>o),this._injectFindResultsCounter(),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:o},s)=>o&&s),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",(o,s)=>o||!s?"":t("Tip: Find some text first in order to replace it.")),i.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__inputs"]},children:[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView]}),i}_onFindButtonExecute(){if(!this._textToFind){const e=this.t;this._findInputView.errorText=e("Text to find must not be empty.");return}this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly})}_injectFindResultsCounter(){const e=this.locale,t=e.t,i=this.bindTemplate,o=new A(this.locale);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",(r,a)=>t("%0 of %1",[r,a])),o.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",i.if("isDirty","ck-hidden")]},children:[{text:i.to("_resultsCounterText")}]});const s=()=>{const r=this._findInputView.fieldView.element;if(!r||!Gt(r))return;const a=new z(o.element).width,l=e.uiLanguageDirection==="ltr"?"paddingRight":"paddingLeft";a?r.style[l]=`calc( 2 * var(--ck-spacing-standard) + ${a}px )`:r.style[l]=""};this.on("change:_resultsCounterText",s,{priority:"low"}),this.on("change:isDirty",s,{priority:"low"}),this._findInputView.template.children[0].children.push(o)}_createAdvancedOptionsCollapsible(){const e=this.locale.t,t=new mu(this.locale,[this._matchCaseSwitchView,this._wholeWordsOnlySwitchView]);return t.set({label:e("Advanced options"),isCollapsed:!0}),t}_createActionButtonsDiv(){const e=new A(this.locale);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:t},i)=>t&&i),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replaceAll:t},i)=>t&&i),this._replaceButtonView.on("execute",()=>{this.fire("replace",{searchText:this._textToFind,replaceText:this._textToReplace})}),this._replaceAllButtonView.on("execute",()=>{this.fire("replaceAll",{searchText:this._textToFind,replaceText:this._textToReplace}),this.focus()}),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),e.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__actions"]},children:[this._replaceAllButtonView,this._replaceButtonView,this._findButtonView]}),e}_createMatchCaseSwitch(){const e=this.locale.t,t=new Ji(this.locale);return t.set({label:e("Match case"),withText:!0}),t.bind("isOn").to(this,"_matchCase"),t.on("execute",()=>{this._matchCase=!this._matchCase,this.isDirty=!0}),t}_createWholeWordsOnlySwitch(){const e=this.locale.t,t=new Ji(this.locale);return t.set({label:e("Whole words only"),withText:!0}),t.bind("isOn").to(this,"_wholeWordsOnly"),t.on("execute",()=>{this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0}),t}_initFocusCycling(){[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._advancedOptionsCollapsibleView.buttonView,this._matchCaseSwitchView,this._wholeWordsOnlySwitchView,this._replaceAllButtonView,this._replaceButtonView,this._findButtonView].forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}_initKeystrokeHandling(){const e=i=>i.stopPropagation(),t=i=>{i.stopPropagation(),i.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",i=>{t(i),this._findNextButtonView.fire("execute")}),this._keystrokes.set("shift+f3",i=>{t(i),this._findPrevButtonView.fire("execute")}),this._keystrokes.set("enter",i=>{const o=i.target;o===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),t(i)):o===this._replaceInputView.fieldView.element&&!this.isDirty&&(this._replaceButtonView.fire("execute"),t(i))}),this._keystrokes.set("shift+enter",i=>{i.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),t(i))}),this._keystrokes.set("arrowright",e),this._keystrokes.set("arrowleft",e),this._keystrokes.set("arrowup",e),this._keystrokes.set("arrowdown",e)}_createButton(e){const t=new P(this.locale);return t.set(e),t}_createInputField(e,t){const i=new Te(this.locale,nt);return i.label=e,i.class=t,i}}class OS extends w{constructor(e){super(e),h(this,"formView"),e.config.define("findAndReplace.uiType","dialog"),this.formView=null}static get requires(){return[du]}static get pluginName(){return"FindAndReplaceUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.config.get("findAndReplace.uiType")==="dropdown",i=e.commands.get("find"),o=this.editor.t;e.ui.componentFactory.add("findAndReplace",()=>{let s;return t?(s=this._createDropdown(),s.bind("isEnabled").to(i)):s=this._createDialogButtonForToolbar(),e.keystrokes.set("Ctrl+F",(r,a)=>{if(i.isEnabled){if(s instanceof Jw){const l=s.buttonView;l.isOn||l.fire("execute")}else s.isOn?e.plugins.get("Dialog").view.focus():s.fire("execute");a()}}),s}),t||e.ui.componentFactory.add("menuBar:findAndReplace",()=>this._createDialogButtonForMenuBar()),e.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Find in the document"),keystroke:"CTRL+F"}]})}_createDropdown(){const e=this.editor,t=e.locale.t,i=Ee(e.locale);return i.once("change:isOpen",()=>{this.formView=this._createFormView(),this.formView.children.add(new Jt(e.locale,{label:t("Find and replace")}),0),i.panelView.children.add(this.formView)}),i.on("change:isOpen",(o,s,r)=>{r?this._setupFormView():this.fire("searchReseted")},{priority:"low"}),i.buttonView.set({icon:fd,label:t("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),i}_createDialogButtonForToolbar(){const e=this.editor,t=this._createButton(P),i=e.plugins.get("Dialog");return t.set({tooltip:!0}),t.bind("isOn").to(i,"id",o=>o==="findAndReplace"),t.on("execute",()=>{t.isOn?i.hide():this._showDialog()}),t}_createDialogButtonForMenuBar(){const e=this._createButton(ve),t=this.editor.plugins.get("Dialog"),i=this.editor.plugins.get("Dialog");return e.set({role:"menuitemcheckbox",isToggleable:!0}),e.bind("isOn").to(i,"id",o=>o==="findAndReplace"),e.on("execute",()=>{if(t.id==="findAndReplace"){t.hide();return}this._showDialog()}),e}_createButton(e){const t=this.editor,i=t.commands.get("find"),o=new e(t.locale),s=t.locale.t;return o.bind("isEnabled").to(i),o.set({icon:fd,label:s("Find and replace"),keystroke:"CTRL+F"}),o}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.formView||(this.formView=this._createFormView()),t.show({id:"findAndReplace",title:i("Find and replace"),content:this.formView,position:vt.EDITOR_TOP_SIDE,onShow:()=>{this._setupFormView()},onHide:()=>{this.fire("searchReseted")}})}_createFormView(){const e=this.editor,t=new(ho(RS))(e.locale),i=e.commands,o=this.editor.plugins.get("FindAndReplaceEditing").state;t.bind("highlightOffset").to(o,"highlightedOffset"),t.listenTo(o.results,"change",()=>{t.matchCount=o.results.length});const s=i.get("findNext"),r=i.get("findPrevious"),a=i.get("replace"),l=i.get("replaceAll");return t.bind("_areCommandsEnabled").to(s,"isEnabled",r,"isEnabled",a,"isEnabled",l,"isEnabled",(c,u,d,m)=>({findNext:c,findPrevious:u,replace:d,replaceAll:m})),t.delegate("findNext","findPrevious","replace","replaceAll").to(this),t.on("change:isDirty",(c,u,d)=>{d&&this.fire("searchReseted")}),t}_setupFormView(){this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()}}class BS extends O{constructor(e,t){super(e),h(this,"_state"),this.isEnabled=!0,this.affectsData=!1,this._state=t}execute(e,{matchCase:t,wholeWords:i}={}){const{editor:o}=this,{model:s}=o,r=o.plugins.get("FindAndReplaceUtils");let a,l="";typeof e=="string"?a=(...d)=>({results:r.findByTextCallback(e,{matchCase:t,wholeWords:i})(...d),searchText:e}):a=e;const c=a;a=(...d)=>{const m=c(...d);return m&&"searchText"in m&&(l=m.searchText),m};const u=s.document.getRootNames().reduce((d,m)=>r.updateFindResultFromRange(s.createRangeIn(s.document.getRoot(m)),s,a,d),null);return this._state.clear(s),this._state.results.addMany(u),this._state.highlightedResult=u.get(0),this._state.searchText=l,a&&(this._state.lastSearchCallback=a),this._state.matchCase=!!t,this._state.matchWholeWords=!!i,{results:u,findCallback:a}}}class MS extends ue(){constructor(e){super(),this.set("results",new _e),this.set("highlightedResult",null),this.set("highlightedOffset",0),this.set("searchText",""),this.set("replaceText",""),this.set("lastSearchCallback",null),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",(t,{removed:i,index:o})=>{if(Array.from(i).length){let s=!1;if(e.change(r=>{for(const a of i)this.highlightedResult===a&&(s=!0),e.markers.has(a.marker.name)&&r.removeMarker(a.marker)}),s){const r=o>=this.results.length?0:o;this.highlightedResult=this.results.get(r)}}}),this.on("change:highlightedResult",()=>{this.refreshHighlightOffset(e)})}clear(e){this.searchText="",e.change(t=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],o=e.markers.get(`findResultHighlighted:${i}`);o&&t.removeMarker(o)}[...this.results].forEach(({marker:i})=>{t.removeMarker(i)})}),this.results.clear()}refreshHighlightOffset(e){const{highlightedResult:t,results:i}=this;t?this.highlightedOffset=qb(e,[...i]).indexOf(t)+1:this.highlightedOffset=0}}function qb(n,e){const t={before:-1,same:0,after:1,different:1};return n.document.getRootNames().flatMap(i=>e.filter(o=>o.marker.getStart().root.rootName===i).sort((o,s)=>t[o.marker.getStart().compareWith(s.marker.getStart())]))}class Gb extends O{constructor(e,t){super(e),h(this,"_state"),this.isEnabled=!0,this._state=t,this._isEnabledBasedOnSelection=!1}_replace(e,t){const{model:i}=this.editor,o=t.marker.getRange();i.canEditAt(o)&&i.change(s=>{if(o.root.rootName==="$graveyard"){this._state.results.remove(t);return}let r={};for(const a of o.getItems())if(a.is("$text")||a.is("$textProxy")){r=a.getAttributes();break}i.insertContent(s.createText(e,r),o),this._state.results.has(t)&&this._state.results.remove(t)})}}class LS extends Gb{execute(e,t){const i=Math.max(this._state.highlightedOffset-1,0);if(this._replace(e,t),this._state.results.length){const o=qb(this.editor.model,[...this._state.results]);this._state.highlightedResult=o[i%o.length]}}}class FS extends Gb{execute(e,t){const{editor:i}=this,{model:o}=i,s=i.plugins.get("FindAndReplaceUtils"),r=t instanceof _e?t:o.document.getRootNames().reduce((a,l)=>s.updateFindResultFromRange(o.createRangeIn(o.document.getRoot(l)),o,s.findByTextCallback(t,this._state),a),null);r.length&&o.change(()=>{[...r].forEach(a=>{this._replace(e,a)})})}}class Kb extends O{constructor(e,t){super(e),h(this,"_state"),this.affectsData=!1,this._state=t,this.isEnabled=!1,this.listenTo(this._state.results,"change",()=>{this.isEnabled=this._state.results.length>1})}refresh(){this.isEnabled=this._state.results.length>1}execute(){const e=this._state.results,t=e.getIndex(this._state.highlightedResult),i=t+1>=e.length?0:t+1;this._state.highlightedResult=this._state.results.get(i)}}class NS extends Kb{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),t=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(t)}}class DS extends w{static get pluginName(){return"FindAndReplaceUtils"}static get isOfficialPlugin(){return!0}updateFindResultFromRange(e,t,i,o){const s=o||new _e,r=a=>s.find(l=>{const{marker:c}=l,u=c.getRange(),d=a.getRange();return u.isEqual(d)});return t.change(a=>{[...e].forEach(({type:l,item:c})=>{if(l==="elementStart"&&t.schema.checkChild(c,"$text")){let u=i({item:c,text:this.rangeToText(t.createRangeIn(c))});if(!u)return;"results"in u&&(u=u.results),u.forEach(d=>{const m=`findResult:${ze()}`,f=a.addMarker(m,{usingOperation:!1,affectsData:!1,range:a.createRange(a.createPositionAt(c,d.start),a.createPositionAt(c,d.end))}),g=zS(s,f);r(f)||s.add({id:m,label:d.label,marker:f},g)})}})}),s}rangeToText(e){return Array.from(e.getItems({shallow:!0})).reduce((t,i)=>i.is("$text")||i.is("$textProxy")?t+i.data:`${t}
`,"")}findByTextCallback(e,t){let i="gu";t.matchCase||(i+="i");let o=`(${ta(e)})`;if(t.wholeWords){const a="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+a).test(e)||(o=`(^|${a}|_)${o}`),new RegExp(a+"$").test(e)||(o=`${o}(?=_|${a}|$)`)}const s=new RegExp(o,i);function r({text:a}){return[...a.matchAll(s)].map(HS)}return r}}function zS(n,e){const t=n.find(({marker:i})=>e.getStart().isBefore(i.getStart()));return t?n.getIndex(t):n.length}function HS(n){const e=n.length-1;let t=n.index;return n.length===3&&(t+=n[1].length),{label:n[e],start:t,end:t+n[e].length}}const $S="ck-find-result_selected";class WS extends w{constructor(){super(...arguments),h(this,"state"),h(this,"_onDocumentChange",()=>{const e=new Set,t=new Set,i=this.editor.model,{results:o}=this.state,s=i.document.differ.getChanges(),r=i.document.differ.getChangedMarkers();s.forEach(c=>{c.position&&(c.name==="$text"||c.position.nodeAfter&&i.schema.isInline(c.position.nodeAfter)?(e.add(c.position.parent),[...i.markers.getMarkersAtPosition(c.position)].forEach(u=>{t.add(u.name)})):c.type==="insert"&&c.position.nodeAfter&&e.add(c.position.nodeAfter))}),r.forEach(({name:c,data:{newRange:u}})=>{u&&u.start.root.rootName==="$graveyard"&&t.add(c)}),e.forEach(c=>{[...i.markers.getMarkersIntersectingRange(i.createRangeIn(c))].forEach(u=>t.add(u.name))}),t.forEach(c=>{o.has(c)&&(o.get(c)===this.state.highlightedResult&&(this.state.highlightedResult=null),o.remove(c))});const a=[],l=this.editor.plugins.get("FindAndReplaceUtils");e.forEach(c=>{const u=l.updateFindResultFromRange(i.createRangeOn(c),i,this.state.lastSearchCallback,o);a.push(...u)}),r.forEach(c=>{if(c.data.newRange){const u=l.updateFindResultFromRange(c.data.newRange,i,this.state.lastSearchCallback,o);a.push(...u)}}),!this.state.highlightedResult&&a.length?this.state.highlightedResult=a[0]:this.state.refreshHighlightOffset(i)})}static get requires(){return[DS]}static get pluginName(){return"FindAndReplaceEditing"}static get isOfficialPlugin(){return!0}init(){this.state=new MS(this.editor.model),this.set("_isSearchActive",!1),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",(t,i,o,s)=>{const{model:r}=this.editor;r.change(a=>{if(s){const l=s.marker.name.split(":")[1],c=r.markers.get(`findResultHighlighted:${l}`);c&&a.removeMarker(c)}if(o){const l=o.marker.name.split(":")[1];a.addMarker(`findResultHighlighted:${l}`,{usingOperation:!1,affectsData:!1,range:o.marker.getRange()})}})});/* istanbul ignore next -- @preserve */const e=St(((t,i,o)=>{if(o){const s=this.editor.editing.view.domConverter,r=this.editor.editing.mapper.toViewRange(o.marker.getRange());np({target:s.viewRangeToDom(r),viewportOffset:40})}}).bind(this),32);this.listenTo(this.state,"change:highlightedResult",e,{priority:"low"}),this.listenTo(this.editor,"destroy",e.cancel),this.on("change:_isSearchActive",(t,i,o)=>{o?this.listenTo(this.editor.model.document,"change:data",this._onDocumentChange):this.stopListening(this.editor.model.document,"change:data",this._onDocumentChange)})}find(e,t){return this._isSearchActive=!0,this.editor.execute("find",e,t),this.state.results}stop(){this.state.clear(this.editor.model),this._isSearchActive=!1}_defineCommands(){this.editor.commands.add("find",new BS(this.editor,this.state)),this.editor.commands.add("findNext",new Kb(this.editor,this.state)),this.editor.commands.add("findPrevious",new NS(this.editor,this.state)),this.editor.commands.add("replace",new LS(this.editor,this.state)),this.editor.commands.add("replaceAll",new FS(this.editor,this.state))}_defineConverters(){const{editor:e}=this;e.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:t})=>{const[,i]=t.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":i}}}}),e.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:t})=>{const[,i]=t.split(":");return{name:"span",classes:[$S],attributes:{"data-find-result":i}}}})}}class jS extends w{static get requires(){return[WS,OS]}static get pluginName(){return"FindAndReplace"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get("FindAndReplaceUI"),t=this.editor.plugins.get("FindAndReplaceEditing"),i=t.state;e.on("findNext",(o,s)=>{s?(i.searchText=s.searchText,t.find(s.searchText,s)):this.editor.execute("findNext")}),e.on("findPrevious",(o,s)=>{s&&i.searchText!==s.searchText?t.find(s.searchText):this.editor.execute("findPrevious")}),e.on("replace",(o,s)=>{i.searchText!==s.searchText&&t.find(s.searchText);const r=i.highlightedResult;r&&this.editor.execute("replace",s.replaceText,r)}),e.on("replaceAll",(o,s)=>{i.searchText!==s.searchText&&t.find(s.searchText),this.editor.execute("replaceAll",s.replaceText,i.results)}),e.on("searchReseted",()=>{i.clear(this.editor.model),t.stop()})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ba extends O{constructor(e,t){super(e),h(this,"attributeKey"),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,o=e.value,s=e.batch,r=a=>{if(i.isCollapsed)o?a.setSelectionAttribute(this.attributeKey,o):a.removeSelectionAttribute(this.attributeKey);else{const l=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const c of l)o?a.setAttribute(this.attributeKey,o,c):a.removeAttribute(this.attributeKey,c)}};s?t.enqueueChange(s,a=>{r(a)}):t.change(a=>{r(a)})}}const lt="fontSize",ct="fontFamily",ii="fontColor",vi="fontBackgroundColor";function Zb(n,e){const t={model:{key:n,values:[]},view:{},upcastAlso:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]=i.view,i.upcastAlso&&(t.upcastAlso[i.model]=i.upcastAlso);return t}function Jb(n){return e=>qS(e.getStyle(n))}function Qb(n){return(e,{writer:t})=>t.createAttributeElement("span",{style:`${n}:${e}`},{priority:7})}function US({dropdownView:n,colors:e,columns:t,removeButtonLabel:i,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a}){const l=n.locale,c=new wu(l,{colors:e,columns:t,removeButtonLabel:i,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a});return n.colorSelectorView=c,n.panelView.children.add(c),c}function qS(n){return n.replace(/\s/g,"")}class GS extends ba{constructor(e){super(e,ct)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Yb(n){return n.map(KS).filter(e=>e!==void 0)}function KS(n){if(typeof n=="object")return n;if(n==="default")return{title:"Default",model:void 0};if(typeof n=="string")return ZS(n)}function ZS(n){const e=n.replace(/"|'/g,"").split(","),t=e[0],i=e.map(JS).join(", ");return{title:t,model:i,view:{name:"span",styles:{"font-family":i},priority:7}}}function JS(n){return n=n.trim(),n.indexOf(" ")>0&&(n=`'${n}'`),n}class QS extends w{static get pluginName(){return"FontFamilyEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(ct,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:ct}),e.model.schema.setAttributeProperties(ct,{isFormatting:!0,copyOnEnter:!0});const t=Yb(e.config.get("fontFamily.options")).filter(o=>o.model),i=Zb(ct,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(ct,new GS(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:ct,view:(t,{writer:i})=>i.createAttributeElement("span",{style:"font-family:"+t},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:ct,value:t=>t.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:ct,value:e=>e.getAttribute("face")}})}}class YS extends w{static get pluginName(){return"FontFamilyUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),o=e.commands.get(ct),s=t("Font Family"),r=XS(i,o);e.ui.componentFactory.add(ct,a=>{const l=Ee(a);return wt(l,r,{role:"menu",ariaLabel:s}),l.buttonView.set({label:s,icon:gd,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),l.bind("isEnabled").to(o),this.listenTo(l,"execute",c=>{e.execute(c.source.commandName,{value:c.source.commandParam}),e.editing.view.focus()}),l}),e.ui.componentFactory.add(`menuBar:${ct}`,a=>{const l=new Tt(a);l.buttonView.set({label:s,icon:gd}),l.bind("isEnabled").to(o);const c=new Si(a);for(const u of r){const d=new Oi(a,l),m=new ve(a);m.set({role:"menuitemradio",isToggleable:!0}),m.bind(...Object.keys(u.model)).to(u.model),m.delegate("execute").to(l),m.on("execute",()=>{e.execute(u.model.commandName,{value:u.model.commandParam}),e.editing.view.focus()}),d.children.add(m),c.items.add(d)}return l.panelView.children.add(c),l})}_getLocalizedOptions(){const e=this.editor,t=e.t;return Yb(e.config.get(ct).options).map(i=>(i.title==="Default"&&(i.title=t("Default")),i))}}function XS(n,e){const t=new _e;for(const i of n){const o={type:"button",model:new et({commandName:ct,commandParam:i.model,label:i.title,role:"menuitemradio",withText:!0})};o.model.bind("isOn").to(e,"value",s=>s===i.model?!0:!s||!i.model?!1:s.split(",")[0].replace(/'/g,"").toLowerCase()===i.model.toLowerCase()),i.view&&typeof i.view!="string"&&i.view.styles&&o.model.set("labelStyle",`font-family: ${i.view.styles["font-family"]}`),t.add(o)}return t}class eP extends w{static get requires(){return[QS,YS]}static get pluginName(){return"FontFamily"}static get isOfficialPlugin(){return!0}}class tP extends ba{constructor(e){super(e,lt)}}function Eu(n){return n.map(e=>iP(e)).filter(e=>e!==void 0)}const Nm={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function iP(n){if(typeof n=="number"&&(n=String(n)),typeof n=="object"&&sP(n))return ac(n);const e=oP(n);if(e)return ac(e);if(n==="default")return{model:void 0,title:"Default"};if(!rP(n))return nP(n)}function nP(n){return typeof n=="string"&&(n={title:n,model:`${parseFloat(n)}px`}),n.view={name:"span",styles:{"font-size":n.model}},ac(n)}function ac(n){return n.view&&typeof n.view!="string"&&!n.view.priority&&(n.view.priority=7),n}function oP(n){return typeof n=="string"?Nm[n]:Nm[n.model]}function sP(n){return n.title&&n.model&&n.view}function rP(n){let e;if(typeof n=="object")if(n.model)e=parseFloat(n.model);else throw new b("font-size-invalid-definition",null,n);else e=parseFloat(n);return isNaN(e)}const Dm=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class aP extends w{static get pluginName(){return"FontSizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(lt,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:lt}),e.model.schema.setAttributeProperties(lt,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=Eu(this.editor.config.get("fontSize.options")).filter(s=>s.model),o=Zb(lt,i);t?(this._prepareAnyValueConverters(o),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(o),e.commands.add(lt,new tP(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter(o=>!ha(String(o))&&!iw(String(o)));if(i.length)throw new b("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:lt,view:(o,{writer:s})=>{if(o)return s.createAttributeElement("span",{style:"font-size:"+o},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:lt,value:o=>o.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:lt,value:e=>{const t=e.getAttribute("size"),i=t[0]==="-"||t[0]==="+";let o=parseInt(t,10);i&&(o=3+o);const s=Dm.length-1,r=Math.min(Math.max(o,0),s);return Dm[r]}}})}}class lP extends w{static get pluginName(){return"FontSizeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),o=e.commands.get(lt),s=t("Font Size"),r=cP(i,o);e.ui.componentFactory.add(lt,a=>{const l=Ee(a);return wt(l,r,{role:"menu",ariaLabel:s}),l.buttonView.set({label:s,icon:pd,tooltip:!0}),l.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),l.bind("isEnabled").to(o),this.listenTo(l,"execute",c=>{e.execute(c.source.commandName,{value:c.source.commandParam}),e.editing.view.focus()}),l}),e.ui.componentFactory.add(`menuBar:${lt}`,a=>{const l=new Tt(a);l.buttonView.set({label:s,icon:pd}),l.bind("isEnabled").to(o);const c=new Si(a);for(const u of r){const d=new Oi(a,l),m=new ve(a);m.set({role:"menuitemradio",isToggleable:!0}),m.bind(...Object.keys(u.model)).to(u.model),m.delegate("execute").to(l),m.on("execute",()=>{e.execute(u.model.commandName,{value:u.model.commandParam}),e.editing.view.focus()}),d.children.add(m),c.items.add(d)}return l.panelView.children.add(c),l})}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return Eu(e.config.get(lt).options).map(o=>{const s=i[o.title];return s&&s!=o.title&&(o=Object.assign({},o,{title:s})),o})}}function cP(n,e){const t=new _e;for(const i of n){const o={type:"button",model:new et({commandName:lt,commandParam:i.model,label:i.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};i.view&&typeof i.view!="string"&&(i.view.styles&&o.model.set("labelStyle",`font-size:${i.view.styles["font-size"]}`),i.view.classes&&o.model.set("class",`${o.model.class} ${i.view.classes}`)),o.model.bind("isOn").to(e,"value",s=>s===i.model),t.add(o)}return t}class uP extends w{static get requires(){return[aP,lP]}static get pluginName(){return"FontSize"}static get isOfficialPlugin(){return!0}normalizeSizeOptions(e){return Eu(e)}}class hP extends ba{constructor(e){super(e,ii)}}class dP extends w{static get pluginName(){return"FontColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(ii,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:ii,value:Jb("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:ii,value:t=>t.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:ii,view:Qb("color")}),e.commands.add(ii,new hP(e)),e.model.schema.extend("$text",{allowAttributes:ii}),e.model.schema.setAttributeProperties(ii,{isFormatting:!0,copyOnEnter:!0})}}class Xb extends w{constructor(e,{commandName:t,componentName:i,icon:o,dropdownLabel:s}){super(e),h(this,"commandName"),h(this,"componentName"),h(this,"icon"),h(this,"dropdownLabel"),h(this,"columns"),this.commandName=t,this.componentName=i,this.icon=o,this.dropdownLabel=s,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,t=e.locale,i=t.t,o=e.commands.get(this.commandName),s=e.config.get(this.componentName),r=ws(s.colors),a=ps(t,r),l=s.documentColors,c=s.colorPicker!==!1;e.ui.componentFactory.add(this.componentName,u=>{const d=Ee(u);let m=!1;const f=US({dropdownView:d,colors:a.map(g=>({label:g.label,color:g.model,options:{hasBorder:g.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:l!==0?i("Document colors"):"",documentColorsCount:l===void 0?this.columns:l,colorPickerViewConfig:c?s.colorPicker||{}:!1});return f.bind("selectedColor").to(o,"value"),d.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),d.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),d.bind("isEnabled").to(o),f.on("execute",(g,p)=>{d.isOpen&&e.execute(this.commandName,{value:p.value,batch:this._undoStepBatch}),p.source!=="colorPicker"&&e.editing.view.focus(),p.source==="colorPickerSaveButton"&&(d.isOpen=!1)}),f.on("colorPicker:show",()=>{this._undoStepBatch=e.model.createBatch()}),f.on("colorPicker:cancel",()=>{this._undoStepBatch.operations.length&&(d.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()}),d.on("change:isOpen",(g,p,_)=>{m||(m=!0,d.colorSelectorView.appendUI()),_&&(l!==0&&f.updateDocumentColors(e.model,this.componentName),f.updateSelectedColors(),f.showColorGridsFragment())}),ga(d,()=>d.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find(g=>g.isOn)),d}),e.ui.componentFactory.add(`menuBar:${this.componentName}`,u=>{const d=new Tt(u);d.buttonView.set({label:this.dropdownLabel,icon:this.icon}),d.bind("isEnabled").to(o);let m=!1;const f=new wu(u,{colors:a.map(g=>({label:g.label,color:g.model,options:{hasBorder:g.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:l!==0?i("Document colors"):"",documentColorsCount:l===void 0?this.columns:l,colorPickerViewConfig:!1});return f.bind("selectedColor").to(o,"value"),f.delegate("execute").to(d),f.on("execute",(g,p)=>{e.execute(this.commandName,{value:p.value,batch:this._undoStepBatch}),e.editing.view.focus()}),d.on("change:isOpen",(g,p,_)=>{m||(m=!0,f.appendUI()),_&&(l!==0&&f.updateDocumentColors(e.model,this.componentName),f.updateSelectedColors(),f.showColorGridsFragment())}),d.panelView.children.add(f),d})}}class mP extends Xb{constructor(e){const t=e.locale.t;super(e,{commandName:ii,componentName:ii,icon:AC,dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class e1 extends w{static get requires(){return[dP,mP]}static get pluginName(){return"FontColor"}static get isOfficialPlugin(){return!0}}class fP extends ba{constructor(e){super(e,vi)}}class gP extends w{static get pluginName(){return"FontBackgroundColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(vi,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(iu),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:vi,value:Jb("background-color")}}),e.conversion.for("downcast").attributeToElement({model:vi,view:Qb("background-color")}),e.commands.add(vi,new fP(e)),e.model.schema.extend("$text",{allowAttributes:vi}),e.model.schema.setAttributeProperties(vi,{isFormatting:!0,copyOnEnter:!0})}}class pP extends Xb{constructor(e){const t=e.locale.t;super(e,{commandName:vi,componentName:vi,icon:CC,dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class t1 extends w{static get requires(){return[gP,pP]}static get pluginName(){return"FontBackgroundColor"}static get isOfficialPlugin(){return!0}}class wP extends w{static get requires(){return[eP,uP,e1,t1]}static get pluginName(){return"Font"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bP extends O{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document,i=ae(t.selection.getSelectedBlocks());this.value=!!i&&i.is("element","paragraph"),this.isEnabled=!!i&&zm(i,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,o=e.selection||i.selection;t.canEditAt(o)&&t.change(s=>{const r=o.getSelectedBlocks();for(const a of r)!a.is("element","paragraph")&&zm(a,t.schema)&&s.rename(a,"paragraph")})}}function zm(n,e){return e.checkChild(n.parent,"paragraph")&&!e.isObject(n)}class _P extends O{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let o=e.position;return t.canEditAt(o)?t.change(s=>{if(o=this._findPositionToInsertParagraph(o,s),!o)return null;const r=s.createElement("paragraph");return i&&t.schema.setAllowedAttributes(r,i,s),t.insertContent(r,o),s.setSelection(r,"in"),s.createPositionAt(r,0)}):null}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const o=i.schema.findAllowedParent(e,"paragraph");if(!o)return null;const s=e.parent,r=i.schema.checkChild(s,"$text");return s.isEmpty||r&&e.isAtEnd?i.createPositionAfter(s):!s.isEmpty&&r&&e.isAtStart?i.createPositionBefore(s):t.split(e,o).position}}const i1=class n1 extends w{static get pluginName(){return"Paragraph"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new bP(e)),e.commands.add("insertParagraph",new _P(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(i,{writer:o})=>!n1.paragraphLikeElements.has(i.name)||i.isEmpty?null:o.createElement("paragraph"),view:/.+/,converterPriority:"low"})}};h(i1,"paragraphLikeElements",new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]));let Su=i1;class vP extends w{static get requires(){return[Su]}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("paragraph",i=>{const o=new P(i),s=e.commands.get("paragraph");return o.label=t("Paragraph"),o.icon=yw,o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(s),o.bind("isOn").to(s,"value"),o.on("execute",()=>{e.execute("paragraph")}),o})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class yP extends O{constructor(e,t){super(e),h(this,"modelElements"),this.modelElements=t}refresh(){const e=ae(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>Hm(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,i=t.document,o=e.value;t.change(s=>{const r=Array.from(i.selection.getSelectedBlocks()).filter(a=>Hm(a,o,t.schema));for(const a of r)a.is("element",o)||s.rename(a,o)})}}function Hm(n,e,t){return t.checkChild(n.parent,e)&&!t.isObject(n)}const $m="paragraph";class kP extends w{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}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[Su]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const o of t)o.model!=="paragraph"&&(e.model.schema.register(o.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(o),i.push(o.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new yP(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(o,s)=>{const r=e.model.document.selection.getFirstPosition().parent;i.some(a=>r.is("element",a.model))&&!r.is("element",$m)&&r.childCount===0&&s.writer.rename(r,$m)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:kt.low+1})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function o1(n){const e=n.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 n.config.get("heading.options").map(i=>{const o=t[i.title];return o&&o!=i.title&&(i.title=o),i})}class CP extends w{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=o1(e),o=t("Choose heading"),s=t("Heading");e.ui.componentFactory.add("heading",r=>{const a={},l=new _e,c=e.commands.get("heading"),u=e.commands.get("paragraph"),d=[c];for(const f of i){const g={type:"button",model:new et({label:f.title,class:f.class,role:"menuitemradio",withText:!0})};f.model==="paragraph"?(g.model.bind("isOn").to(u,"value"),g.model.set("commandName","paragraph"),d.push(u)):(g.model.bind("isOn").to(c,"value",p=>p===f.model),g.model.set({commandName:"heading",commandValue:f.model})),l.add(g),a[f.model]=f.title}const m=Ee(r);return wt(m,l,{ariaLabel:s,role:"menu"}),m.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),m.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),m.bind("isEnabled").toMany(d,"isEnabled",(...f)=>f.some(g=>g)),m.buttonView.bind("label").to(c,"value",u,"value",(f,g)=>{const p=g?"paragraph":f;return typeof p=="boolean"||!a[p]?o:a[p]}),m.buttonView.bind("ariaLabel").to(c,"value",u,"value",(f,g)=>{const p=g?"paragraph":f;return typeof p=="boolean"||!a[p]?s:`${a[p]}, ${s}`}),this.listenTo(m,"execute",f=>{const{commandName:g,commandValue:p}=f.source;e.execute(g,p?{value:p}:void 0),e.editing.view.focus()}),m}),e.ui.componentFactory.add("menuBar:heading",r=>{const a=new Tt(r),l=e.commands.get("heading"),c=e.commands.get("paragraph"),u=[l],d=new Si(r);a.set({class:"ck-heading-dropdown"}),d.set({ariaLabel:t("Heading"),role:"menu"}),a.buttonView.set({label:t("Heading")}),a.panelView.children.add(d);for(const m of i){const f=new Oi(r,a),g=new ve(r);f.children.add(g),d.items.add(f),g.set({isToggleable:!0,label:m.title,role:"menuitemradio",class:m.class}),g.delegate("execute").to(a),g.on("execute",()=>{const p=m.model==="paragraph"?"paragraph":"heading";e.execute(p,{value:m.model}),e.editing.view.focus()}),m.model==="paragraph"?(g.bind("isOn").to(c,"value"),u.push(c)):g.bind("isOn").to(l,"value",p=>p===m.model)}return a.bind("isEnabled").toMany(u,"isEnabled",(...m)=>m.some(f=>f)),a})}}class AP extends w{static get requires(){return[kP,CP]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}}const xP={heading1:xC,heading2:TC,heading3:EC,heading4:SC,heading5:PC,heading6:IC};class TP extends w{init(){o1(this.editor).filter(e=>e.model!=="paragraph").map(e=>this._createButton(e))}_createButton(e){const t=this.editor;t.ui.componentFactory.add(e.model,i=>{const o=new P(i),s=t.commands.get("heading");return o.label=e.title,o.icon=e.icon||xP[e.model],o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(s),o.bind("isOn").to(s,"value",r=>r==e.model),o.on("execute",()=>{t.execute("heading",{value:e.model}),t.editing.view.focus()}),o})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class EP extends O{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=SP(i,t,e)}execute(){const e=this.editor.model;e.change(t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})})}}function SP(n,e,t){const i=PP(n,t);return e.checkChild(i,"horizontalLine")}function PP(n,e){const t=ku(n,e).start.parent;return t.isEmpty&&!t.is("element","$root")?t.parent:t}class IP extends w{static get pluginName(){return"HorizontalLineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,o=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),o.for("dataDowncast").elementToElement({model:"horizontalLine",view:(s,{writer:r})=>r.createEmptyElement("hr")}),o.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(s,{writer:r})=>{const a=i("Horizontal line"),l=r.createContainerElement("div",null,r.createEmptyElement("hr"));return r.addClass("ck-horizontal-line",l),r.setCustomProperty("hr",!0,l),VP(l,r,a)}}),o.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new EP(e))}}function VP(n,e,t){return e.setCustomProperty("horizontalLine",!0,n),gt(n,e,{label:t})}class RP extends w{static get pluginName(){return"HorizontalLineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("horizontalLine",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:horizontalLine",()=>this._createButton(ve))}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("horizontalLine"),s=new e(t.locale),r=i.t;return s.set({label:r("Horizontal line"),icon:VC}),s.bind("isEnabled").to(o,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("horizontalLine"),t.editing.view.focus()}),s}}class OP extends w{static get requires(){return[IP,RP,Vt]}static get pluginName(){return"HorizontalLine"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function oi(n,e,t,i){e&&BP(n,e,i),t&&si(n,t,i)}function si(n,e,t){if(e.attributes)for(const[i,o]of Object.entries(e.attributes))n.setAttribute(i,o,t);e.styles&&n.setStyle(e.styles,t),e.classes&&n.addClass(e.classes,t)}function BP(n,e,t){if(e.attributes)for(const[i]of Object.entries(e.attributes))n.removeAttribute(i,t);if(e.styles)for(const i of Object.keys(e.styles))n.removeStyle(i,t);e.classes&&n.removeClass(e.classes,t)}function MP(n,e){const t=mt(n);let i="attributes";for(i in e)i=="classes"?t[i]=Array.from(new Set([...n[i]||[],...e[i]])):t[i]={...n[i],...e[i]};return t}function jn(n,e,t,i,o){const s=e.getAttribute(t),r={};for(const a of["attributes","styles","classes"]){if(a!=i){s&&s[a]&&(r[a]=s[a]);continue}if(i=="classes"){const c=new Set(s&&s.classes||[]);o(c),c.size&&(r[a]=Array.from(c));continue}const l=new Map(Object.entries(s&&s[a]||{}));o(l),l.size&&(r[a]=Object.fromEntries(l))}Object.keys(r).length?e.is("documentSelection")?n.setSelectionAttribute(t,r):n.setAttribute(t,r,e):s&&(e.is("documentSelection")?n.removeSelectionAttribute(t):n.removeAttribute(t,e))}function LP(n){return A_(n).replace(/ /g,"")}function Ft(n){return`html${LP(n)}Attributes`}function Pu({model:n}){return(e,t)=>t.writer.createElement(n,{htmlContent:e.getCustomProperty("$rawContent")})}function FP(n,{view:e,isInline:t}){const i=n.t;return(o,{writer:s})=>{const r=i("HTML object"),a=_a(e,o,s),l=o.getAttribute(Ft(e));s.addClass("html-object-embed__content",a),l&&si(s,l,a);const c=s.createContainerElement(t?"span":"div",{class:"html-object-embed","data-html-object-embed-label":r},a);return gt(c,s,{label:r})}}function _a(n,e,t){return t.createRawElement(n,null,(i,o)=>{o.setContentOf(i,e.getAttribute("htmlContent"))})}function NP({view:n,model:e,allowEmpty:t},i){return s=>{s.on(`element:${n}`,(r,a,l)=>{let c=i.processViewAttributes(a.viewItem,l);if(!(!c&&!l.consumable.test(a.viewItem,{name:!0}))){if(c=c||{},l.consumable.consume(a.viewItem,{name:!0}),a.modelRange||(a=Object.assign(a,l.convertChildren(a.viewItem,a.modelCursor))),t&&a.modelRange.isCollapsed&&Object.keys(c).length){const u=l.writer.createElement("htmlEmptyElement");if(!l.safeInsert(u,a.modelCursor))return;const d=l.getSplitParts(u);a.modelRange=l.writer.createRange(a.modelRange.start,l.writer.createPositionAfter(d[d.length-1])),l.updateConversionResult(u,a),o(u,c,l);return}for(const u of a.modelRange.getItems())o(u,c,l)}},{priority:"low"})};function o(s,r,a){if(a.schema.checkAttribute(s,e)){const l=s.getAttribute(e),c=MP(r,l||{});a.writer.setAttribute(e,c,s)}}}function Wm({model:n,view:e},t){return(i,{writer:o,consumable:s})=>{if(!i.hasAttribute(n))return null;const r=o.createContainerElement(e),a=i.getAttribute(n);return s.consume(i,`attribute:${n}`),si(o,a,r),r.getFillerOffset=()=>null,t?gt(r,o):r}}function DP({priority:n,view:e}){return(t,i)=>{if(!t)return;const{writer:o}=i,s=o.createAttributeElement(e,null,{priority:n});return si(o,t,s),s}}function mo({view:n},e){return t=>{t.on(`element:${n}`,(i,o,s)=>{if(!o.modelRange||o.modelRange.isCollapsed)return;const r=e.processViewAttributes(o.viewItem,s);r&&s.writer.setAttribute(Ft(o.viewItem.name),r,o.modelRange)},{priority:"low"})}}function vs({view:n,model:e}){return t=>{t.on(`attribute:${Ft(n)}:${e}`,(i,o,s)=>{if(!s.consumable.consume(o.item,i.name))return;const{attributeOldValue:r,attributeNewValue:a}=o,l=s.writer,c=s.mapper.toViewElement(o.item);oi(l,r,a,c)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/var jm={block:[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"horizontalLine",view:"hr"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6","$text"],allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowIn:["$root","$container"],allowChildren:["paragraph","htmlP","htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDivDl",view:"div",modelSchema:{allowChildren:["htmlDt","htmlDd"],allowIn:"htmlDl"}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDivDl"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlHr",view:"hr",isEmpty:!0,modelSchema:{inheritAllFrom:"$blockObject"}}],inline:[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref"},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}]};class fo extends w{constructor(){super(...arguments),h(this,"_definitions",[])}static get pluginName(){return"DataSchema"}static get isOfficialPlugin(){return!0}init(){for(const e of jm.block)this.registerBlockElement(e);for(const e of jm.inline)this.registerInlineElement(e)}registerBlockElement(e){this._definitions.push({...e,isBlock:!0})}registerInlineElement(e){this._definitions.push({...e,isInline:!0})}extendBlockElement(e){this._extendDefinition({...e,isBlock:!0})}extendInlineElement(e){this._extendDefinition({...e,isInline:!0})}getDefinitionsForView(e,t=!1){const i=new Set;for(const o of this._getMatchingViewDefinitions(e)){if(t)for(const s of this._getReferences(o.model))i.add(s);i.add(o)}return i}getDefinitionsForModel(e){return this._definitions.filter(t=>t.model==e)}_getMatchingViewDefinitions(e){return this._definitions.filter(t=>t.view&&zP(e,t.view))}*_getReferences(e){const t=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter(o=>o.model==e);for(const{modelSchema:o}of i)if(o)for(const s of t)for(const r of he(o[s]||[])){const a=this._definitions.filter(l=>l.model==r);for(const l of a)r!==e&&(yield*this._getReferences(l.model),yield l)}}_extendDefinition(e){const t=Array.from(this._definitions.entries()).filter(([,i])=>i.model==e.model);if(t.length==0){this._definitions.push(e);return}for(const[i,o]of t)this._definitions[i]=Og({},o,e,(s,r)=>Array.isArray(s)?s.concat(r):void 0)}}function zP(n,e){return typeof n=="string"?n===e:n instanceof RegExp?n.test(e):!1}class Pe extends w{constructor(e){super(e),h(this,"_dataSchema"),h(this,"_allowedAttributes"),h(this,"_disallowedAttributes"),h(this,"_allowedElements"),h(this,"_disallowedElements"),h(this,"_dataInitialized"),h(this,"_coupledAttributes"),this._dataSchema=e.plugins.get("DataSchema"),this._allowedAttributes=new ft,this._disallowedAttributes=new ft,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}static get pluginName(){return"DataFilter"}static get isOfficialPlugin(){return!0}static get requires(){return[fo,Vt]}loadAllowedConfig(e){for(const t of e){const i=t.name||/[\s\S]+/,o=qm(t);this.allowElement(i),o.forEach(s=>this.allowAttributes(s))}}loadDisallowedConfig(e){for(const t of e){const i=t.name||/[\s\S]+/,o=qm(t);o.length==0?this.disallowElement(i):o.forEach(s=>this.disallowAttributes(s))}}loadAllowedEmptyElementsConfig(e){for(const t of e)this.allowEmptyElement(t)}allowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))this._addAllowedElement(t),this._coupledAttributes=null}disallowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!1))this._disallowedElements.add(t.view)}allowEmptyElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))t.isInline&&this._dataSchema.extendInlineElement({...t,allowEmpty:!0})}allowAttributes(e){this._allowedAttributes.add(e)}disallowAttributes(e){this._disallowedAttributes.add(e)}processViewAttributes(e,t){const{consumable:i}=t;return Um(e,this._disallowedAttributes,i),HP(e,Um(e,this._allowedAttributes,i))}_addAllowedElement(e){if(!this._allowedElements.has(e)){if(this._allowedElements.add(e),"appliesToBlock"in e&&typeof e.appliesToBlock=="string")for(const t of this._dataSchema.getDefinitionsForModel(e.appliesToBlock))t.isBlock&&this._addAllowedElement(t);this._dataInitialized&&this.editor.data.once("set",()=>{this._fireRegisterEvent(e)},{priority:kt.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",()=>{this._dataInitialized=!0;for(const e of this._allowedElements)this._fireRegisterEvent(e)},{priority:kt.highest+1})}_registerElementHandlers(){this.on("register",(e,t)=>{const i=this.editor.model.schema;if(t.isObject&&!i.isRegistered(t.model))this._registerObjectElement(t);else if(t.isBlock)this._registerBlockElement(t);else if(t.isInline)this._registerInlineElement(t);else throw new b("data-filter-invalid-definition",null,t);e.stop()},{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const e=this.editor.model,t=e.document.selection;e.document.registerPostFixer(i=>{const o=e.document.differ.getChanges();let s=!1;const r=this._getCoupledAttributesMap();for(const a of o){if(a.type!="attribute"||a.attributeNewValue!==null)continue;const l=r.get(a.attributeKey);if(l)for(const{item:c}of a.range.getWalker())for(const u of l)c.hasAttribute(u)&&(i.removeAttribute(u,c),s=!0)}return s}),this.listenTo(t,"change:attribute",(i,{attributeKeys:o})=>{const s=new Set,r=this._getCoupledAttributesMap();for(const a of o){if(t.hasAttribute(a))continue;const l=r.get(a);if(l)for(const c of l)t.hasAttribute(c)&&s.add(c)}s.size!=0&&e.change(a=>{for(const l of s)a.removeSelectionAttribute(l)})})}_registerAssociatedHtmlAttributesPostFixer(){const e=this.editor.model;e.document.registerPostFixer(t=>{const i=e.document.differ.getChanges();let o=!1;for(const s of i)if(!(s.type!=="insert"||s.name==="$text"))for(const r of s.attributes.keys())!r.startsWith("html")||!r.endsWith("Attributes")||e.schema.checkAttribute(s.name,r)||(t.removeAttribute(r,s.position.nodeAfter),o=!0);return o})}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const e of this._allowedElements)if(e.coupledAttribute&&e.model){const t=this._coupledAttributes.get(e.coupledAttribute);t?t.push(e.model):this._coupledAttributes.set(e.coupledAttribute,[e.model])}return this._coupledAttributes}_fireRegisterEvent(e){e.view&&this._disallowedElements.has(e.view)||this.fire(e.view?`register:${e.view}`:"register",e)}_registerObjectElement(e){const t=this.editor,i=t.model.schema,o=t.conversion,{view:s,model:r}=e;i.register(r,e.modelSchema);/* istanbul ignore next: paranoid check -- @preserve */s&&(i.extend(e.model,{allowAttributes:[Ft(s),"htmlContent"]}),t.data.registerRawContentMatcher({name:s}),o.for("upcast").elementToElement({view:s,model:Pu(e),converterPriority:kt.low+2}),o.for("upcast").add(mo(e,this)),o.for("editingDowncast").elementToStructure({model:{name:r,attributes:[Ft(s)]},view:FP(t,e)}),o.for("dataDowncast").elementToElement({model:r,view:(a,{writer:l})=>_a(s,a,l)}),o.for("dataDowncast").add(vs(e)))}_registerBlockElement(e){const t=this.editor,i=t.model.schema,o=t.conversion,{view:s,model:r}=e;if(!i.isRegistered(e.model)){if(!e.modelSchema||(i.register(e.model,e.modelSchema),!s))return;o.for("upcast").elementToElement({model:r,view:s,converterPriority:kt.low+2}),o.for("downcast").elementToElement({model:r,view:(a,{writer:l})=>e.isEmpty?l.createEmptyElement(s):l.createContainerElement(s)})}s&&(i.extend(e.model,{allowAttributes:Ft(s)}),o.for("upcast").add(mo(e,this)),o.for("downcast").add(vs(e)))}_registerInlineElement(e){const t=this.editor,i=t.model.schema,o=t.conversion,s=e.model;if(!e.appliesToBlock&&(i.extend("$text",{allowAttributes:s}),e.attributeProperties&&i.setAttributeProperties(s,e.attributeProperties),o.for("upcast").add(NP(e,this)),o.for("downcast").attributeToElement({model:s,view:DP(e)}),!!e.allowEmpty)){if(i.setAttributeProperties(s,{copyFromObject:!1}),!i.isRegistered("htmlEmptyElement")){i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"});const r=a=>Array.from(a.getAttributeKeys()).some(l=>l.startsWith("html"));t.model.document.registerPostFixer(a=>{const l=t.model.document.differ.getChanges(),c=new Set;for(const u of l)if(u.type!=="remove"){if(u.type==="attribute"&&u.attributeNewValue===null)for(const{item:d}of u.range)d.is("element","htmlEmptyElement")&&!r(d)&&c.add(d);if(u.type==="insert"&&u.position.nodeAfter){const d=u.position.nodeAfter;for(const{item:m}of a.createRangeOn(d))m.is("element","htmlEmptyElement")&&!r(m)&&c.add(m)}}for(const u of c)a.remove(u);return c.size>0})}t.data.htmlProcessor.domConverter.registerInlineObjectMatcher(r=>r.name==e.view&&r.isEmpty&&Array.from(r.getAttributeKeys()).length?{name:!0}:null),o.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:Wm(e,!0)}),o.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:Wm(e)})}}}function Um(n,e,t){const i=e.matchAll(n)||[],o=n.document.stylesProcessor;return i.reduce((s,{match:r})=>{for(const[a,l]of r.attributes||[])if(a=="style"){const c=l,u=o.getRelatedStyles(c).filter(d=>d.split("-").length>c.split("-").length).sort((d,m)=>m.split("-").length-d.split("-").length);for(const d of u)t.consume(n,{styles:[d]})&&s.styles.push(d);t.consume(n,{styles:[c]})&&s.styles.push(c)}else if(a=="class"){const c=l;t.consume(n,{classes:[c]})&&s.classes.push(c)}else t.consume(n,{attributes:[a]})&&s.attributes.push(a);return s},{attributes:[],classes:[],styles:[]})}function HP(n,{attributes:e,classes:t,styles:i}){return!e.length&&!t.length&&!i.length?null:{...e.length&&{attributes:$P(n,e)},...i.length&&{styles:WP(n,i)},...t.length&&{classes:t}}}function $P(n,e){const t={};for(const i of e){const o=n.getAttribute(i);o!==void 0&&tp(i)&&(t[i]=o)}return t}function WP(n,e){const t=new so(n.document.stylesProcessor);for(const i of e){const o=n.getStyle(i);o!==void 0&&t.set(i,o)}return Object.fromEntries(t.getStylesEntries())}function pl(n,e){const{name:t}=n,i=n[e];return Ut(i)?Object.entries(i).map(([o,s])=>({name:t,[e]:{[o]:s}})):Array.isArray(i)?i.map(o=>({name:t,[e]:[o]})):[n]}function qm(n){const{name:e,attributes:t,classes:i,styles:o}=n,s=[];return t&&s.push(...pl({name:e,attributes:t},"attributes")),i&&s.push(...pl({name:e,classes:i},"classes")),o&&s.push(...pl({name:e,styles:o},"styles")),s}class jP extends w{static get requires(){return[Pe]}static get pluginName(){return"CodeBlockElementSupport"}static get isOfficialPlugin(){return!0}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const e=this.editor.plugins.get(Pe);e.on("register:pre",(t,i)=>{if(i.model!=="codeBlock")return;const o=this.editor,s=o.model.schema,r=o.conversion;s.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),r.for("upcast").add(UP(e)),r.for("downcast").add(qP()),t.stop()})}}function UP(n){return e=>{e.on("element:code",(t,i,o)=>{const s=i.viewItem,r=s.parent;if(!r||!r.is("element","pre"))return;a(r,"htmlPreAttributes"),a(s,"htmlContentAttributes");function a(l,c){const u=n.processViewAttributes(l,o);u&&o.writer.setAttribute(c,u,i.modelRange)}},{priority:"low"})}}function qP(){return n=>{n.on("attribute:htmlPreAttributes:codeBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=t,r=i.mapper.toViewElement(t.item).parent;oi(i.writer,o,s,r)}),n.on("attribute:htmlContentAttributes:codeBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=t,r=i.mapper.toViewElement(t.item);oi(i.writer,o,s,r)})}}class GP extends w{static get requires(){return[Pe]}static get pluginName(){return"DualContentModelElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.plugins.get(Pe).on("register",(e,t)=>{const i=t,o=this.editor,s=o.model.schema,r=o.conversion;if(!i.paragraphLikeModel||s.isRegistered(i.model)||s.isRegistered(i.paragraphLikeModel))return;const a={model:i.paragraphLikeModel,view:i.view};s.register(i.model,i.modelSchema),s.register(a.model,{inheritAllFrom:"$block"}),r.for("upcast").elementToElement({view:i.view,model:(l,{writer:c})=>this._hasBlockContent(l)?c.createElement(i.model):c.createElement(a.model),converterPriority:kt.low+.5}),r.for("downcast").elementToElement({view:i.view,model:i.model}),this._addAttributeConversion(i),r.for("downcast").elementToElement({view:a.view,model:a.model}),this._addAttributeConversion(a),e.stop()})}_hasBlockContent(e){const t=this.editor.editing.view,i=t.domConverter.blockElements;for(const o of t.createRangeIn(e).getItems())if(o.is("element")&&i.includes(o.name))return!0;return!1}_addAttributeConversion(e){const t=this.editor,i=t.conversion,o=t.plugins.get(Pe);t.model.schema.extend(e.model,{allowAttributes:Ft(e.view)}),i.for("upcast").add(mo(e,o)),i.for("downcast").add(vs(e))}}class KP extends w{static get requires(){return[fo,Ao]}static get pluginName(){return"HeadingElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("HeadingEditing"))return;const t=e.config.get("heading.options");this.registerHeadingElements(e,t)}registerHeadingElements(e,t){const i=e.plugins.get(fo),o=[];for(const s of t)"model"in s&&"view"in s&&(i.registerBlockElement({view:s.view,model:s.model}),o.push(s.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:o}}),i.extendBlockElement({model:"htmlSummary",modelSchema:{allowChildren:o}})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ys(n,e,t){const i=n.createRangeOn(e);for(const{item:o}of i.getWalker())if(o.is("element",t))return o}class ZP extends w{static get requires(){return[Pe]}static get pluginName(){return"ImageElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("ImageInlineEditing")&&!e.plugins.has("ImageBlockEditing"))return;const t=e.model.schema,i=e.conversion,o=e.plugins.get(Pe);o.on("register:figure",()=>{i.for("upcast").add(YP(o))}),o.on("register:img",(s,r)=>{r.model!=="imageBlock"&&r.model!=="imageInline"||(t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(JP(o)),i.for("downcast").add(XP()),e.plugins.has("LinkImage")&&i.for("upcast").add(QP(o,e)),s.stop())})}}function JP(n){return e=>{e.on("element:img",(t,i,o)=>{if(!i.modelRange)return;const s=i.viewItem,r=n.processViewAttributes(s,o);r&&o.writer.setAttribute("htmlImgAttributes",r,i.modelRange)},{priority:"low"})}}function QP(n,e){const t=e.plugins.get("ImageUtils");return i=>{i.on("element:a",(o,s,r)=>{const a=s.viewItem;if(!t.findViewImgElement(a))return;const l=s.modelCursor.parent;if(!l.is("element","imageBlock"))return;const c=n.processViewAttributes(a,r);c&&r.writer.setAttribute("htmlLinkAttributes",c,l)},{priority:"low"})}}function YP(n){return e=>{e.on("element:figure",(t,i,o)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("image"))return;const r=n.processViewAttributes(s,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,i.modelRange)},{priority:"low"})}}function XP(){return n=>{e("htmlImgAttributes"),t("img","htmlImgAttributes"),t("figure","htmlFigureAttributes"),t("a","htmlLinkAttributes");function e(i){n.on(`attribute:${i}:imageInline`,(o,s,r)=>{if(!r.consumable.consume(s.item,o.name))return;const{attributeOldValue:a,attributeNewValue:l}=s,c=r.mapper.toViewElement(s.item);oi(r.writer,a,l,c)},{priority:"low"})}function t(i,o){n.on(`attribute:${o}:imageBlock`,(s,r,a)=>{if(!a.consumable.test(r.item,s.name))return;const{attributeOldValue:l,attributeNewValue:c}=r,u=a.mapper.toViewElement(r.item),d=ys(a.writer,u,i);d&&(oi(a.writer,l,c,d),a.consumable.consume(r.item,s.name))},{priority:"low"}),i==="a"&&n.on("attribute:linkHref:imageBlock",(s,r,a)=>{if(!a.consumable.consume(r.item,"attribute:htmlLinkAttributes:imageBlock"))return;const l=a.mapper.toViewElement(r.item),c=ys(a.writer,l,"a");si(a.writer,r.item.getAttribute("htmlLinkAttributes"),c)},{priority:"low"})}}}class e4 extends w{static get requires(){return[Pe]}static get pluginName(){return"MediaEmbedElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("MediaEmbed")||e.config.get("mediaEmbed.previewsInData"))return;const t=e.model.schema,i=e.conversion,o=this.editor.plugins.get(Pe),s=this.editor.plugins.get(fo),r=e.config.get("mediaEmbed.elementName");s.registerBlockElement({model:"media",view:r}),o.on("register:figure",()=>{i.for("upcast").add(i4(o))}),o.on(`register:${r}`,(a,l)=>{l.model==="media"&&(t.extend("media",{allowAttributes:[Ft(r),"htmlFigureAttributes"]}),i.for("upcast").add(t4(o,r)),i.for("dataDowncast").add(n4(r)),a.stop())})}}function t4(n,e){const t=(i,o,s)=>{const r=o.viewItem;a(r,Ft(e));function a(l,c){const u=n.processViewAttributes(l,s);u&&s.writer.setAttribute(c,u,o.modelRange)}};return i=>{i.on(`element:${e}`,t,{priority:"low"})}}function i4(n){return e=>{e.on("element:figure",(t,i,o)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("media"))return;const r=n.processViewAttributes(s,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,i.modelRange)},{priority:"low"})}}function n4(n){return e=>{t(n,Ft(n)),t("figure","htmlFigureAttributes");function t(i,o){e.on(`attribute:${o}:media`,(s,r,a)=>{if(!a.consumable.consume(r.item,s.name))return;const{attributeOldValue:l,attributeNewValue:c}=r,u=a.mapper.toViewElement(r.item),d=ys(a.writer,u,i);oi(a.writer,l,c,d)})}}}class o4 extends w{static get requires(){return[Pe]}static get pluginName(){return"ScriptElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(Pe);e.on("register:script",(t,i)=>{const o=this.editor,s=o.model.schema,r=o.conversion;s.register("htmlScript",i.modelSchema),s.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),o.data.registerRawContentMatcher({name:"script"}),r.for("upcast").elementToElement({view:"script",model:Pu(i)}),r.for("upcast").add(mo(i,e)),r.for("downcast").elementToElement({model:"htmlScript",view:(a,{writer:l})=>_a("script",a,l)}),r.for("downcast").add(vs(i)),t.stop()})}}const s4=["width","max-width","min-width","height","min-height","max-height"];class r4 extends w{static get requires(){return[Pe]}static get pluginName(){return"TableElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("TableEditing"))return;const t=e.model.schema,i=e.conversion,o=e.plugins.get(Pe),s=e.plugins.get("TableUtils");o.on("register:figure",()=>{i.for("upcast").add(c4(o))}),o.on("register:table",(r,a)=>{a.model==="table"&&(t.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),i.for("upcast").add(l4(o)),i.for("downcast").add(u4()),e.model.document.registerPostFixer(a4(e.model,s)),r.stop())})}}function a4(n,e){return t=>{const i=n.document.differ.getChanges();let o=!1;for(const s of i){if(s.type!="attribute"||s.attributeKey!="headingRows")continue;const r=s.range.start.nodeAfter,a=r.getAttribute("htmlTheadAttributes"),l=r.getAttribute("htmlTbodyAttributes");a&&!s.attributeNewValue?(t.removeAttribute("htmlTheadAttributes",r),o=!0):l&&s.attributeNewValue==e.getRows(r)&&(t.removeAttribute("htmlTbodyAttributes",r),o=!0)}return o}}function l4(n){return e=>{e.on("element:table",(t,i,o)=>{if(!i.modelRange)return;const s=i.viewItem;r(s,"htmlTableAttributes");for(const a of s.getChildren())a.is("element","thead")&&r(a,"htmlTheadAttributes"),a.is("element","tbody")&&r(a,"htmlTbodyAttributes");function r(a,l){const c=n.processViewAttributes(a,o);c&&o.writer.setAttribute(l,c,i.modelRange)}},{priority:"low"})}}function c4(n){return e=>{e.on("element:figure",(t,i,o)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("table"))return;const r=n.processViewAttributes(s,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,i.modelRange)},{priority:"low"})}}function u4(){return n=>{e("table","htmlTableAttributes"),e("figure","htmlFigureAttributes"),e("thead","htmlTheadAttributes"),e("tbody","htmlTbodyAttributes");function e(t,i){n.on(`attribute:${i}:table`,(o,s,r)=>{if(!r.consumable.test(s.item,o.name))return;const a=r.mapper.toViewElement(s.item),l=ys(r.writer,a,t);if(l)if(r.consumable.consume(s.item,o.name),i==="htmlTableAttributes"&&a!==l){const c=Gm(s.attributeOldValue),u=Gm(s.attributeNewValue);oi(r.writer,c.tableAttributes,u.tableAttributes,l),oi(r.writer,c.figureAttributes,u.figureAttributes,a)}else oi(r.writer,s.attributeOldValue,s.attributeNewValue,l)})}}}function Gm(n){const e={},t={...n};if(!n||!("styles"in n))return{figureAttributes:e,tableAttributes:t};t.styles={};for(const[i,o]of Object.entries(n.styles))s4.includes(i)?e.styles={...e.styles,[i]:o}:t.styles={...t.styles,[i]:o};return{figureAttributes:e,tableAttributes:t}}class h4 extends w{static get requires(){return[Pe]}static get pluginName(){return"StyleElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(Pe);e.on("register:style",(t,i)=>{const o=this.editor,s=o.model.schema,r=o.conversion;s.register("htmlStyle",i.modelSchema),s.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),o.data.registerRawContentMatcher({name:"style"}),r.for("upcast").elementToElement({view:"style",model:Pu(i)}),r.for("upcast").add(mo(i,e)),r.for("downcast").elementToElement({model:"htmlStyle",view:(a,{writer:l})=>_a("style",a,l)}),r.for("downcast").add(vs(i)),t.stop()})}}class d4 extends w{static get requires(){return[Pe]}static get pluginName(){return"ListElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("ListEditing"))return;const t=e.model.schema,i=e.conversion,o=e.plugins.get(Pe),s=e.plugins.get("ListEditing"),r=e.plugins.get("ListUtils"),a=["ul","ol","li"];s.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:si}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:si}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:si}),o.on("register",(l,c)=>{if(!a.includes(c.view)||(l.stop(),t.checkAttribute("$block","htmlLiAttributes")))return;const u=a.map(d=>Ft(d));t.extend("$listItem",{allowAttributes:u}),i.for("upcast").add(d=>{d.on("element:ul",wl("htmlUlAttributes",o),{priority:"low"}),d.on("element:ol",wl("htmlOlAttributes",o),{priority:"low"}),d.on("element:li",wl("htmlLiAttributes",o),{priority:"low"})})}),s.on("postFixer",(l,{listNodes:c,writer:u})=>{for(const{node:d,previousNodeInList:m}of c)if(m){if(m.getAttribute("listType")==d.getAttribute("listType")){const f=Km(m.getAttribute("listType")),g=m.getAttribute(f);!lo(d.getAttribute(f),g)&&u.model.schema.checkAttribute(d,f)&&(u.setAttribute(f,g,d),l.return=!0)}if(m.getAttribute("listItemId")==d.getAttribute("listItemId")){const f=m.getAttribute("htmlLiAttributes");!lo(d.getAttribute("htmlLiAttributes"),f)&&u.model.schema.checkAttribute(d,"htmlLiAttributes")&&(u.setAttribute("htmlLiAttributes",f,d),l.return=!0)}}}),s.on("postFixer",(l,{listNodes:c,writer:u})=>{for(const{node:d}of c){const m=d.getAttribute("listType");!r.isNumberedListType(m)&&d.getAttribute("htmlOlAttributes")&&(u.removeAttribute("htmlOlAttributes",d),l.return=!0),r.isNumberedListType(m)&&d.getAttribute("htmlUlAttributes")&&(u.removeAttribute("htmlUlAttributes",d),l.return=!0)}})}afterInit(){const e=this.editor;if(!e.commands.get("indentList"))return;const t=e.commands.get("indentList");this.listenTo(t,"afterExecute",(i,o)=>{e.model.change(s=>{for(const r of o){const a=Km(r.getAttribute("listType"));e.model.schema.checkAttribute(r,a)&&s.setAttribute(a,{},r)}})})}}function wl(n,e){return(t,i,o)=>{const s=i.viewItem;i.modelRange||Object.assign(i,o.convertChildren(i.viewItem,i.modelCursor));const r=e.processViewAttributes(s,o);for(const a of i.modelRange.getItems({shallow:!0}))a.hasAttribute("listItemId")&&(a.hasAttribute("htmlUlAttributes")||a.hasAttribute("htmlOlAttributes")||o.writer.model.schema.checkAttribute(a,n)&&o.writer.setAttribute(n,r||{},a))}}function Km(n){return n==="numbered"||n=="customNumbered"?"htmlOlAttributes":"htmlUlAttributes"}class m4 extends w{static get requires(){return[Pe]}static get pluginName(){return"HorizontalLineElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("HorizontalLineEditing"))return;const t=e.model.schema,i=e.conversion,o=e.plugins.get(Pe);o.on("register:hr",(s,r)=>{r.model==="horizontalLine"&&(t.extend("horizontalLine",{allowAttributes:["htmlHrAttributes"]}),i.for("upcast").add(mo(r,o)),i.for("downcast").add(f4()),s.stop())})}}function f4(){return n=>{n.on("attribute:htmlHrAttributes:horizontalLine",(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=t,r=i.mapper.toViewElement(t.item),a=ys(i.writer,r,"hr");a&&(oi(i.writer,o,s,a),i.consumable.consume(t.item,e.name))},{priority:"low"})}}class g4 extends w{static get requires(){return[Pe,fo]}static get pluginName(){return"CustomElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(Pe),t=this.editor.plugins.get(fo);e.on("register:$customElement",(i,o)=>{i.stop();const s=this.editor,r=s.model.schema,a=s.conversion,l=s.editing.view.domConverter.unsafeElements,c=s.data.htmlProcessor.domConverter.preElements;r.register(o.model,o.modelSchema),r.extend(o.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),s.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),a.for("upcast").elementToElement({view:/.*/,model:(u,d)=>{if(u.name=="$comment"||!p4(u.name)||t.getDefinitionsForView(u.name).size)return null;l.includes(u.name)||l.push(u.name),c.includes(u.name)||c.push(u.name);const m=d.writer.createElement(o.model,{htmlElementName:u.name}),f=e.processViewAttributes(u,d);f&&d.writer.setAttribute("htmlCustomElementAttributes",f,m);let g;if(u.is("element","template")&&u.getCustomProperty("$rawContent"))g=u.getCustomProperty("$rawContent");else{const p=new Ht(u.document).createDocumentFragment(u),_=s.data.htmlProcessor.domConverter.viewToDom(p),v=_.firstChild;for(;v.firstChild;)_.appendChild(v.firstChild);v.remove(),g=s.data.htmlProcessor.htmlWriter.getHtml(_)}d.writer.setAttribute("htmlContent",g,m);for(const{item:p}of s.editing.view.createRangeIn(u))d.consumable.consume(p,{name:!0});return m},converterPriority:"low"}),a.for("editingDowncast").elementToElement({model:{name:o.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(u,{writer:d})=>{const m=u.getAttribute("htmlElementName"),f=d.createRawElement(m);return u.hasAttribute("htmlCustomElementAttributes")&&si(d,u.getAttribute("htmlCustomElementAttributes"),f),f}}),a.for("dataDowncast").elementToElement({model:{name:o.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(u,{writer:d})=>{const m=u.getAttribute("htmlElementName"),f=u.getAttribute("htmlContent"),g=d.createRawElement(m,null,(p,_)=>{_.setContentOf(p,f)});return u.hasAttribute("htmlCustomElementAttributes")&&si(d,u.getAttribute("htmlCustomElementAttributes"),g),g}})})}}function p4(n){try{document.createElement(n)}catch{return!1}return!0}class w4 extends w{static get pluginName(){return"GeneralHtmlSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[Pe,jP,GP,KP,ZP,e4,o4,r4,h4,d4,m4,g4]}init(){const e=this.editor,t=e.plugins.get(Pe);t.loadAllowedEmptyElementsConfig(e.config.get("htmlSupport.allowEmpty")||[]),t.loadAllowedConfig(e.config.get("htmlSupport.allow")||[]),t.loadDisallowedConfig(e.config.get("htmlSupport.disallow")||[])}getGhsAttributeNameForElement(e){const t=this.editor.plugins.get("DataSchema"),i=Array.from(t.getDefinitionsForView(e,!1)),o=i.find(s=>s.isInline&&!i[0].isObject);return o?o.model:Ft(e)}addModelHtmlClass(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"classes",l=>{for(const c of he(t))l.add(c)})})}removeModelHtmlClass(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"classes",l=>{for(const c of he(t))l.delete(c)})})}setModelHtmlAttributes(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"attributes",l=>{for(const[c,u]of Object.entries(t))l.set(c,u)})})}removeModelHtmlAttributes(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"attributes",l=>{for(const c of he(t))l.delete(c)})})}setModelHtmlStyles(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"styles",l=>{for(const[c,u]of Object.entries(t))l.set(c,u)})})}removeModelHtmlStyles(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"styles",l=>{for(const c of he(t))l.delete(c)})})}}function*Un(n,e,t){if(e)if(!(Symbol.iterator in e)&&e.is("documentSelection")&&e.isCollapsed)n.schema.checkAttributeInSelection(e,t)&&(yield e);else for(const i of b4(n,e,t))yield*i.getItems({shallow:!0})}function b4(n,e,t){return!(Symbol.iterator in e)&&(e.is("node")||e.is("$text")||e.is("$textProxy"))?n.schema.checkAttribute(e,t)?[n.createRangeOn(e)]:[]:n.schema.getValidRanges(n.createSelection(e).getRanges(),t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function _4(n){return n.createContainerElement("span",{class:"image-inline"},n.createEmptyElement("img"))}function Zm(n){return n.createContainerElement("figure",{class:"image"},[n.createEmptyElement("img"),n.createSlot("children")])}function s1(n,e){const t=n.plugins.get("ImageUtils"),i=n.plugins.has("ImageInlineEditing")&&n.plugins.has("ImageBlockEditing");return s=>t.isInlineImageView(s)?i&&(s.getStyle("display")=="block"||s.findAncestor(t.isBlockImageView)?"imageBlock":"imageInline")!==e?null:o(s):null;function o(s){const r={name:!0};return s.hasAttribute("src")&&(r.attributes=["src"]),r}}function Iu(n,e){const t=ae(e.getSelectedBlocks());return!t||n.isObject(t)||t.isEmpty&&t.name!="listItem"?"imageBlock":"imageInline"}function Wr(n){return n&&n.endsWith("px")?parseInt(n):null}function jr(n){const e=Wr(n.getStyle("width")),t=Wr(n.getStyle("height"));return!!(e&&t)}const v4=/^(image|image-inline)$/;class Ke extends w{constructor(){super(...arguments),h(this,"_domEmitter",new(st()))}static get pluginName(){return"ImageUtils"}static get isOfficialPlugin(){return!0}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null,o={}){const s=this.editor,r=s.model,a=r.document.selection,l=r1(s,t||a,i);e={...Object.fromEntries(a.getAttributes()),...e};for(const c in e)r.schema.checkAttribute(l,c)||delete e[c];return r.change(c=>{const{setImageSizes:u=!0}=o,d=c.createElement(l,e);return r.insertObject(d,t,null,{setSelection:"on",findOptimalPosition:!t&&l!="imageInline"?"auto":void 0}),d.parent?(u&&this.setImageNaturalSizeAttributes(d),d):null})}setImageNaturalSizeAttributes(e){const t=e.getAttribute("src");t&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change(i=>{const o=new I.window.Image;this._domEmitter.listenTo(o,"load",()=>{!e.getAttribute("width")&&!e.getAttribute("height")&&this.editor.model.enqueueChange(i.batch,s=>{s.setAttribute("width",o.naturalWidth,e),s.setAttribute("height",o.naturalHeight,e)}),this._domEmitter.stopListening(o,"load")}),o.src=t}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let o=t.parent;for(;o;){if(o.is("element")&&this.isImageWidget(o))return o;o=o.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:v4})}isImageAllowed(){const e=this.editor.model.document.selection;return y4(this.editor,e)&&k4(e)}toImageWidget(e,t,i){return t.setCustomProperty("image",!0,e),gt(e,t,{label:()=>{const o=this.findViewImgElement(e).getAttribute("alt");return o?`${o} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&Se(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function y4(n,e){if(r1(n,e,null)=="imageBlock"){const t=C4(e,n.model);if(n.model.schema.checkChild(t,"imageBlock"))return!0}else if(n.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}function k4(n){return[...n.focus.getAncestors()].every(e=>!e.is("element","imageBlock"))}function C4(n,e){const t=ku(n,e).start.parent;return t.isEmpty&&!t.is("element","$root")?t.parent:t}function r1(n,e,t){const i=n.model.schema,o=n.config.get("image.insert.type");return n.plugins.has("ImageBlockEditing")?n.plugins.has("ImageInlineEditing")?t||(o==="inline"?"imageInline":o!=="auto"?"imageBlock":e.is("selection")?Iu(i,e):i.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class A4 extends O{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),o=t.model,s=i.getClosestSelectedImageElement(o.document.selection);o.change(r=>{r.setAttribute("alt",e.newValue,s)})}}class x4 extends w{static get requires(){return[Ke]}static get pluginName(){return"ImageTextAlternativeEditing"}static get isOfficialPlugin(){return!0}init(){this.editor.commands.add("imageTextAlternative",new A4(this.editor))}}class T4 extends A{constructor(e){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"labeledInput"),h(this,"backButtonView"),h(this,"saveButtonView"),h(this,"children"),h(this,"_focusables"),h(this,"_focusCycler"),this.focusTracker=new ee,this.keystrokes=new te,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new $e(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new Ie,this.keystrokes.set("Esc",(t,i)=>{this.fire("cancel"),i()}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),[this.backButtonView,this.labeledInput,this.saveButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new P(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Text Alternative")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new Te(this.locale,nt);return t.label=e("Text alternative"),t.class="ck-labeled-field-view_full-width",t}}function E4(n){const e=n.plugins.get("ContextualBalloon");if(n.plugins.get("ImageUtils").getClosestSelectedImageWidget(n.editing.view.document.selection)){const t=Vu(n);e.updatePosition(t)}}function Vu(n){const e=n.editing.view,t=Ne.defaultPositions,i=n.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(i.getClosestSelectedImageWidget(e.document.selection)),positions:[t.northArrowSouth,t.northArrowSouthWest,t.northArrowSouthEast,t.southArrowNorth,t.southArrowNorthWest,t.southArrowNorthEast,t.viewportStickyNorth]}}class S4 extends w{constructor(){super(...arguments),h(this,"_balloon"),h(this,"_form")}static get requires(){return[Ue]}static get pluginName(){return"ImageTextAlternativeUI"}static get isOfficialPlugin(){return!0}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",i=>{const o=e.commands.get("imageTextAlternative"),s=new P(i);return s.set({label:t("Change image text alternative"),icon:bA,tooltip:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",r=>!!r),this.listenTo(s,"execute",()=>{this._showForm()}),s})}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(ho(T4))(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.listenTo(e.ui,"update",()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&E4(e):this._hideForm(!0)}),$t({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Vu(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class a1 extends w{static get requires(){return[x4,S4]}static get pluginName(){return"ImageTextAlternative"}static get isOfficialPlugin(){return!0}}function P4(n){const e=(t,i,o)=>{if(!o.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const s=n.findViewImgElement(i.viewItem);if(!s||!o.consumable.test(s,{name:!0}))return;o.consumable.consume(i.viewItem,{name:!0,classes:"image"});const r=o.convertItem(s,i.modelCursor),a=ae(r.modelRange.getItems());if(!a){o.consumable.revert(i.viewItem,{name:!0,classes:"image"});return}o.convertChildren(i.viewItem,a),o.updateConversionResult(a,i)};return t=>{t.on("element:figure",e)}}function I4(n){const e=["srcset","media","type","sizes"],t=(i,o,s)=>{const r=o.viewItem;if(!s.consumable.test(r,{name:!0}))return;const a=new Map;for(const u of r.getChildren())if(u.is("element","source")){const d={};for(const m of e)u.hasAttribute(m)&&s.consumable.test(u,{attributes:m})&&(d[m]=u.getAttribute(m));Object.keys(d).length&&a.set(u,d)}const l=n.findViewImgElement(r);if(!l)return;let c=o.modelCursor.parent;if(!c.is("element","imageBlock")){const u=s.convertItem(l,o.modelCursor);o.modelRange=u.modelRange,o.modelCursor=u.modelCursor,c=ae(u.modelRange.getItems())}s.consumable.consume(r,{name:!0});for(const[u,d]of a)s.consumable.consume(u,{attributes:Object.keys(d)});a.size&&s.writer.setAttribute("sources",Array.from(a.values()),c),s.convertChildren(r,c)};return i=>{i.on("element:picture",t)}}function l1(n,e){const t=(i,o,s)=>{if(!s.consumable.consume(o.item,i.name))return;const r=s.writer,a=s.mapper.toViewElement(o.item),l=n.findViewImgElement(a);o.attributeNewValue===null?(r.removeAttribute("srcset",l),r.removeAttribute("sizes",l)):o.attributeNewValue&&(r.setAttribute("srcset",o.attributeNewValue,l),r.setAttribute("sizes","100vw",l))};return i=>{i.on(`attribute:srcset:${e}`,t)}}function V4(n){const e=(t,i,o)=>{if(!o.consumable.consume(i.item,t.name))return;const s=o.writer,r=o.mapper.toViewElement(i.item),a=n.findViewImgElement(r),l=i.attributeNewValue;if(l&&l.length){const c=[];let u=a.parent;for(;u&&u.is("attributeElement");){const f=u.parent;s.unwrap(s.createRangeOn(a),u),c.unshift(u),u=f}const d=a.parent.is("element","picture"),m=d?a.parent:s.createContainerElement("picture",null);d||s.insert(s.createPositionBefore(a),m),s.remove(s.createRangeIn(m)),s.insert(s.createPositionAt(m,"end"),l.map(f=>s.createEmptyElement("source",f))),s.move(s.createRangeOn(a),s.createPositionAt(m,"end"));for(const f of c)s.wrap(s.createRangeOn(m),f)}else if(a.parent.is("element","picture")){const c=a.parent;s.move(s.createRangeOn(a),s.createPositionBefore(c)),s.remove(c)}};return t=>{t.on("attribute:sources:imageBlock",e),t.on("attribute:sources:imageInline",e)}}function Ur(n,e,t){const i=(o,s,r)=>{if(!r.consumable.consume(s.item,o.name))return;const a=r.writer,l=r.mapper.toViewElement(s.item),c=n.findViewImgElement(l);a.setAttribute(s.attributeKey,s.attributeNewValue||"",c)};return o=>{o.on(`attribute:${t}:${e}`,i)}}class Ru extends Zt{observe(e){this.listenTo(e,"load",(t,i)=>{const o=i.target;this.checkShouldIgnoreEventFromTarget(o)||o.tagName=="IMG"&&this._fireEvents(i)},{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class R4 extends O{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||t==="block"&&J("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||t==="inline"&&J("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=he(e.source),i=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((r,a)=>{const l=i.getSelectedElement();if(typeof r=="string"&&(r={src:r}),a&&l&&o.isImage(l)){const c=this.editor.model.createPositionAfter(l);o.insertImage({...r,...s},c,e.imageType)}else e.breakBlock?o.insertImage({...r,...s},i.getFirstPosition(),e.imageType):o.insertImage({...r,...s},null,e.imageType)})}}class O4 extends O{constructor(e){super(e),this.decorate("cleanupImage")}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change(o=>{o.setAttribute("src",e.source,t),this.cleanupImage(o,t),i.setImageNaturalSizeAttributes(t)})}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}}class Ou extends w{static get requires(){return[Ke]}static get pluginName(){return"ImageEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Ru),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new R4(e),o=new O4(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",o),e.commands.add("imageInsert",i)}}class c1 extends w{static get requires(){return[Ke]}static get pluginName(){return"ImageSizeAttributes"}static get isOfficialPlugin(){return!0}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),o=e==="imageBlock"?"figure":"img";t.conversion.for("upcast").attributeToAttribute({view:{name:o,styles:{width:/.+/}},model:{key:"width",value:r=>jr(r)?Wr(r.getStyle("width")):null}}).attributeToAttribute({view:{name:o,key:"width"},model:"width"}).attributeToAttribute({view:{name:o,styles:{height:/.+/}},model:{key:"height",value:r=>jr(r)?Wr(r.getStyle("height")):null}}).attributeToAttribute({view:{name:o,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add(r=>{s(r,"width","width",!0,!0),s(r,"height","height",!0,!0)}),t.conversion.for("dataDowncast").add(r=>{s(r,"width","width",!1),s(r,"height","height",!1)}),t.conversion.for("upcast").add(r=>{r.on("element:img",(a,l,c)=>{const u=l.viewItem.getAttribute("width"),d=l.viewItem.getAttribute("height");u&&d&&c.consumable.consume(l.viewItem,{styles:["aspect-ratio"]})})});function s(r,a,l,c,u=!1){r.on(`attribute:${a}:${e}`,(d,m,f)=>{if(!f.consumable.consume(m.item,d.name))return;const g=f.writer,p=f.mapper.toViewElement(m.item),_=i.findViewImgElement(p);m.attributeNewValue!==null?g.setAttribute(l,m.attributeNewValue,_):g.removeAttribute(l,_);const v=m.item.getAttribute("width"),E=m.item.getAttribute("height"),M=v&&E;if(M&&u&&g.setAttribute("loading","lazy",_),m.item.hasAttribute("sources"))return;const G=m.item.hasAttribute("resizedWidth");e==="imageInline"&&!G&&!c||M&&g.setStyle("aspect-ratio",`${v}/${E}`,_)})}}}class u1 extends O{constructor(e,t){super(e),h(this,"_modelElementName"),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);this._modelElementName==="imageBlock"?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(e={}){const t=this.editor,i=this.editor.model,o=t.plugins.get("ImageUtils"),s=o.getClosestSelectedImageElement(i.document.selection),r=Object.fromEntries(s.getAttributes());return!r.src&&!r.uploadId?null:i.change(a=>{const{setImageSizes:l=!0}=e,c=Array.from(i.markers).filter(m=>m.getRange().containsItem(s)),u=o.insertImage(r,i.createSelection(s,"on"),this._modelElementName,{setImageSizes:l});if(!u)return null;const d=a.createRangeOn(u);for(const m of c){const f=m.getRange(),g=f.root.rootName!="$graveyard"?f.getJoined(d,!0):d;a.updateMarker(m,{range:g})}return{oldElement:s,newElement:u}})}}class h1 extends w{static get requires(){return[Ke]}static get pluginName(){return"ImagePlaceholder"}static get isOfficialPlugin(){return!0}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add(o=>{o.on("attribute:placeholder",(s,r,a)=>{if(!a.consumable.test(r.item,s.name)||!r.item.is("element","imageBlock")&&!r.item.is("element","imageInline"))return;a.consumable.consume(r.item,s.name);const l=a.writer,c=a.mapper.toViewElement(r.item),u=i.findViewImgElement(c);r.attributeNewValue?(l.addClass("image_placeholder",u),l.setStyle("background-image",`url(${r.attributeNewValue})`,u),l.setCustomProperty("editingPipeline:doNotReuseOnce",!0,u)):(l.removeClass("image_placeholder",u),l.removeStyle("background-image",u))})})}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,o=i.view,s=e.plugins.get("ImageUtils");o.addObserver(Ru),this.listenTo(o.document,"imageLoaded",(r,a)=>{const l=o.domConverter.mapDomToView(a.target);if(!l)return;const c=s.getImageWidgetFromImageView(l);if(!c)return;const u=i.mapper.toModelElement(c);!u||!u.hasAttribute("placeholder")||t.enqueueChange({isUndoable:!1},d=>{d.removeAttribute("placeholder",u)})})}}class d1 extends w{static get requires(){return[Ou,c1,Ke,h1,pt]}static get pluginName(){return"ImageBlockEditing"}static get isOfficialPlugin(){return!0}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 u1(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,o=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(s,{writer:r})=>Zm(r)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(s,{writer:r})=>o.toImageWidget(Zm(r),r,t("image widget"))}),i.for("downcast").add(Ur(o,"imageBlock","src")).add(Ur(o,"imageBlock","alt")).add(l1(o,"imageBlock")),i.for("upcast").elementToElement({view:s1(e,"imageBlock"),model:(s,{writer:r})=>r.createElement("imageBlock",s.hasAttribute("src")?{src:s.getAttribute("src")}:void 0)}).add(P4(o))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,o=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(r,a)=>{const l=Array.from(a.content.getChildren());let c;if(!l.every(o.isInlineImageView))return;a.targetRanges?c=e.editing.mapper.toModelRange(a.targetRanges[0]):c=t.document.selection.getFirstRange();const u=t.createSelection(c);if(Iu(t.schema,u)==="imageBlock"){const d=new Ht(i.document),m=l.map(f=>d.createElement("figure",{class:"image"},f));a.content=d.createDocumentFragment(m)}}),this.listenTo(s,"contentInsertion",(r,a)=>{a.method==="paste"&&t.change(l=>{const c=l.createRangeIn(a.content);for(const u of c.getItems())u.is("element","imageBlock")&&o.setImageNaturalSizeAttributes(u)})})}}class B4 extends A{constructor(e,t=[]){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"_focusables"),h(this,"_focusCycler"),h(this,"children"),this.focusTracker=new ee,this.keystrokes=new te,this._focusables=new Ie,this.children=this.createCollection(),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const i of t)this.children.add(i),this._focusables.add(i),i instanceof mu&&this._focusables.addMany(i.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),Ri({view:this});for(const t of this._focusables)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element);const e=t=>t.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class m1 extends w{constructor(e){super(e),h(this,"dropdownView"),h(this,"_integrations",new Map),e.config.define("image.insert.integrations",["upload","assetManager","url"])}static get pluginName(){return"ImageInsertUI"}static get isOfficialPlugin(){return!0}static get requires(){return[Ke]}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",()=>{this.isImageSelected=i.isImage(t.getSelectedElement())});const o=r=>this._createToolbarComponent(r),s=r=>this._createMenuBarComponent(r);e.ui.componentFactory.add("insertImage",o),e.ui.componentFactory.add("imageInsert",o),e.ui.componentFactory.add("menuBar:insertImage",s)}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:o,menuBarButtonViewCreator:s,requiresForm:r=!1,override:a=!1}){this._integrations.has(e)&&!a&&J("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,menuBarButtonViewCreator:s,formViewCreator:o,requiresForm:r})}_createToolbarComponent(e){const t=this.editor,i=e.t,o=this._prepareIntegrations();if(!o.length)return null;let s;const r=o[0];if(o.length==1){if(!r.requiresForm)return r.buttonViewCreator(!0);s=r.buttonViewCreator(!0)}else{const c=r.buttonViewCreator(!1);s=new Xi(e,c),s.tooltip=!0,s.bind("label").to(this,"isImageSelected",u=>i(u?"Replace image":"Insert image"))}const a=this.dropdownView=Ee(e,s),l=o.map(({observable:c})=>typeof c=="function"?c():c);return a.bind("isEnabled").toMany(l,"isEnabled",(...c)=>c.some(u=>u)),a.once("change:isOpen",()=>{const c=o.flatMap(({formViewCreator:d})=>d(o.length==1)),u=new B4(t.locale,c);a.panelView.children.add(u)}),a}_createMenuBarComponent(e){const t=e.t,i=this._prepareIntegrations();if(!i.length)return null;const o=i.flatMap(({menuBarButtonViewCreator:a})=>a(i.length==1)),s=new Tt(e),r=new Si(e);s.panelView.children.add(r),s.buttonView.set({icon:RC,label:t("Image")});for(const a of o){const l=new Oi(e,s);l.children.add(a),r.items.add(l),a.delegate("execute").to(s)}return s}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return J("image-insert-integrations-not-specified"),t;for(const i of e){if(!this._integrations.has(i)){["upload","assetManager","url"].includes(i)||J("image-insert-unknown-integration",{item:i});continue}t.push(this._integrations.get(i))}return t.length||J("image-insert-integrations-not-registered"),t}}class M4 extends w{static get requires(){return[d1,Vt,a1,m1]}static get pluginName(){return"ImageBlock"}static get isOfficialPlugin(){return!0}}class L4 extends w{static get requires(){return[Ou,c1,Ke,h1,pt]}static get pluginName(){return"ImageInlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"],disallowIn:["caption"]}),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new u1(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,o=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(s,{writer:r})=>r.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(s,{writer:r})=>o.toImageWidget(_4(r),r,t("image widget"))}),i.for("downcast").add(Ur(o,"imageInline","src")).add(Ur(o,"imageInline","alt")).add(l1(o,"imageInline")),i.for("upcast").elementToElement({view:s1(e,"imageInline"),model:(s,{writer:r})=>r.createElement("imageInline",s.hasAttribute("src")?{src:s.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,o=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(r,a)=>{const l=Array.from(a.content.getChildren());let c;if(!l.every(o.isBlockImageView))return;a.targetRanges?c=e.editing.mapper.toModelRange(a.targetRanges[0]):c=t.document.selection.getFirstRange();const u=t.createSelection(c);if(Iu(t.schema,u)==="imageInline"){const d=new Ht(i.document),m=l.map(f=>f.childCount===1?(Array.from(f.getAttributes()).forEach(g=>d.setAttribute(...g,o.findViewImgElement(f))),f.getChild(0)):f);a.content=d.createDocumentFragment(m)}}),this.listenTo(s,"contentInsertion",(r,a)=>{a.method==="paste"&&t.change(l=>{const c=l.createRangeIn(a.content);for(const u of c.getItems())u.is("element","imageInline")&&o.setImageNaturalSizeAttributes(u)})})}}class f1 extends w{static get requires(){return[L4,Vt,a1,m1]}static get pluginName(){return"ImageInline"}static get isOfficialPlugin(){return!0}}class F4 extends w{static get requires(){return[M4,f1]}static get pluginName(){return"Image"}static get isOfficialPlugin(){return!0}}class g1 extends w{static get pluginName(){return"ImageCaptionUtils"}static get isOfficialPlugin(){return!0}static get requires(){return[Ke]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return e.name=="figcaption"&&t.isBlockImageView(e.parent)?{name:!0}:null}}class N4 extends O{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(d1)){this.isEnabled=!1,this.value=!1;return}const o=e.model.document.selection,s=o.getSelectedElement();if(!s){const r=t.getCaptionFromModelSelection(o);this.isEnabled=!!r,this.value=!!r;return}this.isEnabled=i.isImage(s),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(s):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change(i=>{this.value?this._hideImageCaption(i):this._showImageCaption(i,t)})}_showImageCaption(e,t){const i=this.editor.model.document.selection,o=this.editor.plugins.get("ImageCaptionEditing"),s=this.editor.plugins.get("ImageUtils");let r=i.getSelectedElement();const a=o._getSavedCaption(r);s.isInlineImage(r)&&(this.editor.execute("imageTypeBlock"),r=i.getSelectedElement());const l=a||e.createElement("caption");e.append(l,r),t&&e.setSelection(l,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,o=t.plugins.get("ImageCaptionEditing"),s=t.plugins.get("ImageCaptionUtils");let r=i.getSelectedElement(),a;r?a=s.getCaptionFromImageModelElement(r):(a=s.getCaptionFromModelSelection(i),r=a.parent),o._saveCaption(r,a),e.setSelection(r,"on"),e.remove(a)}}class D4 extends w{constructor(e){super(e),h(this,"_savedCaptionsMap"),this._savedCaptionsMap=new WeakMap}static get requires(){return[Ke,g1]}static get pluginName(){return"ImageCaptionEditing"}static get isOfficialPlugin(){return!0}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 N4(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),o=e.plugins.get("ImageCaptionUtils"),s=e.t;e.conversion.for("upcast").elementToElement({view:r=>o.matchImageCaptionViewElement(r),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(r,{writer:a})=>i.isBlockImage(r.parent)?a.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(r,{writer:a})=>{if(!i.isBlockImage(r.parent))return null;const l=a.createEditableElement("figcaption");a.setCustomProperty("imageCaption",!0,l),l.placeholder=s("Enter image caption"),sa({view:t,element:l,keepOnFocus:!0});const c=r.parent.getAttribute("alt"),u=c?s("Caption for image: %0",[c]):s("Caption for the image");return wa(l,a,{label:u})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),o=e.commands.get("imageTypeInline"),s=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 d=i.getCaptionFromImageModelElement(l);if(d){this._saveCaption(c,d);return}}const u=this._getSavedCaption(l);u&&this._saveCaption(c,u)};o&&this.listenTo(o,"execute",r,{priority:"low"}),s&&this.listenTo(s,"execute",r,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?ne.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),o=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",()=>{const s=t.document.differ.getChanges();for(const r of s){if(r.attributeKey!=="alt")continue;const a=r.range.start.nodeAfter;if(i.isBlockImage(a)){const l=o.getCaptionFromImageModelElement(a);if(!l)return;e.editing.reconvertItem(l)}}})}}class z4 extends w{static get requires(){return[g1]}static get pluginName(){return"ImageCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),o=e.t;e.ui.componentFactory.add("toggleImageCaption",s=>{const r=e.commands.get("toggleImageCaption"),a=new P(s);return a.set({icon:pw,tooltip:!0,isToggleable:!0}),a.bind("isOn","isEnabled").to(r,"value","isEnabled"),a.bind("label").to(r,"value",l=>o(l?"Toggle caption off":"Toggle caption on")),this.listenTo(a,"execute",()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const l=i.getCaptionFromModelSelection(e.model.document.selection);if(l){const c=e.editing.mapper.toViewElement(l);t.scrollToTheSelection(),t.change(u=>{u.addClass("image__caption_highlighted",c)})}e.editing.view.focus()}),a})}}class H4 extends w{static get requires(){return[D4,z4]}static get pluginName(){return"ImageCaption"}static get isOfficialPlugin(){return!0}}function p1(n){const e=n.map(t=>t.replace("+","\\+"));return new RegExp(`^image\\/(${e.join("|")})$`)}function $4(n){return new Promise((e,t)=>{const i=n.getAttribute("src");fetch(i).then(o=>o.blob()).then(o=>{const s=w1(o,i),r=`image.${s.replace("image/","")}`,a=new File([o],r,{type:s});e(a)}).catch(o=>o&&o.name==="TypeError"?j4(i).then(e).catch(t):t(o))})}function W4(n,e){return!n.isInlineImageView(e)||!e.getAttribute("src")?!1:!!e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||!!e.getAttribute("src").match(/^blob:/g)}function w1(n,e){return n.type?n.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}function j4(n){return U4(n).then(e=>{const t=w1(e,n),i=`image.${t.replace("image/","")}`;return new File([e],i,{type:t})})}function U4(n){return new Promise((e,t)=>{const i=I.document.createElement("img");i.addEventListener("load",()=>{const o=I.document.createElement("canvas");o.width=i.width,o.height=i.height,o.getContext("2d").drawImage(i,0,0),o.toBlob(s=>s?e(s):t())}),i.addEventListener("error",()=>t()),i.src=n})}class q4 extends w{static get pluginName(){return"ImageUploadUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("uploadImage",()=>this._createToolbarButton()),e.ui.componentFactory.add("imageUpload",()=>this._createToolbarButton()),e.ui.componentFactory.add("menuBar:uploadImage",()=>this._createMenuBarButton("standalone")),e.plugins.has("ImageInsertUI")&&e.plugins.get("ImageInsertUI").registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:t=>this._createMenuBarButton(t?"insertOnly":"insertNested")})}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("uploadImage"),s=t.config.get("image.upload.types"),r=p1(s),a=new e(t.locale),l=i.t;return a.set({acceptedType:s.map(c=>`image/${c}`).join(","),allowMultipleFiles:!0,label:l("Upload from computer"),icon:OC}),a.bind("isEnabled").to(o),a.on("done",(c,u)=>{const d=Array.from(u).filter(m=>r.test(m.type));d.length&&(t.execute("uploadImage",{file:d}),t.editing.view.focus())}),a}_createToolbarButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this.editor.commands.get("uploadImage"),o=this._createButton(jd);return o.tooltip=!0,o.bind("label").to(t,"isImageSelected",i,"isAccessAllowed",(s,r)=>e(r?s?"Replace image from computer":"Upload image from computer":"You have no image upload permissions.")),o}_createDropdownButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this._createButton(jd);return i.withText=!0,i.bind("label").to(t,"isImageSelected",o=>e(o?"Replace from computer":"Upload from computer")),i.on("execute",()=>{t.dropdownView.isOpen=!1}),i}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createButton(mb);switch(i.withText=!0,e){case"standalone":i.label=t("Image from computer");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("From computer");break}return i}}class G4 extends w{constructor(e){super(e),h(this,"placeholder"),h(this,"uploadStatusChange",(t,i,o)=>{const s=this.editor,r=i.item,a=r.getAttribute("uploadId");if(!o.consumable.consume(i.item,t.name))return;const l=s.plugins.get("ImageUtils"),c=s.plugins.get(At),u=a?i.attributeNewValue:null,d=this.placeholder,m=s.editing.mapper.toViewElement(r),f=o.writer;if(u=="reading"){Jm(m,f),Qm(l,d,m,f);return}if(u=="uploading"){const g=c.loaders.get(a);Jm(m,f),g?(Ym(m,f),Z4(m,f,g,s.editing.view),eI(l,m,f,g)):Qm(l,d,m,f);return}u=="complete"&&c.loaders.get(a)&&Q4(m,f,s.editing.view),J4(m,f),Ym(m,f),K4(m,f)}),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}static get pluginName(){return"ImageUploadProgress"}static get isOfficialPlugin(){return!0}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 Jm(n,e){n.hasClass("ck-appear")||e.addClass("ck-appear",n)}function K4(n,e){e.removeClass("ck-appear",n)}function Qm(n,e,t,i){t.hasClass("ck-image-upload-placeholder")||i.addClass("ck-image-upload-placeholder",t);const o=n.findViewImgElement(t);o.getAttribute("src")!==e&&i.setAttribute("src",e,o),b1(t,"placeholder")||i.insert(i.createPositionAfter(o),X4(i))}function Ym(n,e){n.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",n),_1(n,e,"placeholder")}function Z4(n,e,t,i){const o=Y4(e);e.insert(e.createPositionAt(n,"end"),o),t.on("change:uploadedPercent",(s,r,a)=>{i.change(l=>{l.setStyle("width",a+"%",o)})})}function J4(n,e){_1(n,e,"progressBar")}function Q4(n,e,t){const i=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(n,"end"),i),setTimeout(()=>{t.change(o=>o.remove(o.createRangeOn(i)))},3e3)}function Y4(n){const e=n.createUIElement("div",{class:"ck-progress-bar"});return n.setCustomProperty("progressBar",!0,e),e}function X4(n){const e=n.createUIElement("div",{class:"ck-upload-placeholder-loader"});return n.setCustomProperty("placeholder",!0,e),e}function b1(n,e){for(const t of n.getChildren())if(t.getCustomProperty(e))return t}function _1(n,e,t){const i=b1(n,t);i&&e.remove(e.createRangeOn(i))}function eI(n,e,t,i){if(i.data){const o=n.findViewImgElement(e);t.setAttribute("src",i.data,o)}}class tI extends O{constructor(e){super(e),this.set("isAccessAllowed",!0)}refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=he(e.file),i=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((r,a)=>{const l=i.getSelectedElement();if(a&&l&&o.isImage(l)){const c=this.editor.model.createPositionAfter(l);this._uploadImage(r,s,c)}else this._uploadImage(r,s)})}_uploadImage(e,t,i){const o=this.editor,s=o.plugins.get(At).createLoader(e),r=o.plugins.get("ImageUtils");s&&r.insertImage({...t,uploadId:s.id},i)}}class iI extends w{constructor(e){super(e),h(this,"_uploadImageElements"),h(this,"_uploadedImages",new Map),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}static get requires(){return[At,Nr,pt,Ke]}static get pluginName(){return"ImageUploadEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.document,i=e.conversion,o=e.plugins.get(At),s=e.plugins.get("ImageUtils"),r=e.plugins.get("ClipboardPipeline"),a=p1(e.config.get("image.upload.types")),l=new tI(e);e.commands.add("uploadImage",l),e.commands.add("imageUpload",l),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}).add(c=>c.on("element:img",(u,d,m)=>{if(!m.consumable.test(d.viewItem,{attributes:["data-ck-upload-id"]}))return;const f=d.viewItem.getAttribute("data-ck-upload-id");if(!f)return;const[g]=Array.from(d.modelRange.getItems({shallow:!0})),p=o.loaders.get(f);g&&(m.writer.setAttribute("uploadId",f,g),m.consumable.consume(d.viewItem,{attributes:["data-ck-upload-id"]}),p&&p.data&&m.writer.setAttribute("uploadStatus",p.status,g))},{priority:"low"})),this.listenTo(e.editing.view.document,"clipboardInput",(c,u)=>{if(nI(u.dataTransfer))return;const d=Array.from(u.dataTransfer.files).filter(m=>m?a.test(m.type):!1);if(d.length&&(c.stop(),e.model.change(m=>{u.targetRanges&&m.setSelection(u.targetRanges.map(f=>e.editing.mapper.toModelRange(f))),e.execute("uploadImage",{file:d})}),!e.commands.get("uploadImage").isAccessAllowed)){const m=e.plugins.get("Notification"),f=e.locale.t;m.showWarning(f("You have no image upload permissions."),{namespace:"image"})}}),this.listenTo(r,"inputTransformation",(c,u)=>{const d=Array.from(e.editing.view.createRangeIn(u.content)).map(f=>f.item).filter(f=>W4(s,f)&&!f.getAttribute("uploadProcessed")).map(f=>({promise:$4(f),imageElement:f}));if(!d.length)return;const m=new Ht(e.editing.view.document);for(const f of d){m.setAttribute("uploadProcessed",!0,f.imageElement);const g=o.createLoader(f.promise);g&&(m.setAttribute("src","",f.imageElement),m.setAttribute("uploadId",g.id,f.imageElement))}}),e.editing.view.document.on("dragover",(c,u)=>{u.preventDefault()}),t.on("change",()=>{const c=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),u=new Set;for(const d of c)if(d.type=="insert"&&d.name!="$text"){const m=d.position.nodeAfter,f=d.position.root.rootName=="$graveyard";for(const g of oI(e,m)){const p=g.getAttribute("uploadId");if(!p)continue;const _=o.loaders.get(p);if(!_){!f&&this._uploadedImages.has(p)&&e.model.enqueueChange({isUndoable:!1},v=>{v.setAttribute("uploadStatus","complete",g),this.fire("uploadComplete",{data:this._uploadedImages.get(p),imageElement:g})});continue}f?u.has(p)||Array.from(this._uploadImageElements.get(p)).every(v=>v.root.rootName=="$graveyard")&&_.abort():(u.add(p),this._uploadImageElements.has(p)?this._uploadImageElements.get(p).add(g):this._uploadImageElements.set(p,new Set([g])),_.status=="idle"&&this._readAndUpload(_))}}}),this.on("uploadComplete",(c,{imageElement:u,data:d})=>{const m=d.urls?d.urls:d;this.editor.model.change(f=>{f.setAttribute("src",m.default,u),this._parseAndSetSrcsetAttributeOnImage(m,u,f),s.setImageNaturalSizeAttributes(u)})},{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageBlock")),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageInline"))}_readAndUpload(e){const t=this.editor,i=t.model,o=t.locale.t,s=t.plugins.get(At),r=t.plugins.get(Nr),a=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},u=>{const d=l.get(e.id);for(const m of d)u.setAttribute("uploadStatus","reading",m)}),e.read().then(()=>{const u=e.upload();t.ui&&t.ui.ariaLiveAnnouncer.announce(o("Uploading image"));for(const d of l.get(e.id)){/* istanbul ignore next -- @preserve */if(N.isSafari){const m=t.editing.mapper.toViewElement(d),f=a.findViewImgElement(m);t.editing.view.once("render",()=>{if(!f.parent)return;const g=t.editing.view.domConverter.mapViewToDom(f.parent);if(!g)return;const p=g.style.display;g.style.display="none",g._ckHack=g.offsetHeight,g.style.display=p})}i.enqueueChange({isUndoable:!1},m=>{m.setAttribute("uploadStatus","uploading",d)})}return u}).then(u=>{i.enqueueChange({isUndoable:!1},d=>{for(const m of l.get(e.id))d.setAttribute("uploadStatus","complete",m),this.fire("uploadComplete",{data:u,imageElement:m});t.ui&&t.ui.ariaLiveAnnouncer.announce(o("Image upload complete")),this._uploadedImages.set(e.id,u)}),c()}).catch(u=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(o("Error during image upload")),e.status!=="error"&&e.status!=="aborted")throw u;e.status=="error"&&u&&r.showWarning(u,{title:o("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},d=>{for(const m of l.get(e.id))m.root.rootName!=="$graveyard"&&d.remove(m)}),c()});function c(){i.enqueueChange({isUndoable:!1},u=>{for(const d of l.get(e.id))u.removeAttribute("uploadId",d),u.removeAttribute("uploadStatus",d);l.delete(e.id)}),s.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let o=0;const s=Object.keys(e).filter(r=>{const a=parseInt(r,10);if(!isNaN(a))return o=Math.max(o,a),!0}).map(r=>`${e[r]} ${r}w`).join(", ");if(s!=""){const r={srcset:s};!t.hasAttribute("width")&&!t.hasAttribute("height")&&(r.width=o),i.setAttributes(r,t)}}_registerConverters(e){const{conversion:t,plugins:i}=this.editor,o=i.get(At),s=i.get(Ke);t.for("dataDowncast").add(r=>{r.on(`attribute:uploadId:${e}`,(a,l,c)=>{if(!c.consumable.test(l.item,a.name))return;const u=o.loaders.get(l.attributeNewValue);if(!u||!u.data)return null;const d=c.mapper.toViewElement(l.item),m=s.findViewImgElement(d);m&&(c.consumable.consume(l.item,a.name),c.writer.setAttribute("data-ck-upload-id",u.id,m))})})}}function nI(n){return Array.from(n.types).includes("text/html")&&n.getData("text/html")!==""}function oI(n,e){const t=n.plugins.get("ImageUtils");return Array.from(n.model.createRangeOn(e)).filter(i=>t.isImage(i.item)).map(i=>i.item)}class sI extends w{static get pluginName(){return"ImageUpload"}static get isOfficialPlugin(){return!0}static get requires(){return[iI,q4,G4]}}class rI extends O{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,!t||!t.hasAttribute("resizedWidth")?this.value=null:this.value={width:t.getAttribute("resizedWidth"),height:null}}execute(e){const t=this.editor,i=t.model,o=t.plugins.get("ImageUtils"),s=o.getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},s&&i.change(r=>{r.setAttribute("resizedWidth",e.width,s),r.removeAttribute("resizedHeight",s),o.setImageNaturalSizeAttributes(s)})}}class v1 extends w{static get requires(){return[Ke]}static get pluginName(){return"ImageResizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{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 rI(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add(o=>o.on(`attribute:resizedWidth:${e}`,(s,r,a)=>{if(!a.consumable.consume(r.item,s.name))return;const l=a.writer,c=a.mapper.toViewElement(r.item);r.attributeNewValue!==null?(l.setStyle("width",r.attributeNewValue,c),l.addClass("image_resized",c)):(l.removeStyle("width",c),l.removeClass("image_resized",c))})),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:o=>({key:"style",value:{height:o}})}),t.conversion.for("editingDowncast").add(o=>o.on(`attribute:resizedHeight:${e}`,(s,r,a)=>{if(!a.consumable.consume(r.item,s.name))return;const l=a.writer,c=a.mapper.toViewElement(r.item),u=e==="imageInline"?i.findViewImgElement(c):c;r.attributeNewValue!==null?l.setStyle("height",r.attributeNewValue,u):l.removeStyle("height",u)})),t.conversion.for("upcast").attributeToAttribute({view:{name:e==="imageBlock"?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:o=>jr(o)?null:o.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:e==="imageBlock"?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:o=>jr(o)?null:o.getStyle("height")}}),t.conversion.for("upcast").add(o=>{o.on(`element:${e==="imageBlock"?"figure":"img"}`,(s,r,a)=>{a.consumable.consume(r.viewItem,{classes:["image_resized"]})})})}}const bl={small:YC,medium:QC,large:JC,custom:KC,original:ZC};class aI extends w{constructor(e){super(e),h(this,"_resizeUnit"),this._resizeUnit=e.config.get("image.resizeUnit")}static get requires(){return[v1]}static get pluginName(){return"ImageResizeButtons"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const o of t)this._registerImageResizeButton(o);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:o,icon:s}=e;t.ui.componentFactory.add(i,r=>{const a=new P(r),l=t.commands.get("resizeImage"),c=this._getOptionLabelValue(e,!0);if(!bl[s])throw new b("imageresizebuttons-missing-icon",t,e);if(a.set({label:c,icon:bl[s],tooltip:c,isToggleable:!0}),a.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&zo(e)){const u=t.plugins.get("ImageCustomResizeUI");this.listenTo(a,"execute",()=>{u._showForm(this._resizeUnit)})}else{const u=o?o+this._resizeUnit:null;a.bind("isOn").to(l,"value",l,"isEnabled",lc(u)),this.listenTo(a,"execute",()=>{t.execute("resizeImage",{width:u})})}return a})}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,o=e.find(r=>!r.value),s=r=>{const a=t.commands.get("resizeImage"),l=Ee(r,fu),c=l.buttonView,u=i("Resize image");return c.set({tooltip:u,commandValue:o.value,icon:bl.medium,isToggleable:!0,label:this._getOptionLabelValue(o),withText:!0,class:"ck-resize-image-button",ariaLabel:u,ariaLabelledBy:void 0}),c.bind("label").to(a,"value",d=>d&&d.width?d.width:this._getOptionLabelValue(o)),l.bind("isEnabled").to(this),wt(l,()=>this._getResizeDropdownListItemDefinitions(e,a),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(l,"execute",d=>{"onClick"in d.source?d.source.onClick():(t.execute(d.source.commandName,{width:d.source.commandValue}),t.editing.view.focus())}),l};t.ui.componentFactory.add("resizeImage",s),t.ui.componentFactory.add("imageResize",s)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?zo(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):zo(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,o=new _e,s=e.map(r=>zo(r)?{...r,valueWithUnits:"custom"}:r.value?{...r,valueWithUnits:`${r.value}${this._resizeUnit}`}:{...r,valueWithUnits:null});for(const r of s){let a=null;if(i.plugins.has("ImageCustomResizeUI")&&zo(r)){const l=i.plugins.get("ImageCustomResizeUI");a={type:"button",model:new et({label:this._getOptionLabelValue(r),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{l._showForm(this._resizeUnit)}})};const c=Object.values(s).map(u=>u.valueWithUnits);a.model.bind("isOn").to(t,"value",t,"isEnabled",lI(c))}else a={type:"button",model:new et({commandName:"resizeImage",commandValue:r.valueWithUnits,label:this._getOptionLabelValue(r),role:"menuitemradio",withText:!0,icon:null})},a.model.bind("isOn").to(t,"value",t,"isEnabled",lc(r.valueWithUnits));a.model.bind("isEnabled").to(t,"isEnabled"),o.add(a)}return o}}function zo(n){return n.value==="custom"}function lc(n){return(e,t)=>{const i=e;return i===void 0||!t?!1:n===null&&i===n?!0:i!==null&&i.width===n}}function lI(n){return(e,t)=>!n.some(i=>lc(i)(e,t))}const cI="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",_l="image_resized";class uI extends w{static get requires(){return[ul,Ke]}static get pluginName(){return"ImageResizeHandles"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils");t.addObserver(Ru),this.listenTo(t.document,"imageLoaded",(o,s)=>{if(!s.target.matches(cI))return;const r=e.editing.view.domConverter,a=r.domToView(s.target),l=i.getImageWidgetFromImageView(a);let c=this.editor.plugins.get(ul).getResizerByViewElement(l);if(c){c.redraw();return}const u=e.editing.mapper,d=u.toModelElement(l);c=e.plugins.get(ul).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:d,viewElement:l,editor:e,getHandleHost(m){return m.querySelector("img")},getResizeHost(){return r.mapViewToDom(u.toViewElement(d))},isCentered(){return d.getAttribute("imageStyle")=="alignCenter"},onCommit(m){t.change(f=>{f.removeClass(_l,l)}),e.execute("resizeImage",{width:m})}}),c.on("updateSize",()=>{l.hasClass(_l)||t.change(f=>{f.addClass(_l,l)});const m=d.name==="imageInline"?a:l;m.getStyle("height")&&t.change(f=>{f.removeStyle("height",m)})}),c.bind("isEnabled").to(this)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function y1(n){if(!n)return null;const[,e,t]=n.trim().match(/([.,\d]+)(%|px)$/)||[],i=Number.parseFloat(e);return Number.isNaN(i)?null:{value:i,unit:t}}function k1(n,e,t){return t==="px"?{value:e.value,unit:"px"}:{value:e.value/n*100,unit:"%"}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function C1(n){const{editing:e}=n,t=n.plugins.get("ImageUtils").getClosestSelectedImageElement(n.model.document.selection);if(!t)return null;const i=e.mapper.toViewElement(t),o=e.view.domConverter.mapViewToDom(i);return{model:t,view:i,dom:o}}function hI(n,e){const t=C1(n);if(!t)return null;const i=y1(t.model.getAttribute("resizedWidth")||null);if(!i)return null;if(i.unit===e)return i;const o=Au(t.dom),s={value:new z(t.dom).width};return k1(o,s,e)}class dI extends A{constructor(e,t,i){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"unit"),h(this,"backButtonView"),h(this,"saveButtonView"),h(this,"labeledInput"),h(this,"children"),h(this,"_focusables"),h(this,"_focusCycler"),h(this,"_validators"),this.focusTracker=new ee,this.keystrokes=new te,this.unit=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new $e(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new Ie,this._validators=i,this.keystrokes.set("Esc",(o,s)=>{this.fire("cancel"),s()}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),[this.backButtonView,this.labeledInput,this.saveButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new P(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Image Resize")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new Te(this.locale,eb);return t.label=e("Resize image (in %0)",this.unit),t.class="ck-labeled-field-view_full-width",t.fieldView.set({step:.1}),t}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.labeledInput.errorText=t,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:e}=this.labeledInput.fieldView;return e?e.value:null}get parsedSize(){const{rawSize:e}=this;if(e===null)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return e===null?null:`${e}${t}`}}function mI(n,e){const t=C1(n);if(!t)return null;const i=Au(t.dom),o=y1(window.getComputedStyle(t.dom).minWidth)||{value:1},s=Math.max(.1,k1(i,o,e).value);return{unit:e,lower:s,upper:e==="px"?i:100}}class fI extends w{constructor(){super(...arguments),h(this,"_balloon"),h(this,"_form")}static get requires(){return[Ue]}static get pluginName(){return"ImageCustomResizeUI"}static get isOfficialPlugin(){return!0}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(e){const t=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(ho(dI))(t.locale,e,gI(t)),this._form.render(),this.listenTo(this._form,"submit",()=>{this._form.isValid()&&(t.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))}),this.listenTo(this._form.labeledInput,"change:errorText",()=>{t.ui.update()}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),$t({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(e){if(this._isVisible)return;this._form||this._createForm(e);const t=this.editor,i=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:Vu(t)});const o=hI(t,e),s=o?o.value.toFixed(1):"",r=mI(t,e);i.fieldView.value=i.fieldView.element.value=s,r&&Object.assign(i.fieldView,{min:r.lower.toFixed(1),max:Math.ceil(r.upper).toFixed(1)}),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)}}function gI(n){const e=n.t;return[t=>{if(t.rawSize.trim()==="")return e("The value must not be empty.");if(t.parsedSize===null)return e("The value should be a plain number.")}]}class pI extends w{static get requires(){return[v1,uI,fI,aI]}static get pluginName(){return"ImageResize"}static get isOfficialPlugin(){return!0}}class wI extends O{constructor(e,t){super(e),h(this,"_defaultStyles"),h(this,"_styles"),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map(i=>{if(i.isDefault)for(const o of i.modelElements)this._defaultStyles[o]=i.name;return[i.name,i]}))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,o=t.plugins.get("ImageUtils");i.change(s=>{const r=e.value,{setImageSizes:a=!0}=e;let l=o.getClosestSelectedImageElement(i.document.selection);r&&this.shouldConvertImageType(r,l)&&(this.editor.execute(o.isBlockImage(l)?"imageTypeInline":"imageTypeBlock",{setImageSizes:a}),l=o.getClosestSelectedImageElement(i.document.selection)),!r||this._styles.get(r).isDefault?s.removeAttribute("imageStyle",l):s.setAttribute("imageStyle",r,l),a&&o.setImageNaturalSizeAttributes(l)})}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const wr={get inline(){return{name:"inline",title:"In line",icon:bw,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:ru,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:_w,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:Mr,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:Lr,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:vw,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:Mr,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:Lr,modelElements:["imageBlock"],className:"image-style-side"}}},A1={full:GC,left:_w,right:vw,center:Mr,inlineLeft:ru,inlineRight:Lr,inline:bw},x1=[{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 bI(n){return(n.configuredStyles.options||[]).map(e=>yI(e)).filter(e=>kI(e,n))}function _I(n,e){return n&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:n?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}}function vI(n){return n.has("ImageBlockEditing")&&n.has("ImageInlineEditing")?[...x1]:[]}function yI(n){return typeof n=="string"?wr[n]?n={...wr[n]}:n={name:n}:n=CI(wr[n.name],n),typeof n.icon=="string"&&(n.icon=A1[n.icon]||n.icon),n}function kI(n,{isBlockPluginLoaded:e,isInlinePluginLoaded:t}){const{modelElements:i,name:o}=n;if(!i||!i.length||!o)return T1({style:n}),!1;{const s=[e?"imageBlock":null,t?"imageInline":null];if(!i.some(r=>s.includes(r)))return J("image-style-missing-dependency",{style:n,missingPlugins:i.map(r=>r==="imageBlock"?"ImageBlockEditing":"ImageInlineEditing")}),!1}return!0}function CI(n,e){const t={...e};for(const i in n)Object.prototype.hasOwnProperty.call(e,i)||(t[i]=n[i]);return t}function T1(n){J("image-style-configuration-definition-invalid",n)}var cc={normalizeStyles:bI,getDefaultStylesConfiguration:_I,getDefaultDropdownDefinitions:vI,warnInvalidStyle:T1,DEFAULT_OPTIONS:wr,DEFAULT_ICONS:A1,DEFAULT_DROPDOWN_DEFINITIONS:x1};function AI(n){return(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const o=Xm(t.attributeNewValue,n),s=Xm(t.attributeOldValue,n),r=i.mapper.toViewElement(t.item),a=i.writer;s&&a.removeClass(s.className,r),o&&a.addClass(o.className,r)}}function xI(n){const e={imageInline:n.filter(t=>!t.isDefault&&t.modelElements.includes("imageInline")),imageBlock:n.filter(t=>!t.isDefault&&t.modelElements.includes("imageBlock"))};return(t,i,o)=>{if(!i.modelRange)return;const s=i.viewItem,r=ae(i.modelRange.getItems());if(r&&o.schema.checkAttribute(r,"imageStyle"))for(const a of e[r.name])o.consumable.consume(s,{classes:a.className})&&o.writer.setAttribute("imageStyle",a.name,r)}}function Xm(n,e){for(const t of e)if(t.name===n)return t}class E1 extends w{constructor(){super(...arguments),h(this,"normalizedStyles")}static get pluginName(){return"ImageStyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Ke]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=cc,i=this.editor,o=i.plugins.has("ImageBlockEditing"),s=i.plugins.has("ImageInlineEditing");i.config.define("image.styles",t(o,s)),this.normalizedStyles=e({configuredStyles:i.config.get("image.styles"),isBlockPluginLoaded:o,isInlinePluginLoaded:s}),this._setupConversion(o,s),this._setupPostFixer(),i.commands.add("imageStyle",new wI(i,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,o=i.model.schema,s=AI(this.normalizedStyles),r=xI(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",s),i.data.downcastDispatcher.on("attribute:imageStyle",s),e&&(o.extend("imageBlock",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(o.extend("imageInline",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(Ke),o=new Map(this.normalizedStyles.map(s=>[s.name,s]));t.registerPostFixer(s=>{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)),!i.isImage(l))continue;const c=l.getAttribute("imageStyle");if(!c)continue;const u=o.get(c);(!u||!u.modelElements.includes(l.name))&&(s.removeAttribute("imageStyle",l),r=!0)}return r})}}class TI extends w{static get requires(){return[E1]}static get pluginName(){return"ImageStyleUI"}static get isOfficialPlugin(){return!0}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=e.get("ImageStyleEditing"),o=ef(i.normalizedStyles,this.localizedDefaultStylesTitles);for(const r of o)this._createButton(r);const s=ef([...t.filter(Et),...cc.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const r of s)this._createDropdown(r,o)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,o=>{let s;const{defaultItem:r,items:a,title:l}=e,c=a.filter(f=>t.find(({name:g})=>tf(g)===f)).map(f=>{const g=i.create(f);return f===r&&(s=g),g});a.length!==c.length&&cc.warnInvalidStyle({dropdown:e});const u=Ee(o,Xi),d=u.buttonView,m=d.arrowView;return fa(u,c,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:nf(l,s.label),class:null,tooltip:!0}),m.unbind("label"),m.set({label:l}),d.bind("icon").toMany(c,"isOn",(...f)=>{const g=f.findIndex(qn);return g<0?s.icon:c[g].icon}),d.bind("label").toMany(c,"isOn",(...f)=>{const g=f.findIndex(qn);return nf(l,g<0?s.label:c[g].label)}),d.bind("isOn").toMany(c,"isOn",(...f)=>f.some(qn)),d.bind("class").toMany(c,"isOn",(...f)=>f.some(qn)?"ck-splitbutton_flatten":void 0),d.on("execute",()=>{c.some(({isOn:f})=>f)?u.isOpen=!u.isOpen:s.fire("execute")}),u.bind("isEnabled").toMany(c,"isEnabled",(...f)=>f.some(qn)),this.listenTo(u,"execute",()=>{this.editor.editing.view.focus()}),u})}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(tf(t),i=>{const o=this.editor.commands.get("imageStyle"),s=new P(i);return s.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",r=>r===t),s.on("execute",this._executeCommand.bind(this,t)),s})}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function ef(n,e){for(const t of n)e[t.title]&&(t.title=e[t.title]);return n}function tf(n){return`imageStyle:${n}`}function nf(n,e){return(n?n+": ":"")+e}class EI extends w{static get requires(){return[E1,TI]}static get pluginName(){return"ImageStyle"}static get isOfficialPlugin(){return!0}}class SI extends w{static get requires(){return[ci,Ke]}static get pluginName(){return"ImageToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(ci),o=e.plugins.get("ImageUtils");i.register("image",{ariaLabel:t("Image toolbar"),items:PI(e.config.get("image.toolbar")||[]),getRelatedElement:s=>o.getClosestSelectedImageWidget(s)})}}function PI(n){return n.map(e=>Et(e)?e.name:e)}class II extends w{static get requires(){return[Ou,Ke]}static get pluginName(){return"PictureEditing"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:["sources"]}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:["sources"]}),this._setupConversion(),this._setupImageUploadEditingIntegration()}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("upcast").add(I4(i)),t.for("downcast").add(V4(i))}_setupImageUploadEditingIntegration(){const e=this.editor;if(!e.plugins.has("ImageUploadEditing"))return;const t=e.plugins.get("ImageUploadEditing");this.listenTo(t,"uploadComplete",(i,{imageElement:o,data:s})=>{const r=s.sources;r&&e.model.change(a=>{a.setAttributes({sources:r},o)})})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class VI extends w{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("indent",new rd(e)),e.commands.add("outdent",new rd(e))}}class RI extends w{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,o=t.uiLanguageDirection=="ltr"?wd:bd,s=t.uiLanguageDirection=="ltr"?bd:wd;this._defineButton("indent",i("Increase indent"),o),this._defineButton("outdent",i("Decrease indent"),s)}_defineButton(e,t,i){const o=this.editor;o.ui.componentFactory.add(e,()=>{const s=this._createButton(P,e,t,i);return s.set({tooltip:!0}),s}),o.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(ve,e,t,i))}_createButton(e,t,i,o){const s=this.editor,r=s.commands.get(t),a=new e(s.locale);return a.set({label:i,icon:o}),a.bind("isEnabled").to(r,"isEnabled"),this.listenTo(a,"execute",()=>{s.execute(t),s.editing.view.focus()}),a}}class OI extends w{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[VI,RI]}}class er extends O{constructor(e,t){super(e),h(this,"_indentBehavior"),this._indentBehavior=t}refresh(){const e=this.editor.model,t=ae(e.document.selection.getSelectedBlocks());if(!t||!this._isIndentationChangeAllowed(t)){this.isEnabled=!1;return}this.isEnabled=this._indentBehavior.checkEnabled(t.getAttribute("blockIndent"))}execute(){const e=this.editor.model,t=this._getBlocksToChange();e.change(i=>{for(const o of t){const s=o.getAttribute("blockIndent"),r=this._indentBehavior.getNextIndent(s);r?i.setAttribute("blockIndent",r,o):i.removeAttribute("blockIndent",o)}})}_getBlocksToChange(){const e=this.editor.model.document.selection;return Array.from(e.getSelectedBlocks()).filter(t=>this._isIndentationChangeAllowed(t))}_isIndentationChangeAllowed(e){const t=this.editor;return t.model.schema.checkAttribute(e,"blockIndent")?!t.plugins.has("ListUtils")||!this._indentBehavior.isForward?!0:!t.plugins.get("ListUtils").isListItemBlock(e):!1}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class of{constructor(e){h(this,"isForward"),h(this,"offset"),h(this,"unit"),this.isForward=e.direction==="forward",this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(!(!e||e.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=this.isForward?this.offset:-this.offset,o=t+i;return o>0?o+this.unit:void 0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class sf{constructor(e){h(this,"isForward"),h(this,"classes"),this.isForward=e.direction==="forward",this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const BI=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class MI extends w{constructor(e){super(e),e.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.config.get("indentBlock");t.classes&&t.classes.length?(this._setupConversionUsingClasses(t.classes),e.commands.add("indentBlock",new er(e,new sf({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlock",new er(e,new sf({direction:"backward",classes:t.classes})))):(e.data.addStyleProcessorRules(L5),this._setupConversionUsingOffset(),e.commands.add("indentBlock",new er(e,new of({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlock",new er(e,new of({direction:"backward",offset:t.offset,unit:t.unit}))))}afterInit(){const e=this.editor,t=e.model.schema,i=e.commands.get("indent"),o=e.commands.get("outdent"),s=e.config.get("heading.options");(s&&s.map(r=>r.model)||BI).forEach(r=>{t.isRegistered(r)&&t.extend(r,{allowAttributes:"blockIndent"})}),t.setAttributeProperties("blockIndent",{isFormatting:!0}),i.registerChildCommand(e.commands.get("indentBlock")),o.registerChildCommand(e.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const e=this.editor.conversion,t=this.editor.locale.contentLanguageDirection==="rtl"?"margin-right":"margin-left";e.for("upcast").attributeToAttribute({view:{styles:{[t]:/[\s\S]+/}},model:{key:"blockIndent",value:i=>{if(!i.is("element","li"))return i.getStyle(t)}}}),e.for("downcast").attributeToAttribute({model:"blockIndent",view:i=>({key:"style",value:{[t]:i}})})}_setupConversionUsingClasses(e){const t={model:{key:"blockIndent",values:[]},view:{}};for(const i of e)t.model.values.push(i),t.view[i]={key:"class",value:[i]};this.editor.conversion.attributeToAttribute(t)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Bu(n,e){return e=e||Dl(n),`${n}:${e}`}function LI(n){const[e,t]=n.split(":");return{languageCode:e,textDirection:t}}class FI extends O{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"language")}execute({languageCode:e,textDirection:t}={}){const i=this.editor.model,o=i.document.selection,s=e?Bu(e,t):!1;i.change(r=>{if(o.isCollapsed)s?r.setSelectionAttribute("language",s):r.removeSelectionAttribute("language");else{const a=i.schema.getValidRanges(o.getRanges(),"language");for(const l of a)s?r.setAttribute("language",s,l):r.removeAttribute("language",l)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.getAttribute("language")||!1;for(const o of i.getRanges())for(const s of o.getItems())if(t.checkAttribute(s,"language"))return s.getAttribute("language")||!1;return!1}}class NI extends w{static get pluginName(){return"TextPartLanguageEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"language"}),e.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),e.commands.add("textPartLanguage",new FI(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:t=>{const i=t.getAttribute("lang"),o=t.getAttribute("dir");return Bu(i,o)}},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(t,{writer:i},o)=>{if(!t||!o.item.is("$textProxy")&&!o.item.is("documentSelection"))return;const{languageCode:s,textDirection:r}=LI(t);return i.createAttributeElement("span",{lang:s,dir:r})}})}}class DI extends w{static get pluginName(){return"TextPartLanguageUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=t("Choose language"),o=t("Language");e.ui.componentFactory.add("textPartLanguage",s=>{const{definitions:r,titles:a}=this._getItemMetadata(),l=e.commands.get("textPartLanguage"),c=Ee(s);return wt(c,r,{ariaLabel:o,role:"menu"}),c.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),c.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),c.bind("isEnabled").to(l,"isEnabled"),c.buttonView.bind("label").to(l,"value",u=>u&&a[u]||i),c.buttonView.bind("ariaLabel").to(l,"value",u=>{const d=u&&a[u];return d?`${d}, ${o}`:o}),this.listenTo(c,"execute",u=>{l.execute({languageCode:u.source.languageCode,textDirection:u.source.textDirection}),e.editing.view.focus()}),c}),e.ui.componentFactory.add("menuBar:textPartLanguage",s=>{const{definitions:r}=this._getItemMetadata(),a=e.commands.get("textPartLanguage"),l=new Tt(s);l.buttonView.set({label:o});const c=new Si(s);c.set({ariaLabel:t("Language"),role:"menu"});for(const u of r){if(u.type!="button"){c.items.add(new ma(s));continue}const d=new Oi(s,l),m=new ve(s);m.set({role:"menuitemradio",isToggleable:!0}),m.bind(...Object.keys(u.model)).to(u.model),m.delegate("execute").to(l),d.children.add(m),c.items.add(d)}return l.bind("isEnabled").to(a,"isEnabled"),l.panelView.children.add(c),l.on("execute",u=>{a.execute({languageCode:u.source.languageCode,textDirection:u.source.textDirection}),e.editing.view.focus()}),l})}_getItemMetadata(){const e=this.editor,t=new _e,i={},o=e.commands.get("textPartLanguage"),s=e.config.get("language.textPartLanguage"),r=e.locale.t,a=r("Remove language");t.add({type:"button",model:new et({label:a,languageCode:!1,withText:!0})}),t.add({type:"separator"});for(const l of s){const c={type:"button",model:new et({label:l.title,languageCode:l.languageCode,role:"menuitemradio",textDirection:l.textDirection,withText:!0})},u=Bu(l.languageCode,l.textDirection);c.model.bind("isOn").to(o,"value",d=>d===u),t.add(c),i[u]=l.title}return{definitions:t,titles:i}}}class zI extends w{static get requires(){return[NI,DI]}static get pluginName(){return"TextPartLanguage"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class HI{constructor(){h(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,i,o)=>{if(!o.consumable.test(i.item,"attribute:linkHref")||!(i.item.is("selection")||o.schema.isInline(i.item)))return;const s=o.writer,r=s.document.selection;for(const a of this._definitions){const l=s.createAttributeElement("a",a.attributes,{priority:5});a.classes&&s.addClass(a.classes,l);for(const c in a.styles)s.setStyle(c,a.styles[c],l);s.setCustomProperty("link",!0,l),a.callback(i.attributeNewValue)?i.item.is("selection")?s.wrap(r.getFirstRange(),l):s.wrap(o.mapper.toViewRange(i.range),l):s.unwrap(o.mapper.toViewRange(i.range),l)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",(t,i,{writer:o,mapper:s})=>{const r=s.toViewElement(i.item),a=Array.from(r.getChildren()).find(l=>l.is("element","a"));if(a)for(const l of this._definitions){const c=ri(l.attributes);if(l.callback(i.attributeNewValue)){for(const[u,d]of c)u==="class"?o.addClass(d,a):o.setAttribute(u,d,a);l.classes&&o.addClass(l.classes,a);for(const u in l.styles)o.setStyle(u,l.styles[u],a)}else{for(const[u,d]of c)u==="class"?o.removeClass(d,a):o.removeAttribute(u,a);l.classes&&o.removeClass(l.classes,a);for(const u in l.styles)o.removeStyle(u,a)}}})}}}const $I=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,WI="^(?:(?:):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))",jI=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,UI=/^((\w+:(\/{2,})?)|(\W))/i,qI=["https?","ftps?","mailto"],tr="Ctrl+K";function GI(n){return n.is("attributeElement")&&!!n.getCustomProperty("link")}function rf(n,{writer:e}){const t=e.createAttributeElement("a",{href:n},{priority:5});return e.setCustomProperty("link",!0,t),t}function S1(n,e=qI){const t=String(n),i=e.join("|"),o=new RegExp(`${WI.replace("",i)}`,"i");return KI(t,o)?t:"#"}function KI(n,e){return!!n.replace($I,"").match(e)}function ZI(n,e){const t={"Open in a new tab":n("Open in a new tab"),Downloadable:n("Downloadable")};return e.forEach(i=>("label"in i&&t[i.label]&&(i.label=t[i.label]),i)),e}function JI(n){const e=[];if(n)for(const[t,i]of Object.entries(n)){const o=Object.assign({},i,{id:`link${T_(t)}`});e.push(o)}return e}function uc(n,e){return n?e.checkAttribute(n.name,"linkHref"):!1}function QI(n){return jI.test(n)}function Mu(n,e){const t=QI(n)?"mailto:":e,i=!!t&&!P1(n);return n&&i?t+n:n}function P1(n){return UI.test(n)}function YI(n){window.open(n,"_blank","noopener")}function hc(n){let e="";for(const t of n.getItems()){if(!t.is("$text")&&!t.is("$textProxy"))return;e+=t.data}return e}class XI extends O{constructor(){super(...arguments),h(this,"manualDecorators",new _e),h(this,"automaticDecorators",new HI)}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||ae(t.getSelectedBlocks());uc(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const o of this.manualDecorators)o.value=this._getDecoratorStateFromModel(o.id)}execute(e,t={},i){const o=this.editor.model,s=o.document.selection,r=[],a=[];for(const l in t)t[l]?r.push(l):a.push(l);o.change(l=>{const c=m=>{l.setAttribute("linkHref",e,m),r.forEach(f=>l.setAttribute(f,!0,m)),a.forEach(f=>l.removeAttribute(f,m))},u=(m,f)=>{const g=hc(m);if(!g)return m;let p=i;if(p||(p=f&&f==g?e:g),p!=g){const _=eV(g,p);let v=0;for(const{offset:E,actual:M,expected:G}of _){const X=E+v,T=l.createRange(m.start.getShiftedBy(X),m.start.getShiftedBy(X+M.length)),F=tV(T,m).getAttributes(),x=Array.from(F).filter(([Ve])=>o.schema.getAttributeProperties(Ve).isFormatting),q=l.createText(G,x);c(q),o.insertContent(q,T),v+=G.length}return l.createRange(m.start,m.start.getShiftedBy(p.length))}},d=m=>{const{plugins:f}=this.editor;if(l.setSelection(m.end),f.has("TwoStepCaretMovement"))f.get("TwoStepCaretMovement")._handleForwardMovement();else for(const g of["linkHref",...r,...a])l.removeSelectionAttribute(g)};if(s.isCollapsed){const m=s.getFirstPosition();if(s.hasAttribute("linkHref")){const f=s.getAttribute("linkHref"),g=Ps(m,"linkHref",f,o),p=u(g,f);c(p||g),p&&d(p)}else if(e!==""){const f=ri(s.getAttributes());f.set("linkHref",e),r.forEach(p=>{f.set(p,!0)});const g=o.insertContent(l.createText(i||e,f),m);d(g)}}else{const m=Array.from(s.getRanges()),f=o.schema.getValidRanges(m,"linkHref"),g=[];for(const v of s.getSelectedBlocks())o.schema.checkAttribute(v,"linkHref")&&g.push(l.createRangeOn(v));const p=g.slice();for(const v of f)this._isRangeToUpdate(v,g)&&p.push(v);const _=m.map(v=>({start:Me.fromPosition(v.start,"toPrevious"),end:Me.fromPosition(v.end,"toNext")}));for(let v of p){const E=(v.start.textNode||v.start.nodeAfter).getAttribute("linkHref");v=u(v,E)||v,c(v)}l.setSelection(_.map(v=>{const E=v.start.toPosition(),M=v.end.toPosition();return v.start.detach(),v.end.detach(),o.createRange(E,M)}))}})}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,o=i.getSelectedElement();return uc(o,t.schema)?o.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}function eV(n,e){const t=oo(n,e),i={equal:0,insert:0,delete:0},o=[];let s="",r="";for(const a of[...t,null])a=="insert"?r+=e[i.equal+i.insert]:a=="delete"?s+=n[i.equal+i.delete]:(s.length||r.length)&&(o.push({offset:i.equal,actual:s,expected:r}),s="",r=""),a&&i[a]++;return o}function tV(n,e){if(!n.isCollapsed)return ae(n.getItems());const t=n.start;return t.textNode?t.textNode:!t.nodeBefore||t.isEqual(e.start)?t.nodeAfter:t.nodeBefore}class iV extends O{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();uc(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,o=e.commands.get("link");t.change(s=>{const r=i.isCollapsed?[Ps(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const a of r)if(s.removeAttribute("linkHref",a),o)for(const l of o.manualDecorators)s.removeAttribute(l.id,a)})}}class nV extends ue(){constructor({id:e,label:t,attributes:i,classes:o,styles:s,defaultValue:r}){super(),h(this,"id"),h(this,"defaultValue"),h(this,"label"),h(this,"attributes"),h(this,"classes"),h(this,"styles"),this.id=e,this.set("value",void 0),this.defaultValue=r,this.label=t,this.attributes=i,this.classes=o,this.styles=s}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const oV="ck-link_selected",af="automatic",sV="manual",rV=/^(https?:)?\/\//;class ks extends w{constructor(e){super(e),h(this,"_linkOpeners",[]),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1,toolbar:["linkPreview","|","editLink","linkProperties","unlink"]})}static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Dr,vb,pt]}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:rf}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(o,s)=>rf(S1(o,t),s)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:o=>o.getAttribute("href")}}),e.commands.add("link",new XI(e)),e.commands.add("unlink",new iV(e));const i=ZI(e.t,JI(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter(o=>o.mode===af)),this._enableManualDecorators(i.filter(o=>o.mode===sV)),e.plugins.get(Dr).registerAttribute("linkHref"),Cb(e,"linkHref","a",oV),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_registerLinkOpener(e){this._linkOpeners.push(e)}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:af,callback:o=>!!o&&rV.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 s=new nV(o);i.add(s),t.conversion.for("downcast").attributeToElement({model:s.id,view:(r,{writer:a,schema:l},{item:c})=>{if((c.is("selection")||l.isInline(c))&&r){const u=a.createAttributeElement("a",s.attributes,{priority:5});s.classes&&a.addClass(s.classes,u);for(const d in s.styles)a.setStyle(d,s.styles[d],u);return a.setCustomProperty("link",!0,u),u}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...s._createPattern()},model:{key:s.id}})})}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document,i=o=>{this._linkOpeners.some(s=>s(o))||YI(o)};this.listenTo(t,"click",(o,s)=>{if(!(N.isMac?s.domEvent.metaKey:s.domEvent.ctrlKey))return;let r=s.domTarget;if(r.tagName.toLowerCase()!="a"&&(r=r.closest("a")),!r)return;const a=r.getAttribute("href");a&&(o.stop(),s.preventDefault(),i(a))},{context:"$capture"}),this.listenTo(t,"keydown",(o,s)=>{const r=e.commands.get("link").value;r&&s.keyCode===Z.enter&&s.altKey&&(o.stop(),i(r))})}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",(i,{attributeKeys:o})=>{!o.includes("linkHref")||t.hasAttribute("linkHref")||e.change(s=>{aV(s,lV(e.schema))})})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",(o,s)=>{t.change(r=>{const a=r.createRangeIn(s.content);for(const l of a.getItems())if(l.hasAttribute("linkHref")){const c=Mu(l.getAttribute("linkHref"),i);r.setAttribute("linkHref",c,l)}})})}}function aV(n,e){n.removeSelectionAttribute("linkHref");for(const t of e)n.removeSelectionAttribute(t)}function lV(n){return n.getDefinition("$text").allowAttributes.filter(e=>e.startsWith("link"))}class cV extends P{constructor(e){super(e);const t=this.bindTemplate;this.set({href:void 0,withText:!0}),this.extendTemplate({attributes:{class:["ck-link-toolbar__preview"],href:t.to("href"),target:"_blank",rel:"noopener noreferrer"},on:{click:t.to(i=>{if(this.href){const o=()=>i.preventDefault();this.fire("navigate",this.href,o)}})}}),this.template.tag="a"}}class uV extends A{constructor(e,t){super(e),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"backButtonView"),h(this,"saveButtonView"),h(this,"displayedTextInputView"),h(this,"urlInputView"),h(this,"children"),h(this,"providersListChildren"),h(this,"_validators"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.displayedTextInputView=this._createDisplayedTextInput(),this.urlInputView=this._createUrlInput(),this.providersListChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView()]),this._createFormChildren(),this.listenTo(this.providersListChildren,"add",()=>{this.stopListening(this.providersListChildren,"add"),this.children.add(this._createProvidersListView())}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-link-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),[this.urlInputView,this.saveButtonView,...this.providersListChildren,this.backButtonView,this.displayedTextInputView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}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}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new P(this.locale);return t.set({label:e("Insert"),tooltip:!1,withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Link")});return t.children.add(this.backButtonView,0),t}_createProvidersListView(){const e=new En(this.locale);return e.extendTemplate({attributes:{class:["ck-link-form__providers-list"]}}),e.items.bindTo(this.providersListChildren).using(t=>{const i=new Nt(this.locale);return i.children.add(t),i}),e}_createDisplayedTextInput(){const e=this.locale.t,t=new Te(this.locale,nt);return t.label=e("Displayed text"),t.class="ck-labeled-field-view_full-width",t}_createUrlInput(){const e=this.locale.t,t=new Te(this.locale,nt);return t.fieldView.inputMode="url",t.label=e("Link URL"),t.class="ck-labeled-field-view_full-width",t}_createFormChildren(){this.children.add(new $e(this.locale,{children:[this.displayedTextInputView],class:["ck-form__row_large-top-padding"]})),this.children.add(new $e(this.locale,{children:[this.urlInputView,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding","ck-form__row_large-bottom-padding"]}))}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}class hV extends A{constructor(e){super(e),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"backButtonView"),h(this,"listView"),h(this,"listChildren"),h(this,"emptyListInformation"),h(this,"children"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this.listChildren=this.createCollection(),this.backButtonView=this._createBackButton(),this.listView=this._createListView(),this.emptyListInformation=this._createEmptyLinksListItemView(),this.children=this.createCollection([this._createHeaderView(),this.emptyListInformation]),this.set("title",""),this.set("emptyListPlaceholder",""),this.set("hasItems",!1),this.listenTo(this.listChildren,"change",()=>{this.hasItems=this.listChildren.length>0}),this.on("change:hasItems",(t,i,o)=>{o?(this.children.remove(this.emptyListInformation),this.children.add(this.listView)):(this.children.remove(this.listView),this.children.add(this.emptyListInformation))}),this.keystrokes.set("Esc",(t,i)=>{this.fire("cancel"),i()}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-providers"],tabindex:"-1"},children:this.children})}render(){super.render(),[this.listView,this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createListView(){const e=new En(this.locale);return e.extendTemplate({attributes:{class:["ck-link-providers__list"]}}),e.items.bindTo(this.listChildren).using(t=>{const i=new Nt(this.locale);return i.children.add(t),i}),e}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=new Jt(this.locale);return e.bind("label").to(this,"title"),e.children.add(this.backButtonView,0),e}_createEmptyLinksListItemView(){const e=new A(this.locale);return e.setTemplate({tag:"p",attributes:{class:["ck","ck-link__empty-list-info"]},children:[{text:this.bindTemplate.to("emptyListPlaceholder")}]}),e}}class dV extends A{constructor(e){super(e),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"backButtonView"),h(this,"children"),h(this,"listChildren"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this.backButtonView=this._createBackButton(),this.listChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView(),this._createListView()]),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-properties"],tabindex:"-1"},children:this.children}),this.keystrokes.set("Esc",(t,i)=>{this.fire("back"),i()})}render(){super.render(),[...this.listChildren,this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"back"),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Link properties")});return t.children.add(this.backButtonView,0),t}_createListView(){const e=new En(this.locale);return e.extendTemplate({attributes:{class:["ck-link__list"]}}),e.items.bindTo(this.listChildren).using(t=>{const i=new Nt(this.locale);return i.children.add(t),i}),e}}class mV extends P{constructor(e){super(e),h(this,"arrowView"),this.set({withText:!0}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-link__button"]}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new hi;return e.content=ww,e}}const Xt="link-ui";class fV extends w{constructor(){super(...arguments),h(this,"toolbarView",null),h(this,"formView",null),h(this,"linkProviderItemsView",null),h(this,"propertiesView",null),h(this,"_balloon"),h(this,"_linksProviders",new _e)}static get requires(){return[Ue,ks]}static get pluginName(){return"LinkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;this.set("selectedLinkableText",void 0),e.editing.view.addObserver(ew),this._balloon=e.plugins.get(Ue),this._registerComponents(),this._registerEditingOpeners(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:Xt,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Xt,view:(i,{writer:o})=>{if(!i.markerRange.isCollapsed)return null;const s=o.createUIElement("span");return o.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],s),s}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:tr},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.propertiesView&&this.propertiesView.destroy(),this.formView&&this.formView.destroy(),this.toolbarView&&this.toolbarView.destroy(),this.linkProviderItemsView&&this.linkProviderItemsView.destroy()}registerLinksListProvider(e){const t=this._linksProviders.filter(i=>(i.order||0)<=(e.order||0)).length;this._linksProviders.add(e,t)}_createViews(){const e=this.editor.commands.get("link");this.toolbarView=this._createToolbarView(),this.formView=this._createFormView(),e.manualDecorators.length&&(this.propertiesView=this._createPropertiesView()),this._enableUserBalloonInteractions()}_createToolbarView(){const e=this.editor,t=new Ei(e.locale),i=e.commands.get("link");t.class="ck-link-toolbar";let o=e.config.get("link.toolbar");return i.manualDecorators.length||(o=o.filter(s=>s!=="linkProperties")),t.fillFromConfig(o,e.ui.componentFactory),t.keystrokes.set("Esc",(s,r)=>{this._hideUI(),r()}),t.keystrokes.set(tr,(s,r)=>{this._addFormView(),r()}),e.ui.addToolbar(t,{isContextual:!0,beforeFocus:()=>{this._getSelectedLinkElement()&&!this._isToolbarVisible&&this._showUI(!0)},afterBlur:()=>{this._hideUI(!1)}}),t}_createFormView(){const e=this.editor,t=e.locale.t,i=e.commands.get("link"),o=e.config.get("link.defaultProtocol"),s=new(ho(uV))(e.locale,gV(e));return s.displayedTextInputView.bind("isEnabled").to(this,"selectedLinkableText",r=>r!==void 0),s.urlInputView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("label").to(i,"value",r=>t(r?"Update":"Insert")),this.listenTo(s,"submit",()=>{if(s.isValid()){const r=s.urlInputView.fieldView.element.value,a=Mu(r,o),l=s.displayedTextInputView.fieldView.element.value;e.execute("link",a,this._getDecoratorSwitchesState(),l!==this.selectedLinkableText?l:void 0),this._closeFormView()}}),this.listenTo(s.urlInputView,"change:errorText",()=>{e.ui.update()}),this.listenTo(s,"cancel",()=>{this._closeFormView()}),s.keystrokes.set("Esc",(r,a)=>{this._closeFormView(),a()}),s.providersListChildren.bindTo(this._linksProviders).using(r=>this._createLinksListProviderButton(r)),s}_createLinkProviderListView(e){return e.getListItems().map(({href:t,label:i,icon:o})=>{const s=new P;return s.set({label:i,icon:o,tooltip:!1,withText:!0}),s.on("execute",()=>{this.formView.resetFormStatus(),this.formView.urlInputView.fieldView.value=t,this.editor.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),s})}_createLinkProviderItemsView(e){const t=this.editor,i=t.locale.t,o=new hV(t.locale),{emptyListPlaceholder:s,label:r}=e;return o.emptyListPlaceholder=s||i("No links available"),o.title=r,this.listenTo(o,"cancel",()=>{t.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),o}_createPropertiesView(){const e=this.editor,t=this.editor.commands.get("link"),i=new(ho(dV))(e.locale);return this.listenTo(i,"back",()=>{e.editing.view.focus(),this._removePropertiesView()}),i.listChildren.bindTo(t.manualDecorators).using(o=>{const s=new Ji(e.locale);return s.set({label:o.label,withText:!0}),s.bind("isOn").toMany([o,t],"value",(r,a)=>a===void 0&&r===void 0?!!o.defaultValue:!!r),s.on("execute",()=>{o.set("value",!s.isOn),e.execute("link",t.value,this._getDecoratorSwitchesState())}),s}),i}_getDecoratorSwitchesState(){const e=this.editor.commands.get("link");return Array.from(e.manualDecorators).reduce((t,i)=>{const o=e.value===void 0&&i.value===void 0?i.defaultValue:i.value;return{...t,[i.id]:!!o}},{})}_registerEditingOpeners(){this.editor.plugins.get(ks)._registerLinkOpener(e=>{const t=this._getLinkProviderLinkByHref(e);if(!t)return!1;const{item:i,provider:o}=t;return o.navigate?o.navigate(i):!1})}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("link",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:link",()=>{const t=this._createButton(ve);return t.set({role:"menuitemcheckbox"}),t}),e.ui.componentFactory.add("linkPreview",t=>{const i=new cV(t),o=e.config.get("link.allowedProtocols"),s=e.commands.get("link"),r=t.t;i.bind("isEnabled").to(s,"value",l=>!!l),i.bind("href").to(s,"value",l=>l&&S1(l,o));const a=l=>{if(!l){i.label=void 0,i.icon=void 0,i.tooltip=r("Open link in new tab");return}const c=this._getLinkProviderLinkByHref(l);if(c){const{label:u,tooltip:d,icon:m}=c.item;i.label=u,i.tooltip=d||!1,i.icon=m}else i.label=l,i.icon=void 0,i.tooltip=r("Open link in new tab")};return a(s.value),this.listenTo(s,"change:value",(l,c,u)=>{a(u)}),this.listenTo(i,"navigate",(l,c,u)=>{const d=this._getLinkProviderLinkByHref(c);if(!d)return;const{provider:m,item:f}=d,{navigate:g}=m;g&&g(f)&&(l.stop(),u())}),i}),e.ui.componentFactory.add("unlink",t=>{const i=e.commands.get("unlink"),o=new P(t),s=t.t;return o.set({label:s("Unlink"),icon:kA,tooltip:!0}),o.bind("isEnabled").to(i),this.listenTo(o,"execute",()=>{e.execute("unlink"),this._hideUI()}),o}),e.ui.componentFactory.add("editLink",t=>{const i=e.commands.get("link"),o=new P(t),s=t.t;return o.set({label:s("Edit link"),icon:kw,tooltip:!0}),o.bind("isEnabled").to(i),this.listenTo(o,"execute",()=>{this._addFormView()}),o}),e.ui.componentFactory.add("linkProperties",t=>{const i=e.commands.get("link"),o=new P(t),s=t.t;return o.set({label:s("Link properties"),icon:lA,tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled",i,"value",i,"manualDecorators",(r,a,l)=>r&&!!a&&l.length>0),this.listenTo(o,"execute",()=>{this._addPropertiesView()}),o})}_createLinksListProviderButton(e){const t=this.editor.locale,i=new mV(t);return i.set({label:e.label}),this.listenTo(i,"execute",()=>{this._showLinksProviderView(e)}),i}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("link"),s=new e(t.locale),r=i.t;return s.set({label:r("Link"),icon:LC,keystroke:tr,isToggleable:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",a=>!!a),this.listenTo(s,"execute",()=>{t.editing.view.scrollToTheSelection(),this._showUI(!0),this._getSelectedLinkElement()&&this._addFormView()}),s}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),e.keystrokes.set(tr,(i,o)=>{o(),e.commands.get("link").isEnabled&&(e.editing.view.scrollToTheSelection(),this._showUI(!0))})}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",(e,t)=>{this._isToolbarVisible&&!this.toolbarView.focusTracker.isFocused&&(this.toolbarView.focus(),t())},{priority:"high"}),this.editor.keystrokes.set("Esc",(e,t)=>{this._isUIVisible&&(this._hideUI(),t())}),$t({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideUI(!1)}})}_addToolbarView(){this.toolbarView||this._createViews(),!this._isToolbarInPanel&&this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this.formView.backButtonView.isVisible=e.isEnabled&&!!e.value,this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.selectedLinkableText=this._getSelectedLinkableText(),this.formView.displayedTextInputView.fieldView.value=this.selectedLinkableText||"",this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_addPropertiesView(){this.propertiesView||this._createViews(),!this._arePropertiesInPanel&&(this.propertiesView.disableCssTransitions(),this._balloon.add({view:this.propertiesView,position:this._getBalloonPositionData()}),this.propertiesView.enableCssTransitions(),this.propertiesView.focus())}_showLinksProviderView(e){this.linkProviderItemsView&&this._removeLinksProviderView(),this.linkProviderItemsView=this._createLinkProviderItemsView(e),this._addLinkProviderItemsView(e)}_addLinkProviderItemsView(e){this.linkProviderItemsView.listChildren.clear(),this.linkProviderItemsView.listChildren.addMany(this._createLinkProviderListView(e)),this._balloon.add({view:this.linkProviderItemsView,position:this._getBalloonPositionData()}),this.linkProviderItemsView.focus()}_closeFormView(){const e=this.editor.commands.get("link");this.selectedLinkableText=void 0,e.value!==void 0?this._removeFormView():this._hideUI()}_removePropertiesView(){this._arePropertiesInPanel&&this._balloon.remove(this.propertiesView)}_removeLinksProviderView(){this._isLinksListInPanel&&this._balloon.remove(this.linkProviderItemsView)}_removeFormView(e=!0){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.displayedTextInputView.fieldView.reset(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._isToolbarVisible?this._addFormView():this._addToolbarView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addToolbarView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(e=!0){const t=this.editor;this._isUIInPanel&&(this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e&&t.editing.view.focus(),this._removeLinksProviderView(),this._removePropertiesView(),this._removeFormView(e),this._isToolbarInPanel&&this._balloon.remove(this.toolbarView),this._hideFakeVisualSelection())}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),o=r();const s=()=>{const a=this._getSelectedLinkElement(),l=r();i&&!a||!i&&l!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=a,o=l};function r(){return t.selection.focus.getAncestors().reverse().find(a=>a.is("element"))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _arePropertiesInPanel(){return!!this.propertiesView&&this._balloon.hasView(this.propertiesView)}get _isLinksListInPanel(){return!!this.linkProviderItemsView&&this._balloon.hasView(this.linkProviderItemsView)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isToolbarInPanel(){return!!this.toolbarView&&this._balloon.hasView(this.toolbarView)}get _isPropertiesVisible(){return!!this.propertiesView&&this._balloon.visibleView===this.propertiesView}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}get _isToolbarVisible(){return!!this.toolbarView&&this._balloon.visibleView===this.toolbarView}get _isUIInPanel(){return this._arePropertiesInPanel||this._isLinksListInPanel||this._isFormInPanel||this._isToolbarInPanel}get _isUIVisible(){return this._isPropertiesVisible||this._isLinksListInPanel||this._isFormVisible||this._isToolbarVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;if(this.editor.model.markers.has(Xt)){const i=this.editor.editing.mapper.markerNameToElements(Xt);if(i){const o=Array.from(i),s=e.createRange(e.createPositionBefore(o[0]),e.createPositionAfter(o[o.length-1]));return{target:e.domConverter.viewRangeToDom(s)}}}return{target:()=>{const i=this._getSelectedLinkElement();return i?e.domConverter.mapViewToDom(i):e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&Se(i))return vl(t.getFirstPosition());{const o=t.getFirstRange().getTrimmed(),s=vl(o.start),r=vl(o.end);return!s||s!=r?null:e.createRangeIn(s).getTrimmed().isEqual(o)?s:null}}_getSelectedLinkableText(){const e=this.editor.model,t=this.editor.editing,i=this._getSelectedLinkElement();if(!i)return hc(e.document.selection.getFirstRange());const o=t.view.createRangeOn(i),s=t.mapper.toModelRange(o);return hc(s)}_getLinkProviderLinkByHref(e){if(!e)return null;for(const t of this._linksProviders){const i=t.getItem?t.getItem(e):t.getListItems().find(o=>o.href===e);if(i)return{provider:t,item:i}}return null}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(Xt))t.updateMarker(Xt,{range:i});else if(i.start.isAtEnd){const o=i.start.getLastMatchingPosition(({item:s})=>!e.schema.isContent(s),{boundaries:i});t.addMarker(Xt,{usingOperation:!1,affectsData:!1,range:t.createRange(o,i.end)})}else t.addMarker(Xt,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Xt)&&e.change(t=>{t.removeMarker(Xt)})}}function vl(n){return n.getAncestors().find(e=>GI(e))||null}function gV(n){const e=n.t,t=n.config.get("link.allowCreatingEmptyLinks");return[i=>{if(!t&&!i.url.length)return e("Link URL must not be empty.")}]}const pV=4,I1=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}))|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i"),wV=2;class V1 extends w{static get requires(){return[en,ks]}static get pluginName(){return"AutoLink"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.model.document.selection;e.on("change:range",()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?Ps(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,o=i.document.selection,s=o.getFirstPosition(),r=o.getLastPosition();let a=t.getJoined(this._expandLinkRange(i,s)||t);a&&(a=a.getJoined(this._expandLinkRange(i,r)||t)),a&&(a.start.isBefore(s)||a.end.isAfter(r))&&e.setSelection(a)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,o=e.plugins.get("ClipboardPipeline"),s=e.commands.get("link");o.on("inputTransformation",(r,a)=>{if(!this.isEnabled||!s.isEnabled||i.isCollapsed||a.method!=="paste"||i.rangeCount>1)return;const l=i.getFirstRange(),c=a.dataTransfer.getData("text/plain");if(!c)return;const u=c.match(I1);u&&u[2]===c&&(t.change(d=>{this._selectEntireLinks(d,l),s.execute(c)}),r.stop())},{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new vu(e.model,i=>{let o=i;if(!bV(o))return;o=o.slice(0,-1),"!.:,;?".includes(o[o.length-1])&&(o=o.slice(0,-1));const s=lf(o);if(s)return{url:s,removedTrailingCharacters:i.length-o.length}});t.on("matched:data",(i,o)=>{const{batch:s,range:r,url:a,removedTrailingCharacters:l}=o;if(!s.isTyping)return;const c=r.end.getShiftedBy(-l),u=c.getShiftedBy(-a.length),d=e.model.createRange(u,c);this._applyAutoLink(a,d)}),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",()=>{var o;const s=t.document.selection.getFirstPosition();let r;(o=s.parent.previousSibling)!=null&&o.is("element")?r=t.createRangeIn(s.parent.previousSibling):r=t.createRange(t.createPositionAt(s.parent,0),s),this._checkAndApplyAutoLinkOnRange(r)})}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",()=>{const o=t.document.selection.getFirstPosition(),s=t.createRange(t.createPositionAt(o.parent,0),o.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(s)})}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:o}=kb(e,t),s=lf(i);if(s){const r=t.createRange(o.end.getShiftedBy(-s.length),o.end);this._applyAutoLink(s,r)}}_applyAutoLink(e,t){const i=this.editor.model,o=this.editor.config.get("link.defaultProtocol"),s=Mu(e,o);!this.isEnabled||!_V(t,i)||!P1(s)||vV(t)||this._persistAutoLink(s,t)}_persistAutoLink(e,t){const i=this.editor.model,o=this.editor.plugins.get("Delete");i.enqueueChange(s=>{s.setAttribute("linkHref",e,t),i.enqueueChange(()=>{o.requestUndoOnBackspace()})})}}function bV(n){return n.length>pV&&n[n.length-1]===" "&&n[n.length-2]!==" "}function lf(n){const e=I1.exec(n);return e?e[wV]:null}function _V(n,e){return e.schema.checkAttributeInSelection(e.createSelection(n),"linkHref")}function vV(n){const e=n.start.nodeAfter;return!!e&&e.hasAttribute("linkHref")}class yV extends w{static get requires(){return[ks,fV,V1]}static get pluginName(){return"Link"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Dt{constructor(e,t){h(this,"_startElement"),h(this,"_referenceIndent"),h(this,"_isForward"),h(this,"_includeSelf"),h(this,"_sameAttributes"),h(this,"_sameIndent"),h(this,"_lowerIndent"),h(this,"_higherIndent"),this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward=t.direction=="forward",this._includeSelf=!!t.includeSelf,this._sameAttributes=he(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){const i=new this(e,t)[Symbol.iterator]();return ae(i)}*[Symbol.iterator](){const e=[];for(const{node:t}of new Is(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(ithis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some(o=>t.getAttribute(o)!==this._startElement.getAttribute(o)))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}class Is{constructor(e,t="forward"){h(this,"_node"),h(this,"_isForward"),h(this,"_previousNodesByIndent",[]),h(this,"_previous",null),h(this,"_previousNodeIndent",null),this._node=e,this._isForward=t==="forward"}[Symbol.iterator](){return this}next(){if(!be(this._node))return{done:!0,value:void 0};const e=this._node.getAttribute("listIndent");let t=null;if(this._previous){const o=this._previousNodeIndent;e>o?this._previousNodesByIndent[o]=this._previous:er.getAttribute("listIndent"))),s=new Map;for(const r of t)s.set(r,Dt.first(r,{lowerIndent:!0}));for(const r of t){if(i.has(r))continue;i.add(r);const a=r.getAttribute("listIndent")-1;if(a<0){ya(r,e);continue}if(r.getAttribute("listIndent")==o){const l=TV(r,s.get(r),e);for(const c of l)i.add(c);if(l.length)continue}e.setAttribute("listIndent",a,r)}return Pn(i)}function ya(n,e){n=he(n);for(const t of n)t.is("element","listItem")&&e.rename(t,"paragraph");for(const t of n)for(const i of t.getAttributeKeys())i.startsWith("list")&&e.removeAttribute(i,t);return n}function Cs(n){if(!n.length)return!1;const e=n[0].getAttribute("listItemId");return e?!n.some(t=>t.getAttribute("listItemId")!=e):!1}function xV(n,e){const t=[];let i=Number.POSITIVE_INFINITY;for(const{node:o}of new Is(n.nextSibling)){const s=o.getAttribute("listIndent");if(s==0)break;se.root.rootName!=="$graveyard").sort((e,t)=>e.index-t.index)}function As(n){const e=n.document.selection.getSelectedElement();return e&&n.schema.isObject(e)&&n.schema.isBlock(e)?e:null}function yl(n,e){return e.checkChild(n.parent,"listItem")&&e.checkChild(n,"$text")&&!e.isObject(n)}function qr(n){return n=="numbered"||n=="customNumbered"}function TV(n,e,t){return Qi(e,{direction:"forward"}).pop().index>n.index?dc(n,e,t):[]}class uf extends O{constructor(e,t){super(e),h(this,"_direction"),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=hf(e.document.selection);e.change(i=>{const o=[];Cs(t)&&!Pi(t[0])?(this._direction=="forward"&&o.push(...mc(t,i)),o.push(...Lu(t[0],i))):this._direction=="forward"?o.push(...mc(t,i,{expand:!0})):o.push(...AV(t,i));for(const s of o){if(!s.hasAttribute("listType"))continue;const r=Dt.first(s,{sameIndent:!0});r&&i.setAttribute("listType",r.getAttribute("listType"),s)}this._fireAfterExecute(o)})}_fireAfterExecute(e){this.fire("afterExecute",Pn(new Set(e)))}_checkEnabled(){let e=hf(this.editor.model.document.selection),t=e[0];if(!t)return!1;if(this._direction=="backward"||Cs(e)&&!Pi(e[0]))return!0;e=Vs(e),t=e[0];const i=Dt.first(t,{sameIndent:!0});return i?i.getAttribute("listType")==t.getAttribute("listType"):!1}}function hf(n){const e=Array.from(n.getSelectedBlocks()),t=e.findIndex(i=>!be(i));return t!=-1&&(e.length=t),e}class Go extends O{constructor(e,t,i={}){super(e),h(this,"type"),h(this,"_listWalkerOptions"),this.type=t,this._listWalkerOptions=i.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,o=As(t),s=Array.from(i.selection.getSelectedBlocks()).filter(a=>t.schema.checkAttribute(a,"listType")||yl(a,t.schema)),r=e.forceValue!==void 0?!e.forceValue:this.value;t.change(a=>{if(r){const l=s[s.length-1],c=Qi(l,{direction:"forward"}),u=[];c.length>1&&u.push(...Lu(c[1],a)),u.push(...ya(s,a)),u.push(...xV(l,a)),this._fireAfterExecute(u)}else if((o||i.selection.isCollapsed)&&be(s[0])){const l=R1(o||s[0],this._listWalkerOptions);for(const c of l)a.setAttributes({...e.additionalAttributes,listType:this.type},c);this._fireAfterExecute(l)}else{const l=[];for(const c of s)if(!c.hasAttribute("listType"))!c.is("element","listItem")&&yl(c,t.schema)&&a.rename(c,"listItem"),a.setAttributes({...e.additionalAttributes,listIndent:0,listItemId:go.next(),listType:this.type},c),l.push(c);else for(const u of Vs(c,{withNested:!1}))u.getAttribute("listType")!=this.type&&(a.setAttributes({...e.additionalAttributes,listType:this.type},u),l.push(u));this._fireAfterExecute(l)}})}_fireAfterExecute(e){this.fire("afterExecute",Pn(new Set(e)))}_getValue(){const e=this.editor.model.document.selection,t=Array.from(e.getSelectedBlocks());if(!t.length)return!1;for(const i of t)if(i.getAttribute("listType")!=this.type)return!1;return!0}_checkEnabled(){const e=this.editor.model,t=e.schema,i=e.document.selection,o=Array.from(i.getSelectedBlocks());if(!o.length)return!1;if(this.value)return!0;for(const s of o)if(t.checkAttribute(s,"listType")||yl(s,t))return!0;return!1}}class df extends O{constructor(e,t){super(e),h(this,"_direction"),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute({shouldMergeOnBlocksContentLevel:e=!1}={}){const t=this.editor.model,i=t.document.selection,o=[];t.change(s=>{const{firstElement:r,lastElement:a}=this._getMergeSubjectElements(i,e),l=r.getAttribute("listIndent")||0,c=a.getAttribute("listIndent"),u=a.getAttribute("listItemId");if(l!=c){const d=CV(a);o.push(...mc([a,...d],s,{indentBy:l-c,expand:l{const t=Lu(this._getStartBlock(),e);this._fireAfterExecute(t)})}_fireAfterExecute(e){this.fire("afterExecute",Pn(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&be(t)&&!Pi(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return this._direction=="before"?e:e.nextSibling}}class EV extends w{static get pluginName(){return"ListUtils"}static get isOfficialPlugin(){return!0}expandListBlocksToCompleteList(e){return va(e)}isFirstBlockOfListItem(e){return Pi(e)}isListItemBlock(e){return be(e)}expandListBlocksToCompleteItems(e,t={}){return Vs(e,t)}isNumberedListType(e){return qr(e)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function SV(n){return n.is("element","ol")||n.is("element","ul")}function fc(n){return n.is("element","li")}function PV(n){let e=0,t=n.parent;for(;t;){if(fc(t))e++;else{const i=t.previousSibling;i&&fc(i)&&e++}t=t.parent}return e}function IV(n,e,t,i=B1(t,e)){return n.createAttributeElement(O1(t),null,{priority:2*e/100-100,id:i})}function VV(n,e,t){return n.createAttributeElement("li",null,{priority:(2*e+1)/100-100,id:t})}function O1(n){return n=="numbered"||n=="customNumbered"?"ol":"ul"}function B1(n,e){return`list-${n}-${e}`}function jt(n,e,t){const i=n.nodeBefore;if(be(i)){let o=i;for(const{node:s}of new Is(o,"backward"))if(o=s,t.has(o)||(t.add(o),e.has(i)))return;e.add(o)}else{const o=n.nodeAfter;be(o)&&e.add(o)}}function RV(n,e){let t=0,i=-1,o=null,s=!1;for(const{node:r}of n){const a=r.getAttribute("listIndent");if(a>t){let l;o===null?(o=a-t,l=t):(o>a&&(o=a),l=a-o),l>i+1&&(l=i+1),e.setAttribute("listIndent",l,r),s=!0,i=l}else o=null,t=a+1,i=a}return s}function OV(n,e,t){const i=new Set;let o=!1;for(const{node:s}of n){if(i.has(s))continue;let r=s.getAttribute("listType"),a=s.getAttribute("listItemId");if(e.has(a)&&(a=go.next()),e.add(a),s.is("element","listItem")){s.getAttribute("listItemId")!=a&&(t.setAttribute("listItemId",a,s),o=!0);continue}for(const l of Qi(s,{direction:"forward"}))i.add(l),l.getAttribute("listType")!=r&&(a=go.next(),r=l.getAttribute("listType")),l.getAttribute("listItemId")!=a&&(t.setAttribute("listItemId",a,l),o=!0)}return o}function BV(){return(n,e,t)=>{const{writer:i,schema:o}=t;if(!e.modelRange)return;const s=Array.from(e.modelRange.getItems({shallow:!0})).filter(d=>o.checkAttribute(d,"listItemId"));if(!s.length)return;const r=go.next(),a=PV(e.viewItem);let l=e.viewItem.parent&&e.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=s[0].getAttribute("listType");c&&(l=c);const u={listItemId:r,listIndent:a,listType:l};for(const d of s)d.hasAttribute("listItemId")||i.setAttributes(u,d);s.length>1&&s[1].getAttribute("listItemId")!=u.listItemId&&t.keepEmptyElement(s[0])}}function MV(n,e,t,i){return()=>{const a=n.document.differ.getChanges(),l=[],c=new Set,u=new Set,d=new Set;for(const m of a)if(m.type=="insert"&&m.name!="$text")jt(m.position,c,d),m.attributes.has("listItemId")?u.add(m.position.nodeAfter):jt(m.position.getShiftedBy(m.length),c,d);else if(m.type=="remove"&&m.attributes.has("listItemId"))jt(m.position,c,d);else if(m.type=="attribute"){const f=m.range.start.nodeAfter;t.includes(m.attributeKey)?(jt(m.range.start,c,d),m.attributeNewValue===null?(jt(m.range.start.getShiftedBy(1),c,d),s(f)&&l.push(f)):u.add(f)):be(f)&&s(f)&&l.push(f)}for(const m of c.values())l.push(...o(m,u));for(const m of new Set(l))e.reconvertItem(m)};function o(a,l){const c=[],u=new Set,d=[];for(const{node:m,previous:f}of new Is(a)){if(u.has(m))continue;const g=m.getAttribute("listIndent");f&>.includes(_)));const p=Qi(m,{direction:"forward"});for(const _ of p)u.add(_),(s(_,p)||r(_,d,l))&&c.push(_)}return c}function s(a,l){const c=e.mapper.toViewElement(a);if(!c)return!1;if(i.fire("checkElement",{modelElement:a,viewElement:c}))return!0;if(!a.is("element","paragraph")&&!a.is("element","listItem"))return!1;const u=L1(a,t,l);return u&&c.is("element","p")?!0:!!(!u&&c.is("element","span"))}function r(a,l,c){if(c.has(a))return!1;const u=e.mapper.toViewElement(a);let d=l.length-1;for(let m=u.parent;!m.is("editableElement");m=m.parent){const f=fc(m),g=SV(m);if(!g&&!f)continue;const p=`checkAttributes:${f?"item":"list"}`;if(i.fire(p,{viewElement:m,modelAttributes:l[d]}))break;if(g&&(d--,d<0))return!1}return!0}}function ff(n,e,t,{dataPipeline:i}={}){const o=$V(n);return(s,r,a)=>{const{writer:l,mapper:c,consumable:u}=a,d=r.item;if(!n.includes(r.attributeKey)||!o(d,u))return;const m=FV(d,c,t);M1(m,l,c),zV(m,l);const f=DV(d,m,e,l,{dataPipeline:i});HV(d,f,e,l)}}function LV(n){return(e,t,i)=>{const{writer:o,mapper:s}=i,r=e.name.split(":")[1];if(!n.checkAttribute(r,"listItemId"))return;const a=s.toViewPosition(t.position),l=t.position.getShiftedBy(t.length),c=s.toViewPosition(l,{isPhantom:!0}),u=o.createRange(a,c).getTrimmed().end.nodeBefore;/* istanbul ignore next -- @preserve */u&&M1(u,o,s)}}function gf(n,{dataPipeline:e}={}){return(t,{writer:i})=>{if(!L1(t,n))return null;if(!e)return i.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=i.createContainerElement("p");return i.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function FV(n,e,t){const i=t.createRangeOn(n);return e.toViewRange(i).getTrimmed().end.nodeBefore}function NV(n,e){return(t,i)=>{if(i.modelPosition.offset>0)return;const o=i.modelPosition.parent;if(!be(o)||!n.some(c=>c.scope=="itemMarker"&&c.canInjectMarkerIntoElement&&c.canInjectMarkerIntoElement(o)))return;const s=i.mapper.toViewElement(o),r=e.createRangeIn(s),a=r.getWalker();let l=r.start;for(const{item:c}of a){if(c.is("element")&&i.mapper.toModelElement(c)||c.is("$textProxy"))break;c.is("element")&&c.getCustomProperty("listItemMarker")&&(l=e.createPositionAfter(c),a.skip(({previousPosition:u})=>!u.isEqual(l)))}i.viewPosition=l}}function M1(n,e,t){for(;n.parent.is("attributeElement")&&n.parent.getCustomProperty("listItemWrapper");)e.unwrap(e.createRangeOn(n),n.parent);const i=[];o(e.createPositionBefore(n).getWalker({direction:"backward"})),o(e.createRangeIn(n).getWalker());for(const s of i)e.remove(s);function o(s){for(const{item:r}of s){if(r.is("element")&&t.toModelElement(r))break;r.is("element")&&r.getCustomProperty("listItemMarker")&&i.push(r)}}}function DV(n,e,t,i,{dataPipeline:o}){let s=i.createRangeOn(e);if(!Pi(n))return s;for(const r of t){if(r.scope!="itemMarker")continue;const a=r.createElement(i,n,{dataPipeline:o});if(!a||(i.setCustomProperty("listItemMarker",!0,a),r.canInjectMarkerIntoElement&&r.canInjectMarkerIntoElement(n)?i.insert(i.createPositionAt(e,0),a):(i.insert(s.start,a),s=i.createRange(i.createPositionBefore(a),i.createPositionAfter(e))),!r.createWrapperElement||!r.canWrapElement))continue;const l=r.createWrapperElement(i,n,{dataPipeline:o});i.setCustomProperty("listItemWrapper",!0,l),r.canWrapElement(n)?s=i.wrap(s,l):(s=i.wrap(i.createRangeOn(a),l),s=i.createRange(s.start,i.createPositionAfter(e)))}return s}function zV(n,e){let t=n.parent;for(;t.is("attributeElement")&&["ul","ol","li"].includes(t.name);){const i=t.parent;e.unwrap(e.createRangeOn(n),t),t=i}}function HV(n,e,t,i){if(!n.hasAttribute("listIndent"))return;const o=n.getAttribute("listIndent");let s=n;for(let r=o;r>=0;r--){const a=VV(i,r,s.getAttribute("listItemId")),l=IV(i,r,s.getAttribute("listType"));for(const c of t)(c.scope=="list"||c.scope=="item")&&s.hasAttribute(c.attributeName)&&c.setAttributeOnDowncast(i,s.getAttribute(c.attributeName),c.scope=="list"?l:a);if(e=i.wrap(e,a),e=i.wrap(e,l),r==0||(s=Dt.first(s,{lowerIndent:!0}),!s))break}}function $V(n){return(e,t)=>{const i=[];for(const o of n)e.hasAttribute(o)&&i.push(`attribute:${o}`);return i.every(o=>t.test(e,o)!==!1)?(i.forEach(o=>t.consume(e,o)),!0):!1}}function L1(n,e,t=po(n)){if(!be(n))return!1;for(const i of n.getAttributeKeys())if(!(i.startsWith("selection:")||i=="htmlEmptyBlock")&&!e.includes(i))return!1;return t.length<2}const br=["listType","listIndent","listItemId"];class xs extends w{constructor(e){super(e),h(this,"_downcastStrategies",[]),e.config.define("list.multiBlock",!0)}static get pluginName(){return"ListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Ao,en,EV,pt]}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new b("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:br}),i?(t.schema.extend("$container",{allowAttributesOf:"$listItem"}),t.schema.extend("$block",{allowAttributesOf:"$listItem"}),t.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):t.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const o of br)t.schema.setAttributeProperties(o,{copyOnReplace:!0});e.commands.add("numberedList",new Go(e,"numbered")),e.commands.add("bulletedList",new Go(e,"bulleted")),e.commands.add("customNumberedList",new Go(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new Go(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new uf(e,"forward")),e.commands.add("outdentList",new uf(e,"backward")),e.commands.add("splitListItemBefore",new mf(e,"before")),e.commands.add("splitListItemAfter",new mf(e,"after")),i&&(e.commands.add("mergeListItemBackward",new df(e,"backward")),e.commands.add("mergeListItemForward",new df(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}getListAttributeNames(){return[...br,...this._downcastStrategies.map(e=>e.attributeName)]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",(o,s)=>{const r=e.model.document.selection;As(e.model)||e.model.change(()=>{const a=r.getFirstPosition();if(r.isCollapsed&&s.direction=="backward"){if(!a.isAtStart)return;const l=a.parent;if(!be(l))return;if(!Dt.first(l,{sameAttributes:"listType",sameIndent:!0})&&l.getAttribute("listIndent")===0)cf(l)||e.execute("splitListItemAfter"),e.execute("outdentList");else{if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:pf(e.model,"backward")})}s.preventDefault(),o.stop()}else{if(r.isCollapsed&&!r.getLastPosition().isAtEnd||!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:pf(e.model,"forward")}),s.preventDefault(),o.stop()}})},{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,o=i.get("enter");this.listenTo(e.editing.view.document,"enter",(s,r)=>{const a=t.document,l=a.selection.getFirstPosition().parent;if(a.selection.isCollapsed&&be(l)&&l.isEmpty&&!r.isSoft){const c=Pi(l),u=cf(l);c&&u?(e.execute("outdentList"),r.preventDefault(),s.stop()):c&&!u?(e.execute("splitListItemAfter"),r.preventDefault(),s.stop()):u&&(e.execute("splitListItemBefore"),r.preventDefault(),s.stop())}},{context:"li"}),this.listenTo(o,"afterExecute",()=>{const s=i.get("splitListItemBefore");if(s.refresh(),!s.isEnabled)return;const r=e.model.document.selection.getLastPosition().parent;po(r).length===2&&s.execute()})}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",(t,i)=>{const o=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(o).isEnabled&&(e.execute(o),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),o=e.config.get("list.multiBlock"),s=o?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(a,{writer:l})=>l.createElement(s,{listType:""})}).elementToElement({view:"p",model:(a,{writer:l})=>a.parent&&a.parent.is("element","li")?l.createElement(s,{listType:""}):null,converterPriority:"high"}).add(a=>{a.on("element:li",BV())}),o||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:s,view:gf(i),converterPriority:"high"}).add(a=>{a.on("attribute",ff(i,this._downcastStrategies,t)),a.on("remove",LV(t.schema))}),e.conversion.for("dataDowncast").elementToElement({model:s,view:gf(i,{dataPipeline:!0}),converterPriority:"high"}).add(a=>{a.on("attribute",ff(i,this._downcastStrategies,t,{dataPipeline:!0}))});const r=NV(this._downcastStrategies,e.editing.view);e.editing.mapper.on("modelToViewPosition",r),e.data.mapper.on("modelToViewPosition",r),this.listenTo(t.document,"change:data",MV(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",(a,{viewElement:l,modelAttributes:c})=>{l.id!=c.listItemId&&(a.return=!0,a.stop())}),this.on("checkAttributes:list",(a,{viewElement:l,modelAttributes:c})=>{(l.name!=O1(c.listType)||l.id!=B1(c.listType,c.listIndent))&&(a.return=!0,a.stop())})}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer(i=>WV(e,i,t,this)),this.on("postFixer",(i,{listNodes:o,writer:s})=>{i.return=RV(o,s)||i.return},{priority:"high"}),this.on("postFixer",(i,{listNodes:o,writer:s,seenIds:r})=>{i.return=OV(o,r,s)||i.return},{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",jV(e),{priority:"high"}),this.listenTo(t,"outputTransformation",(i,o)=>{e.change(s=>{const r=Array.from(o.content.getChildren()),a=r[r.length-1];if(r.length>1&&a.is("element")&&a.isEmpty&&r.slice(0,-1).every(be)&&s.remove(a),o.method=="copy"||o.method=="cut"){const l=Array.from(o.content.getChildren());Cs(l)&&ya(l,s)}})})}_setupAccessibilityIntegration(){const e=this.editor,t=e.t;e.accessibility.addKeystrokeInfoGroup({id:"list",label:t("Keystrokes that can be used in a list"),keystrokes:[{label:t("Increase list item indent"),keystroke:"Tab"},{label:t("Decrease list item indent"),keystroke:"Shift+Tab"}]})}}function WV(n,e,t,i){const o=n.document.differ.getChanges(),s=new Set,r=new Set,a=i.editor.config.get("list.multiBlock");let l=!1;for(const u of o){if(u.type=="insert"&&u.name!="$text"){const d=u.position.nodeAfter;if(!n.schema.checkAttribute(d,"listItemId"))for(const m of Array.from(d.getAttributeKeys()))t.includes(m)&&(e.removeAttribute(m,d),l=!0);jt(u.position,r,s),u.attributes.has("listItemId")||jt(u.position.getShiftedBy(u.length),r,s);for(const{item:m,previousPosition:f}of n.createRangeIn(d))be(m)&&jt(f,r,s)}else u.type=="remove"?jt(u.position,r,s):u.type=="attribute"&&t.includes(u.attributeKey)&&(jt(u.range.start,r,s),u.attributeNewValue===null&&jt(u.range.start.getShiftedBy(1),r,s));if(!a&&u.type=="attribute"&&br.includes(u.attributeKey)){const d=u.range.start.nodeAfter;u.attributeNewValue===null&&d&&d.is("element","listItem")?(e.rename(d,"paragraph"),l=!0):u.attributeOldValue===null&&d&&d.is("element")&&d.name!="listItem"&&(e.rename(d,"listItem"),l=!0)}}const c=new Set;for(const u of r.values())l=i.fire("postFixer",{listNodes:new kV(u),listHead:u,writer:e,seenIds:c})||l;return l}function jV(n){return(e,[t,i])=>{const o=t.is("documentFragment")?Array.from(t.getChildren()):[t];if(!o.length)return;const s=(i?n.createSelection(i):n.document.selection).getFirstPosition();let r;if(be(s.parent))r=s.parent;else if(be(s.nodeBefore)&&be(s.nodeAfter))r=s.nodeBefore;else return;n.change(a=>{const l=r.getAttribute("listType"),c=r.getAttribute("listIndent"),u=o[0].getAttribute("listIndent")||0,d=Math.max(c-u,0);for(const m of o){const f=be(m);r.is("element","listItem")&&m.is("element","paragraph")&&a.rename(m,"listItem"),a.setAttributes({listIndent:(f?m.getAttribute("listIndent"):0)+d,listItemId:f?m.getAttribute("listItemId"):go.next(),listType:l},m)}})}}function pf(n,e){const t=n.document.selection;if(!t.isCollapsed)return!As(n);if(e==="forward")return!0;const i=t.getFirstPosition().parent,o=i.previousSibling;return n.schema.isObject(o)?!1:o.isEmpty?!0:Cs([i,o])}function gc(n,e,t,i){n.ui.componentFactory.add(e,()=>{const o=wf(P,n,e,t,i);return o.set({tooltip:!0,isToggleable:!0}),o}),n.ui.componentFactory.add(`menuBar:${e}`,()=>{const o=wf(ve,n,e,t,i);return o.set({role:"menuitemcheckbox",isToggleable:!0}),o})}function wf(n,e,t,i,o){const s=e.commands.get(t),r=new n(e.locale);return r.set({label:i,icon:o}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.on("execute",()=>{e.execute(t),e.editing.view.focus()}),r}class UV extends w{static get pluginName(){return"ListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||gc(this.editor,"numberedList",e("Numbered List"),su),this.editor.ui.componentFactory.has("bulletedList")||gc(this.editor,"bulletedList",e("Bulleted List"),ou)}}class qV extends w{static get requires(){return[xs,UV]}static get pluginName(){return"List"}static get isOfficialPlugin(){return!0}}class GV extends O{refresh(){const e=this._getValue();this.value=e,this.isEnabled=e!=null}execute({startIndex:e=1}={}){const t=this.editor.model,i=t.document;let o=Array.from(i.selection.getSelectedBlocks()).filter(s=>be(s)&&qr(s.getAttribute("listType")));o=va(o),t.change(s=>{for(const r of o)s.setAttribute("listStart",e>=0?e:1,r)})}_getValue(){const e=this.editor.model.document,t=ae(e.selection.getSelectedBlocks());return t&&be(t)&&qr(t.getAttribute("listType"))?t.getAttribute("listStart"):null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const F1={},N1={},D1={},z1=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:n,typeAttribute:e,listType:t}of z1)F1[n]=t,N1[n]=e,e&&(D1[e]=n);function H1(){return z1.map(n=>n.listStyle)}function Fu(n){return F1[n]||null}function $1(n){return D1[n]||null}function pc(n){return N1[n]||null}function KV(n){switch(n){case"lower-alpha":return"lower-latin";case"upper-alpha":return"upper-latin";default:return n}}class ZV extends O{constructor(e,t,i){super(e),h(this,"defaultType"),h(this,"_supportedTypes"),this.defaultType=t,this._supportedTypes=i}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document;t.change(o=>{this._tryToConvertItemsToList(e);let s=Array.from(i.selection.getSelectedBlocks()).filter(r=>r.hasAttribute("listType"));if(s.length){s=va(s);for(const r of s)o.setAttribute("listStyle",e.type||this.defaultType,r)}})}isStyleTypeSupported(e){return this._supportedTypes?this._supportedTypes.includes(e):!0}_getValue(){const e=ae(this.editor.model.document.selection.getSelectedBlocks());return be(e)?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=Fu(e.type);if(!t)return;const i=this.editor,o=`${t}List`;i.commands.get(o).value||i.execute(o)}}class JV extends O{refresh(){const e=this._getValue();this.value=e,this.isEnabled=e!=null}execute(e={}){const t=this.editor.model,i=t.document;let o=Array.from(i.selection.getSelectedBlocks()).filter(s=>be(s)&&s.getAttribute("listType")=="numbered");o=va(o),t.change(s=>{for(const r of o)s.setAttribute("listReversed",!!e.reversed,r)})}_getValue(){const e=this.editor.model.document,t=ae(e.selection.getSelectedBlocks());return be(t)&&t.getAttribute("listType")=="numbered"?t.getAttribute("listReversed"):null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function bf(n){return(e,t,i)=>{const{writer:o,schema:s,consumable:r}=i;if(r.test(t.viewItem,n.viewConsumables)===!1)return;t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor));let a=!1;for(const l of t.modelRange.getItems({shallow:!0}))s.checkAttribute(l,n.attributeName)&&n.appliesToListItem(l)&&(l.hasAttribute(n.attributeName)||(o.setAttribute(n.attributeName,n.getAttributeOnUpcast(t.viewItem),l),a=!0));a&&r.consume(t.viewItem,n.viewConsumables)}}class QV extends w{static get pluginName(){return"ListPropertiesUtils"}static get isOfficialPlugin(){return!0}getAllSupportedStyleTypes(){return H1()}getListTypeFromListStyleType(e){return Fu(e)}getListStyleTypeFromTypeAttribute(e){return $1(e)}getTypeAttributeFromListStyleType(e){return pc(e)}}function W1(n){const{startIndex:e,reversed:t,styles:i}=n;return{styles:YV(i),startIndex:e||!1,reversed:t||!1}}function YV(n){const e={listTypes:["bulleted","numbered"],useAttribute:!1};return n===!0||(n?Array.isArray(n)||typeof n=="string"?e.listTypes=he(n):(e.listTypes=n.listTypes?he(n.listTypes):e.listTypes,e.useAttribute=!!n.useAttribute,n.listStyleTypes&&(e.listStyleTypes=n.listStyleTypes)):e.listTypes=[]),e}const Ho="default";class XV extends w{static get requires(){return[xs,QV]}static get pluginName(){return"ListPropertiesEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("list.properties",{styles:!0,startIndex:!1,reversed:!1})}init(){const e=this.editor,t=e.model,i=e.plugins.get(xs),o=e.config.get("list.properties"),s=e7(o);for(const r of s)r.addCommand(e),t.schema.extend("$listItem",{allowAttributes:r.attributeName}),i.registerDowncastStrategy({scope:"list",attributeName:r.attributeName,setAttributeOnDowncast(a,l,c){r.setAttributeOnDowncast(a,l,c)}});e.conversion.for("upcast").add(r=>{for(const a of s)r.on("element:ol",bf(a)),r.on("element:ul",bf(a))}),i.on("checkAttributes:list",(r,{viewElement:a,modelAttributes:l})=>{for(const c of s)c.getAttributeOnUpcast(a)!=l[c.attributeName]&&(r.return=!0,r.stop())}),this.listenTo(e.commands.get("indentList"),"afterExecute",(r,a)=>{t.change(l=>{for(const c of a)for(const u of s)u.appliesToListItem(c)&&l.setAttribute(u.attributeName,u.defaultValue,c)})}),i.on("postFixer",(r,{listNodes:a,writer:l})=>{for(const{node:c}of a)for(const u of s)u.hasValidAttribute(c)||(u.appliesToListItem(c)?l.setAttribute(u.attributeName,u.defaultValue,c):l.removeAttribute(u.attributeName,c),r.return=!0)}),i.on("postFixer",(r,{listNodes:a,writer:l})=>{for(const{node:c,previousNodeInList:u}of a)if(u&&u.getAttribute("listType")==c.getAttribute("listType"))for(const d of s){const{attributeName:m}=d;if(!d.appliesToListItem(c))continue;const f=u.getAttribute(m);c.getAttribute(m)!=f&&(l.setAttribute(m,f,c),r.return=!0)}})}}function e7(n){const e=[],t=W1(n);if(n.styles){const i=t.styles.useAttribute;e.push({attributeName:"listStyle",defaultValue:Ho,viewConsumables:{styles:"list-style-type"},addCommand(o){let s=H1();i&&(s=s.filter(r=>!!pc(r))),o.commands.add("listStyle",new ZV(o,Ho,s))},appliesToListItem(o){return o.getAttribute("listType")=="numbered"||o.getAttribute("listType")=="bulleted"},hasValidAttribute(o){if(!this.appliesToListItem(o))return!o.hasAttribute("listStyle");if(!o.hasAttribute("listStyle"))return!1;const s=o.getAttribute("listStyle");return s==Ho?!0:Fu(s)==o.getAttribute("listType")},setAttributeOnDowncast(o,s,r){if(s&&s!==Ho)if(i){const a=pc(s);if(a){o.setAttribute("type",a,r);return}}else{o.setStyle("list-style-type",s,r);return}o.removeStyle("list-style-type",r),o.removeAttribute("type",r)},getAttributeOnUpcast(o){const s=o.getStyle("list-style-type");if(s)return KV(s);const r=o.getAttribute("type");return r?$1(r):Ho}})}return n.reversed&&e.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(i){i.commands.add("listReversed",new JV(i))},appliesToListItem(i){return i.getAttribute("listType")=="numbered"},hasValidAttribute(i){return this.appliesToListItem(i)==i.hasAttribute("listReversed")},setAttributeOnDowncast(i,o,s){o?i.setAttribute("reversed","reversed",s):i.removeAttribute("reversed",s)},getAttributeOnUpcast(i){return i.hasAttribute("reversed")}}),n.startIndex&&e.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(i){i.commands.add("listStart",new GV(i))},appliesToListItem(i){return qr(i.getAttribute("listType"))},hasValidAttribute(i){return this.appliesToListItem(i)==i.hasAttribute("listStart")},setAttributeOnDowncast(i,o,s){o==0||o>1?i.setAttribute("start",o,s):i.removeAttribute("start",s)},getAttributeOnUpcast(i){const o=i.getAttribute("start");return o>=0?o:1}}),e}class j1 extends A{constructor(e,{enabledProperties:t,styleButtonViews:i,styleGridAriaLabel:o}){super(e),h(this,"children"),h(this,"stylesView",null),h(this,"additionalPropertiesCollapsibleView",null),h(this,"startIndexFieldView",null),h(this,"reversedSwitchButtonView",null),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"focusables",new Ie),h(this,"focusCycler");const s=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new Ae({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),i&&i.length?(this.stylesView=this._createStylesView(i,o),this.children.add(this.stylesView)):s.push("ck-list-properties_without-styles"),(t.startIndex||t.reversed)&&(this._addNumberedListPropertyViews(t),s.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:s},children:this.children})}render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const e of this.stylesView.children)this.stylesView.focusTracker.add(e.element);vo({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>I.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const e=t=>t.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(e,t){const i=new A(this.locale);return i.children=i.createCollection(),i.children.addMany(e),i.setTemplate({tag:"div",attributes:{"aria-label":t,class:["ck","ck-list-styles-list"]},children:i.children}),i.children.delegate("execute").to(this),i.focus=function(){for(const o of this.children)if(o instanceof P&&o.isOn){o.focus();return}this.children.first.focus()},i.focusTracker=new ee,i.keystrokes=new te,i.render(),i.keystrokes.listenTo(i.element),i}_addNumberedListPropertyViews(e){const t=this.locale.t,i=[];e.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),i.push(this.startIndexFieldView)),e.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),i.push(this.reversedSwitchButtonView)),this.stylesView?(this.additionalPropertiesCollapsibleView=new mu(this.locale,i),this.additionalPropertiesCollapsibleView.set({label:t("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(i,"isEnabled",(...o)=>o.some(s=>s)),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",(o,s,r)=>{r||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)}),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(i)}_createStartIndexField(){const e=this.locale.t,t=new Te(this.locale,eb);return t.set({label:e("Start at"),class:"ck-numbered-list-properties__start-index"}),t.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),t.fieldView.on("input",()=>{const i=t.fieldView.element,o=i.valueAsNumber;if(Number.isNaN(o)){t.errorText=e("Invalid start index value.");return}i.checkValidity()?this.fire("listStart",{startIndex:o}):t.errorText=e("Start index must be greater than 0.")}),t}_createReversedSwitchButton(){const e=this.locale.t,t=new Ji(this.locale);return t.set({withText:!0,label:e("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),t.delegate("execute").to(this,"listReversed"),t}}class t7 extends w{static get pluginName(){return"ListPropertiesUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=e.config.get("list.properties"),o=W1(i),s=o.styles.listTypes;if(s.includes("bulleted")){const r=[{label:t("Toggle the disc list style"),tooltip:t("Disc"),type:"disc",icon:zC},{label:t("Toggle the circle list style"),tooltip:t("Circle"),type:"circle",icon:FC},{label:t("Toggle the square list style"),tooltip:t("Square"),type:"square",icon:WC}],a=t("Bulleted List"),l=t("Bulleted list styles toolbar"),c="bulletedList";e.ui.componentFactory.add(c,_f({editor:e,normalizedConfig:o,parentCommandName:c,buttonLabel:a,buttonIcon:ou,styleGridAriaLabel:l,styleDefinitions:r})),e.ui.componentFactory.add(`menuBar:${c}`,vf({editor:e,normalizedConfig:o,parentCommandName:c,buttonLabel:a,styleGridAriaLabel:l,styleDefinitions:r}))}if(s.includes("numbered")||i.startIndex||i.reversed){const r=[{label:t("Toggle the decimal list style"),tooltip:t("Decimal"),type:"decimal",icon:DC},{label:t("Toggle the decimal with leading zero list style"),tooltip:t("Decimal with leading zero"),type:"decimal-leading-zero",icon:NC},{label:t("Toggle the lower–roman list style"),tooltip:t("Lower–roman"),type:"lower-roman",icon:$C},{label:t("Toggle the upper–roman list style"),tooltip:t("Upper-roman"),type:"upper-roman",icon:UC},{label:t("Toggle the lower–latin list style"),tooltip:t("Lower-latin"),type:"lower-latin",icon:HC},{label:t("Toggle the upper–latin list style"),tooltip:t("Upper-latin"),type:"upper-latin",icon:jC}],a=t("Numbered List"),l=t("Numbered list styles toolbar"),c="numberedList";e.ui.componentFactory.add(c,_f({editor:e,normalizedConfig:o,parentCommandName:c,buttonLabel:a,buttonIcon:su,styleGridAriaLabel:l,styleDefinitions:r})),s.includes("numbered")&&e.ui.componentFactory.add(`menuBar:${c}`,vf({editor:e,normalizedConfig:o,parentCommandName:c,buttonLabel:a,styleGridAriaLabel:l,styleDefinitions:r}))}}}function _f({editor:n,normalizedConfig:e,parentCommandName:t,buttonLabel:i,buttonIcon:o,styleGridAriaLabel:s,styleDefinitions:r}){const a=n.commands.get(t);return l=>{const c=Ee(l,Xi),u=c.buttonView;return c.bind("isEnabled").to(a),c.class="ck-list-styles-dropdown",u.on("execute",()=>{n.execute(t),n.editing.view.focus()}),u.set({label:i,icon:o,tooltip:!0,isToggleable:!0}),u.bind("isOn").to(a,"value",d=>!!d),c.once("change:isOpen",()=>{const d=i7({editor:n,normalizedConfig:e,dropdownView:c,parentCommandName:t,styleGridAriaLabel:s,styleDefinitions:r});c.panelView.children.add(d)}),c.on("execute",()=>{n.editing.view.focus()}),c}}function U1({editor:n,listStyleCommand:e,parentCommandName:t}){const i=n.locale,o=n.commands.get(t);return({label:s,type:r,icon:a,tooltip:l})=>{const c=new P(i);return c.set({label:s,icon:a,tooltip:l}),c.bind("isOn").to(e,"value",u=>u===r),c.on("execute",()=>{o.value?e.value===r?n.execute(t):e.value!==r&&n.execute("listStyle",{type:r}):n.model.change(()=>{n.execute("listStyle",{type:r})})}),c}}function i7({editor:n,normalizedConfig:e,dropdownView:t,parentCommandName:i,styleDefinitions:o,styleGridAriaLabel:s}){const r=n.locale,a={...e,...i!="numberedList"?{startIndex:!1,reversed:!1}:null},l=i.replace("List","");let c=null;if(e.styles.listTypes.includes(l)){const d=n.commands.get("listStyle"),m=U1({editor:n,parentCommandName:i,listStyleCommand:d}),f=e.styles.listStyleTypes;let g=o;if(f){const _=f[l];_&&(g=o.filter(v=>_.includes(v.type)))}const p=q1(d);c=g.filter(p).map(m)}const u=new j1(r,{styleGridAriaLabel:s,enabledProperties:a,styleButtonViews:c});if(e.styles.listTypes.includes(l)&&ga(t,()=>u.stylesView.children.find(d=>d.isOn)),a.startIndex){const d=n.commands.get("listStart");u.startIndexFieldView.bind("isEnabled").to(d),u.startIndexFieldView.fieldView.bind("value").to(d),u.on("listStart",(m,f)=>n.execute("listStart",f))}if(a.reversed){const d=n.commands.get("listReversed");u.reversedSwitchButtonView.bind("isEnabled").to(d),u.reversedSwitchButtonView.bind("isOn").to(d,"value",m=>!!m),u.on("listReversed",()=>{const m=d.value;n.execute("listReversed",{reversed:!m})})}return u.delegate("execute").to(t),u}function vf({editor:n,normalizedConfig:e,parentCommandName:t,buttonLabel:i,styleGridAriaLabel:o,styleDefinitions:s}){return r=>{const a=new Tt(r),l=n.commands.get(t),c=n.commands.get("listStyle"),u=q1(c),d=U1({editor:n,parentCommandName:t,listStyleCommand:c}),m=e.styles.listStyleTypes;let f=s;if(m){const _=l.type,v=m[_];v&&(f=s.filter(E=>v.includes(E.type)))}const g=f.filter(u).map(d),p=new j1(r,{styleGridAriaLabel:o,enabledProperties:{...e,startIndex:!1,reversed:!1},styleButtonViews:g});return p.delegate("execute").to(a),a.buttonView.set({label:i,icon:t==="bulletedList"?ou:su}),a.panelView.children.add(p),a.bind("isEnabled").to(l,"isEnabled"),a.on("execute",()=>{n.editing.view.focus()}),a}}function q1(n){return typeof n.isStyleTypeSupported=="function"?e=>n.isStyleTypeSupported(e.type):()=>!0}class n7 extends w{static get requires(){return[XV,t7]}static get pluginName(){return"ListProperties"}static get isOfficialPlugin(){return!0}}class o7 extends O{constructor(e){super(e),this.on("execute",()=>{this.refresh()},{priority:"highest"})}refresh(){const e=this._getSelectedItems();this.value=this._getValue(e),this.isEnabled=!!e.length}execute(e={}){this.editor.model.change(t=>{const i=this._getSelectedItems(),o=e.forceValue===void 0?!this._getValue(i):e.forceValue;for(const s of i)o?t.setAttribute("todoListChecked",!0,s):t.removeAttribute("todoListChecked",s)})}_getValue(e){return e.every(t=>t.getAttribute("todoListChecked"))}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),o=i.start.parent,s=[];t.checkAttribute(o,"todoListChecked")&&s.push(...po(o));for(const r of i.getItems({shallow:!0}))t.checkAttribute(r,"todoListChecked")&&!s.includes(r)&&s.push(...po(r));return s}}class s7 extends ui{constructor(){super(...arguments),h(this,"domEventType",["change"])}onDomEvent(e){if(e.target){const t=this.view.domConverter.mapDomToView(e.target);t&&t.is("element","input")&&t.getAttribute("type")=="checkbox"&&t.findAncestor({classes:"todo-list__label"})&&this.fire("todoCheckboxChange",e)}}}const r7=na("Ctrl+Enter");class a7 extends w{static get pluginName(){return"TodoListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[xs]}init(){const e=this.editor,t=e.model,i=e.editing,o=e.plugins.get(xs),s=e.config.get("list.multiBlock")?"paragraph":"listItem";e.commands.add("todoList",new Go(e,"todo")),e.commands.add("checkTodoList",new o7(e)),i.view.addObserver(s7),t.schema.extend("$listItem",{allowAttributes:"todoListChecked"}),t.schema.addAttributeCheck(r=>{const a=r.last;if(!a.getAttribute("listItemId")||a.getAttribute("listType")!="todo")return!1},"todoListChecked"),e.conversion.for("upcast").add(r=>{r.on("element:input",c7()),r.on("element:li",l7(),{priority:"low"}),r.on("element:label",kl({name:"label",classes:"todo-list__label"})),r.on("element:label",kl({name:"label",classes:["todo-list__label","todo-list__label_without-description"]})),r.on("element:span",kl({name:"span",classes:"todo-list__label__description"})),r.on("element:ul",u7({name:"ul",classes:"todo-list"}))}),e.conversion.for("downcast").elementToElement({model:s,view:(r,{writer:a})=>{if(ir(r,o.getListAttributeNames()))return a.createContainerElement("span",{class:"todo-list__label__description"})},converterPriority:"highest"}),o.registerDowncastStrategy({scope:"list",attributeName:"listType",setAttributeOnDowncast(r,a,l){a=="todo"?r.addClass("todo-list",l):r.removeClass("todo-list",l)}}),o.registerDowncastStrategy({scope:"itemMarker",attributeName:"todoListChecked",createElement(r,a,{dataPipeline:l}){if(a.getAttribute("listType")!="todo")return null;const c=r.createUIElement("input",{type:"checkbox",...a.getAttribute("todoListChecked")?{checked:"checked"}:null,...l?{disabled:"disabled"}:{tabindex:"-1"}});if(l)return c;const u=r.createContainerElement("span",{contenteditable:"false"},c);return u.getFillerOffset=()=>null,u},canWrapElement(r){return ir(r,o.getListAttributeNames())},createWrapperElement(r,a,{dataPipeline:l}){const c=["todo-list__label"];return ir(a,o.getListAttributeNames())||c.push("todo-list__label_without-description"),r.createAttributeElement(l?"label":"span",{class:c.join(" ")})}}),o.on("checkElement",(r,{modelElement:a,viewElement:l})=>{const c=ir(a,o.getListAttributeNames());l.hasClass("todo-list__label__description")!=c&&(r.return=!0,r.stop())}),o.on("checkElement",(r,{modelElement:a,viewElement:l})=>{const c=a.getAttribute("listType")=="todo"&&Pi(a);let u=!1;const d=e.editing.view.createPositionBefore(l).getWalker({direction:"backward"});for(const{item:m}of d){if(m.is("element")&&e.editing.mapper.toModelElement(m))break;m.is("element","input")&&m.getAttribute("type")=="checkbox"&&(u=!0)}u!=c&&(r.return=!0,r.stop())}),o.on("postFixer",(r,{listNodes:a,writer:l})=>{for(const{node:c,previousNodeInList:u}of a){if(!u||u.getAttribute("listItemId")!=c.getAttribute("listItemId"))continue;const d=u.hasAttribute("todoListChecked"),m=c.hasAttribute("todoListChecked");m&&!d?(l.removeAttribute("todoListChecked",c),r.return=!0):!m&&d&&(l.setAttribute("todoListChecked",!0,c),r.return=!0)}}),t.document.registerPostFixer(r=>{const a=t.document.differ.getChanges();let l=!1;for(const c of a)if(c.type=="attribute"&&c.attributeKey=="listType"){const u=c.range.start.nodeAfter;c.attributeOldValue=="todo"&&u.hasAttribute("todoListChecked")&&(r.removeAttribute("todoListChecked",u),l=!0)}else if(c.type=="insert"&&c.name!="$text")for(const{item:u}of r.createRangeOn(c.position.nodeAfter))u.is("element")&&u.getAttribute("listType")!="todo"&&u.hasAttribute("todoListChecked")&&(r.removeAttribute("todoListChecked",u),l=!0);return l}),this.listenTo(i.view.document,"keydown",(r,a)=>{yn(a)===r7&&(e.execute("checkTodoList"),r.stop())},{priority:"high"}),this.listenTo(i.view.document,"todoCheckboxChange",(r,a)=>{const l=a.target;if(!l||!l.is("element","input"))return;const c=i.view.createPositionAfter(l),u=i.mapper.toModelPosition(c).parent;u&&be(u)&&u.getAttribute("listType")=="todo"&&this._handleCheckmarkChange(u)}),this.listenTo(i.view.document,"arrowKey",d7(t,e.locale),{context:"$text"}),this.listenTo(i.mapper,"viewToModelPosition",(r,a)=>{const l=a.viewPosition.parent,c=l.is("attributeElement","li")&&a.viewPosition.offset==0,u=yf(l)&&a.viewPosition.offset<=1,d=l.is("element","span")&&l.getAttribute("contenteditable")=="false"&&yf(l.parent);if(!c&&!u&&!d)return;const m=a.modelPosition.nodeAfter;m&&m.getAttribute("listType")=="todo"&&(a.modelPosition=t.createPositionAt(m,0))},{priority:"low"}),this._initAriaAnnouncements()}_handleCheckmarkChange(e){const t=this.editor,i=t.model,o=Array.from(i.document.selection.getRanges());i.change(s=>{s.setSelection(e,"end"),t.execute("checkTodoList"),s.setSelection(o)})}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor;let o=null;t&&e.document.selection.on("change:range",()=>{const s=e.document.selection.focus.parent,r=kf(o),a=kf(s);r&&!a?t.ariaLiveAnnouncer.announce(i("Leaving a to-do list")):!r&&a&&t.ariaLiveAnnouncer.announce(i("Entering a to-do list")),o=s})}}function l7(){return(n,e,t)=>{const{writer:i,schema:o}=t;if(!e.modelRange)return;const s=Array.from(e.modelRange.getItems({shallow:!0})).filter(r=>r.getAttribute("listType")==="todo"&&o.checkAttribute(r,"listItemId")).reduce((r,a)=>{const l=a.getAttribute("listItemId");return r.has(l)||r.set(l,po(a)),r},new Map);for(const[,r]of s.entries())if(r.some(a=>a.getAttribute("todoListChecked")))for(const a of r)i.setAttribute("todoListChecked",!0,a)}}function c7(){return(n,e,t)=>{const i=e.modelCursor,o=i.parent,s=e.viewItem;if(!t.consumable.test(s,{name:!0})||s.getAttribute("type")!="checkbox"||!i.isAtStart||!o.hasAttribute("listType"))return;t.consumable.consume(s,{name:!0});const r=t.writer;r.setAttribute("listType","todo",o),e.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,o),e.modelRange=r.createRange(i)}}function kl(n){const e=new ft(n);return(t,i,o)=>{const s=e.match(i.viewItem);s&&o.consumable.consume(i.viewItem,s.match)&&Object.assign(i,o.convertChildren(i.viewItem,i.modelCursor))}}function u7(n){const e=new ft(n);return(t,i,o)=>{const s=e.match(i.viewItem);if(!s)return;const r=s.match;r.name=!1,o.consumable.consume(i.viewItem,r)}}function ir(n,e){return(n.is("element","paragraph")||n.is("element","listItem"))&&n.getAttribute("listType")=="todo"&&Pi(n)&&h7(n,e)}function h7(n,e){for(const t of n.getAttributeKeys())if(!t.startsWith("selection:")&&!e.includes(t))return!1;return!0}function d7(n,e){return(t,i)=>{const o=oa(i.keyCode,e.contentLanguageDirection),s=n.schema,r=n.document.selection;if(!r.isCollapsed)return;const a=r.getFirstPosition(),l=a.parent;if(o=="right"&&a.isAtEnd){const c=s.getNearestSelectionRange(n.createPositionAfter(l),"forward");if(!c)return;const u=c.start.parent;u&&be(u)&&u.getAttribute("listType")=="todo"&&(n.change(d=>d.setSelection(c)),i.preventDefault(),i.stopPropagation(),t.stop())}else if(o=="left"&&a.isAtStart&&be(l)&&l.getAttribute("listType")=="todo"){const c=s.getNearestSelectionRange(n.createPositionBefore(l),"backward");if(!c)return;n.change(u=>u.setSelection(c)),i.preventDefault(),i.stopPropagation(),t.stop()}}}function yf(n){return!!n&&n.is("attributeElement")&&n.hasClass("todo-list__label")}function kf(n){return!n||!n.is("element","paragraph")&&!n.is("element","listItem")?!1:n.getAttribute("listType")=="todo"}class m7 extends w{static get pluginName(){return"TodoListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;gc(this.editor,"todoList",e("To-do List"),vA)}}class f7 extends w{static get requires(){return[a7,m7]}static get pluginName(){return"TodoList"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Cf={"(":")","[":"]","{":"}"};class g7 extends O{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,o=typeof e.mention=="string"?{id:e.mention}:e.mention,s=o.id,r=e.range||i.getFirstRange();if(!t.canEditAt(r))return;const a=e.text||s,l=G1({_text:a,id:s},o);if(!s.startsWith(e.marker))throw new b("mentioncommand-incorrect-id",this);t.change(c=>{const u=ri(i.getAttributes()),d=new Map(u.entries());d.set("mention",l);const m=t.insertContent(c.createText(a,d),r),f=m.start.nodeBefore,g=m.end.nodeAfter,p=g&&g.is("$text")&&g.data.startsWith(" ");let _=!1;if(f&&g&&f.is("$text")&&g.is("$text")){const v=f.data.slice(-1),E=v in Cf,M=E&&g.data.startsWith(Cf[v]);_=E&&M}!_&&!p&&t.insertContent(c.createText(" ",u),r.start.getShiftedBy(a.length))})}}class p7 extends w{static get pluginName(){return"MentionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",attributes:"data-mention",classes:"mention"},model:{key:"mention",value:o=>K1(o)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:b7}),e.conversion.for("downcast").add(w7),i.registerPostFixer(o=>y7(o,i,t.schema)),i.registerPostFixer(o=>k7(o,i)),i.registerPostFixer(o=>_7(o,i)),e.commands.add("mention",new g7(e))}}function G1(n,e){return Object.assign({uid:ze()},n,e||{})}function K1(n,e){const t=n.getAttribute("data-mention"),i=n.getChild(0);if(!i)return;const o={id:t,_text:i.data};return G1(o,e)}function w7(n){n.on("attribute:mention",(e,t,i)=>{const o=t.attributeNewValue;if(!t.item.is("$textProxy")||!o)return;const s=t.range.start;(s.textNode||s.nodeAfter).data!=o._text&&i.consumable.consume(t.item,e.name)},{priority:"highest"})}function b7(n,{writer:e}){if(!n)return;const t={class:"mention","data-mention":n.id},i={id:n.uid,priority:20};return e.createAttributeElement("span",t,i)}function _7(n,e){const t=e.selection,i=t.focus;return t.isCollapsed&&t.hasAttribute("mention")&&v7(i)?(n.removeSelectionAttribute("mention"),!0):!1}function v7(n){const e=n.isAtStart;return n.nodeBefore&&n.nodeBefore.is("$text")||e}function y7(n,e,t){const i=e.differ.getChanges();let o=!1;for(const s of i){if(s.type=="attribute")continue;const r=s.position;if(s.name=="$text"){const a=r.textNode&&r.textNode.nextSibling;o=un(r.textNode,n)||o,o=un(a,n)||o,o=un(r.nodeBefore,n)||o,o=un(r.nodeAfter,n)||o}if(s.name!="$text"&&s.type=="insert"){const a=r.nodeAfter;for(const l of n.createRangeIn(a).getItems())o=un(l,n)||o}if(s.type=="insert"&&t.isInline(s.name)){const a=r.nodeAfter&&r.nodeAfter.nextSibling;o=un(r.nodeBefore,n)||o,o=un(a,n)||o}}return o}function k7(n,e){const t=e.differ.getChanges();let i=!1;for(const o of t)if(o.type==="attribute"&&o.attributeKey!="mention"){const s=o.range.start.nodeBefore,r=o.range.end.nodeAfter;for(const a of[s,r])Z1(a)&&a.getAttribute(o.attributeKey)!=o.attributeNewValue&&(n.setAttribute(o.attributeKey,o.attributeNewValue,a),i=!0)}return i}function Z1(n){if(!n||!(n.is("$text")||n.is("$textProxy"))||!n.hasAttribute("mention"))return!1;const e=n.data,t=n.getAttribute("mention")._text;return e!=t}function un(n,e){return Z1(n)?(e.removeAttribute("mention",n),!0):!1}class C7 extends En{constructor(e){super(e),h(this,"selected"),h(this,"position"),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e{s?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))}),this.listenTo(this.domElement,"click",()=>{this.fire("execute")})}render(){super.render(),this.element=this.domElement}focus(){this.domElement.focus()}}class x7 extends Nt{constructor(){super(...arguments),h(this,"item"),h(this,"marker")}highlight(){const e=this.children.first;e.isOn=!0}removeHighlight(){const e=this.children.first;e.isOn=!1}}const nr=3,T7=[Z.arrowup,Z.arrowdown,Z.esc],E7=[Z.enter,Z.tab];class S7 extends w{constructor(e){super(e),h(this,"_mentionsView"),h(this,"_mentionsConfigurations"),h(this,"_balloon"),h(this,"_items",new _e),h(this,"_lastRequested"),h(this,"_requestFeedDebounced"),this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=St(this._requestFeed,100),e.config.define("mention",{feeds:[]})}static get pluginName(){return"MentionUI"}static get isOfficialPlugin(){return!0}static get requires(){return[Ue]}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||E7,i=T7.concat(t);this._balloon=e.plugins.get(Ue),e.editing.view.document.on("keydown",(r,a)=>{s(a.keyCode)&&this._isUIVisible&&(a.preventDefault(),r.stop(),a.keyCode==Z.arrowdown&&this._mentionsView.selectNext(),a.keyCode==Z.arrowup&&this._mentionsView.selectPrevious(),t.includes(a.keyCode)&&this._mentionsView.executeSelected(),a.keyCode==Z.esc&&(this._hideUIAndRemoveMarker(),e.model.change(l=>{const c=e.model.document.selection.getLastPosition();c!==null&&l.insertText(" ",c)})))},{priority:"highest"}),$t({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const o=e.config.get("mention.feeds");for(const r of o){const{feed:a,marker:l,dropdownLimit:c}=r;if(!M7(l))throw new b("mentionconfig-incorrect-marker",null,{marker:l});const u=typeof a=="function"?a.bind(this.editor):R7(a),d=r.itemRenderer,m={marker:l,feedCallback:u,itemRenderer:d,dropdownLimit:c};this._mentionsConfigurations.set(l,m)}this._setupTextWatcher(o),this.listenTo(e,"change:isReadOnly",()=>{this._hideUIAndRemoveMarker()}),this.on("requestFeed:response",(r,a)=>this._handleFeedResponse(a)),this.on("requestFeed:error",()=>this._hideUIAndRemoveMarker());function s(r){return i.includes(r)}}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new C7(e);return t.items.bindTo(this._items).using(i=>{const{item:o,marker:s}=i,{dropdownLimit:r}=this._mentionsConfigurations.get(s),a=r||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=a)return null;const l=new x7(e),c=this._renderItem(o,s);return c.delegate("execute").to(l),l.children.add(c),l.item=o,l.marker=s,l.on("execute",()=>{t.fire("execute",{item:o,marker:s})}),l}),t.on("execute",(i,o)=>{const s=this.editor,r=s.model,a=o.item,l=o.marker,c=s.model.markers.get("mention"),u=r.createPositionAt(r.document.selection.focus),d=r.createPositionAt(c.getStart()),m=r.createRange(d,u);this._hideUIAndRemoveMarker(),s.execute("mention",{mention:a,text:a.text,marker:l,range:m}),s.editing.view.focus()}),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),o=i(t);if(!(o instanceof Promise)){this.fire("requestFeed:response",{feed:o,marker:e,feedText:t});return}o.then(s=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:s,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:s,marker:e,feedText:t})}).catch(s=>{this.fire("requestFeed:error",{error:s}),J("mention-feed-callback-error",{marker:e})})}_setupTextWatcher(e){const t=this.editor,i=e.map(r=>({...r,pattern:Q1(r.marker,r.minimumCharacters||0)})),o=new vu(t.model,I7(i));o.on("matched",(r,a)=>{const l=J1(i,a.text),c=t.model.document.selection.focus,u=t.model.createPositionAt(c.parent,l.position);if(O7(c)||B7(u)){this._hideUIAndRemoveMarker();return}const d=V7(l,a.text),m=l.marker.length+d.length,f=c.getShiftedBy(-m),g=c.getShiftedBy(-d.length),p=t.model.createRange(f,g);if(Cl(t)){const _=t.model.markers.get("mention");t.model.change(v=>{v.updateMarker(_,{range:p})})}else t.model.change(_=>{_.addMarker("mention",{range:p,usingOperation:!1,affectsData:!1})});this._requestFeedDebounced(l.marker,d)}),o.on("unmatched",()=>{this._hideUIAndRemoveMarker()});const s=t.commands.get("mention");return o.bind("isEnabled").to(s),o}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!Cl(this.editor))return;this._items.clear();for(const s of t){const r=typeof s!="object"?{id:s,text:s}:s;this._items.add({item:r,marker:i})}const o=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(o):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0,balloonClassName:"ck-mention-balloon"}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),Cl(this.editor)&&this.editor.model.change(e=>e.removeMarker("mention")),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let o,s=e.id;const r=this._getItemRenderer(t);if(r){const a=r(e);typeof a!="string"?o=new A7(i.locale,a):s=a}if(!o){const a=new P(i.locale);a.label=s,a.withText=!0,o=a}return o}_getBalloonPanelPositionData(e,t){const i=this.editor,o=i.editing,s=o.view.domConverter,r=o.mapper,a=i.locale.uiLanguageDirection;return{target:()=>{let l=e.getRange();l.start.root.rootName=="$graveyard"&&(l=i.model.document.selection.getFirstRange());const c=r.toViewRange(l);return z.getDomRangeRects(s.viewRangeToDom(c)).pop()},limiter:()=>{const l=this.editor.editing.view,c=l.document.selection.editableElement;return c?l.domConverter.mapViewToDom(c.root):null},positions:P7(t,a)}}}function P7(n,e){const t={caret_se:i=>({top:i.bottom+nr,left:i.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(i,o)=>({top:i.top-o.height-nr,left:i.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(i,o)=>({top:i.bottom+nr,left:i.right-o.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(i,o)=>({top:i.top-o.height-nr,left:i.right-o.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(t,n)?[t[n]]:e!=="rtl"?[t.caret_se,t.caret_sw,t.caret_ne,t.caret_nw]:[t.caret_sw,t.caret_se,t.caret_nw,t.caret_ne]}function J1(n,e){let t;for(const i of n){const o=e.lastIndexOf(i.marker);o>0&&!e.substring(o-1).match(i.pattern)||(!t||o>=t.position)&&(t={marker:i.marker,position:o,minimumCharacters:i.minimumCharacters,pattern:i.pattern})}return t}function Q1(n,e){const t=e==0?"*":`{${e},}`,i=`(?:^|[= \\(\\[{"'])([${n}])([^= ]${t})$`;return new RegExp(i,"u")}function I7(n){return e=>{const t=J1(n,e);if(!t)return!1;let i=0;t.position!==0&&(i=t.position-1);const o=e.substring(i);return t.pattern.test(o)}}function V7(n,e){let t=0;n.position!==0&&(t=n.position-1);const i=Q1(n.marker,0);return e.substring(t).match(i)[2]}function R7(n){return e=>n.filter(t=>(typeof t=="string"?t:String(t.id)).toLowerCase().includes(e.toLowerCase()))}function O7(n){const e=n.textNode&&n.textNode.hasAttribute("mention"),t=n.nodeBefore;return e||t&&t.is("$text")&&t.hasAttribute("mention")}function B7(n){const e=n.nodeAfter;return e&&e.is("$text")&&e.hasAttribute("mention")}function M7(n){return!!n}function Cl(n){return n.model.markers.has("mention")}class Y1 extends w{toMentionAttribute(e,t){return K1(e,t)}static get pluginName(){return"Mention"}static get isOfficialPlugin(){return!0}static get requires(){return[p7,S7]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class L7 extends O{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=F7(i,t,e)}execute(){const e=this.editor.model;e.change(t=>{const i=t.createElement("pageBreak");e.insertObject(i,null,null,{setSelection:"after"})})}}function F7(n,e,t){const i=N7(n,t);return e.checkChild(i,"pageBreak")}function N7(n,e){const t=ku(n,e).start.parent;return t.isEmpty&&!t.is("element","$root")?t.parent:t}class D7 extends w{static get pluginName(){return"PageBreakEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,o=e.conversion;t.register("pageBreak",{inheritAllFrom:"$blockObject"}),o.for("dataDowncast").elementToStructure({model:"pageBreak",view:(s,{writer:r})=>r.createContainerElement("div",{class:"page-break",style:"page-break-after: always"},r.createContainerElement("span",{style:"display: none"}))}),o.for("editingDowncast").elementToStructure({model:"pageBreak",view:(s,{writer:r})=>{const a=i("Page break"),l=r.createContainerElement("div"),c=r.createRawElement("span",{class:"page-break__label"},function(u){u.innerText=i("Page break")});return r.addClass("page-break",l),r.insert(r.createPositionAt(l,0),c),z7(l,r,a)}}),o.for("upcast").elementToElement({view:s=>{const r=s.getStyle("page-break-before")=="always",a=s.getStyle("page-break-after")=="always";if(!r&&!a)return null;if(s.childCount==1){const l=s.getChild(0);if(!l.is("element","span")||l.getStyle("display")!="none")return null}else if(s.childCount>1)return null;return{name:!0}},model:"pageBreak",converterPriority:"high"}),e.commands.add("pageBreak",new L7(e))}}function z7(n,e,t){return e.setCustomProperty("pageBreak",!0,n),gt(n,e,{label:t})}class H7 extends w{static get pluginName(){return"PageBreakUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("pageBreak",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:pageBreak",()=>this._createButton(ve))}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("pageBreak"),s=new e(t.locale),r=i.t;return s.set({label:r("Page break"),icon:XC}),s.bind("isEnabled").to(o,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("pageBreak"),t.editing.view.focus()}),s}}class $7 extends w{static get requires(){return[D7,H7,Vt]}static get pluginName(){return"PageBreak"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function W7(n,e){const t=[];for(const i of e.createRangeIn(n)){const o=i.item;o.is("element","a")&&!o.hasAttribute("href")&&(o.hasAttribute("id")||o.hasAttribute("name"))&&t.push(o)}for(const i of t){const o=i.parent.getChildIndex(i)+1,s=i.getChildren();e.insertChild(o,s,i.parent)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function X1(n){const e=parseFloat(n);return n.endsWith("pt")?Yn(e*96/72):n.endsWith("pc")?Yn(e*12*96/72):n.endsWith("in")?Yn(e*96):n.endsWith("cm")?Yn(e*96/2.54):n.endsWith("mm")?Yn(e/10*96/2.54):n}function Af(n){return n!==void 0&&n.endsWith("px")}function Yn(n){return Math.round(n)+"px"}function j7(n,e,t){if(!n.childCount)return;const i=new Ht(n.document),o=q7(n,i);if(!o.length)return;const s={},r=[];for(const a of o)if(a.indent!==void 0){G7(a)||(r.length=0);const l=`${a.id}:${a.indent}`,c=Math.min(a.indent-1,r.length);if(cr.length-1||r[c].listElement.name!=d.type){c==0&&d.type=="ol"&&a.id!==void 0&&s[l]&&(d.startIndex=s[l]);const m=X7(d,i,t);if(Af(a.marginLeft)&&(c==0||Af(r[c-1].marginLeft))){let f=a.marginLeft;c>0&&(f=Yn(parseFloat(f)-parseFloat(r[c-1].marginLeft))),i.setStyle("padding-left",f,m)}if(r.length==0){const f=a.element.parent,g=f.getChildIndex(a.element)+1;i.insertChild(g,m,f)}else{const f=r[c-1].listItemElements;i.appendChild(m,f[f.length-1])}r[c]={...a,listElement:m,listItemElements:[]},c==0&&a.id!==void 0&&(s[l]=d.startIndex||1)}}const u=a.element.name=="li"?a.element:i.createElement("li");i.appendChild(u,r[c].listElement),r[c].listItemElements.push(u),c==0&&a.id!==void 0&&s[l]++,a.element!=u&&i.appendChild(a.element,u),t6(a.element,i),i.removeStyle("text-indent",a.element),i.removeStyle("margin-left",a.element)}else{const l=r.find(c=>c.marginLeft==a.marginLeft);if(l){const c=l.listItemElements;i.appendChild(a.element,c[c.length-1]),i.removeStyle("margin-left",a.element)}else r.length=0}}function U7(n,e){for(const t of e.createRangeIn(n)){const i=t.item;if(i.is("element","li")){const o=i.getChild(0);o&&o.is("element","p")&&e.unwrapElement(o)}}}function q7(n,e){const t=e.createRangeIn(n),i=[],o=new Set;for(const s of t.getItems()){if(!s.is("element")||!s.name.match(/^(p|h\d+|li|div)$/))continue;let r=i6(s);if(r!==void 0&&parseFloat(r)==0&&!Array.from(s.getClassNames()).find(a=>a.startsWith("MsoList"))&&(r=void 0),s.hasStyle("mso-list")||r!==void 0&&o.has(r)){const a=e6(s);i.push({element:s,id:a.id,order:a.order,indent:a.indent,marginLeft:r}),r!==void 0&&o.add(r)}else o.clear()}return i}function G7(n){const e=n.element.previousSibling;return K7(e||n.element.parent)}function K7(n){return n.is("element","ol")||n.is("element","ul")}function Z7(n,e){const t=new RegExp(`@list l${n.id}:level${n.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,s=new RegExp(`@list\\s+l${n.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),r=new RegExp(`@list l${n.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=s.exec(e),l=r.exec(e),c=a&&!l,u=t.exec(e);let d="decimal",m="ol",f=null;if(u&&u[1]){const g=i.exec(u[1]);if(g&&g[1]&&(d=g[1].trim(),m=d!=="bullet"&&d!=="image"?"ol":"ul"),d==="bullet"){const p=J7(n.element);p&&(d=p)}else{const p=o.exec(u[1]);p&&p[1]&&(f=parseInt(p[1]))}c&&(m="ol")}return{type:m,startIndex:f,style:Y7(d),isLegalStyleList:c}}function J7(n){if(n.name=="li"&&n.parent.name=="ul"&&n.parent.hasAttribute("type"))return n.parent.getAttribute("type");const e=Q7(n);if(!e)return null;const t=e._data;return t==="o"?"circle":t==="·"?"disc":t==="§"?"square":null}function Q7(n){if(n.getChild(0).is("$text"))return null;for(const e of n.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 Y7(n){if(n.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(n){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 n;default:return null}}function X7(n,e,t){const i=e.createElement(n.type);return n.style&&e.setStyle("list-style-type",n.style,i),n.startIndex&&n.startIndex>1&&e.setAttribute("start",n.startIndex,i),n.isLegalStyleList&&t&&e.addClass("legal-list",i),i}function e6(n){const e=n.getStyle("mso-list");if(e===void 0)return{};const t=e.match(/(^|\s{1,100})l(\d+)/i),i=e.match(/\s{0,100}lfo(\d+)/i),o=e.match(/\s{0,100}level(\d+)/i);return t&&i&&o?{id:t[2],order:i[1],indent:parseInt(o[1])}:{indent:1}}function t6(n,e){const t=new ft({name:"span",styles:{"mso-list":"Ignore"}}),i=e.createRangeIn(n);for(const o of i)o.type==="elementStart"&&t.match(o.item)&&e.remove(o.item)}function i6(n){const e=n.getStyle("margin-left");return e===void 0||e.endsWith("px")?e:X1(e)}function n6(n,e){if(!n.childCount)return;const t=new Ht(n.document),i=s6(n,t);r6(i,n,t),l6(i,n,t),a6(n,t);const o=c6(n,t);o.length&&h6(o,u6(e),t)}function o6(n){return btoa(n.match(/\w{2}/g).map(e=>String.fromCharCode(parseInt(e,16))).join(""))}function s6(n,e){const t=e.createRangeIn(n),i=new ft({name:/v:(.+)/}),o=[];for(const s of t){if(s.type!="elementStart")continue;const r=s.item,a=r.previousSibling,l=a&&a.is("element")?a.name:null,c=["Chart"],u=i.match(r),d=r.getAttribute("o:gfxdata"),m=l==="v:shapetype",f=d&&c.some(g=>r.getAttribute("id").includes(g));u&&d&&!m&&!f&&o.push(s.item.getAttribute("id"))}return o}function r6(n,e,t){const i=t.createRangeIn(e),o=new ft({name:"img"}),s=[];for(const r of i)if(r.item.is("element")&&o.match(r.item)){const a=r.item,l=a.getAttribute("v:shapes")?a.getAttribute("v:shapes").split(" "):[];l.length&&l.every(c=>n.indexOf(c)>-1)?s.push(a):a.getAttribute("src")||s.push(a)}for(const r of s)t.remove(r)}function a6(n,e){const t=e.createRangeIn(n),i=new ft({name:/v:(.+)/}),o=[];for(const s of t)s.type=="elementStart"&&i.match(s.item)&&o.push(s.item);for(const s of o)e.remove(s)}function l6(n,e,t){const i=t.createRangeIn(e),o=[];for(const a of i)if(a.type=="elementStart"&&a.item.is("element","v:shape")){const l=a.item.getAttribute("id");if(n.includes(l))continue;s(a.item.parent.getChildren(),l)||o.push(a.item)}for(const a of o){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 s(a,l){for(const c of a){/* istanbul ignore else -- @preserve */if(c.is("element")&&(c.name=="img"&&c.getAttribute("v:shapes")==l||s(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 c6(n,e){const t=e.createRangeIn(n),i=new ft({name:"img"}),o=[];let s=0;for(const r of t)r.item.is("element")&&i.match(r.item)&&(r.item.getAttribute("src").startsWith("file://")&&o.push({element:r.item,imageIndex:s}),s++);return o}function u6(n){if(!n)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"),i=n.match(t),o=[];if(i)for(const s of i){let r=!1;s.includes("\\pngblip")?r="image/png":s.includes("\\jpegblip")&&(r="image/jpeg"),r&&o.push({hex:s.replace(e,"").replace(/[^\da-fA-F]/g,""),type:r})}return o}function h6(n,e,t){for(let i=0;i!t.hasStyle(`border-${s}-style`)))e.setStyle("border-style","none",t);else for(const s of i)t.hasStyle(`border-${s}-style`)||e.setStyle(`border-${s}-style`,"none",t);const o=["width","height",...i.map(s=>`border-${s}-width`),...i.map(s=>`padding-${s}`)];for(const s of o)t.hasStyle(s)&&e.setStyle(s,X1(t.getStyle(s)),t)}}const f6=//i,g6=/xmlns:o="urn:schemas-microsoft-com/i;class p6{constructor(e,t=!1){h(this,"document"),h(this,"hasMultiLevelListPlugin"),this.document=e,this.hasMultiLevelListPlugin=t}isActive(e){return f6.test(e)||g6.test(e)}execute(e){const t=new Ht(this.document),{body:i,stylesString:o}=e._parsedData;W7(i,t),j7(i,o,this.hasMultiLevelListPlugin),n6(i,e.dataTransfer.getData("text/rtf")),m6(i,t),d6(i),e.content=i}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function w6(n,e){for(const t of n.getChildren())if(t.is("element","b")&&t.getStyle("font-weight")==="normal"){const i=n.getChildIndex(t);e.remove(t),e.insertChild(i,t.getChildren(),n)}}function b6(n,e){const t=new aa(e.document.stylesProcessor),i=new ca(t,{renderingMode:"data"}),o=i.blockElements,s=i.inlineObjectElements,r=[];for(const a of e.createRangeIn(n)){const l=a.item;if(l.is("element","br")){const c=xf(l,"forward",e,{blockElements:o,inlineObjectElements:s}),u=xf(l,"backward",e,{blockElements:o,inlineObjectElements:s}),d=Tf(c,o);(Tf(u,o)||d)&&r.push(l)}}for(const a of r)a.hasClass("Apple-interchange-newline")?e.remove(a):e.replace(a,e.createElement("p"))}function xf(n,e,t,{blockElements:i,inlineObjectElements:o}){let s=t.createPositionAt(n,e=="forward"?"after":"before");return s=s.getLastMatchingPosition(({item:r})=>r.is("element")&&!i.includes(r.name)&&!o.includes(r.name),{direction:e}),e=="forward"?s.nodeAfter:s.nodeBefore}function Tf(n,e){return!!n&&n.is("element")&&e.includes(n.name)}const _6=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class v6{constructor(e){h(this,"document"),this.document=e}isActive(e){return _6.test(e)}execute(e){const t=new Ht(this.document),{body:i}=e._parsedData;w6(i,t),U7(i,t),b6(i,t),e.content=i}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function y6(n,e){for(const t of n.getChildren())t.is("element","table")&&t.hasAttribute("xmlns")&&e.removeAttribute("xmlns",t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function k6(n,e){for(const t of n.getChildren())if(t.is("element","google-sheets-html-origin")){const i=n.getChildIndex(t);e.remove(t),e.insertChild(i,t.getChildren(),n)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function C6(n,e){for(const t of n.getChildren())t.is("element","table")&&t.getStyle("width")==="0px"&&e.removeStyle("width",t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function A6(n,e){for(const t of Array.from(n.getChildren()))t.is("element","style")&&e.remove(t)}const x6=/[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}function S6(n){n.querySelectorAll("span[style*=spacerun]").forEach(e=>{const t=e,i=t.innerText.length||0;t.innerText=Array(i+1).join(" ").substr(0,i)})}function Ef(n){return n.replace(/(\s+)<\/span>/g,(e,t)=>t.length===1?" ":Array(t.length+1).join(" ").substr(0,t.length))}function P6(n,e){const t=new DOMParser;n=n.replace(/
`;class TO extends w{constructor(){super(...arguments),h(this,"htmlDataProcessor")}init(){this.htmlDataProcessor=new jp(this.editor.editing.view.document),this.editor.ui.componentFactory.add("cutToNote",e=>{const t=new P(e);return t.set({label:"Cut & paste selection to sub-note",icon:xO,tooltip:!0}),t.on("execute",()=>{const i=this.editor.editing.view.getDomRoot();glob.getComponentByEl(i).triggerCommand("cutIntoNote")}),t}),this.editor.getSelectedHtml=()=>this.getSelectedHtml(),this.editor.removeSelection=()=>this.removeSelection()}getSelectedHtml(){const e=this.editor.model,t=e.document,i=this.editor.data.toView(e.getSelectedContent(t.selection));return this.htmlDataProcessor.toData(i)}async removeSelection(){const e=this.editor.model;e.deleteContent(e.document.selection),this.editor.execute("paragraph"),await this.getComponent().triggerCommand("saveNoteDetailNow")}getComponent(){const e=this.editor.editing.view.getDomRoot();return glob.getComponentByEl(e)}}class EO extends w{static get requires(){return[At]}static get pluginName(){return"UploadimagePlugin"}init(){this.editor.plugins.get("FileRepository").createUploadAdapter=e=>new SO(e)}}class SO{constructor(e){h(this,"loader"),h(this,"xhr"),this.loader=e}upload(){return this.loader.file.then(e=>new Promise((t,i)=>{this._initRequest().then(()=>{this._initListeners(t,i),this._sendRequest()})}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){return glob.getHeaders().then(e=>{const t=this.xhr=new XMLHttpRequest,{noteId:i}=glob.getActiveContextNote(),o=`api/notes/${i}/attachments/upload`;t.open("POST",o,!0),t.responseType="json";for(const s in e)t.setRequestHeader(s,e[s])})}async _initListeners(e,t){const i=this.xhr;if(!i){t("Missing XHR");return}const o=this.loader,s=await o.file;if(!s){t("Missing file");return}const r=`Cannot upload file: ${s.name}.`;i.addEventListener("error",()=>t(r)),i.addEventListener("abort",()=>t()),i.addEventListener("load",()=>{const a=i.response;if(!a||!a.uploaded)return t(a&&a.error&&a.error.message?a.error.message:r);e({default:a.url})}),i.upload&&i.upload.addEventListener("progress",a=>{a.lengthComputable&&(o.uploadTotal=a.total,o.uploaded=a.loaded)})}async _sendRequest(){var e;const t=new FormData,i=await this.loader.file;i&&(t.append("upload",i),(e=this.xhr)==null||e.send(t))}}class PO extends w{init(){this.editor.conversion.for("downcast").attributeToElement({model:"italic",view:"em",converterPriority:"high"})}}class IO extends w{init(){this.editor.conversion.for("downcast").attributeToElement({model:"strikethrough",view:"del",converterPriority:"high"})}}const VO=`
`;class S0 extends w{static get requires(){return[OO]}}class RO extends O{execute({href:e}){if(!(e!=null&&e.trim()))return;const t=this.editor;glob.getReferenceLinkTitle(e).then(()=>{t.model.change(i=>{const o=i.createElement("reference",{href:e});t.model.insertContent(o),i.setSelection(o,"after")})})}refresh(){const e=this.editor.model,t=e.document.selection;this.isEnabled=t.focus!==null&&e.schema.checkChild(t.focus.parent,"reference")}}class OO extends w{static get requires(){return[Vt,ks]}init(){this._defineSchema(),this._defineConverters(),this.editor.commands.add("referenceLink",new RO(this.editor)),this.editor.editing.mapper.on("viewToModelPosition",Cu(this.editor.model,e=>e.hasClass("reference-link"))),this.editor.plugins.get("LinkEditing")._registerLinkOpener(()=>!0)}_defineSchema(){this.editor.model.schema.register("reference",{allowWhere:"$text",isInline:!0,isObject:!0,allowAttributes:["href","uploadId","uploadStatus"]})}_defineConverters(){const e=this.editor,t=e.conversion;t.for("upcast").elementToElement({view:{name:"a",classes:["reference-link"]},model:(i,{writer:o})=>{const s=i.getAttribute("href");return o.createElement("reference",{href:s})}}),t.for("editingDowncast").elementToElement({model:"reference",view:(i,{writer:o})=>{const s=i.getAttribute("href"),r=o.createContainerElement("a",{href:s,class:"reference-link"},{renderUnsafeAttributes:["href"]}),a=o.createUIElement("span",{},function(l){const c=this.toDomElement(l),u=e.editing.view.getDomRoot();return glob.getComponentByEl(u).loadReferenceLinkTitle($(c),s),c});return o.insert(o.createPositionAt(r,0),a),gt(r,o)}}),t.for("dataDowncast").elementToElement({model:"reference",view:(i,{writer:o})=>{const s=i.getAttribute("href"),r=o.createContainerElement("a",{href:s,class:"reference-link"}),a=glob.getReferenceLinkTitleSync(s),l=o.createText(a);return o.insert(o.createPositionAt(r,0),l),r}})}}class BO extends w{static get requires(){return[S0]}init(){const e=this.editor;e.ui.componentFactory.add("internalLink",t=>{const i=new P(t);return i.set({label:"Internal Trilium link (CTRL-L)",icon:VO,tooltip:!0}),i.bind("isEnabled").to(e,"isReadOnly",o=>!o),i.on("execute",()=>{const o=e.editing.view.getDomRoot();glob.getComponentByEl(o).triggerCommand("addLinkToText")}),i})}}const MO=`
`;class LO extends w{init(){const e=this.editor;e.ui.componentFactory.add("dateTime",t=>{const i=new P(t);return i.set({label:"Date time",icon:MO,tooltip:!0}),i.bind("isEnabled").to(e,"isReadOnly",o=>!o),i.on("execute",()=>{const o=e.editing.view.getDomRoot();glob.getComponentByEl(o).triggerCommand("insertDateTimeToText"),e.editing.view.focus()}),i})}}class FO extends w{static get requires(){return[e0]}init(){this.editor.model.schema.setAttributeProperties("linkHref",{isFormatting:!0})}}class NO extends w{init(){this.editor.keystrokes.set("Tab",(e,t)=>{const i=this.editor.commands.get("indentBlock");i&&i.isEnabled&&!this.isInTable()&&(i.execute(),t())}),this.editor.keystrokes.set("Shift+Tab",(e,t)=>{const i=this.editor.commands.get("outdentBlock");i&&i.isEnabled&&!this.isInTable()&&(i.execute(),t())})}isInTable(){let e=this.editor.model.document.selection.getFirstPosition();for(;e;){if("name"in e&&e.name==="tableCell")return!0;e="parent"in e?e.parent:null}return!1}}const DO='';class zO extends w{init(){this.editor.ui.componentFactory.add("markdownImport",e=>{const t=new P(e);return t.set({label:"Markdown import from clipboard",icon:DO,tooltip:!0}),t.on("execute",()=>{glob.importMarkdownInline()}),t})}}class HO extends w{static get requires(){return[Y1]}afterInit(){const e=this.editor;e.commands.add("mention",new $O(e))}}class $O extends O{execute(e){const{model:t}=this.editor,{document:i}=t,{selection:o}=i,s=e.mention,r=e.range||o.getFirstRange();if(s.id.startsWith("#")||s.id.startsWith("~"))t.change(a=>{t.insertContent(a.createText(s.id,{}),r)});else if(s.action==="create-note"){const a=this.editor.editing.view.getDomRoot();glob.getComponentByEl(a).createNoteForReferenceLink(s.noteTitle).then(l=>{this.insertReference(r,l)})}else this.insertReference(r,s.notePath)}insertReference(e,t){const{model:i}=this.editor;i.change(o=>{i.insertContent(o.createText("",{}),e),this.editor.execute("referenceLink",{href:"#"+t})})}}const WO='';class jO extends w{static get requires(){return[qO,UO]}}class UO extends w{init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("includeNote",i=>{const o=e.commands.get("insertIncludeNote"),s=new P(i);return s.set({label:t("Include note"),icon:WO,tooltip:!0}),o&&s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",()=>e.execute("insertIncludeNote")),s})}}class qO extends w{static get requires(){return[Vt]}init(){this._defineSchema(),this._defineConverters(),this.editor.commands.add("insertIncludeNote",new GO(this.editor))}_defineSchema(){this.editor.model.schema.register("includeNote",{isObject:!0,allowAttributes:["noteId","boxSize"],allowWhere:"$block"})}_defineConverters(){const e=this.editor,t=e.conversion;t.for("upcast").elementToElement({model:(i,{writer:o})=>o.createElement("includeNote",{noteId:i.getAttribute("data-note-id"),boxSize:i.getAttribute("data-box-size")}),view:{name:"section",classes:"include-note"}}),t.for("dataDowncast").elementToElement({model:"includeNote",view:(i,{writer:o})=>o.createContainerElement("section",{class:"include-note","data-note-id":i.getAttribute("noteId"),"data-box-size":i.getAttribute("boxSize")})}),t.for("editingDowncast").elementToElement({model:"includeNote",view:(i,{writer:o})=>{const s=i.getAttribute("noteId"),r=i.getAttribute("boxSize"),a=o.createContainerElement("section",{class:"include-note box-size-"+r,"data-note-id":s,"data-box-size":r}),l=o.createUIElement("div",{class:"include-note-wrapper","data-cke-ignore-events":!0},function(c){const u=this.toDomElement(c),d=e.editing.view.getDomRoot();return glob.getComponentByEl(d).loadIncludedNote(s,$(u)),KO(u,e),u});return o.insert(o.createPositionAt(a,0),l),gt(a,o,{label:"include note widget"})}})}}class GO extends O{execute(){const e=this.editor.editing.view.getDomRoot();glob.getComponentByEl(e).triggerCommand("addIncludeNoteToText")}refresh(){const e=this.editor.model,t=e.document.selection.getFirstPosition(),i=t&&e.schema.findAllowedParent(t,"includeNote");this.isEnabled=i!==null}}function KO(n,e){n.addEventListener("mousedown",t,{capture:!0}),n.addEventListener("focus",t,{capture:!0}),n.addEventListener("keydown",t,{capture:!0});function t(i){i.stopPropagation(),e.editing.view._renderer.isFocused=!1}}class ZO extends O{refresh(){this.isEnabled=!0}execute(e){const t=this.editor,i=t.model,o=t.plugins.get(At);i.change(s=>{const r=e.file;for(const a of r)JO(s,i,o,a)})}}function JO(n,e,t,i){const o=t.createLoader(i);o&&QO(n,e,{href:"",uploadId:o.id})}function QO(n,e,t={},i){const o=n.createElement("reference",t);e.insertContent(o,e.document.selection),n.insertText(" ",o,"after")}class YO extends w{static get requires(){return[At,Nr,_s]}static get pluginName(){return"FileUploadEditing"}init(){const e=this.editor,t=e.model.document,i=e.conversion,o=e.plugins.get(At);e.commands.add("fileUpload",new ZO(e)),i.for("upcast").attributeToAttribute({view:{name:"a",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",(s,r)=>{if(nB(r.dataTransfer))return;const a=Array.from(r.dataTransfer.files);e.model.change(l=>{r.targetRanges&&l.setSelection(r.targetRanges.map(c=>e.editing.mapper.toModelRange(c))),a.length&&(s.stop(),e.model.enqueueChange(()=>{e.execute("fileUpload",{file:a})}))})}),this.listenTo(e.plugins.get(_s),"inputTransformation",(s,r)=>{const a=Array.from(e.editing.view.createRangeIn(r.content)).filter(c=>eB(c.item)&&!c.item.getAttribute("uploadProcessed")).map(c=>({promise:XO(c.item),fileElement:c}));if(!a.length)return;const l=new Ht(this.editor.editing.view.document);for(const c of a){l.setAttribute("uploadProcessed",!0,c.fileElement);const u=o.createLoader(c.promise);u&&(l.setAttribute("href","",c.fileElement),l.setAttribute("uploadId",u.id,c.fileElement))}}),e.editing.view.document.on("dragover",(s,r)=>{r.preventDefault()}),t.on("change",()=>{const s=t.differ.getChanges({includeChangesInGraveyard:!0});for(const r of s)if(r.type=="insert"){const a=r.position.nodeAfter;if(a){const l=r.position.root.rootName=="$graveyard";for(const c of oB(e,a)){const u=c.getAttribute("uploadId");if(!u)continue;const d=o.loaders.get(u);d&&(l?d.abort():d.status=="idle"&&this._readAndUpload(d,c))}}}})}_readAndUpload(e,t){const i=this.editor,o=i.model,s=i.locale.t,r=i.plugins.get(At),a=i.plugins.get(Nr);return o.enqueueChange(c=>{c.setAttribute("uploadStatus","reading",t)}),e.read().then(()=>{const c=e.upload();return o.enqueueChange(u=>{u.setAttribute("uploadStatus","uploading",t)}),c}).then(c=>(o.enqueueChange(u=>{u.setAttributes({uploadStatus:"complete",href:c.default},t)}),l(),new Promise(u=>setTimeout(u,100)))).then(()=>{i.setData(i.getData())}).catch(c=>{if(e.status!=="error"&&e.status!=="aborted")throw c;e.status=="error"&&c&&a.showWarning(c,{title:s("Upload failed"),namespace:"upload"}),l(),o.enqueueChange(u=>{u.remove(t)})});function l(){o.enqueueChange(c=>{c.removeAttribute("uploadId",t),c.removeAttribute("uploadStatus",t)}),r.destroyLoader(e)}}}function XO(n){return new Promise((e,t)=>{const i=n.getAttribute("href");fetch(i).then(o=>o.blob()).then(o=>{const s=tB(o,i)??"",r=`file.${s?.replace("file/","")}`,a=iB(o,r,s);a?e(a):t()}).catch(t)})}function eB(n){return!n.is("element","a")||!n.getAttribute("href")?!1:n.getAttribute("href")}function tB(n,e){var t;if(n.type)return n.type;if(e.match(/data:(image\/\w+);base64/))return(t=e.match(/data:(image\/\w+);base64/))==null?void 0:t[1].toLowerCase();throw new Error("Could not retrieve mime type for file.")}function iB(n,e,t){try{return new File([n],e,{type:t})}catch{return null}}function nB(n){return Array.from(n.types).includes("text/html")&&n.getData("text/html")!==""}function oB(n,e){return Array.from(n.model.createRangeOn(e)).filter(t=>t.item.hasAttribute("href")).map(t=>t.item)}class sB extends w{static get requires(){return[YO]}static get pluginName(){return"fileUploadPlugin"}}class rB extends w{constructor(){super(...arguments),h(this,"config"),h(this,"hljs")}async init(){const e=this.editor.config.get("syntaxHighlighting");!e||!e.enabled||(this.config=e,this.hljs=await e.loadHighlightJs(),this.initTextEditor(this.editor))}initTextEditor(e){Hi("initTextEditor");const t=e.model.document;e.conversion.for("editingDowncast").markerToHighlight({model:"hljs",view:({markerName:i})=>{Ye("markerName "+i);const[,o,s]=i.split(":");return{name:"span",classes:[o],attributes:{"data-syntax-result":s}}}}),t.registerPostFixer(i=>{var o,s,r;Hi("postFixer");const a=t.differ.getChanges();let l=new Set;function c(u){if("getChildren"in u)for(const d of u.getChildren())d.is("element","paragraph")||(d.is("element","codeBlock")?l.add(d):d.childCount>0&&c(d))}for(const u of a)if(Ye("change "+JSON.stringify(u)),"name"in u&&u.name!=="paragraph"&&u.name!=="codeBlock"&&(o=u?.position)!=null&&o.nodeAfter&&u.position.nodeAfter.childCount>0)c(u.position.nodeAfter);else if(u.type=="insert"&&u.name=="codeBlock"){const d=(s=u.position)==null?void 0:s.nodeAfter;d&&(Hi("dirtying inserted codeBlock "+JSON.stringify(d.toJSON())),l.add(d))}else if(u.type=="remove"&&u.name=="codeBlock"&&u.position)Hi("removing codeBlock at path "+JSON.stringify(u.position.toJSON()));else if((u.type=="remove"||u.type=="insert")&&(r=u?.position)!=null&&r.parent.is("element","codeBlock")){const d=u.position.parent;Hi("dirtying codeBlock "+JSON.stringify(d.toJSON())),l.add(d)}for(let u of l)this.highlightCodeBlock(u,i);return!1})}highlightCodeBlock(e,t){var i;Hi("highlighting codeblock "+JSON.stringify(e.toJSON()));const o=(i=e.root.document)==null?void 0:i.model;if(!o)return;const s=o.createRangeIn(e);for(const _ of o.markers.getMarkersIntersectingRange(s))Ye("removing marker "+_.name),t.removeMarker(_.name);const r=e.getAttribute("language");if(r=="text-plain"){Hi("not highlighting plaintext codeblock");return}if(e.childCount>=aB)return;let a="";for(let _=0;_=f.length)if(m++,m0&&(E=E.slice(0,M)),Ye("Found span start "+E),c=u.indexOf(">",c)+1;let G=t.createPositionAt(e,(g?.startOffset??0)+p);d.push({className:E,posStart:G})}else if(u[c]=="<"&&u[c+1]=="/"){c=u.indexOf(">",c+1)+1;let _=d.pop(),v=_?.posStart,E=_?.className,M=t.createPositionAt(e,(g?.startOffset??0)+p);if(v){let G=t.createRange(v,M),X="hljs:"+E+":"+Tl;Tl=Tl+1&16777215,Ye("Found span end "+E),Ye("Adding marker "+X+": "+JSON.stringify(G.toJSON())),t.addMarker(X,{range:G,usingOperation:!1})}}else{if(lB(m=xa.indexOf("warn")&&(Pc=console.warn.bind(console,Aa+": "));let Hi=function(...n){};ju>=xa.indexOf("log")&&(Hi=console.log.bind(console,Aa+": "));let Ye=function(...n){};ju>=xa.indexOf("debug")&&(Ye=console.debug.bind(console,Aa+": "));function lB(n,e){console.assert(n,Aa+": "+e)}let Tl=0;var cB=`
`;const hn="kbd";class uB extends w{static get pluginName(){return"KbdEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:hn}),e.model.schema.setAttributeProperties(hn,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:hn,view:hn}),e.commands.add(hn,new tn(e,hn)),e.keystrokes.set("CTRL+ALT+K",hn)}}const El="kbd";class hB extends w{static get pluginName(){return"KbdUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(El,i=>{const o=e.commands.get(El),s=new P(i);return s.set({label:t("Keyboard shortcut"),icon:cB,keystroke:"CTRL+ALT+K",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute(El),e.editing.view.focus()}),s})}}class dB extends w{static get requires(){return[uB,hB]}static get pluginName(){return"Kbd"}}var mB=typeof global=="object"&&global&&global.Object===Object&&global,fB=typeof self=="object"&&self&&self.Object===Object&&self,P0=mB||fB||Function("return this")(),Qr=P0.Symbol,I0=Object.prototype,gB=I0.hasOwnProperty,pB=I0.toString,$o=Qr?Qr.toStringTag:void 0;function wB(n){var e=gB.call(n,$o),t=n[$o];try{n[$o]=void 0;var i=!0}catch{}var o=pB.call(n);return i&&(e?n[$o]=t:delete n[$o]),o}var bB=Object.prototype,_B=bB.toString;function vB(n){return _B.call(n)}var yB="[object Null]",kB="[object Undefined]",eg=Qr?Qr.toStringTag:void 0;function CB(n){return n==null?n===void 0?kB:yB:eg&&eg in Object(n)?wB(n):vB(n)}function AB(n){return n!=null&&typeof n=="object"}var xB="[object Symbol]";function TB(n){return typeof n=="symbol"||AB(n)&&CB(n)==xB}var EB=/\s/;function SB(n){for(var e=n.length;e--&&EB.test(n.charAt(e)););return e}var PB=/^\s+/;function IB(n){return n&&n.slice(0,SB(n)+1).replace(PB,"")}function Ic(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var tg=NaN,VB=/^[-+]0x[0-9a-f]+$/i,RB=/^0b[01]+$/i,OB=/^0o[0-7]+$/i,BB=parseInt;function ig(n){if(typeof n=="number")return n;if(TB(n))return tg;if(Ic(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Ic(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=IB(n);var t=RB.test(n);return t||OB.test(n)?BB(n.slice(2),t?2:8):VB.test(n)?tg:+n}var Sl=function(){return P0.Date.now()},MB="Expected a function",LB=Math.max,FB=Math.min;function NB(n,e,t){var i,o,s,r,a,l,c=0,u=!1,d=!1,m=!0;if(typeof n!="function")throw new TypeError(MB);e=ig(e)||0,Ic(t)&&(u=!!t.leading,d="maxWait"in t,s=d?LB(ig(t.maxWait)||0,e):s,m="trailing"in t?!!t.trailing:m);function f(T){var F=i,x=o;return i=o=void 0,c=T,r=n.apply(x,F),r}function g(T){return c=T,a=setTimeout(v,e),u?f(T):r}function p(T){var F=T-l,x=T-c,q=e-F;return d?FB(q,s-x):q}function _(T){var F=T-l,x=T-c;return l===void 0||F>=e||F<0||d&&x>=s}function v(){var T=Sl();if(_(T))return E(T);a=setTimeout(v,p(T))}function E(T){return a=void 0,m&&i?f(T):(i=o=void 0,r)}function M(){a!==void 0&&clearTimeout(a),c=0,i=l=o=a=void 0}function G(){return a===void 0?r:E(Sl())}function X(){var T=Sl(),F=_(T);if(i=arguments,o=this,l=T,F){if(a===void 0)return g(l);if(d)return clearTimeout(a),a=setTimeout(v,e),f(l)}return a===void 0&&(a=setTimeout(v,e)),r}return X.cancel=M,X.flush=G,X}/**
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/function Uu(n,e){var t;const i=n.model.document.selection,o=i.getSelectedElement()||((t=i.getLastPosition())==null?void 0:t.parent);return!!(o&&o.is("element","mermaid")&&o.getAttribute("displayMode")===e)}class DB extends O{refresh(){var e;const t=this.editor,i=t.model.document.selection,o=i.getSelectedElement();o&&o.name==="mermaid"||(e=i.getLastPosition())!=null&&e.findAncestor("mermaid")?this.isEnabled=!!o:this.isEnabled=!1,this.value=Uu(t,"preview")}execute(){var e;const t=this.editor.model,i=this.editor.model.document.selection,o=i.getSelectedElement()||((e=i.getLastPosition())==null?void 0:e.parent);o&&t.change(s=>{o.getAttribute("displayMode")!=="preview"&&s.setAttribute("displayMode","preview",o)})}}class zB extends O{refresh(){var e;const t=this.editor,i=t.model.document.selection,o=i.getSelectedElement();o&&o.name==="mermaid"||(e=i.getLastPosition())!=null&&e.findAncestor("mermaid")?this.isEnabled=!!o:this.isEnabled=!1,this.value=Uu(t,"source")}execute(){var e;const t=this.editor.model,i=this.editor.model.document.selection,o=i.getSelectedElement()||((e=i.getLastPosition())==null?void 0:e.parent);t.change(s=>{o.getAttribute("displayMode")!=="source"&&s.setAttribute("displayMode","source",o)})}}class HB extends O{refresh(){var e;const t=this.editor,i=t.model.document.selection,o=i.getSelectedElement();o&&o.name==="mermaid"||(e=i.getLastPosition())!=null&&e.findAncestor("mermaid")?this.isEnabled=!!o:this.isEnabled=!1,this.value=Uu(t,"split")}execute(){var e;const t=this.editor.model,i=this.editor.model.document.selection,o=i.getSelectedElement()||((e=i.getLastPosition())==null?void 0:e.parent);t.change(s=>{o.getAttribute("displayMode")!=="split"&&s.setAttribute("displayMode","split",o)})}}const $B=`flowchart TB
A --> B
B --> C`;class WB extends O{refresh(){const e=this.editor.model.document.selection.getSelectedElement();e&&e.name==="mermaid"?this.isEnabled=!1:this.isEnabled=!0}execute(){const e=this.editor.model;let t;return e.change(i=>{t=i.createElement("mermaid",{displayMode:"split",source:$B}),e.insertContent(t)}),t}}const jB=300;class UB extends w{constructor(){super(...arguments),h(this,"_config"),h(this,"mermaid")}static get pluginName(){return"MermaidEditing"}init(){this._registerCommands(),this._defineConverters(),this._config=this.editor.config.get("mermaid")}afterInit(){this.editor.model.schema.register("mermaid",{allowAttributes:["displayMode","source"],allowWhere:"$block",isObject:!0})}_registerCommands(){const e=this.editor;e.commands.add("mermaidPreviewCommand",new DB(e)),e.commands.add("mermaidSplitViewCommand",new HB(e)),e.commands.add("mermaidSourceViewCommand",new zB(e)),e.commands.add("insertMermaidCommand",new WB(e))}_defineConverters(){const e=this.editor;e.data.downcastDispatcher.on("insert:mermaid",this._mermaidDataDowncast.bind(this)),e.editing.downcastDispatcher.on("insert:mermaid",this._mermaidDowncast.bind(this)),e.editing.downcastDispatcher.on("attribute:source:mermaid",this._sourceAttributeDowncast.bind(this)),e.data.upcastDispatcher.on("element:code",this._mermaidUpcast.bind(this),{priority:"high"}),e.conversion.for("editingDowncast").attributeToAttribute({model:{name:"mermaid",key:"displayMode"},view:t=>({key:"class",value:"ck-mermaid__"+t+"-mode"})})}_mermaidDataDowncast(e,t,i){const o=this.editor.model,{writer:s,mapper:r}=i;if(!i.consumable.consume(t.item,"insert"))return;const a=r.toViewPosition(o.createPositionBefore(t.item)),l=s.createContainerElement("code",{class:"language-mermaid"}),c=s.createContainerElement("pre",{spellcheck:"false"}),u=s.createText(t.item.getAttribute("source"));s.insert(o.createPositionAt(l,"end"),u),s.insert(o.createPositionAt(c,"end"),l),s.insert(a,c),r.bindElements(t.item,l)}_mermaidDowncast(e,t,i){const{writer:o,mapper:s,consumable:r}=i,{editor:a}=this,{model:l,t:c}=a,u=this;if(!r.consume(t.item,"insert"))return;const d=s.toViewPosition(l.createPositionBefore(t.item)),m={class:["ck-mermaid__wrapper"]},f={class:["ck-mermaid__editing-view"],placeholder:c("Insert mermaid source code"),"data-cke-ignore-events":!0},g=o.createContainerElement("div",m),p=o.createUIElement("textarea",f,v),_=o.createUIElement("div",{class:["ck-mermaid__preview"]},E);return o.insert(o.createPositionAt(g,"start"),_),o.insert(o.createPositionAt(g,"start"),p),o.insert(d,g),s.bindElements(t.item,g),gt(g,o,{label:c("Mermaid widget"),hasSelectionHandle:!0});function v(M){const G=this.toDomElement(M);G.value=t.item.getAttribute("source");const X=NB(T=>{a.model.change(F=>{F.setAttribute("source",T.target.value,t.item)})},jB);return G.addEventListener("input",X),G.addEventListener("focus",()=>{const T=a.model;T.document.selection.getSelectedElement()!==t.item&&T.change(F=>F.setSelection(t.item,"on"))},!0),G}function E(M){const G=t.item.getAttribute("source"),X=this.toDomElement(M);return X.innerHTML=G,window.setTimeout(()=>{u._renderMermaid(X)},100),X}}_sourceAttributeDowncast(e,t,i){const o=t.attributeNewValue,s=this.editor.editing.view.domConverter;if(o){const r=i.mapper.toViewElement(t.item);if(!r)return;for(const a of r.getChildren()){const l=a;if(l.name==="textarea"&&l.hasClass("ck-mermaid__editing-view")){const c=s.viewToDom(l);c.value!=o&&(c.value=o)}else if(l.name==="div"&&l.hasClass("ck-mermaid__preview")){const c=s.viewToDom(l);c&&(c.innerHTML=o,c.removeAttribute("data-processed"),this._renderMermaid(c))}}}}_mermaidUpcast(e,t,i){const o=t.viewItem,s=!o.parent||!o.parent.is("element","pre"),r=t.modelCursor.findAncestor("code"),{consumable:a,writer:l}=i;if(!o.hasClass("language-mermaid")||s||r||!a.test(o,{name:!0}))return;const c=Array.from(o.getChildren()).filter(d=>d.is("$text")).map(d=>d.data).join(""),u=l.createElement("mermaid",{source:c,displayMode:"split"});i.safeInsert(u,t.modelCursor)&&(a.consume(o,{name:!0}),i.updateConversionResult(u,t))}async _renderMermaid(e){var t,i,o;!window.mermaid&&typeof((t=this._config)==null?void 0:t.lazyLoad)=="function"&&(this.mermaid=await this._config.lazyLoad()),(o=this.mermaid)==null||o.init(((i=this._config)==null?void 0:i.config)??{},e)}}class qB extends w{static get requires(){return[ci]}static get pluginName(){return"MermaidToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(ci),o=["mermaidSourceView","mermaidSplitView","mermaidPreview","|","mermaidInfo"];o&&i.register("mermaidToolbar",{ariaLabel:t("Mermaid toolbar"),items:o,getRelatedElement:s=>GB(s)})}}function GB(n){const e=n.getSelectedElement();return e&&e.hasClass("ck-mermaid__wrapper")?e:null}var KB=`
`,ZB=`
`,JB=`
`,QB=`
`,YB=`
`;class XB extends w{static get pluginName(){return"MermaidUI"}init(){this._addButtons()}_addButtons(){const e=this.editor;this._addInsertMermaidButton(),this._addMermaidInfoButton(),this._createToolbarButton(e,"mermaidPreview","Preview",ZB),this._createToolbarButton(e,"mermaidSourceView","Source view",QB),this._createToolbarButton(e,"mermaidSplitView","Split view",JB)}_addInsertMermaidButton(){const e=this.editor,t=e.t,i=e.editing.view;e.ui.componentFactory.add("mermaid",o=>{const s=new P(o),r=e.commands.get("insertMermaidCommand");if(!r)throw new Error("Missing command.");return s.set({label:t("Insert Mermaid diagram"),icon:KB,tooltip:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),r.listenTo(s,"execute",()=>{var a;const l=e.execute("insertMermaidCommand"),c=e.editing.mapper.toViewElement(l);if(i.scrollToTheSelection(),i.focus(),c){const u=i.domConverter.viewToDom(c);u&&((a=u.querySelector(".ck-mermaid__editing-view"))==null||a.focus())}}),s})}_addMermaidInfoButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("mermaidInfo",i=>{const o=new P(i),s="https://ckeditor.com/blog/basic-overview-of-creating-flowcharts-using-mermaid/";return o.set({label:t("Read more about Mermaid diagram syntax"),icon:YB,tooltip:!0}),o.on("execute",()=>{window.open(s,"_blank","noopener")}),o})}_createToolbarButton(e,t,i,o){const s=e.t;e.ui.componentFactory.add(t,r=>{const a=new P(r),l=e.commands.get(`${t}Command`);if(!l)throw new Error("Missing command.");return a.set({label:s(i),icon:o,tooltip:!0}),a.bind("isOn","isEnabled").to(l,"value","isEnabled"),l.listenTo(a,"execute",()=>{e.execute(`${t}Command`),e.editing.view.scrollToTheSelection(),e.editing.view.focus()}),a})}}class e9 extends w{static get requires(){return[UB,qB,XB]}static get pluginName(){return"Mermaid"}}var t9=`
`;const qu=["note","tip","important","caution","warning"],ao="admonitionType",i9=qu[0];class n9 extends O{constructor(){super(...arguments),h(this,"_lastType")}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,o=t.document.selection,s=Array.from(o.getSelectedBlocks()),r=this._getType(e);t.change(a=>{if(!r)this._removeQuote(a,s.filter(lr));else{const l=s.filter(c=>lr(c)||og(i,c));this._applyQuote(a,l,r)}})}_getType(e){const t=e.forceValue===void 0?!this.value:e.forceValue;return t?typeof t=="string"?t:e.usePreviousChoice&&this._lastType?this._lastType:"note":!1}_getValue(){const e=this.editor.model.document.selection,t=ae(e.getSelectedBlocks());if(!t)return!1;const i=lr(t);return i!=null&&i.is("element")?i.getAttribute(ao):!1}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=ae(e.getSelectedBlocks());return i?og(t,i):!1}_removeQuote(e,t){ng(e,t).reverse().forEach(i=>{if(i.start.isAtStart&&i.end.isAtEnd){e.unwrap(i.start.parent);return}if(i.start.isAtStart){const s=e.createPositionBefore(i.start.parent);e.move(i,s);return}i.end.isAtEnd||e.split(i.end);const o=e.createPositionAfter(i.end.parent);e.move(i,o)})}_applyQuote(e,t,i){this._lastType=i;const o=[];ng(e,t).reverse().forEach(s=>{let r=lr(s.start);if(r)r.is("element")&&this.editor.model.change(a=>{a.setAttribute(ao,i,r)});else{const a={};a[ao]=i,r=e.createElement("aside",a),e.wrap(s,r)}o.push(r)}),o.reverse().reduce((s,r)=>s.nextSibling==r?(e.merge(e.createPositionAfter(s)),s):r)}}function lr(n){return n.parent.name=="aside"?n.parent:null}function ng(n,e){let t,i=0;const o=[];for(;i{let l=i9;for(const u of r.getClassNames())u!=="admonition"&&qu.includes(u)&&(l=u);const c={};return c[ao]=l,a.createElement("aside",c)}}),e.conversion.for("downcast").elementToElement({model:"aside",view:"aside"}).attributeToAttribute({model:ao,view:r=>({key:"class",value:["admonition",r]})}),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","aside")&&c.isEmpty)return r.remove(c),!0;if(c.is("element","aside")&&!t.checkChild(l.position,c))return r.unwrap(c),!0;if(c.is("element")){const u=r.createRangeIn(c);for(const d of u.getItems())if(d.is("element","aside")&&!t.checkChild(r.createPositionBefore(d),d))return r.unwrap(d),!0}}else if(l.type=="remove"){const c=l.position.parent;if(c.is("element","aside")&&c.isEmpty)return r.remove(c),!0}return!1});const i=this.editor.editing.view.document,o=e.model.document.selection,s=e.commands.get("admonition");s&&(this.listenTo(i,"enter",(r,a)=>{!o.isCollapsed||!s.value||o.getLastPosition().parent.isEmpty&&(e.execute("admonition"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"aside"}),this.listenTo(i,"delete",(r,a)=>{if(a.direction!="backward"||!o.isCollapsed||!s.value)return;const l=o.getLastPosition().parent;l.isEmpty&&!l.previousSibling&&(e.execute("admonition"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"aside"}))}}const s9={note:{title:"참고"},tip:{title:"도움말"},important:{title:"중요"},caution:{title:"주의"},warning:{title:"경고"}};class r9 extends w{static get pluginName(){return"AdmonitionUI"}init(){this.editor.ui.componentFactory.add("admonition",()=>this._createButton())}_createButton(){const e=this.editor,t=e.locale,i=e.commands.get("admonition"),o=Ee(t,Xi),s=o.buttonView,r=t.t;return wt(o,this._getDropdownItems()),s.set({label:r("Admonition"),icon:t9,isToggleable:!0,tooltip:!0}),s.on("execute",()=>{e.execute("admonition",{usePreviousChoice:!0}),e.editing.view.focus()}),s.bind("isOn").to(i,"value",a=>!!a),o.bind("isEnabled").to(i,"isEnabled"),o.on("execute",a=>{e.execute("admonition",{forceValue:a.source.commandParam}),e.editing.view.focus()}),o}_getDropdownItems(){const e=new _e,t=this.editor.commands.get("admonition");if(!t)return e;for(const[i,o]of Object.entries(s9)){const s={type:"button",model:new et({commandParam:i,label:o.title,class:`ck-tn-admonition-option ck-tn-admonition-${i}`,role:"menuitemradio",withText:!0})};s.model.bind("isOn").to(t,"value",r=>r===i),e.add(s)}return e}}function a9(n){if(n.length===2&&qu.includes(n[1]))return n[1]}class l9 extends w{static get requires(){return[yu]}afterInit(){if(!this.editor.commands.get("admonition"))return;const e=this;Wt(this.editor,e,/^\!\!\[*\! (.+) $/,({match:t})=>{const i=a9(t);i?this.editor.execute("admonition",{forceValue:i}):(this.editor.execute("admonition"),t.length>1&&this.editor.execute("insertText",{text:(t[1]??"")+" "}))})}}class c9 extends w{static get requires(){return[o9,r9,l9]}static get pluginName(){return"Admonition"}}var u9=`
`;const h9="footnote",U={footnoteItem:"footnoteItem",footnoteReference:"footnoteReference",footnoteSection:"footnoteSection",footnoteContent:"footnoteContent",footnoteBackLink:"footnoteBackLink"},Wi={footnoteContent:"footnote-content",footnoteItem:"footnote-item",footnoteReference:"footnote-reference",footnoteSection:"footnote-section",footnoteBackLink:"footnote-back-link",footnotes:"footnotes"},ji={insertFootnote:"InsertFootnote"},L={footnoteContent:"data-footnote-content",footnoteId:"data-footnote-id",footnoteIndex:"data-footnote-index",footnoteItem:"data-footnote-item",footnoteReference:"data-footnote-reference",footnoteSection:"data-footnote-section",footnoteBackLink:"data-footnote-back-link"},wn=(n,e,t=i=>!0)=>{const i=n.model.createRangeIn(e),o=[];for(const s of i.getItems())s instanceof ne&&t(s)&&o.push(s);return o},wo=(n,e,t=i=>!0)=>{const i=n.model.createRangeIn(e);for(const o of i.getItems())if(o instanceof ne&&t(o))return o;return null},d9=(n,e,t=i=>!0)=>{const i=n.editing.view.createRangeIn(e);for(const o of i.getItems())if(o instanceof ai&&t(o))return o;return null},m9=(n,e)=>{const t=n.model.document.selection.anchor,i=t&&(t.textNode||t.getShiftedBy(-1).textNode);if(!t||!i)return{remove:[],format:[]};const o=e.matchAll(/\[\^([0-9]+)\]/g);for(const s of o||[]){const r=e.indexOf(s[0]),a=r+s[0].length,l=t.parent.getChildStartOffset(i);if(l===null||t.offset!==l+a)continue;const c=r+2,u=c+s[1].length;return{remove:[[r,a]],format:[[c,u]]}}return{remove:[],format:[]}},f9=(n,e,t)=>{const i=e.commands.get(ji.insertFootnote);if(!i||!i.isEnabled)return;const o=[...n[0].getItems()][0];if(!(o instanceof Lt||o instanceof Ce))return!1;const s=o.data.match(/[0-9]+/);if(!s)return!1;const r=parseInt(s[0]),a=wo(e,t,c=>c.is("element",U.footnoteSection));if(!a){if(r!==1)return!1;e.execute(ji.insertFootnote);return}const l=wn(e,a,c=>c.is("element",U.footnoteItem)).length;if(r===l+1){e.execute(ji.insertFootnote);return}else if(r>=1&&r<=l){e.execute(ji.insertFootnote,{footnoteIndex:r});return}return!1},g9=(n,e)=>{if(n.plugins.has("Autoformat")){const t=n.plugins.get("Autoformat");mn(n,t,i=>m9(n,i),(i,o)=>f9(o,n,e))}},p9=n=>{const e=n.conversion;e.for("downcast").attributeToAttribute({model:L.footnoteId,view:L.footnoteId}),e.for("downcast").attributeToAttribute({model:L.footnoteIndex,view:L.footnoteIndex}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteSection]:!0}},model:U.footnoteSection,converterPriority:"high"}),e.for("dataDowncast").elementToElement({model:U.footnoteSection,view:{name:"ol",attributes:{[L.footnoteSection]:"",role:"doc-endnotes"},classes:[Wi.footnoteSection,Wi.footnotes]}}),e.for("editingDowncast").elementToElement({model:U.footnoteSection,view:(t,i)=>{const o=i.writer,s=o.createContainerElement("div",{[L.footnoteSection]:"",role:"doc-endnotes list",class:Wi.footnoteSection});return gt(s,o,{label:"footnote widget"})}}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteContent]:!0}},model:(t,i)=>i.writer.createElement(U.footnoteContent)}),e.for("dataDowncast").elementToElement({model:U.footnoteContent,view:{name:"div",attributes:{[L.footnoteContent]:""},classes:[Wi.footnoteContent]}}),e.for("editingDowncast").elementToElement({model:U.footnoteContent,view:(t,i)=>{const o=i.writer,s=o.createEditableElement("div",{[L.footnoteContent]:"",class:Wi.footnoteContent});return wa(s,o)}}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteItem]:!0}},model:(t,i)=>{const o=i.writer,s=t.getAttribute(L.footnoteId),r=t.getAttribute(L.footnoteIndex);return s===void 0||r===void 0?null:o.createElement(U.footnoteItem,{[L.footnoteIndex]:r,[L.footnoteId]:s})},converterPriority:"high"}),e.for("dataDowncast").elementToElement({model:U.footnoteItem,view:ag}),e.for("editingDowncast").elementToElement({model:U.footnoteItem,view:ag}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteReference]:!0}},model:(t,i)=>{const o=i.writer,s=t.getAttribute(L.footnoteIndex),r=t.getAttribute(L.footnoteId);return s===void 0||r===void 0?null:o.createElement(U.footnoteReference,{[L.footnoteIndex]:s,[L.footnoteId]:r})}}),e.for("editingDowncast").elementToElement({model:U.footnoteReference,view:(t,i)=>{const o=i.writer,s=rg(t,i);return gt(s,o)}}),e.for("dataDowncast").elementToElement({model:U.footnoteReference,view:rg}),e.for("editingDowncast").add(t=>{t.on(`attribute:${L.footnoteIndex}:${U.footnoteReference}`,(i,o,s)=>w9(o,s,n),{priority:"high"})}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteBackLink]:!0}},model:(t,i)=>{const o=i.writer,s=t.getAttribute(L.footnoteId);return s===void 0?null:o.createElement(U.footnoteBackLink,{[L.footnoteId]:s})}}),e.for("dataDowncast").elementToElement({model:U.footnoteBackLink,view:sg}),e.for("editingDowncast").elementToElement({model:U.footnoteBackLink,view:sg})};function sg(n,e){const t=e.writer,i=`${n.getAttribute(L.footnoteId)}`;if(i===void 0)throw new Error("Footnote return link has no provided Id.");const o=t.createContainerElement("span",{class:Wi.footnoteBackLink,[L.footnoteBackLink]:"",[L.footnoteId]:i}),s=t.createContainerElement("sup"),r=t.createContainerElement("strong"),a=t.createContainerElement("a",{href:`#fnref${i}`}),l=t.createText("^");return t.insert(t.createPositionAt(a,0),l),t.insert(t.createPositionAt(r,0),a),t.insert(t.createPositionAt(s,0),r),t.insert(t.createPositionAt(o,0),s),o}function rg(n,e){const t=e.writer,i=`${n.getAttribute(L.footnoteIndex)}`,o=`${n.getAttribute(L.footnoteId)}`;if(i==="undefined")throw new Error("Footnote reference has no provided index.");if(o==="undefined")throw new Error("Footnote reference has no provided id.");const s=t.createContainerElement("span",{class:Wi.footnoteReference,[L.footnoteReference]:"",[L.footnoteIndex]:i,[L.footnoteId]:o,role:"doc-noteref",id:`fnref${o}`}),r=t.createText(`[${i}]`),a=t.createContainerElement("a",{href:`#fn${o}`}),l=t.createContainerElement("sup");return t.insert(t.createPositionAt(a,0),r),t.insert(t.createPositionAt(l,0),a),t.insert(t.createPositionAt(s,0),l),s}function ag(n,e){const t=e.writer,i=n.getAttribute(L.footnoteIndex),o=n.getAttribute(L.footnoteId);if(!i)throw new Error("Footnote item has no provided index.");if(!o)throw new Error("Footnote item has no provided id.");return t.createContainerElement("li",{class:Wi.footnoteItem,[L.footnoteItem]:"",[L.footnoteIndex]:`${i}`,[L.footnoteId]:`${o}`,role:"doc-endnote",id:`fn${o}`})}function w9(n,e,t){const{item:i,attributeNewValue:o}=n;if(!(i instanceof ne)||!e.consumable.consume(i,`attribute:${L.footnoteIndex}:${U.footnoteReference}`))return;const s=e.mapper.toViewElement(i);if(!s)return;const r=e.writer,a=d9(t,s,u=>u.name==="a"),l=a?.getChild(0);if(!l||!a){r.remove(s);return}r.remove(l);const c=r.createText(`[${o}]`);r.insert(r.createPositionAt(a,0),c),r.setAttribute("href",`#fn${i.getAttribute(L.footnoteId)}`,a),r.setAttribute(L.footnoteIndex,o,s)}const b9=n=>{n.register(U.footnoteSection,{isObject:!0,allowWhere:"$block",allowIn:"$root",allowChildren:U.footnoteItem,allowAttributes:[L.footnoteSection]}),n.register(U.footnoteItem,{isBlock:!0,isObject:!0,allowContentOf:"$root",allowAttributes:[L.footnoteSection,L.footnoteId,L.footnoteIndex]}),n.register(U.footnoteContent,{allowIn:U.footnoteItem,allowContentOf:"$root",allowAttributes:[L.footnoteSection]}),n.register(U.footnoteReference,{allowWhere:"$text",isInline:!0,isObject:!0,allowAttributes:[L.footnoteReference,L.footnoteId,L.footnoteIndex]}),n.register(U.footnoteBackLink,{allowIn:U.footnoteItem,isInline:!0,isSelectable:!1,allowAttributes:[L.footnoteBackLink,L.footnoteId]}),n.addChildCheck((e,t)=>{if(e.endsWith(U.footnoteContent)&&t.name===U.footnoteSection||e.endsWith(U.footnoteContent)&&t.name==="listItem")return!1})};class _9 extends O{execute({footnoteIndex:e}={footnoteIndex:0}){this.editor.model.enqueueChange(t=>{const i=this.editor.model.document,o=i.getRoot();if(!o)return;const s=this._getFootnoteSection(t,o);let r,a;if(e===0)r=`${s.maxOffset+1}`,a=Math.random().toString(36).slice(2);else{r=`${e}`;const f=wo(this.editor,s,g=>g.is("element",U.footnoteItem)&&g.getAttribute(L.footnoteIndex)===r);f&&(a=f.getAttribute(L.footnoteId))}if(!a||!r)return;t.setSelection(i.selection.getLastPosition());const l=t.createElement(U.footnoteReference,{[L.footnoteId]:a,[L.footnoteIndex]:r});if(this.editor.model.insertContent(l),t.setSelection(l,"after"),e!==0)return;const c=t.createElement(U.footnoteContent),u=t.createElement(U.footnoteItem,{[L.footnoteId]:a,[L.footnoteIndex]:r}),d=t.createElement(U.footnoteBackLink,{[L.footnoteId]:a}),m=t.createElement("paragraph");t.append(m,c),t.append(c,u),t.insert(d,u,0),this.editor.model.insertContent(u,t.createPositionAt(s,s.maxOffset))})}refresh(){const e=this.editor.model,t=e.document.selection.getLastPosition(),i=t&&e.schema.findAllowedParent(t,U.footnoteReference);this.isEnabled=i!==null}_getFootnoteSection(e,t){const i=wo(this.editor,t,s=>s.is("element",U.footnoteSection));if(i)return i;const o=e.createElement(U.footnoteSection);return this.editor.model.insertContent(o,e.createPositionAt(t,t.maxOffset)),o}}class v9 extends w{static get pluginName(){return"FootnotesEditing"}static get requires(){return[Vt,yu]}get rootElement(){const e=this.editor.model.document.getRoot();if(!e)throw new Error("Document has no rootElement element.");return e}init(){b9(this.editor.model.schema),p9(this.editor),this.editor.commands.add(ji.insertFootnote,new _9(this.editor)),g9(this.editor,this.rootElement),this.editor.model.document.on("change:data",(e,t)=>{const i=[...e.source.differ.getChanges()];i.some(o=>o.type==="insert"&&o.name===U.footnoteReference)&&this._orderFootnotes(t),i.forEach(o=>{if(o.type==="attribute"&&o.attributeKey===L.footnoteIndex){const{attributeNewValue:s}=o,r=[...o.range.getItems()].find(l=>l.is("element",U.footnoteItem)),a=r instanceof ne&&r.getAttribute(L.footnoteId);if(!a)return;this._updateReferenceIndices(t,`${a}`,s)}})},{priority:"high"}),this._handleDelete(),this.editor.editing.mapper.on("viewToModelPosition",Cu(this.editor.model,e=>e.hasAttribute(L.footnoteReference)))}_handleDelete(){const e=this.editor.editing.view.document,t=this.editor;this.listenTo(e,"delete",(i,o)=>{const s=t.model.document,r=s.selection.getSelectedElement(),a=s.selection.getLastPosition(),l=s.selection.getFirstPosition();if(!a||!l)throw new Error("Selection must have at least one range to perform delete operation.");this.editor.model.change(c=>{r&&r.is("element",U.footnoteSection)&&this._removeReferences(c);const u=r&&r.is("element",U.footnoteItem),d=u?r:a.findAncestor(U.footnoteItem);if(!d)return;const m=a.findAncestor("paragraph"),f=l.findAncestor("paragraph"),g=a.findAncestor(U.footnoteContent);if(!g||!f||!m)return;const p=f.maxOffset===0&&g.childCount===1;(u||p)&&(this._removeFootnote(c,d),o.preventDefault(),i.stop())})},{priority:"high"})}_clearContents(e,t){const i=e.createRangeIn(t);e.appendElement("paragraph",t),e.remove(i)}_removeFootnote(e,t){if(!this.editor)return;const i=t.findAncestor(U.footnoteSection);if(!i){e.remove(t);return}const o=i.getChildIndex(t),s=t.getAttribute(L.footnoteId);if(this._removeReferences(e,`${s}`),e.remove(t),i.childCount===0)e.remove(i),this._removeReferences(e);else{if(o==null)throw new Error("Index is nullish");const a=o===0?i.getChild(o):i.getChild((o??0)-1);if(!(a instanceof ne))return;const l=wn(this.editor,a,c=>c.is("element","paragraph")).pop();l&&e.setSelection(l,"end")}if(o==null)throw new Error("Index is nullish");const r=[...i.getChildren()].slice(o??0);for(const[a,l]of r.entries())e.setAttribute(L.footnoteIndex,`${o??0+a+1}`,l)}_removeReferences(e,t=void 0){const i=[];if(!this.rootElement)throw new Error("Document has no root element.");wn(this.editor,this.rootElement,o=>o.is("element",U.footnoteReference)).forEach(o=>{const s=o.getAttribute(L.footnoteId);(!t||s===t)&&i.push(o)});for(const o of i)e.remove(o)}_updateReferenceIndices(e,t,i){const o=wn(this.editor,this.rootElement,s=>s.is("element",U.footnoteReference)&&s.getAttribute(L.footnoteId)===t);this.editor.model.enqueueChange(e,s=>{o.forEach(r=>{s.setAttribute(L.footnoteIndex,i,r)})})}_orderFootnotes(e){const t=wn(this.editor,this.rootElement,o=>o.is("element",U.footnoteReference)),i=[...new Set(t.map(o=>o.getAttribute(L.footnoteId)))].map(o=>wo(this.editor,this.rootElement,s=>s.is("element",U.footnoteItem)&&s.getAttribute(L.footnoteId)===o));this.editor.model.enqueueChange(e,o=>{const s=wo(this.editor,this.rootElement,r=>r.is("element",U.footnoteSection));if(s){for(const r of i.reverse())r&&o.move(o.createRangeOn(r),s,0);for(const r of wn(this.editor,s,a=>a.is("element",U.footnoteItem))){const a=`${(s?.getChildIndex(r)??-1)+1}`;r&&o.setAttribute(L.footnoteIndex,a,r);const l=r.getAttribute(L.footnoteId);l&&this._updateReferenceIndices(e,`${l}`,`${a}`)}}})}}class y9 extends w{static get pluginName(){return"FootnoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(h9,i=>{const o=Ee(i,Xi),s=o.buttonView,r=e.commands.get(ji.insertFootnote);if(!r)throw new Error("Command not found.");return s.set({label:t("Footnote"),icon:u9,tooltip:!0,isToggleable:!0}),s.bind("isOn").to(r,"value",a=>!!a),s.on("execute",()=>{e.execute(ji.insertFootnote,{footnoteIndex:0}),e.editing.view.focus()}),o.class="ck-code-block-dropdown",o.bind("isEnabled").to(r),o.on("change:isOpen",(a,l,c)=>{var u,d,m;if((u=o?.listView)==null||u.items.clear(),c)wt(o,this.getDropdownItemsDefinitions());else{(d=o?.listView)==null||d.items.clear();const f=(m=o?.listView)==null?void 0:m.element;f&&f.parentNode&&f.parentNode.removeChild(f)}}),this.listenTo(o,"execute",a=>{e.execute(ji.insertFootnote,{footnoteIndex:a.source.commandParam}),e.editing.view.focus()}),o})}getDropdownItemsDefinitions(){const e=new _e,t={type:"button",model:new et({commandParam:0,label:"New footnote",withText:!0})};e.add(t);const i=this.editor.model.document.getRoot();if(!i)throw new Error("Document has no root element.");return wo(this.editor,i,o=>o.is("element",U.footnoteSection))&&wn(this.editor,i,o=>o.is("element",U.footnoteItem)).forEach(o=>{const s=o.getAttribute(L.footnoteIndex),r={type:"button",model:new et({commandParam:s,label:`Insert footnote ${s}`,withText:!0})};e.add(r)}),e}}class k9 extends w{static get pluginName(){return"Footnotes"}static get requires(){return[v9,y9]}}var C9=`
`;function A9(n){const e=n.getSelectedElement();return e&&(e.is("element","mathtex-inline")||e.is("element","mathtex-display"))?e:null}function V0(n){return n!=null&&typeof n=="object"&&"version"in n&&typeof n.version=="string"&&n.version.split(".").length===3&&n.version.split(".")[0]==="3"}function R0(n){return n!=null&&typeof n=="object"&&"Hub"in n}function O0(n){return n.match(/^(\\\[.*?\\\]|\\\(.*?\\\))$/)}function x9(n){var e;return(e=n.match(/(\\\[|\\\]|\\\(|\\\))/g))==null?void 0:e.length}function Gu(n){n=n.trim();const e=n.includes("\\(")&&n.includes("\\)"),t=n.includes("\\[")&&n.includes("\\]");return(e||t)&&(n=n.substring(2,n.length-2).trim()),{equation:n,display:t}}async function Ku(n,e,t="katex",i,o=!1,s=!1,r="",a=[],l={}){if(t=="mathjax")V0(MathJax)?Pl(e,s,r,a,c=>{E9(n,c,o,()=>{s&&(c.style.visibility="visible")})}):Pl(e,s,r,a,c=>{window.setTimeout(()=>{S9(n,c,o),s&&R0(MathJax)&&MathJax.Hub.Queue(()=>{c.style.visibility="visible"})})});else if(t==="katex"&&window.katex!==void 0)Pl(e,s,r,a,c=>{katex&&katex.render(n,c,{throwOnError:!1,displayMode:o,...l}),s&&(c.style.visibility="visible")});else if(typeof t=="function")t(n,e,o);else if(i!=null)try{window.CKEDITOR_MATH_LAZY_LOAD??(window.CKEDITOR_MATH_LAZY_LOAD=i()),e.innerHTML=n,await window.CKEDITOR_MATH_LAZY_LOAD,await Ku(n,e,t,void 0,o,s,r,a,l)}catch(c){e.innerHTML=n,console.error(`math-tex-typesetting-lazy-load-failed: Lazy load failed: ${String(c)}`)}else e.innerHTML=n,console.warn(`math-tex-typesetting-missing: Missing the mathematical typesetting engine (${String(t)}) for tex.`)}function T9(n){const e=n.editing.view,t=Ne.defaultPositions,i=e.document.selection.getSelectedElement();if(i)return{target:e.domConverter.viewToDom(i),positions:[t.southArrowNorth,t.southArrowNorthWest,t.southArrowNorthEast]};{const o=e.document.selection.getFirstRange();if(!o)throw new b("math-missing-range");return{target:e.domConverter.viewRangeToDom(o),positions:[t.southArrowNorth,t.southArrowNorthWest,t.southArrowNorthEast]}}}function Pl(n,e,t,i,o){e?P9(n,t,i,s=>{o(s)}):o(n)}function E9(n,e,t,i){let o;V0(MathJax)&&(MathJax.tex2chtmlPromise?o=MathJax.tex2chtmlPromise:MathJax.tex2svgPromise&&(o=MathJax.tex2svgPromise),o?.(n,{display:t}).then(s=>{e.firstChild&&e.removeChild(e.firstChild),e.appendChild(s),i()}))}function S9(n,e,t){R0(MathJax)&&(t?e.innerHTML="\\["+n+"\\]":e.innerHTML="\\("+n+"\\)",MathJax.Hub.Queue(["Typeset",MathJax.Hub,e]))}function P9(n,e,t,i){const o=I9(n,e,t);i(o)}function I9(n,e,t){let i=document.getElementById(e);return i||(i=document.createElement("div"),i.setAttribute("id",e),i.classList.add(...t),i.style.visibility="hidden",n.appendChild(i)),i}class Yr extends O{constructor(){super(...arguments),h(this,"value",null),h(this,"display",!1)}execute(e,t,i="script",o){const s=this.editor.model,r=s.document.selection.getSelectedElement();s.change(a=>{let l;if(r&&(r.is("element","mathtex-inline")||r.is("element","mathtex-display"))){const c=r.getAttribute("type"),u=o?i:c||i;l=a.createElement(t?"mathtex-display":"mathtex-inline",{equation:e,type:u,display:t})}else l=a.createElement(t?"mathtex-display":"mathtex-inline",{equation:e,type:i,display:t});s.insertContent(l)})}refresh(){const e=this.editor.model.document.selection,t=e.getSelectedElement();this.isEnabled=t===null||t.is("element","mathtex-inline")||t.is("element","mathtex-display");const i=A9(e),o=i?.getAttribute("equation");this.value=typeof o=="string"?o:null;const s=i?.getAttribute("display");this.display=typeof s=="boolean"?s:!1}}class B0 extends w{static get requires(){return[Vt]}static get pluginName(){return"MathEditing"}constructor(e){super(e),e.config.define("math",{engine:"mathjax",outputType:"script",className:"math-tex",forceOutputType:!1,enablePreview:!0,previewClassName:[],popupClassName:[],katexRenderOptions:{}})}init(){const e=this.editor,t=e.data.processor,i=t.toView.bind(t),o=/([\s\S]*?)<\/span>/g;t.toView=s=>{const r=s.replace(o,(a,l)=>`${l.replace(/\n/g,"___MATH_TEX_LF___")}`);return i(r)},e.commands.add("math",new Yr(e)),this._defineSchema(),this._defineConverters(),e.editing.mapper.on("viewToModelPosition",Cu(e.model,s=>s.hasClass("math")))}_defineSchema(){const e=this.editor.model.schema;e.register("mathtex-inline",{allowWhere:"$text",isInline:!0,isObject:!0,allowAttributes:["equation","type","display"]}),e.register("mathtex-display",{inheritAllFrom:"$blockObject",allowAttributes:["equation","type","display"]})}_defineConverters(){const e=this.editor.conversion,t=this.editor.config.get("math");e.for("upcast").elementToElement({view:{name:"script",attributes:{type:"math/tex"}},model:(s,{writer:r})=>{const a=s.getChild(0);if(a!=null&&a.is("$text")){const l=a.data.trim();return r.createElement("mathtex-inline",{equation:l,type:t.forceOutputType?t.outputType:"script",display:!1})}return null}}).elementToElement({view:{name:"script",attributes:{type:"math/tex; mode=display"}},model:(s,{writer:r})=>{const a=s.getChild(0);if(a!=null&&a.is("$text")){const l=a.data.trim();return r.createElement("mathtex-display",{equation:l,type:t.forceOutputType?t.outputType:"script",display:!0})}return null}}).elementToElement({view:{name:"span",classes:[t.className]},model:(s,{writer:r})=>{const a=s.getChild(0);if(a!=null&&a.is("$text")){const l=a.data.trim().replace(/___MATH_TEX_LF___/g,`
`),c=Object.assign(Gu(l),{type:t.forceOutputType?t.outputType:"span"});return r.createElement(c.display?"mathtex-display":"mathtex-inline",c)}return null}}).elementToElement({view:{name:"span",classes:["ql-formula"]},model:(s,{writer:r})=>{const a=s.getAttribute("data-value");if(a==null)throw new b("missing-equation",{pluginName:"math"});return r.createElement("mathtex-inline",{equation:a.trim(),type:t.forceOutputType?t.outputType:"script",display:!1})}}),e.for("editingDowncast").elementToElement({model:"mathtex-inline",view:(s,{writer:r})=>{const a=i(s,r);return gt(a,r)}}).elementToElement({model:"mathtex-display",view:(s,{writer:r})=>{const a=i(s,r);return gt(a,r)}}),e.for("dataDowncast").elementToElement({model:"mathtex-inline",view:o}).elementToElement({model:"mathtex-display",view:o});function i(s,r){const a=String(s.getAttribute("equation")),l=!!s.getAttribute("display"),c="user-select: none; "+(l?"":"display: inline-block;"),u="ck-math-tex "+(l?"ck-math-tex-display":"ck-math-tex-inline"),d=r.createContainerElement(l?"div":"span",{style:c,class:u}),m=r.createUIElement("div",null,function(f){const g=this.toDomElement(f);return Ku(a,g,t.engine,t.lazyLoad,l,!1,`math-editing-${ze()}`,t.previewClassName,t.katexRenderOptions),g});return r.insert(r.createPositionAt(d,0),m),d}function o(s,{writer:r}){const a=s.getAttribute("equation");if(typeof a!="string")throw new b("missing-equation",{pluginName:"math"});const l=s.getAttribute("type"),c=s.getAttribute("display");if(l==="span"){const u=r.createContainerElement("span",{class:t.className});return c?r.insert(r.createPositionAt(u,0),r.createText("\\["+a+"\\]")):r.insert(r.createPositionAt(u,0),r.createText("\\("+a+"\\)")),u}else{const u=r.createContainerElement("script",{type:c?"math/tex; mode=display":"math/tex"});return r.insert(r.createPositionAt(u,0),r.createText(a)),u}}}}class V9 extends A{constructor(e,t,i,o,s,r){super(i),h(this,"previewUid"),h(this,"previewClassName"),h(this,"katexRenderOptions"),h(this,"engine"),h(this,"lazyLoad"),this.engine=e,this.lazyLoad=t,this.previewUid=o,this.katexRenderOptions=r,this.previewClassName=s,this.set("value",""),this.set("display",!1),this.on("change",()=>{this.isRendered&&this.updateMath()}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-math-preview","ck-reset_all-excluded"]}})}updateMath(){this.element&&Ku(this.value,this.element,this.engine,this.lazyLoad,this.display,!0,this.previewUid,this.previewClassName,this.katexRenderOptions)}render(){super.render(),this.updateMath()}}class R9 extends Te{constructor(e){super(e,Ix),h(this,"value",null),h(this,"isReadOnly",!1)}}class O9 extends A{constructor(e,t,i,o=!1,s,r,a,l){super(e),h(this,"saveButtonView"),h(this,"mathInputView"),h(this,"displayButtonView"),h(this,"cancelButtonView"),h(this,"previewEnabled"),h(this,"previewLabel"),h(this,"mathView"),h(this,"locale",new lp),h(this,"lazyLoad"),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"_focusables",new Ie),h(this,"_focusCycler",new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}));const c=e.t;this.saveButtonView=this._createButton(c("Save"),Es,"ck-button-save",null),this.saveButtonView.type="submit",this.mathInputView=this._createMathInput(),this.displayButtonView=this._createDisplayButton(),this.cancelButtonView=this._createButton(c("Cancel"),_o,"ck-button-cancel","cancel"),this.previewEnabled=o;let u=[];this.previewEnabled?(this.previewLabel=new xt(e),this.previewLabel.text=c("Equation preview"),this.mathView=new V9(t,i,e,s,r,l),this.mathView.bind("display").to(this.displayButtonView,"isOn"),u=[this.mathInputView,this.displayButtonView,this.previewLabel,this.mathView]):u=[this.mathInputView,this.displayButtonView],this.setTemplate({tag:"form",attributes:{class:["ck","ck-math-form",...a],tabindex:"-1",spellcheck:"false"},children:[{tag:"div",attributes:{class:["ck-math-view"]},children:u},this.saveButtonView,this.cancelButtonView]})}render(){super.render(),Ri({view:this}),[this.mathInputView,this.displayButtonView,this.saveButtonView,this.cancelButtonView].forEach(e=>{e.element&&(this._focusables.add(e),this.focusTracker.add(e.element))}),this.element&&this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}get equation(){var e;return((e=this.mathInputView.fieldView.element)==null?void 0:e.value)??""}set equation(e){this.mathInputView.fieldView.element&&(this.mathInputView.fieldView.element.value=e),this.previewEnabled&&this.mathView&&(this.mathView.value=e)}_createMathInput(){const e=this.locale.t,t=new R9(this.locale),i=t.fieldView;t.infoText=e("Insert equation in TeX format.");const o=()=>{if(i.element!=null){let s=i.element.value.trim();if(O0(s)){const r=Gu(s);i.element.value=r.equation,s=r.equation,this.displayButtonView.isOn=r.display}this.previewEnabled&&this.mathView&&(this.mathView.value=s),this.saveButtonView.isEnabled=!!s}};return i.on("render",o),i.on("input",o),t}_createButton(e,t,i,o){const s=new P(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),o&&s.delegate("execute").to(this,o),s}_createDisplayButton(){const e=this.locale.t,t=new Ji(this.locale);return t.set({label:e("Display mode"),withText:!0}),t.extendTemplate({attributes:{class:"ck-button-display-toggle"}}),t.on("execute",()=>{t.isOn=!t.isOn,this.previewEnabled&&this.mathView&&(this.mathView.display=t.isOn)}),t}}const lg="Ctrl+M";class M0 extends w{constructor(){super(...arguments),h(this,"_previewUid",`math-preview-${ze()}`),h(this,"_balloon",this.editor.plugins.get(Ue)),h(this,"formView",null)}static get requires(){return[Ue,B0]}static get pluginName(){return"MathUI"}init(){this.editor.editing.view.addObserver(ew),this._createToolbarMathButton(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}destroy(){var e,t;super.destroy(),(e=this.formView)==null||e.destroy();const i=document.getElementById(this._previewUid);i&&((t=i.parentNode)==null||t.removeChild(i))}_showUI(){const e=this.editor.commands.get("math");e!=null&&e.isEnabled&&(this._addFormView(),this._balloon.showStack("main"),requestAnimationFrame(()=>{var t,i;(i=(t=this.formView)==null?void 0:t.mathInputView.fieldView.element)==null||i.focus()}))}_createFormView(){const e=this.editor,t=e.commands.get("math");if(!(t instanceof Yr))throw new b("math-command");const i=e.config.get("math"),o=new O9(e.locale,i.engine,i.lazyLoad,i.enablePreview,this._previewUid,i.previewClassName,i.popupClassName,i.katexRenderOptions);return o.mathInputView.bind("value").to(t,"value"),o.displayButtonView.bind("isOn").to(t,"display"),o.mathInputView.bind("isReadOnly").to(t,"isEnabled",s=>!s),o.saveButtonView.bind("isEnabled").to(t),o.displayButtonView.bind("isEnabled").to(t),this.listenTo(o,"submit",()=>{e.execute("math",o.equation,o.displayButtonView.isOn,i.outputType,i.forceOutputType),this._closeFormView()}),this.listenTo(o,"cancel",()=>{this._closeFormView()}),o.keystrokes.set("esc",(s,r)=>{this._closeFormView(),r()}),o.keystrokes.set("enter",(s,r)=>{s.shiftKey||(o.fire("submit"),r())}),o.mathInputView.fieldView.once("render",()=>{const s=o.mathInputView.fieldView.element;s&&Object.assign(s.style,{resize:"both",height:"100px",width:"400px",minWidth:"100%"})}),o}_addFormView(){var e,t;if(this._isFormInPanel)return;const i=this.editor,o=i.commands.get("math");if(!(o instanceof Yr))throw new b("plugin-load",{pluginName:"math"});this.formView!=null&&(this._balloon.add({view:this.formView,position:T9(i)}),this._balloon.visibleView===this.formView&&((e=this.formView.mathInputView.fieldView.element)==null||e.select()),document.getElementById(this._previewUid)&&this.formView.previewEnabled&&((t=this.formView.mathView)==null||t.updateMath()),this.formView.equation=o.value??"",this.formView.displayButtonView.isOn=o.display||!1)}_hideUI(){if(!this._isFormInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView()}_closeFormView(){const e=this.editor.commands.get("math");e?.value!=null?this._removeFormView():this._hideUI()}_removeFormView(){if(this._isFormInPanel&&this.formView){this.formView.saveButtonView.focus(),this._balloon.remove(this.formView);const e=document.getElementById(this._previewUid);e&&(e.style.visibility="hidden"),this.editor.editing.view.focus()}}_createToolbarMathButton(){const e=this.editor,t=e.commands.get("math");if(!t)throw new b("plugin-load",{pluginName:"math"});const i=e.t;e.keystrokes.set(lg,(o,s)=>{s(),t.isEnabled&&this._showUI()}),this.editor.ui.componentFactory.add("math",o=>{const s=new P(o);return s.isEnabled=!0,s.label=i("Insert math"),s.icon=C9,s.keystroke=lg,s.tooltip=!0,s.isToggleable=!0,s.bind("isEnabled").to(t,"isEnabled"),this.listenTo(s,"execute",()=>{this._showUI()}),s})}_enableUserBalloonInteractions(){const e=this.editor,t=this.editor.editing.view.document;if(this.listenTo(t,"click",()=>{const i=e.commands.get("math");i!=null&&i.isEnabled&&i.value&&this._showUI()}),e.keystrokes.set("Esc",(i,o)=>{this._isUIVisible&&(this._hideUI(),o())}),this.formView)$t({emitter:this.formView,activator:()=>!!this._isFormInPanel,contextElements:this._balloon.view.element?[this._balloon.view.element]:[],callback:()=>{this._hideUI()}});else throw new Error("missing form view")}get _isUIVisible(){return this._balloon.visibleView==this.formView}get _isFormInPanel(){return this.formView&&this._balloon.hasView(this.formView)}}class B9 extends w{constructor(e){super(e),h(this,"_timeoutId"),h(this,"_positionToInsert"),this._timeoutId=null,this._positionToInsert=null}static get requires(){return[_s,Ub]}static get pluginName(){return"AutoMath"}init(){var e;const t=this.editor,i=t.model.document;this.listenTo(t.plugins.get(_s),"inputTransformation",()=>{const o=i.selection.getFirstRange();if(!o)return;const s=Me.fromPosition(o.start);s.stickiness="toPrevious";const r=Me.fromPosition(o.end);r.stickiness="toNext",i.once("change:data",()=>{this._mathBetweenPositions(s,r),s.detach(),r.detach()},{priority:"high"})}),(e=t.commands.get("undo"))==null||e.on("execute",()=>{var o;this._timeoutId&&(window.clearTimeout(this._timeoutId),(o=this._positionToInsert)==null||o.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_mathBetweenPositions(e,t){const i=this.editor,o=this.editor.config.get("math"),s=new ht(e,t),r=s.getWalker({ignoreElementEnd:!0});let a="";for(const c of r)c.item.is("$textProxy")&&(a+=c.item.data);if(a=a.trim(),!O0(a)||x9(a)!==2)return;const l=i.commands.get("math");l!=null&&l.isEnabled&&(this._positionToInsert=Me.fromPosition(e),this._timeoutId=window.setTimeout(()=>{i.model.change(c=>{var u,d;this._timeoutId=null,c.remove(s);let m;((u=this._positionToInsert)==null?void 0:u.root.rootName)!=="$graveyard"&&(m=this._positionToInsert),i.model.change(f=>{const g=Object.assign(Gu(a),{type:o?.outputType}),p=f.createElement(g.display?"mathtex-display":"mathtex-inline",g);i.model.insertContent(p,m),f.setSelection(p,"on")}),(d=this._positionToInsert)==null||d.detach(),this._positionToInsert=null})},100))}}let L0=class extends w{static get requires(){return[B0,M0,B9,Vt]}static get pluginName(){return"Math"}};class M9 extends w{static get requires(){return[L0,"Autoformat"]}init(){const e=this.editor;e.plugins.has("Math")||J("autoformat-math-feature-missing",e)}afterInit(){const e=this.editor,t=e.commands.get("math");if(t instanceof Yr){const i=()=>{if(!t.isEnabled)return!1;t.display=!0,window.setTimeout(()=>{const o=e.plugins.get("MathUI");o instanceof M0&&o._showUI()},50)};Wt(e,this,/^\$\$$/,i),Wt(e,this,/^\\\[$/,i)}}static get pluginName(){return"AutoformatMath"}}class F0 extends w{static get requires(){return[Tu]}init(){const e=this.editor,t=e.ui.componentFactory,i=this._getNormalizedAndLocalizedLanguageDefinitions(e),o=this._getLanguageListItemDefinitions(i),s=e.commands.get("codeBlock");t.add("codeBlockDropdown",r=>{const a=Ee(this.editor.locale,fu);return a.buttonView.set({withText:!0}),a.bind("isEnabled").to(s,"value",l=>!!l),a.buttonView.bind("label").to(s,"value",l=>{const c=i.find(u=>u.language===l);return c?.label}),a.on("execute",l=>{e.execute("codeBlock",{language:l.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),wt(a,o),a})}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new _e;for(const o of e){const s={type:"button",model:new et({_codeBlockLanguage:o.language,label:o.label,role:"menuitemradio",withText:!0})};s.model.bind("isOn").to(t,"value",r=>r===s.model._codeBlockLanguage),i.add(s)}return i}_getNormalizedAndLocalizedLanguageDefinitions(e){const t=e.config.get("codeBlock.languages");for(const i of t)i.class===void 0&&(i.class=`language-${i.language}`);return t}}const L9='';class F9 extends w{init(){const e=this.editor;e.commands.add("copyToClipboard",new N9(this.editor)),e.ui.componentFactory.add("copyToClipboard",t=>{const i=new P(t);return i.set({tooltip:"Copy to clipboard",icon:L9}),this.listenTo(i,"execute",()=>{e.execute("copyToClipboard")}),i})}}class N9 extends O{constructor(){super(...arguments),h(this,"executeCallback")}execute(...e){var t,i;const o=this.editor.model.document.selection;this.executeCallback||(this.executeCallback=(t=this.editor.config.get("clipboard"))==null?void 0:t.copy);const s=(i=o.getFirstPosition())==null?void 0:i.findAncestor("codeBlock");if(!s){console.warn("Unable to find code block element to copy from.");return}const r=Array.from(s.getChildren()).map(a=>"data"in a?a.data:`
`).join("");r?this.executeCallback?this.executeCallback(r):navigator.clipboard.writeText(r).then(()=>{console.log("Code block copied to clipboard")}).catch(a=>{console.error("Failed to copy code block",a)}):console.warn("No code block selected or found.")}}class D9 extends w{static get requires(){return[ci,Tu,F0,F9]}afterInit(){const e=this.editor;e.plugins.get(ci).register("codeblock",{items:["codeBlockDropdown","|","copyToClipboard"],balloonClassName:"ck-toolbar-container codeblock-language-list",getRelatedElement(t){const i=t.getFirstPosition();if(!i)return null;let o=i.parent;for(;o;){if(o.is("element","pre"))return o;o=o.parent}return null}}),e.plugins.has("BalloonToolbar")&&e.listenTo(e.plugins.get("BalloonToolbar"),"show",t=>{const i=e.model.document.selection.getFirstPosition();i?.findAncestor("codeBlock")&&t.stop()},{priority:"high"})}}class z9 extends w{init(){const e=this.editor;e.commands.add("moveBlockUp",new H9(e)),e.commands.add("moveBlockDown",new $9(e)),this.bindMoveBlockShortcuts(e)}bindMoveBlockShortcuts(e){e.editing.view.once("render",()=>{const t=e.editing.view.getDomRoot();if(!t)return;const i=o=>{const s={ArrowUp:"moveBlockUp",ArrowDown:"moveBlockDown"}[o.key],r=o.ctrlKey||o.metaKey,a=(r||o.altKey)&&!(r&&o.altKey);s&&a&&(o.preventDefault(),o.stopImmediatePropagation(),e.execute(s))};t.addEventListener("keydown",i,{capture:!0})})}}class N0 extends O{execute(){var e,t;const i=this.editor.model,o=i.document.selection,s=this.getSelectedBlocks(o);if(!(s.length>0&&s.every(d=>!!this.getSibling(d))))return;const r=this.offset==="before"?s:[...s].reverse(),a=s[0],l=s[s.length-1],c=((e=i.document.selection.getFirstPosition())==null?void 0:e.offset)??0,u=((t=i.document.selection.getLastPosition())==null?void 0:t.offset)??0;i.change(d=>{for(const p of r){const _=this.getSibling(p);if(_){const v=i.createRangeOn(p);d.move(v,_,this.offset)}}let m;const f=a.maxOffset??c,g=l.maxOffset??u;if(c<=f&&u<=g){const p=Math.min(c,f),_=Math.min(u,g);m=d.createRange(d.createPositionAt(a,p),d.createPositionAt(l,_))}else m=d.createRange(d.createPositionBefore(a),d.createPositionAfter(l));d.setSelection(m),this.editor.editing.view.focus(),this.scrollToSelection()})}getSelectedBlocks(e){const t=[...e.getSelectedBlocks()],i=[];if(!t.length){const o=e.getSelectedElement();if(o)return[o]}for(const o of t){let s=o;for(;s.parent&&s.parent.name!=="$root";)s=s.parent;i.push(s)}return i.filter((o,s)=>s===0||o!==i[s-1])}scrollToSelection(){requestAnimationFrame(()=>{this.editor.editing.view.scrollToTheSelection()})}}class H9 extends N0{getSibling(e){return e.previousSibling}get offset(){return"before"}}class $9 extends N0{getSibling(e){return e.nextSibling}get offset(){return"after"}}class W9 extends w{init(){var e,t;const i=this.editor,o=()=>{requestAnimationFrame(()=>{i.editing.view.scrollToTheSelection()})};(e=i.commands.get("undo"))==null||e.on("execute",o),(t=i.commands.get("redo"))==null||t.on("execute",o)}}const j9=[EO,TO,PO,IO,BO,LO,FO,NO,zO,jO,sB,rB,F0,D9,z9,W9],U9=[dB,e9,c9,k9,L0,M9],D0=[_s,Ao,Wb,Tb,pa,Ub,Su,Y1,HO,S0],z0=[...D0,aC,yu,iE,cE,yE,dE,rE,bE,gE,IE,AP,F4,H4,EI,SI,sI,pI,f1,yV,V1,qV,n7,f7,O6,II,E8,S8,pO,K8,Ai,AO,X8,BT,OI,MI,vP,TP,GT,wP,e1,t1,Tu,Wb,OP,e0,$6,K6,jS,$7,w4,zI,hR,C3,yS,...j9,...U9],q9=[...z0,yT];class G9 extends Nb{static get builtinPlugins(){return D0}}class K9 extends X3{static get builtinPlugins(){return z0}}class Z9 extends Nb{static get builtinPlugins(){return q9}}export{G9 as AttributeEditor,K9 as ClassicEditor,lw as EditorWatchdog,Z9 as PopupEditor};