mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
* N°9128 - Update CKEditor5 to v48 * Move some CSS vars to ckeditor, align variable overload in portal and backoffice * Add specifics to 3.2 portal * Update CKEditor5 build files * Update scssphp with patched version that handles pseudo selectors and attribute selectors * Update scssphp patched version to fix missing $this * Fix translations specific language file import * Remove unused maximize parameters * Update CKEditor5 build files * Fix font size/color for 3.2 portal * Avoid CKEditor styles from bleeding into fields
1 line
1.1 MiB
1 line
1.1 MiB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ClassicEditor=t():e.ClassicEditor=t()}(self,()=>(()=>{"use strict";var e={d:(t,i)=>{for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function i(e){return null!==e&&("object"==typeof e||"function"==typeof e)}function n(e){return"string"==typeof e||e instanceof String}function s(e){if("object"!=typeof e)return!1;if(null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];if(null==t)return!1;return!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function o(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function r(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}e.d(t,{default:()=>$x});const a="[object RegExp]",l="[object String]",c="[object Number]",d="[object Boolean]",u="[object Arguments]",h="[object Symbol]",m="[object Date]",g="[object Map]",f="[object Set]",p="[object Array]",b="[object ArrayBuffer]",w="[object Object]",_="[object DataView]",v="[object Uint8Array]",y="[object Uint8ClampedArray]",k="[object Uint16Array]",C="[object Uint32Array]",A="[object Int8Array]",T="[object Int16Array]",E="[object Int32Array]",x="[object Float32Array]",P="[object Float64Array]";function S(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function I(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function O(e,t,i,n=new Map,s=void 0){const o=s?.(e,t,i,n);if(void 0!==o)return o;if(S(e))return e;if(n.has(e))return n.get(e);if(Array.isArray(e)){const t=new Array(e.length);n.set(e,t);for(let o=0;o<e.length;o++)t[o]=O(e[o],o,i,n,s);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){const t=new Map;n.set(e,t);for(const[o,r]of e)t.set(o,O(r,o,i,n,s));return t}if(e instanceof Set){const t=new Set;n.set(e,t);for(const o of e)t.add(O(o,void 0,i,n,s));return t}if("undefined"!=typeof Buffer&&Buffer.isBuffer(e))return e.subarray();if(I(e)){const t=new(Object.getPrototypeOf(e).constructor)(e.length);n.set(e,t);for(let o=0;o<e.length;o++)t[o]=O(e[o],o,i,n,s);return t}if(e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return n.set(e,t),R(t,e,i,n,s),t}if("undefined"!=typeof File&&e instanceof File){const t=new File([e],e.name,{type:e.type});return n.set(e,t),R(t,e,i,n,s),t}if("undefined"!=typeof Blob&&e instanceof Blob){const t=new Blob([e],{type:e.type});return n.set(e,t),R(t,e,i,n,s),t}if(e instanceof Error){const t=structuredClone(e);return n.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,t.constructor=e.constructor,R(t,e,i,n,s),t}if(e instanceof Boolean){const t=new Boolean(e.valueOf());return n.set(e,t),R(t,e,i,n,s),t}if(e instanceof Number){const t=new Number(e.valueOf());return n.set(e,t),R(t,e,i,n,s),t}if(e instanceof String){const t=new String(e.valueOf());return n.set(e,t),R(t,e,i,n,s),t}if("object"==typeof e&&function(e){switch(r(e)){case u:case p:case b:case _:case d:case m:case x:case P:case A:case T:case E:case g:case c:case w:case a:case f:case l:case h:case v:case y:case k:case C:return!0;default:return!1}}(e)){const t=Object.create(Object.getPrototypeOf(e));return n.set(e,t),R(t,e,i,n,s),t}return e}function R(e,t,i=e,n,s){const r=[...Object.keys(t),...o(t)];for(let o=0;o<r.length;o++){const a=r[o],l=Object.getOwnPropertyDescriptor(e,a);(null==l||l.writable)&&(e[a]=O(t[a],a,i,n,s))}}function V(e,t){return function(e,t){return O(e,void 0,e,new Map,t)}(e,(i,n,s,o)=>{const a=t?.(i,n,s,o);if(void 0!==a)return a;if("object"==typeof e){if(r(e)===w&&"function"!=typeof e.constructor){const t={};return o.set(e,t),R(t,e,s,o),t}switch(Object.prototype.toString.call(e)){case c:case l:case d:{const t=new e.constructor(e?.valueOf());return R(t,e),t}case u:{const t={};return R(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}function B(e){return"object"==typeof e&&null!==e}function M(e){return B(e)&&1===e.nodeType&&!s(e)}function F(e){return"function"==typeof e}function N(e){return V(e)}function L(e){return"__proto__"===e}function D(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===r(e)}function z(e){return null!=e&&"function"!=typeof e&&function(e){return Number.isSafeInteger(e)&&e>=0}(e.length)}function H(e){return B(e)&&z(e)}function W(e){return I(e)}function j(e,...t){const i=t.slice(0,-1),n=t[t.length-1];let s=e;for(let e=0;e<i.length;e++){s=U(s,i[e],n,new Map)}return s}function U(e,t,i,n){if(S(e)&&(e=Object(e)),null==t||"object"!=typeof t)return e;if(n.has(t))return function(e){if(S(e))return e;if(Array.isArray(e)||I(e)||e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e);if(null==t)return Object.assign(Object.create(t),e);const i=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new i(e);if(e instanceof RegExp){const t=new i(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new i(e.buffer.slice(0));if(e instanceof Error){let t;return t=e instanceof AggregateError?new i(e.errors,e.message,{cause:e.cause}):new i(e.message,{cause:e.cause}),t.stack=e.stack,Object.assign(t,e),t}if("undefined"!=typeof File&&e instanceof File)return new i([e],e.name,{type:e.type,lastModified:e.lastModified});if("object"==typeof e){const i=Object.create(t);return Object.assign(i,e)}return e}(n.get(t));if(n.set(t,e),Array.isArray(t)){t=t.slice();for(let e=0;e<t.length;e++)t[e]=t[e]??void 0}const r=[...Object.keys(t),...o(t)];for(let o=0;o<r.length;o++){const a=r[o];if(L(a))continue;let l=t[a],c=e[a];if(D(l)&&(l={...l}),D(c)&&(c={...c}),"undefined"!=typeof Buffer&&Buffer.isBuffer(l)&&(l=N(l)),Array.isArray(l))if(Array.isArray(c)){const e=[],t=Reflect.ownKeys(c);for(let i=0;i<t.length;i++){const n=t[i];e[n]=c[n]}c=e}else if(H(c)){const e=[];for(let t=0;t<c.length;t++)e[t]=c[t];c=e}else c=[];const d=i(c,l,a,e,t,n);void 0!==d?e[a]=d:Array.isArray(l)||B(c)&&B(l)&&(s(c)||s(l)||W(c)||W(l))?e[a]=U(c,l,i,n):null==c&&s(l)?e[a]=U({},l,i,n):null==c&&W(l)?e[a]=N(l):void 0!==c&&void 0===l||(e[a]=l)}return e}function q(){}function K(e,...t){return j(e,...t,q)}let G;try{G={window,document}}catch{G={window:{},document:{}}}function J(){try{return navigator.userAgent.toLowerCase()}catch{return""}}const Y=J(),Q={isMac:X(Y),isWindows:Z(Y),isGecko:ee(Y),isSafari:te(Y),isiOS:ie(Y),isAndroid:ne(Y),isBlink:se(Y),get isMediaForcedColors(){return!!G.window.matchMedia&&G.window.matchMedia("(forced-colors: active)").matches},get isMotionReduced(){return!!G.window.matchMedia&&G.window.matchMedia("(prefers-reduced-motion)").matches},features:{isRegExpUnicodePropertySupported:oe()}};function X(e){return e.indexOf("macintosh")>-1}function Z(e){return e.indexOf("windows")>-1}function ee(e){return!!e.match(/gecko\/\d+/)}function te(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}function ie(e){return!!e.match(/iphone|ipad/i)||X(e)&&navigator.maxTouchPoints>0}function ne(e){return e.indexOf("android")>-1}function se(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}function oe(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch{}return e}function re(e,t,i,n){i=i||function(e,t){return e===t};const s=Array.isArray(e)?e:Array.prototype.slice.call(e),o=Array.isArray(t)?t:Array.prototype.slice.call(t),r=function(e,t,i){const n=ae(e,t,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const s=le(e,n),o=le(t,n),r=ae(s,o,i),a=e.length-r,l=t.length-r;return{firstIndex:n,lastIndexOld:a,lastIndexNew:l}}(s,o,i),a=n?function(e,t){const{firstIndex:i,lastIndexOld:n,lastIndexNew:s}=e;if(-1===i)return Array(t).fill("equal");let o=[];i>0&&(o=o.concat(Array(i).fill("equal")));s-i>0&&(o=o.concat(Array(s-i).fill("insert")));n-i>0&&(o=o.concat(Array(n-i).fill("delete")));s<t&&(o=o.concat(Array(t-s).fill("equal")));return o}(r,o.length):function(e,t){const i=[],{firstIndex:n,lastIndexOld:s,lastIndexNew:o}=t;o-n>0&&i.push({index:n,type:"insert",values:e.slice(n,o)});s-n>0&&i.push({index:n+(o-n),type:"delete",howMany:s-n});return i}(o,r);return a}function ae(e,t,i){for(let n=0;n<Math.max(e.length,t.length);n++)if(void 0===e[n]||void 0===t[n]||!i(e[n],t[n]))return n;return-1}function le(e,t){return e.slice(t).reverse()}function ce(e,t,i){i=i||function(e,t){return e===t};const n=e.length,s=t.length;if(n>200||s>200||n+s>300)return ce.fastDiff(e,t,i,!0);let o,r;if(s<n){const i=e;e=t,t=i,o="delete",r="insert"}else o="insert",r="delete";const a=e.length,l=t.length,c=l-a,d={},u={};function h(n){const s=(void 0!==u[n-1]?u[n-1]:-1)+1,c=void 0!==u[n+1]?u[n+1]:-1,h=s>c?-1:1;d[n+h]&&(d[n]=d[n+h].slice(0)),d[n]||(d[n]=[]),d[n].push(s>c?o:r);let m=Math.max(s,c),g=m-n;for(;g<a&&m<l&&i(e[g],t[m]);)g++,m++,d[n].push("equal");return m}let m,g=0;do{for(m=-g;m<c;m++)u[m]=h(m);for(m=c+g;m>c;m--)u[m]=h(m);u[c]=h(c),g++}while(u[c]!==l);return d[c].slice(1)}ce.fastDiff=re;class de{source;name;path;stop;off;return;constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=function e(){e.called=!0},this.off=function e(){e.called=!0}}}const ue=new Array(256).fill("").map((e,t)=>("0"+t.toString(16)).slice(-2));function he(){const[e,t,i,n]=crypto.getRandomValues(new Uint32Array(4));return"e"+ue[255&e]+ue[e>>8&255]+ue[e>>16&255]+ue[e>>24&255]+ue[255&t]+ue[t>>8&255]+ue[t>>16&255]+ue[t>>24&255]+ue[255&i]+ue[i>>8&255]+ue[i>>16&255]+ue[i>>24&255]+ue[255&n]+ue[n>>8&255]+ue[n>>16&255]+ue[n>>24&255]}const me={get(e="normal"){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function ge(e,t){const i=me.get(t.priority);let n=0,s=e.length;for(;n<s;){const t=n+s>>1;me.get(e[t].priority)<i?s=t:n=t+1}e.splice(n,0,t)}class fe extends Error{context;data;constructor(e,t,i,n){super(function(e,t,i){const n=new WeakSet,s=(e,t)=>{if("object"==typeof t&&null!==t){if(n.has(t))return`[object ${t.constructor.name}]`;n.add(t)}return t},o=t?` ${JSON.stringify(t,s)}`:"",r=be(e),a=i?`\nOriginal error: ${i.name}: ${i.message}`:"";return e+o+r+a}(e,i,n)),this.name="CKEditorError",this.context=t,this.data=i,n&&(this.stack=n.stack)}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;throw new fe("unexpected-error",t,void 0,e)}}function pe(e,t){console.warn(...we(e,t))}function be(e){return`\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-${e}`}function we(e,t){const i=be(e);return t?[e,t,i]:[e,i]}const _e=new Date(2026,2,31);if(globalThis.CKEDITOR_VERSION)throw new fe("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION="48.0.0";const ve=Symbol("listeningTo"),ye=Symbol("emitterId"),ke=Symbol("delegations"),Ce=Ae(Object);function Ae(e){if(!e)return Ce;return class extends e{on(e,t,i){this.listenTo(this,e,t,i)}once(e,t,i){let n=!1;this.listenTo(this,e,(e,...i)=>{n||(n=!0,e.off(),t.call(this,e,...i))},i)}off(e,t){this.stopListening(this,e,t)}listenTo(e,t,i,n={}){let s,o;this[ve]||(this[ve]={});const r=this[ve];Ee(e)||Te(e);const a=Ee(e);(s=r[a])||(s=r[a]={emitter:e,callbacks:{}}),(o=s.callbacks[t])||(o=s.callbacks[t]=[]),o.push(i),function(e,t,i,n,s){t._addEventListener?t._addEventListener(i,n,s):e._addEventListener.call(t,i,n,s)}(this,e,t,i,n)}stopListening(e,t,i){const n=this[ve];let s=e&&Ee(e);const o=n&&s?n[s]:void 0,r=o&&t?o.callbacks[t]:void 0;if(!(!n||e&&!o||t&&!r))if(i){Oe(this,e,t,i);-1!==r.indexOf(i)&&(1===r.length?delete o.callbacks[t]:Oe(this,e,t,i))}else if(r){for(;i=r.pop();)Oe(this,e,t,i);delete o.callbacks[t]}else if(o){for(t in o.callbacks)this.stopListening(e,t);delete n[s]}else{for(s in n)this.stopListening(n[s].emitter);delete this[ve]}}fire(e,...t){try{const i=e instanceof de?e:new de(this,e),n=i.name;let s=function(e,t){if(!e._events)return null;let i=t;do{const t=e._events[i];if(t&&t.callbacks&&t.callbacks.length)return t.callbacks;const n=i.lastIndexOf(":");i=n>-1?i.substring(0,n):""}while(i);return null}(this,n);if(i.path.push(this),s){s=s.slice();for(let e=0;e<s.length;e++){const o=s[e].callback;if(o.call(this,i,...t),i.off.called&&(delete i.off.called,this._removeEventListener(n,o)),i.stop.called)break}}const o=this[ke];if(o){const e=o.get(n),s=o.get("*");e&&Ie(e,i,t),s&&Ie(s,i,t)}return i.return}catch(e){fe.rethrowUnexpectedError(e,this)}}delegate(...e){return{to:(t,i)=>{this[ke]||(this[ke]=new Map),e.forEach(e=>{const n=this[ke].get(e);n?n.set(t,i):this[ke].set(e,new Map([[t,i]]))})}}}stopDelegating(e,t){if(this[ke])if(e)if(t){const i=this[ke].get(e);i&&i.delete(t)}else this[ke].delete(e);else this[ke].clear()}_addEventListener(e,t,i){!function(e,t){const i=xe(e);if(i[t])return;let n=t,s=null;const o=[];for(;""!==n&&!i[n];)i[n]=Pe(),o.push(i[n]),s&&i[n].childEvents.push(s),s=n,n=n.substr(0,n.lastIndexOf(":"));if(""!==n){for(const e of o)e.callbacks=i[n].callbacks.slice();i[n].childEvents.push(s)}}(this,e);const n=Se(this,e),s={callback:t,priority:me.get(i.priority)};for(const e of n)ge(e,s)}_removeEventListener(e,t){const i=Se(this,e);for(const e of i)for(let i=0;i<e.length;i++)e[i].callback==t&&(e.splice(i,1),i--)}}}function Te(e,t){e[ye]||(e[ye]=t||he())}function Ee(e){return e[ye]}function xe(e){return e._events||Object.defineProperty(e,"_events",{value:{}}),e._events}function Pe(){return{callbacks:[],childEvents:[]}}function Se(e,t){const i=xe(e)[t];if(!i)return[];let n=[i.callbacks];for(let t=0;t<i.childEvents.length;t++){const s=Se(e,i.childEvents[t]);n=n.concat(s)}return n}function Ie(e,t,i){for(let[n,s]of e){s?"function"==typeof s&&(s=s(t.name)):s=t.name;const e=new de(t.source,s);e.path=[...t.path],n.fire(e,...i)}}function Oe(e,t,i,n){t._removeEventListener?t._removeEventListener(i,n):e._removeEventListener.call(t,i,n)}const Re=Symbol("observableProperties"),Ve=Symbol("boundObservables"),Be=Symbol("boundProperties"),Me=Symbol("decoratedMethods"),Fe=Symbol("decoratedOriginal"),Ne=Le(Ae());function Le(e){if(!e)return Ne;return class extends e{set(e,t){if(i(e))return void Object.keys(e).forEach(t=>{this.set(t,e[t])},this);De(this);const n=this[Re];if(e in this&&!n.has(e))throw new fe("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>n.get(e),set(t){const i=n.get(e);let s=this.fire(`set:${e}`,e,t,i);void 0===s&&(s=t),i===s&&n.has(e)||(n.set(e,s),this.fire(`change:${e}`,e,s,i))}}),this[e]=t}bind(...e){if(!e.length||!$e(e))throw new fe("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new fe("observable-bind-duplicate-properties",this);De(this);const t=this[Be];e.forEach(e=>{if(t.has(e))throw new fe("observable-bind-rebind",this)});const i=new Map;return e.forEach(e=>{const n={property:e,to:[]};t.set(e,n),i.set(e,n)}),{to:ze,toMany:He,_observable:this,_bindProperties:e,_to:[],_bindings:i}}unbind(...e){if(!this[Re])return;const t=this[Be],i=this[Ve];if(e.length){if(!$e(e))throw new fe("observable-unbind-wrong-properties",this);e.forEach(e=>{const n=t.get(e);n&&(n.to.forEach(([e,t])=>{const s=i.get(e),o=s[t];o.delete(n),o.size||delete s[t],Object.keys(s).length||(i.delete(e),this.stopListening(e,"change"))}),t.delete(e))})}else i.forEach((e,t)=>{this.stopListening(t,"change")}),i.clear(),t.clear()}decorate(e){De(this);const t=this[e];if(!t)throw new fe("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,(e,i)=>{e.return=t.apply(this,i)}),this[e]=function(...t){return this.fire(e,t)},this[e][Fe]=t,this[Me]||(this[Me]=[]),this[Me].push(e)}stopListening(e,t,i){if(!e&&this[Me]){for(const e of this[Me])this[e]=this[e][Fe];delete this[Me]}super.stopListening(e,t,i)}[Re];[Me];[Be];[Ve]}}function De(e){e[Re]||(Object.defineProperty(e,Re,{value:new Map}),Object.defineProperty(e,Ve,{value:new Map}),Object.defineProperty(e,Be,{value:new Map}))}function ze(...e){const t=function(...e){if(!e.length)throw new fe("observable-bind-to-parse-error",null);const t={to:[]};let i;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach(e=>{if("string"==typeof e)i.properties.push(e);else{if("object"!=typeof e)throw new fe("observable-bind-to-parse-error",null);i={observable:e,properties:[]},t.to.push(i)}}),t}(...e),i=Array.from(this._bindings.keys()),n=i.length;if(!t.callback&&t.to.length>1)throw new fe("observable-bind-to-no-callback",this);if(n>1&&t.callback)throw new fe("observable-bind-to-extra-callback",this);var s;t.to.forEach(e=>{if(e.properties.length&&e.properties.length!==n)throw new fe("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)}),this._to=t.to,t.callback&&(this._bindings.get(i[0]).callback=t.callback),s=this._observable,this._to.forEach(e=>{const t=s[Ve];let i;t.get(e.observable)||s.listenTo(e.observable,"change",(n,o)=>{i=t.get(e.observable)[o],i&&i.forEach(e=>{We(s,e.property)})})}),function(e){let t;e._bindings.forEach((i,n)=>{e._to.forEach(s=>{t=s.properties[i.callback?0:e._bindProperties.indexOf(n)],i.to.push([s.observable,t]),function(e,t,i,n){const s=e[Ve],o=s.get(i),r=o||{};r[n]||(r[n]=new Set);r[n].add(t),o||s.set(i,r)}(e._observable,i,s.observable,t)})})}(this),this._bindProperties.forEach(e=>{We(this._observable,e)})}function He(e,t,i){if(this._bindings.size>1)throw new fe("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const i=e.map(e=>[e,t]);return Array.prototype.concat.apply([],i)}(e,t),i)}function $e(e){return e.every(e=>"string"==typeof e)}function We(e,t){const i=e[Be].get(t);let n;i.callback?n=i.callback.apply(e,i.to.map(e=>e[0][e[1]])):(n=i.to[0],n=n[0][n[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=n:e.set(t,n)}class je{_replacedElements;constructor(){this._replacedElements=[]}replace(e,t){this._replacedElements.push({element:e,newElement:t}),e.style.display="none",t&&e.parentNode.insertBefore(t,e.nextSibling)}restore(){this._replacedElements.forEach(({element:e,newElement:t})=>{e.style.display="",t&&t.remove()}),this._replacedElements=[]}}function Ue(e){let t=0;for(const i of e)t++;return t}function qe(e,t){const i=Math.min(e.length,t.length);for(let n=0;n<i;n++)if(e[n]!=t[n])return n;return e.length==t.length?"same":e.length<t.length?"prefix":"extension"}function Ke(e){return!(!e||!e[Symbol.iterator])}function Ge(e,t,i={},s=[]){const o=i&&i.xmlns,r=o?e.createElementNS(o,t):e.createElement(t);for(const e in i)r.setAttribute(e,i[e]);!n(s)&&Ke(s)||(s=[s]);for(let t of s)n(t)&&(t=e.createTextNode(t)),r.appendChild(t);return r}class Je{_config;constructor(e,t){this._config=Object.create(null),t&&this.define(Ye(t)),e&&this._setObjectToTarget(this._config,e)}set(e,t){this._setToTarget(this._config,e,t)}define(e,t){this._setToTarget(this._config,e,t,!0)}get(e){return this._getFromSource(this._config,e)}*names(){for(const e of Object.keys(this._config))yield e}_setToTarget(e,t,i,n=!1){if(s(t))return void this._setObjectToTarget(e,t,n);const o=t.split(".");t=o.pop();for(const t of o)s(e[t])||(e[t]=Object.create(null)),e=e[t];if(s(i))return s(e[t])||(e[t]=Object.create(null)),e=e[t],void this._setObjectToTarget(e,i,n);n&&void 0!==e[t]||(e[t]=i)}_getFromSource(e,t){const i=t.split(".");t=i.pop();for(const t of i){if(!s(e[t])){e=null;break}e=e[t]}return e?Ye(e[t]):void 0}_setObjectToTarget(e,t,i){Object.keys(t).forEach(n=>{this._setToTarget(e,n,t[n],i)})}}function Ye(e){return V(e,Qe)}function Qe(e){return M(e)||"function"==typeof e?e:void 0}function Xe(e){if(e){if(e.defaultView)return e instanceof e.defaultView.Document;if(e.ownerDocument&&e.ownerDocument.defaultView)return e instanceof e.ownerDocument.defaultView.Node}return!1}function Ze(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const et=tt(Ae());function tt(e){if(!e)return et;return class extends e{listenTo(e,t,i,n={}){if(Xe(e)||Ze(e)||e instanceof G.window.EventTarget){const s={capture:!!n.useCapture,passive:!!n.usePassive},o=this._getProxyEmitter(e,s)||new it(e,s);this.listenTo(o,t,i,n)}else super.listenTo(e,t,i,n)}stopListening(e,t,i){if(Xe(e)||Ze(e)||e instanceof G.window.EventTarget){const n=this._getAllProxyEmitters(e);for(const e of n)this.stopListening(e,t,i)}else super.stopListening(e,t,i)}_getProxyEmitter(e,t){return function(e,t){const i=e[ve];return i&&i[t]?i[t].emitter:null}(this,nt(e,t))}_getAllProxyEmitters(e){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map(t=>this._getProxyEmitter(e,t)).filter(e=>!!e)}}}class it extends(Ae()){_domNode;_options;constructor(e,t){super(),Te(this,nt(e,t)),this._domNode=e,this._options=t}_domListeners;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),Ae().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){Ae().prototype._removeEventListener.call(this,e,t),this.detach(e)}_createDomListener(e){const t=t=>{this.fire(e,t)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}}function nt(e,t){let i=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=he())}(e);for(const e of Object.keys(t).sort())t[e]&&(i+="-"+e);return i}function st(e){const t=[];let i=e;for(;i&&i.nodeType!=Node.DOCUMENT_NODE;)t.unshift(i),i=i.parentNode;return t}function ot(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}function rt(e){if(!e.target)return null;const t=e.target.ownerDocument,i=e.clientX,n=e.clientY;let s=null;return t.caretRangeFromPoint&&t.caretRangeFromPoint(i,n)?s=t.caretRangeFromPoint(i,n):e.rangeParent&&(s=t.createRange(),s.setStart(e.rangeParent,e.rangeOffset),s.collapse(!0)),s}function at(e){return e&&e.parentNode?e.offsetParent===G.document.body?null:e.offsetParent:null}function lt(e){return"[object Text]"==Object.prototype.toString.call(e)}function ct(e){return"[object Range]"==Object.prototype.toString.apply(e)}const dt=["top","right","bottom","left","width","height"],ut=new Set(["relative","absolute","fixed","sticky"]);class ht{top;right;bottom;left;width;height;_source;constructor(e){const t=ct(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),ft(e)||t)if(t){const t=ht.getDomRangeRects(e);mt(this,ht.getBoundingRect(t))}else mt(this,e.getBoundingClientRect());else if(Ze(e)){const{innerWidth:t,innerHeight:i}=e;mt(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else mt(this,e)}clone(){return new ht(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 e=new ht(t);return e._source=this._source,e}}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(gt(e))return t;let i,n=e,s=e.parentNode||e.commonAncestorContainer;for(;s&&!gt(s);){const e="visible"===bt(s);if(wt(n)&&(i=n),e||i&&"absolute"===pt(i)&&!wt(s)){n=s,s=s.parentNode;continue}const o=new ht(s),r=t.getIntersection(o);if(!r)return null;r.getArea()<t.getArea()&&(t=r),n=s,s=s.parentNode}return t}isEqual(e){for(const t of dt)if(this[t]!==e[t])return!1;return!0}contains(e){const t=this.getIntersection(e);return!(!t||!t.isEqual(e))}toAbsoluteRect(){const{scrollX:e,scrollY:t}=G.window,i=this.clone().moveBy(e,t);if(ft(i._source)){const e=at(i._source);e&&function(e,t){const i=new ht(t),n=ot(t);let s=0,o=0;s-=i.left,o-=i.top,s+=t.scrollLeft,o+=t.scrollTop,s-=n.left,o-=n.top,e.moveBy(s,o)}(i,e)}return i}excludeScrollbarsAndBorders(){const e=this._source;let t,i,n;if(Ze(e))t=e.innerWidth-e.document.documentElement.clientWidth,i=e.innerHeight-e.document.documentElement.clientHeight,n=e.getComputedStyle(e.document.documentElement).direction;else{const s=ot(e);t=e.offsetWidth-e.clientWidth-s.left-s.right,i=e.offsetHeight-e.clientHeight-s.top-s.bottom,n=e.ownerDocument.defaultView.getComputedStyle(e).direction,this.left+=s.left,this.top+=s.top,this.right-=s.right,this.bottom-=s.bottom,this.width=this.right-this.left,this.height=this.bottom-this.top}return this.width-=t,"ltr"===n?this.right-=t:this.left+=t,this.height-=i,this.bottom-=i,this}static getDomRangeRects(e){const t=[],i=Array.from(e.getClientRects());if(i.length)for(const n of i){const i=new ht(n);i._source=e,t.push(i)}else{let i=e.startContainer;lt(i)&&(i=i.parentNode);const n=new ht(i.getBoundingClientRect());n.right=n.left,n.width=0,t.push(n)}return t}static getDomElementRects(e){return Array.from(e.getClientRects()).map(t=>{const i=new ht(t);return i._source=e,i})}static getBoundingRect(e){const t={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:0,height:0};let i=0;for(const n of e)i++,t.left=Math.min(t.left,n.left),t.top=Math.min(t.top,n.top),t.right=Math.max(t.right,n.right),t.bottom=Math.max(t.bottom,n.bottom);return 0==i?null:(t.width=t.right-t.left,t.height=t.bottom-t.top,new ht(t))}}function mt(e,t){for(const i of dt)e[i]=t[i]}function gt(e){return!!ft(e)&&e===e.ownerDocument.body}function ft(e){return null!==e&&"object"==typeof e&&1===e.nodeType&&"function"==typeof e.getBoundingClientRect}function pt(e){return e.ownerDocument.defaultView.getComputedStyle(e).position}function bt(e){return e instanceof HTMLElement?e.ownerDocument.defaultView.getComputedStyle(e).overflow:"visible"}function wt(e){return e instanceof HTMLElement&&ut.has(pt(e))}class _t{_element;_callback;static _observerInstance=null;static _elementCallbacks=null;constructor(e,t){_t._observerInstance||_t._createObserver(),this._element=e,this._callback=t,_t._addElementCallback(e,t),_t._observerInstance.observe(e)}get element(){return this._element}destroy(){_t._deleteElementCallback(this._element,this._callback)}static _addElementCallback(e,t){_t._elementCallbacks||(_t._elementCallbacks=new Map);let i=_t._elementCallbacks.get(e);i||(i=new Set,_t._elementCallbacks.set(e,i)),i.add(t)}static _deleteElementCallback(e,t){const i=_t._getElementCallbacks(e);i&&(i.delete(t),i.size||(_t._elementCallbacks.delete(e),_t._observerInstance.unobserve(e))),_t._elementCallbacks&&!_t._elementCallbacks.size&&(_t._observerInstance=null,_t._elementCallbacks=null)}static _getElementCallbacks(e){return _t._elementCallbacks?_t._elementCallbacks.get(e):null}static _createObserver(){_t._observerInstance=new G.window.ResizeObserver(e=>{for(const t of e){const e=_t._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}})}}function vt(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function yt(e){return t=>t+e}function kt(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function Ct(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}function At(e){return e&&e.nodeType===Node.COMMENT_NODE}function Tt(e){try{G.document.createAttribute(e)}catch{return!1}return!0}function Et(e){return!!e&&(lt(e)?Et(e.parentElement):!!e.getClientRects&&!!e.getClientRects().length)}function xt({element:e,target:t,positions:i,limiter:n,fitInViewport:s,viewportOffsetConfig:o}){F(t)&&(t=t()),F(n)&&(n=n());const r=at(e),a=St(o),l=new ht(e),c=Pt(t,a);let d;if(!c||!a.getIntersection(c))return null;const u={targetRect:c,elementRect:l,positionedElementAncestor:r,viewportRect:a};if(n||s){if(n){const e=Pt(n,a);e&&(u.limiterRect=e)}d=function(e,t){const{elementRect:i}=t,n=i.getArea(),s=e.map(e=>new It(e,t)).filter(e=>!!e.name);let o=0,r=null;for(const e of s){const{limiterIntersectionArea:t,viewportIntersectionArea:i}=e;if(t===n)return e;const s=i**2+t**2;s>o&&(o=s,r=e)}return r}(i,u)}else d=new It(i[0],u);return d}function Pt(e,t){const i=new ht(e).getVisible();return i?i.getIntersection(t):null}function St(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new ht(G.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t.left+=e.left,t.right-=e.right,t.width-=e.left+e.right,t}class It{name;config;_positioningFunctionCoordinates;_options;_cachedRect;_cachedAbsoluteRect;constructor(e,t){const i=e(t.targetRect,t.elementRect,t.viewportRect,t.limiterRect);if(!i)return;const{left:n,top:s,name:o,config:r}=i;this.name=o,this.config=r,this._positioningFunctionCoordinates={left:n,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._options.elementRect.clone().moveTo(this._positioningFunctionCoordinates.left,this._positioningFunctionCoordinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=this._rect.toAbsoluteRect()),this._cachedAbsoluteRect}}function Ot(e){const t=e.parentNode;t&&t.removeChild(e)}function Rt(){const e=G.window.visualViewport;if(!e||!Q.isiOS&&!Q.isSafari)return{left:0,top:0};return{left:Math.max(Math.round(e.offsetLeft),0),top:Math.max(Math.round(e.offsetTop),0)}}function Vt({window:e,rect:t,alignToTop:i,forceScroll:n,viewportOffset:s}){const o=t.clone().moveBy(0,s.bottom),r=t.clone().moveBy(0,-s.top),a=new ht(e).excludeScrollbarsAndBorders(),l=i&&n,c=[r,o].every(e=>a.contains(e));let{scrollX:d,scrollY:u}=e;const h=d,m=u;l?u-=a.top-t.top+s.top:c||(Ft(r,a)?u-=a.top-t.top+s.top:Mt(o,a)&&(u+=i?t.top-a.top-s.top:t.bottom-a.bottom+s.bottom)),c||(Nt(t,a)?d-=a.left-t.left+s.left:Lt(t,a)&&(d+=t.right-a.right+s.right)),d==h&&u===m||e.scrollTo(d,u)}function Bt({parent:e,getRect:t,alignToTop:i,forceScroll:n,ancestorOffset:s=0,limiterElement:o}){const r=Dt(e),a=i&&n;let l,c,d;const u=o||r.document.body;for(;e!=u;)c=t(),l=new ht(e).excludeScrollbarsAndBorders(),d=l.contains(c),a?e.scrollTop-=l.top-c.top+s:d||(Ft(c,l)?e.scrollTop-=l.top-c.top+s:Mt(c,l)&&(e.scrollTop+=i?c.top-l.top-s:c.bottom-l.bottom+s)),d||(Nt(c,l)?e.scrollLeft-=l.left-c.left+s:Lt(c,l)&&(e.scrollLeft+=c.right-l.right+s)),e=e.parentNode}function Mt(e,t){return e.bottom>t.bottom}function Ft(e,t){return e.top<t.top}function Nt(e,t){return e.left<t.left}function Lt(e,t){return e.right>t.right}function Dt(e){return ct(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function zt(e){if(ct(e)){let t=e.commonAncestorContainer;return lt(t)&&(t=t.parentNode),t}return e.parentNode}function Ht(e,t){const i=Dt(e),n=new ht(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new ht(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}const $t={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},Wt={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},jt={37:"←",38:"↑",39:"→",40:"↓",9:"⇥",33:"Page Up",34:"Page Down"},Ut=Qt(),qt=Object.fromEntries(Object.entries(Ut).map(([e,t])=>{let i;return i=t in jt?jt[t]:e.charAt(0).toUpperCase()+e.slice(1),[t,i]}));function Kt(e){let t;if("string"==typeof e){if(t=Ut[e.toLowerCase()],!t)throw new fe("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?Ut.alt:0)+(e.ctrlKey?Ut.ctrl:0)+(e.shiftKey?Ut.shift:0)+(e.metaKey?Ut.cmd:0);return t}function Gt(e){return"string"==typeof e&&(e=function(e){return e.split("+").map(e=>e.trim())}(e)),e.map(e=>"string"==typeof e?function(e){if(e.endsWith("!"))return Kt(e.slice(0,-1));const t=Kt(e);return(Q.isMac||Q.isiOS)&&t==Ut.ctrl?Ut.cmd:t}(e):e).reduce((e,t)=>t+e,0)}function Jt(e,t){let i=Gt(e);const n=t?"Mac"===t:Q.isMac||Q.isiOS;return Object.entries(n?$t:Wt).reduce((e,[t,n])=>(0!=(i&Ut[t])&&(i&=~Ut[t],e+=n),e),"")+(i?qt[i]:"")}function Yt(e,t){const i="ltr"===t;switch(e){case Ut.arrowleft:return i?"left":"right";case Ut.arrowright:return i?"right":"left";case Ut.arrowup:return"up";case Ut.arrowdown:return"down"}}function Qt(){const e={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 t=65;t<=90;t++){e[String.fromCharCode(t).toLowerCase()]=t}for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;return Object.assign(e,{"'":222,",":108,"-":109,".":110,"/":111,";":186,"=":187,"[":219,"\\":220,"]":221,"`":223}),e}const Xt=["ar","ara","dv","div","fa","per","fas","he","heb","ku","kur","ug","uig","ur","urd"];function Zt(e){return Xt.includes(e)?"rtl":"ltr"}function ei(e){return Array.isArray(e)?e:[e]}function ti(e,t,i=1,n){if("number"!=typeof i)throw new fe("translation-service-quantity-not-a-number",null,{quantity:i});const s=n||G.window.CKEDITOR_TRANSLATIONS,o=function(e){return Object.keys(e).length}(s);1===o&&(e=Object.keys(s)[0]);const r=t.id||t.string;if(0===o||!function(e,t,i){return!!i[e]&&!!i[e].dictionary[t]}(e,r,s))return 1!==i?t.plural:t.string;const a=s[e].dictionary,l=s[e].getPluralForm||(e=>1===e?0:1),c=a[r];if("string"==typeof c)return c;return c[Number(l(i))]}G.window.CKEDITOR_TRANSLATIONS||(G.window.CKEDITOR_TRANSLATIONS={});class ii{uiLanguage;uiLanguageDirection;contentLanguage;contentLanguageDirection;t;translations;constructor({uiLanguage:e="en",contentLanguage:t,translations:i}={}){this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=Zt(this.uiLanguage),this.contentLanguageDirection=Zt(this.contentLanguage),this.translations=function(e){return Array.isArray(e)?e.reduce((e,t)=>K(e,t)):e}(i),this.t=(e,t)=>this._t(e,t)}_t(e,t=[]){t=ei(t),"string"==typeof e&&(e={string:e});const i=!!e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,(e,i)=>i<t.length?t[i]:e)}(ti(this.uiLanguage,e,i,this.translations),t)}}class ni extends(Ae()){_items;_itemMap;_idProperty;_bindToCollection;_bindToExternalToInternalMap;_bindToInternalToExternalMap;_skippedIndexesFromExternal;constructor(e={},t={}){super();const i=Ke(e);if(i||(t=e),this._items=[],this._itemMap=new Map,this._idProperty=t.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],i)for(const t of e)this._items.push(t),this._itemMap.set(this._getItemIdBeforeAdding(t),t)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(e,t){return this.addMany([e],t)}addMany(e,t){if(void 0===t)t=this._items.length;else if(t>this._items.length||t<0)throw new fe("collection-add-item-invalid-index",this);let i=0;for(const n of e){const e=this._getItemIdBeforeAdding(n),s=t+i;this._items.splice(s,0,n),this._itemMap.set(e,n),this.fire("add",n,s),i++}return this.fire("change",{added:e,removed:[],index:t}),this}get(e){let t;if("string"==typeof e)t=this._itemMap.get(e);else{if("number"!=typeof e)throw new fe("collection-get-invalid-arg",this);t=this._items[e]}return t||null}has(e){if("string"==typeof e)return this._itemMap.has(e);{const t=e[this._idProperty];return t&&this._itemMap.has(t)}}getIndex(e){let t;return t="string"==typeof e?this._itemMap.get(e):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 fe("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:e=>{this._setUpBindToBinding(t=>new e(t))},using:e=>{"function"==typeof e?this._setUpBindToBinding(e):this._setUpBindToBinding(t=>t[e])}}}_setUpBindToBinding(e){const t=this._bindToCollection,i=(i,n,s)=>{const o=t._bindToCollection==this,r=t._bindToInternalToExternalMap.get(n);if(o&&r)this._bindToExternalToInternalMap.set(n,r),this._bindToInternalToExternalMap.set(r,n);else{const i=e(n);if(!i)return void this._skippedIndexesFromExternal.push(s);let o=s;for(const e of this._skippedIndexesFromExternal)s>e&&o--;for(const e of t._skippedIndexesFromExternal)o>=e&&o++;this._bindToExternalToInternalMap.set(n,i),this._bindToInternalToExternalMap.set(i,n),this.add(i,o);for(let e=0;e<t._skippedIndexesFromExternal.length;e++)o<=t._skippedIndexesFromExternal[e]&&t._skippedIndexesFromExternal[e]++}};for(const e of t)i(0,e,t.getIndex(e));this.listenTo(t,"add",i),this.listenTo(t,"remove",(e,t,i)=>{const n=this._bindToExternalToInternalMap.get(t);n&&this.remove(n),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce((e,t)=>(i<t&&e.push(t-1),i>t&&e.push(t),e),[])})}_getItemIdBeforeAdding(e){const t=this._idProperty;let i;if(t in e){if(i=e[t],"string"!=typeof i)throw new fe("collection-add-invalid-id",this);if(this.get(i))throw new fe("collection-add-item-already-exists",this)}else e[t]=i=he();return i}_remove(e){let t,i,n,s=!1;const o=this._idProperty;if("string"==typeof e?(i=e,n=this._itemMap.get(i),s=!n,n&&(t=this._items.indexOf(n))):"number"==typeof e?(t=e,n=this._items[t],s=!n,n&&(i=n[o])):(n=e,i=n[o],t=this._items.indexOf(n),s=-1==t||!this._itemMap.get(i)),s)throw new fe("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const r=this._bindToInternalToExternalMap.get(n);return this._bindToInternalToExternalMap.delete(n),this._bindToExternalToInternalMap.delete(r),this.fire("remove",n,t),[n,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}function si(e){const t=e.next();return t.done?null:t.value}class oi extends(tt(Le())){_elements=new Set;_externalViews=new Set;_blurTimeout=null;constructor(){super(),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(ai(e))this._addElement(e);else if(ri(e))this._addView(e);else{if(!e.element)throw new fe("focustracker-add-view-missing-element",{focusTracker:this,view:e});this._addElement(e.element)}}remove(e){ai(e)?this._removeElement(e):ri(e)?this._removeView(e):this._removeElement(e.element)}_addElement(e){if(this._elements.has(e))throw new fe("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",()=>{const t=this.externalViews.find(t=>function(e,t){if(li(e,t))return!0;return!!t.focusTracker.externalViews.find(t=>li(e,t))}(e,t));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(){if(this.elements.find(e=>e.contains(document.activeElement)))return;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 ri(e){return"focusTracker"in e&&e.focusTracker instanceof oi}function ai(e){return M(e)}function li(e,t){return!!t.element&&t.element.contains(document.activeElement)&&e.contains(t.element)}class ci{_listener;constructor(){this._listener=new(tt())}listenTo(e){this._listener.listenTo(e,"keydown",(e,t)=>{this._listener.fire("_keydown:"+Kt(t),t)})}set(e,t,i={}){const n=Gt(e),s=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,(e,n)=>{i.filter&&!i.filter(n)||(t(n,()=>{n.preventDefault(),n.stopPropagation(),e.stop()}),e.return=!0)},{priority:s})}press(e){return!!this._listener.fire("_keydown:"+Kt(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}function di(e){return Ke(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}function ui(e,t,i){const n=e.length,s=t.length;for(let t=n-1;t>=i;t--)e[t+s]=e[t];for(let n=0;n<s;n++)e[i+n]=t[n]}function hi(e,t){let i;function n(...s){n.cancel(),i=setTimeout(()=>e(...s),t)}return n.cancel=()=>{clearTimeout(i)},n}function mi(e){try{if(!e.startsWith("ey"))return null;const t=atob(e.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(t)}catch{return null}}function gi(e){const t=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"details",isVoid:!1},{name:"dialog",isVoid:!1},{name:"dd",isVoid:!1},{name:"div",isVoid:!1},{name:"dl",isVoid:!1},{name:"dt",isVoid:!1},{name:"fieldset",isVoid:!1},{name:"figcaption",isVoid:!1},{name:"figure",isVoid:!1},{name:"footer",isVoid:!1},{name:"form",isVoid:!1},{name:"h1",isVoid:!1},{name:"h2",isVoid:!1},{name:"h3",isVoid:!1},{name:"h4",isVoid:!1},{name:"h5",isVoid:!1},{name:"h6",isVoid:!1},{name:"header",isVoid:!1},{name:"hgroup",isVoid:!1},{name:"hr",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"th",isVoid:!1},{name:"thead",isVoid:!1},{name:"tfoot",isVoid:!1},{name:"tr",isVoid:!1},{name:"ul",isVoid:!1}],i=t.map(e=>e.name).join("|"),n=e.replace(new RegExp(`</?(${i})( .*?)?>`,"g"),"\n$&\n").replace(/<br[^>]*>/g,"$&\n").split("\n");let s=0,o=!1;return n.map(e=>(o=function(e,t){const i=/<pre( .*?)?>/.test(e),n=/<\/pre>/.test(e);return(!i||!n)&&(i?"first":n?"last":("first"===t||"middle"===t)&&"middle")}(e,o),e.length||o?function(e,t){return t.some(t=>!t.isVoid&&!!new RegExp(`<${t.name}( .*?)?>`).test(e))}(e,t)?fi(e,s++):function(e,t){return t.some(t=>new RegExp(`</${t.name}>`).test(e))}(e,t)?fi(e,--s):fi(e,"middle"===o||"last"===o?0:s):"")).join("").trimEnd()}function fi(e,t,i=" "){return`${i.repeat(Math.max(0,t))}${e}\n`}function pi(e,t){return!!(i=e.charAt(t-1))&&1==i.length&&/[\ud800-\udbff]/.test(i)&&function(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}(e.charAt(t));var i}function bi(e,t){return!!(i=e.charAt(t))&&1==i.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(i);var i}const wi=vi();function _i(e,t){const i=String(e).matchAll(wi);return Array.from(i).some(e=>e.index<t&&t<e.index+e[0].length)}function vi(){const e=/\p{Regional_Indicator}{2}/u.source,t="(?:"+[/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,/\p{Emoji}\u{FE0F}?\u{20E3}/u,/\p{Emoji}\u{FE0F}/u,/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u].map(e=>e.source).join("|")+")";return new RegExp(`${e}|${t}(?:${t})*`,"ug")}function yi(e){if(!e)return null;const t=function(e){const t=e.split(".");if(3!=t.length)return null;return t[1]}(e);return t?mi(t):null}function ki(e,t,{signal:i,edges:n}={}){let s,o=null;const r=null!=n&&n.includes("leading"),a=null==n||n.includes("trailing"),l=()=>{null!==o&&(e.apply(s,o),s=void 0,o=null)};let c=null;const d=()=>{null!=c&&clearTimeout(c),c=setTimeout(()=>{c=null,a&&l(),u()},t)},u=()=>{null!==c&&(clearTimeout(c),c=null),s=void 0,o=null},h=function(...e){if(i?.aborted)return;s=this,o=e;const t=null==c;d(),r&&t&&l()};return h.schedule=d,h.cancel=u,h.flush=()=>{l()},i?.addEventListener("abort",u,{once:!0}),h}function Ci(e,t=0,i={}){"object"!=typeof i&&(i={});const{leading:n=!1,trailing:s=!0,maxWait:o}=i,r=Array(2);let a;n&&(r[0]="leading"),s&&(r[1]="trailing");let l=null;const c=ki(function(...t){a=e.apply(this,t),l=null},t,{edges:r}),d=function(...t){return null!=o&&(null===l&&(l=Date.now()),Date.now()-l>=o)?(a=e.apply(this,t),l=Date.now(),c.cancel(),c.schedule(),a):(c.apply(this,t),a)};return d.cancel=c.cancel,d.flush=()=>(c.flush(),a),d}function Ai(e,t=0,i={}){const{leading:n=!0,trailing:s=!0}=i;return Ci(e,t,{leading:n,maxWait:t,trailing:s})}function Ti(e){const t=e?.constructor;return e===("function"==typeof t?t.prototype:Object.prototype)}function Ei(e){return"symbol"==typeof e||e instanceof Symbol}function xi(e){if(!e)return 0===e?e:0;if((e=function(e){return Ei(e)?NaN:Number(e)}(e))===1/0||e===-1/0){return(e<0?-1:1)*Number.MAX_VALUE}return e==e?e:0}function Pi(e,t){if((e=function(e){const t=xi(e),i=t%1;return i?t-i:t}(e))<1||!Number.isSafeInteger(e))return[];const i=new Array(e);for(let n=0;n<e;n++)i[n]="function"==typeof t?t(n):n;return i}function Si(e){if(null==e)return[];switch(typeof e){case"object":case"function":return z(e)?function(e){const t=Pi(e.length,e=>`${e}`),i=new Set(t);n=e,"undefined"!=typeof Buffer&&Buffer.isBuffer(n)&&(i.add("offset"),i.add("parent"));var n;W(e)&&(i.add("buffer"),i.add("byteLength"),i.add("byteOffset"));const s=Ii(e).filter(e=>!i.has(e));if(Array.isArray(e))return[...t,...s];return[...t.filter(t=>Object.hasOwn(e,t)),...s]}(e):Ti(e)?function(e){const t=Ii(e);return t.filter(e=>"constructor"!==e)}(e):Ii(e);default:return Ii(Object(e))}}function Ii(e){const t=[];for(const i in e)t.push(i);return t}function Oi(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Ri(e,...t){for(let i=0;i<t.length;i++)Vi(e,t[i]);return e}function Vi(e,t){const i=Si(t);for(let n=0;n<i.length;n++){const s=i[n];s in e&&Oi(e[s],t[s])||(e[s]=t[s])}}function Bi(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return e.map(Bi).join(",");const t=String(e);return"0"===t&&Object.is(Number(e),-0)?"-0":t}function Mi(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function Fi(e){return"string"==typeof e||"symbol"==typeof e?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function Ni(e){if(Array.isArray(e))return e.map(Fi);if("symbol"==typeof e)return[e];const t=[],i=(e=Bi(e)).length;if(0===i)return t;let n=0,s="",o="",r=!1;for(46===e.charCodeAt(0)&&(t.push(""),n++);n<i;){const a=e[n];o?"\\"===a&&n+1<i?(n++,s+=e[n]):a===o?o="":s+=a:r?'"'===a||"'"===a?o=a:"]"===a?(r=!1,t.push(s),s=""):s+=a:"["===a?(r=!0,s&&(t.push(s),s="")):"."===a?s&&(t.push(s),s=""):s+=a,n++}return s&&t.push(s),t}function Li(e,t,i){if(null==e)return i;switch(typeof t){case"string":{if(L(t))return i;const n=e[t];return void 0===n?Mi(t)?Li(e,Ni(t),i):i:n}case"number":case"symbol":{"number"==typeof t&&(t=Fi(t));const n=e[t];return void 0===n?i:n}default:{if(Array.isArray(t))return function(e,t,i){if(0===t.length)return i;let n=e;for(let e=0;e<t.length;e++){if(null==n)return i;if(L(t[e]))return i;n=n[t[e]]}if(void 0===n)return i;return n}(e,t,i);if(L(t=Object.is(t?.valueOf(),-0)?"-0":String(t)))return i;const n=e[t];return void 0===n?i:n}}}const Di=(e,t,i)=>{const n=e[t];Object.hasOwn(e,t)&&Oi(n,i)&&(void 0!==i||t in e)||(e[t]=i)},zi=/^(?:0|[1-9]\d*)$/;function Hi(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return zi.test(e)}}const $i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Wi=/^\w*$/;function ji(e,t,n,s){if(null==e&&!i(e))return e;let o;var r,a;r=t,a=e,o=!Array.isArray(r)&&("number"==typeof r||"boolean"==typeof r||null==r||Ei(r)||"string"==typeof r&&(Wi.test(r)||!$i.test(r))||null!=a&&Object.hasOwn(a,r))?[t]:Array.isArray(t)?t:Ni(t);const l=n(Li(e,o));let c=e;for(let t=0;t<o.length&&null!=c;t++){const n=Fi(o[t]);if(L(n))continue;let r;if(t===o.length-1)r=l;else{const a=c[n],l=s?.(a,n,e);r=void 0!==l?l:i(a)?a:Hi(o[t+1])?[]:{}}Di(c,n,r),c=c[n]}return e}function Ui(e,t,i){return ji(e,t,()=>i,()=>{})}function qi(e,t){if(!Number.isInteger(e)||e<0)throw new Error("n must be a non-negative integer.");let i=0;return(...n)=>{if(++i>=e)return t(...n)}}function Ki(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function Gi(e,t,i){return Ji(e,t,void 0,void 0,void 0,void 0,i)}function Ji(e,t,i,n,s,o,r){const a=r(e,t,i,n,s,o);if(void 0!==a)return a;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return Yi(e,t,o,r)}return Yi(e,t,o,r)}function Yi(e,t,i,n){if(Object.is(e,t))return!0;let s=r(e),S=r(t);if(s===u&&(s=w),S===u&&(S=w),s!==S)return!1;switch(s){case l:return e.toString()===t.toString();case c:return Oi(e.valueOf(),t.valueOf());case d:case m:case h:return Object.is(e.valueOf(),t.valueOf());case a:return e.source===t.source&&e.flags===t.flags;case"[object Function]":return e===t}const I=(i=i??new Map).get(e),O=i.get(t);if(null!=I&&null!=O)return I===t;i.set(e,t),i.set(t,e);try{switch(s){case g:if(e.size!==t.size)return!1;for(const[s,o]of e.entries())if(!t.has(s)||!Ji(o,t.get(s),s,e,t,i,n))return!1;return!0;case f:{if(e.size!==t.size)return!1;const s=Array.from(e.values()),o=Array.from(t.values());for(let r=0;r<s.length;r++){const a=s[r],l=o.findIndex(s=>Ji(a,s,void 0,e,t,i,n));if(-1===l)return!1;o.splice(l,1)}return!0}case p:case v:case y:case k:case C:case"[object BigUint64Array]":case A:case T:case E:case"[object BigInt64Array]":case x:case P:if("undefined"!=typeof Buffer&&Buffer.isBuffer(e)!==Buffer.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!Ji(e[s],t[s],s,e,t,i,n))return!1;return!0;case b:return e.byteLength===t.byteLength&&Yi(new Uint8Array(e),new Uint8Array(t),i,n);case _:return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&Yi(new Uint8Array(e),new Uint8Array(t),i,n);case"[object Error]":return e.name===t.name&&e.message===t.message;case w:{if(!(Yi(e.constructor,t.constructor,i,n)||Ki(e)&&Ki(t)))return!1;const s=[...Object.keys(e),...o(e)],r=[...Object.keys(t),...o(t)];if(s.length!==r.length)return!1;for(let o=0;o<s.length;o++){const r=s[o],a=e[r];if(!Object.hasOwn(t,r))return!1;if(!Ji(a,t[r],r,e,t,i,n))return!1}return!0}default:return!1}}finally{i.delete(e),i.delete(t)}}function Qi(e,t,i){return"function"!=typeof i&&(i=()=>{}),Gi(e,t,(...n)=>{const s=i(...n);return void 0!==s?Boolean(s):e instanceof Map&&t instanceof Map||e instanceof Set&&t instanceof Set?Qi(Array.from(e),Array.from(t),qi(2,i)):void 0})}function Xi(e,t){return Gi(e,t,q)}function Zi(e){if(S(e))return e;const t=r(e);if(!function(e){switch(r(e)){case u:case p:case b:case _:case d:case m:case x:case P:case A:case T:case E:case g:case c:case w:case a:case f:case l:case h:case v:case y:case k:case C:return!0;default:return!1}}(e))return{};if(i=e,Array.isArray(i)){const t=Array.from(e);return e.length>0&&"string"==typeof e[0]&&Object.hasOwn(e,"index")&&(t.index=e.index,t.input=e.input),t}var i;if(W(e)){const t=e;return new(0,t.constructor)(t.buffer,t.byteOffset,t.length)}if(t===b)return new ArrayBuffer(e.byteLength);if(t===_){const t=e,i=t.buffer,n=t.byteOffset,s=t.byteLength,o=new ArrayBuffer(s),r=new Uint8Array(i,n,s);return new Uint8Array(o).set(r),new DataView(o)}if(t===d||t===c||t===l){const i=new(0,e.constructor)(e.valueOf());return t===l?function(e,t){const i=t.valueOf().length;for(const n in t)Object.hasOwn(t,n)&&(Number.isNaN(Number(n))||Number(n)>=i)&&(e[n]=t[n])}(i,e):en(i,e),i}if(t===m)return new Date(Number(e));if(t===a){const t=e,i=new RegExp(t.source,t.flags);return i.lastIndex=t.lastIndex,i}if(t===h)return Object(Symbol.prototype.valueOf.call(e));if(t===g){const t=e,i=new Map;return t.forEach((e,t)=>{i.set(t,e)}),i}if(t===f){const t=e,i=new Set;return t.forEach(e=>{i.add(e)}),i}if(t===u){const t=e,i={};return en(i,t),i.length=t.length,i[Symbol.iterator]=t[Symbol.iterator],i}const n={};return function(e,t){const i=Object.getPrototypeOf(t);if(null!==i){"function"==typeof t.constructor&&Object.setPrototypeOf(e,i)}}(n,e),en(n,e),function(e,t){const i=Object.getOwnPropertySymbols(t);for(let n=0;n<i.length;n++){const s=i[n];Object.prototype.propertyIsEnumerable.call(t,s)&&(e[s]=t[s])}}(n,e),n}function en(e,t){for(const i in t)Object.hasOwn(t,i)&&(e[i]=t[i])}const tn=new WeakMap;let nn=!1;function sn({view:e,element:t,text:i,isDirectHost:n=!0,keepOnFocus:s=!1}){const o=e.document;function r(i){const r={text:i,isDirectHost:n,keepOnFocus:s,hostElement:n?t:null};tn.get(o).set(t,r),e.change(e=>rn([[t,r]],e))}tn.has(o)||(tn.set(o,new Map),o.registerPostFixer(e=>rn(tn.get(o),e)),o.on("change:isComposing",()=>{e.change(e=>rn(tn.get(o),e))},{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",(e,t,i)=>r(i)),t.placeholder?r(t.placeholder):i&&r(i),i&&function(){nn||pe("enableViewPlaceholder-deprecated-text-option");nn=!0}()}function on(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function rn(e,t){const i=[];let n=!1;for(const[s,o]of e)o.isDirectHost&&(i.push(s),an(t,s,o)&&(n=!0));for(const[s,o]of e){if(o.isDirectHost)continue;const e=ln(s);e!==o.hostElement&&o.hostElement&&(t.removeAttribute("data-placeholder",o.hostElement),on(t,o.hostElement),o.hostElement=null,n=!0),e&&(i.includes(e)||(o.hostElement=e,an(t,s,o)&&(n=!0)))}return n}function an(e,t,i){const{text:n,isDirectHost:s,hostElement:o}=i;let r=!1;o.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,o),r=!0);return(s||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;if(function(e){for(const t of e.getChildren())if(!t.is("uiElement"))return!0;return!1}(e))return!1;const i=e.document,n=i.selection.anchor;return!(i.isComposing&&n&&n.parent===e||!t&&i.isFocused&&(!n||n.parent===e))}(o,i.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,o)&&(r=!0):on(e,o)&&(r=!0),r}function ln(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}class cn{is(){throw new Error("is() method is abstract")}}class dn extends(Ae(cn)){document;parent;constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if(-1==(e=this.parent.getChildIndex(this)))throw new fe("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return 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}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=qe(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]<i[n]}}isAfter(e){return this!=e&&(this.root===e.root&&!this.isBefore(e))}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,t,i){this.fire(`change:${e}`,t,i),this.parent&&this.parent._fireChange(e,t,i)}toJSON(){const e={path:this.getPath(),type:"Node"};return this!==this.root&&this.root.is("rootElement")&&(e.root=this.root.toJSON()),e}}dn.prototype.is=function(e){return"node"===e||"view:node"===e};class un extends dn{_textData;constructor(e,t){super(e),this._textData=t}get data(){return this._textData}get _data(){return this.data}set _data(e){this._fireChange("text",this),this._textData=e}isSimilar(e){return e instanceof un&&(this===e||this.data===e.data)}toJSON(){const e=super.toJSON();return e.type="Text",e.data=this.data,e}_clone(){return new un(this.document,this.data)}}un.prototype.is=function(e){return"$text"===e||"view:$text"===e||"text"===e||"view:text"===e||"node"===e||"view:node"===e};class hn extends cn{textNode;data;offsetInText;constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.data.length)throw new fe("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new fe("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}}hn.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class mn{_consumables=new Map;add(e,t){let i;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?i=this._consumables.get(e):(i=new gn(e),this._consumables.set(e,i)),i.add(t?fn(t):e._getConsumables()))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(fn(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return!!this.test(e,t)&&(this._consumables.set(e,!1),!0);const i=this._consumables.get(e);return void 0!==i&&i.consume(fn(t))}revert(e,t){const i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(fn(t)))}static createFrom(e,t){if(t||(t=new mn),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment")){t.add(e);for(const i of e.getChildren())mn.createFrom(i,t)}return t}}class gn{element;_canConsumeName=null;_attributes=new Map;constructor(e){this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes)if(i){let e=this._attributes.get(t);e&&"boolean"!=typeof e||(e=new Map,this._attributes.set(t,e)),e.set(i,!0)}else{if("style"==t||"class"==t)throw new fe("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 e=this._attributes.get(t);if(void 0===e)return null;if(!1===e)return!1;if(!0!==e)if(i){const t=e.get(i);if(void 0===t)return null;if(!t)return!1}else for(const t of e.values())if(!t)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 e=this._attributes.get(t);if("boolean"==typeof e)for(const[e]of this.element._getConsumables(t,i).attributes)this._attributes.set(e,!1);else if(i)for(const[,n]of this.element._getConsumables(t,i).attributes)e.set(n,!1);else for(const t of e.keys())e.set(t,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes){const e=this._attributes.get(t);if(!1!==e){if(void 0!==e&&!0!==e)if(i){!1===e.get(i)&&e.set(i,!0)}else for(const t of e.keys())e.set(t,!0)}else this._attributes.set(t,!0)}}}function fn(e){const t=[];return"attributes"in e&&e.attributes&&pn(t,e.attributes),"classes"in e&&e.classes&&pn(t,e.classes,"class"),"styles"in e&&e.styles&&pn(t,e.styles,"style"),{name:e.name||!1,attributes:t}}function pn(e,t,i){if("string"!=typeof t)for(const n of t)Array.isArray(n)?e.push(n):e.push(i?[i,n]:[n]);else e.push(i?[i,t]:[t])}class bn{_patterns=[];constructor(...e){this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const i=this._isElementMatching(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){const t=[];for(const i of e)for(const e of this._patterns){const n=this._isElementMatching(i,e);n&&t.push({element:i,pattern:e,match:n})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}_isElementMatching(e,t){if("function"==typeof t){const i=t(e);return i&&"object"==typeof i?fn(i):i}const i={};if(t.name&&(i.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!i.name))return null;const n=[];return t.attributes&&!function(e,t,i){let n;"object"!=typeof e||e instanceof RegExp||Array.isArray(e)?n=["class","style"]:(void 0!==e.style&&pe("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&pe("matcher-pattern-deprecated-attributes-class-key",e));return t._collectAttributesMatch(_n(e),i,n)}(t.attributes,e,n)||t.classes&&!function(e,t,i){return t._collectAttributesMatch(_n(e,"class"),i)}(t.classes,e,n)||t.styles&&!function(e,t,i){return t._collectAttributesMatch(_n(e,"style"),i)}(t.styles,e,n)?null:(n.length&&(i.attributes=n),i)}}function wn(e,t){return!0===e||e===t||e instanceof RegExp&&!!String(t).match(e)}function _n(e,t){if(Array.isArray(e))return e.map(e=>"object"!=typeof e||e instanceof RegExp?t?[t,e,!0]:[e,!0]:(void 0!==e.key&&void 0!==e.value||pe("matcher-pattern-missing-key-or-value",e),t?[t,e.key,e.value]:[e.key,e.value]));if("object"!=typeof e||e instanceof RegExp)return[t?[t,e,!0]:[e,!0]];const i=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&i.push(t?[t,n,e[n]]:[n,e[n]]);return i}class vn{_styles;_cachedStyleNames=null;_cachedExpandedStyleNames=null;_styleProcessor;constructor(e){this._styles={},this._styleProcessor=e}get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=function(e){let t=null,i=0,n=0,s=null;const o=new Map;if(""===e)return o;";"!=e.charAt(e.length-1)&&(e+=";");for(let r=0;r<e.length;r++){const a=e.charAt(r);if(null===t)switch(a){case":":s||(s=e.substr(i,r-i),n=r+1);break;case'"':case"'":t=a;break;case";":{const t=e.substr(n,r-n);s&&o.set(s.trim(),t.trim()),s=null,i=r+1;break}}else a===t&&(t=null)}return o}(e);for(const[e,i]of t)this._styleProcessor.toNormalizedForm(e,i,this._styles);return this}has(e){if(this.isEmpty)return!1;const t=this._styleProcessor.getReducedForm(e,this._styles).find(([t])=>t===e);return Array.isArray(t)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,i(e))for(const[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t={};for(const i of ei(e)){const e=kn(i),n=Li(this._styles,e);if(n)Cn(t,e,n);else{const e=this.getAsString(i);void 0!==e&&this._styleProcessor.toNormalizedForm(i,e,t)}}Object.keys(t).length&&(An(this._styles,t),this._cachedStyleNames=null,this._cachedExpandedStyleNames=null)}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this.getStylesEntries().map(e=>e.join(":")).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!i(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find(([t])=>t===e);return Array.isArray(t)?t[1]:void 0}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||=this._styleProcessor.getStyleNames(this._styles),this._cachedExpandedStyleNames):(this._cachedStyleNames||=this.getStylesEntries().map(([e])=>e),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 n of this.getStyleNames(!0))if(wn(e,n)){if(!0===t){i.push(n);continue}wn(t,this.getAsString(n))&&i.push(n)}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 e of this.getStyleNames()){for(const i of this._styleProcessor.getRelatedStyles(e))t.push(i);t.push(e)}return t}_canMergeFrom(e){for(const t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(const t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(const t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}}class yn{_normalizers;_extractors;_reducers;_consumables;constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(i(t))Cn(n,kn(e),t);else if(this._normalizers.has(e)){const i=this._normalizers.get(e),{path:s,value:o}=i(t);Cn(n,s,o)}else Cn(n,e,t)}getNormalized(e,t){if(!e)return K({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if("string"==typeof i)return Li(t,i);const n=i(e,t);if(n)return n}return Li(t,kn(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);if(void 0===i)return[];if(this._reducers.has(e)){return this._reducers.get(e)(i)}return[[e,i]]}getStyleNames(e){const t=new Set;for(const i of this._consumables.keys()){const n=this.getNormalized(i,e);n&&("object"!=typeof n||Object.keys(n).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 kn(e){return e.replace("-",".")}function Cn(e,t,n){let s=n;i(n)&&!Array.isArray(n)&&(s=K({},Li(e,t),n)),Ui(e,t,s)}function An(e,t){for(const i of Object.keys(t))null===e[i]||Array.isArray(e[i])||"object"!=typeof e[i]||"object"!=typeof t[i]?delete e[i]:(An(e[i],t[i]),Object.keys(e[i]).length||delete e[i])}class Tn{_set=new Set;get isEmpty(){return 0==this._set.size}get size(){return this._set.size}has(e){return this._set.has(e)}keys(){return Array.from(this._set.keys())}setTo(e){this.clear();for(const t of e.split(/\s+/))t&&this._set.add(t);return this}set(e){for(const t of ei(e))t&&this._set.add(t)}remove(e){for(const t of ei(e))this._set.delete(t)}clear(){this._set.clear()}toString(){return Array.from(this._set).join(" ")}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.keys())if(!e.has(t))return!1;return!0}_clone(){const e=new this.constructor;return e._set=new Set(this._set),e}_getTokensMatch(e){const t=[];if(!0===e){for(const e of this._set.keys())t.push(e);return t}if("string"==typeof e){for(const i of e.split(/\s+/)){if(!this._set.has(i))return;t.push(i)}return t}for(const i of this._set.keys())i.match(e)&&t.push(i);return t.length?t:void 0}_getConsumables(e){return e?[e]:this.keys()}_canMergeFrom(){return!0}_mergeFrom(e){for(const t of e._set.keys())this._set.has(t)||this._set.add(t)}_isMatching(e){for(const t of e._set.keys())if(!this._set.has(t))return!1;return!0}}class En extends dn{name;_unsafeAttributesToRender=[];_attrs;_children;_customProperties=new Map;get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}constructor(e,t,i,n){super(e),this.name=t,this._attrs=this._parseAttributes(i),this._children=[],n&&this._insertChild(0,n)}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes&&(yield"class"),this._styles&&(yield"style");for(const e of this._attrs.keys())"class"!=e&&"style"!=e&&(yield e)}*getAttributes(){for(const[e,t]of this._attrs.entries())yield[e,String(t)]}getAttribute(e){return this._attrs.has(e)?String(this._attrs.get(e)):void 0}hasAttribute(e,t){return!!this._attrs.has(e)&&(void 0===t||(Pn(this.name,e)||xn(this.name,e)?this._attrs.get(e).has(t):this._attrs.get(e)===t))}isSimilar(e){if(!(e instanceof En))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size)return!1;for(const[t,i]of this._attrs){const n=e._attrs.get(t);if(void 0===n)return!1;if("string"==typeof i||"string"==typeof n){if(n!==i)return!1}else if(!i.isSimilar(n))return!1}return!0}hasClass(...e){for(const t of e)if(!this._classes||!this._classes.has(t))return!1;return!0}getClassNames(){const e=this._classes?this._classes.keys():[],t=e[Symbol.iterator]();return Object.assign(e,{next:t.next.bind(t)})}getStyle(e){return this._styles&&this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles&&this._styles.getNormalized(e)}getStyleNames(e){return this._styles?this._styles.getStyleNames(e):[]}hasStyle(...e){for(const t of e)if(!this._styles||!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new bn(...e);let i=this.parent;for(;i&&!i.is("documentFragment");){if(t.match(i))return i;i=i.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=this._classes?this._classes.keys().sort().join(","):"",t=this._styles&&String(this._styles),i=Array.from(this._attrs).filter(([e])=>"style"!=e&&"class"!=e).map(e=>`${e[0]}="${e[1]}"`).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}toJSON(){const e=super.toJSON();if(e.name=this.name,e.type="Element",this._attrs.size&&(e.attributes=Object.fromEntries(this.getAttributes())),this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._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 n=function(e,t){if("string"==typeof t)return[new un(e,t)];Ke(t)||(t=[t]);const i=[];for(const n of t)"string"==typeof n?i.push(new un(e,n)):n instanceof hn?i.push(new un(e,n.data)):i.push(n);return i}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_setAttribute(e,t,i=!0){if(this._fireChange("attributes",this),Pn(this.name,e)||xn(this.name,e)){let n=this._attrs.get(e);n||(n=Pn(this.name,e)?new vn(this.document.stylesProcessor):new Tn,this._attrs.set(e,n)),i?n.setTo(String(t)):Pn(this.name,e)?Array.isArray(t)?n.set(t[0],t[1]):n.set(t):n.set("string"==typeof t?t.split(/\s+/):t)}else this._attrs.set(e,String(t))}_removeAttribute(e,t){if(this._fireChange("attributes",this),void 0!==t&&(Pn(this.name,e)||xn(this.name,e))){const i=this._attrs.get(e);return!!i&&(xn(this.name,e)&&"string"==typeof t&&(t=t.split(/\s+/)),i.remove(t),!!i.isEmpty&&this._attrs.delete(e))}return this._attrs.delete(e)}_addClass(e){this._setAttribute("class",e,!1)}_removeClass(e){this._removeAttribute("class",e)}_setStyle(e,t){"string"!=typeof e?this._setAttribute("style",e,!1):this._setAttribute("style",[e,t],!1)}_removeStyle(e){this._removeAttribute("style",e)}_collectAttributesMatch(e,t,i){for(const[n,s,o]of e){let e=!1,r=!1;for(const[a,l]of this._attrs)if(!(i&&i.includes(a)||!wn(n,a)))if(e=!0,"string"==typeof l){if(wn(s,l))t.push([a]),r=!0;else if(!(n instanceof RegExp))return!1}else{const e=l._getTokensMatch(s,o||!0);if(e){r=!0;for(const i of e)t.push([a,i])}else if(!(n instanceof RegExp))return!1}if(!e||!r)return!1}return!0}_getConsumables(e,t){const i=[];if(e){const n=this._attrs.get(e);if(void 0!==n)if("string"==typeof n)i.push([e]);else for(const s of n._getConsumables(t))i.push([e,s])}else for(const[e,t]of this._attrs)if("string"==typeof t)i.push([e]);else for(const n of t._getConsumables())i.push([e,n]);return{name:!e,attributes:i}}_canMergeAttributesFrom(e){if(this.name!=e.name)return!1;for(const[t,i]of e._attrs){const e=this._attrs.get(t);if(void 0!==e)if("string"==typeof e||"string"==typeof i){if(e!==i)return!1}else if(!e._canMergeFrom(i))return!1}return!0}_mergeAttributesFrom(e){this._fireChange("attributes",this);for(const[t,i]of e._attrs){const e=this._attrs.get(t);void 0===e||"string"==typeof e||"string"==typeof i?this._setAttribute(t,i):e._mergeFrom(i)}}_canSubtractAttributesOf(e){if(this.name!=e.name)return!1;for(const[t,i]of e._attrs){const e=this._attrs.get(t);if(void 0===e)return!1;if("string"==typeof e||"string"==typeof i){if(e!==i)return!1}else if(!e._isMatching(i))return!1}return!0}_subtractAttributesOf(e){this._fireChange("attributes",this);for(const[t,i]of e._attrs){const e=this._attrs.get(t);"string"==typeof e||"string"==typeof i?this._attrs.delete(t):(e.remove(i.keys()),e.isEmpty&&this._attrs.delete(t))}}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}_parseAttributes(e){const t=di(e);for(const[e,i]of t)if(null===i)t.delete(e);else if(Pn(this.name,e)){const n=i instanceof vn?i._clone():new vn(this.document.stylesProcessor).setTo(String(i));t.set(e,n)}else if(xn(this.name,e)){const n=i instanceof Tn?i._clone():(new Tn).setTo(String(i));t.set(e,n)}else"string"!=typeof i&&t.set(e,String(i));return t}}function xn(e,t){return"class"==t||"a"==e&&"rel"==t}function Pn(e,t){return"style"==t}En.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Sn extends En{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=In}toJSON(){const e=super.toJSON();return e.type="ContainerElement",e}}function In(){const e=[...this.getChildren()],t=e[this.childCount-1];if(t&&t.is("element","br"))return this.childCount;for(const t of e)if(!t.is("uiElement"))return null;return this.childCount}Sn.prototype.is=function(e,t){return t?t===this.name&&("containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class On extends(Le(Sn)){constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",t=>t&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}toJSON(){const e=super.toJSON();return e.type="EditableElement",e.isReadOnly=this.isReadOnly,e.isFocused=this.isFocused,e}}On.prototype.is=function(e,t){return t?t===this.name&&("editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};const Rn=Symbol("rootName");class Vn extends On{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(Rn)}set rootName(e){this._setCustomProperty(Rn,e)}toJSON(){return this.rootName}set _name(e){this.name=e}}Vn.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Bn{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new fe("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new fe("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=Mn._createAt(e.startPosition):this._position=Mn._createAt(e.boundaries["backward"==e.direction?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i;do{i=this.position,t=this.next()}while(!t.done&&e(t.value));t.done||(this._position=i)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone()}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&e.offset===i.childCount)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let n;if(i&&i.is("view:$text")){if(e.isAtEnd)return this._position=Mn._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{n=(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset}const s=new hn(i,e.offset,n);return e.offset+=n,this._position=e,this._formatReturnValue("text",s,t,e,n)}if(n&&n.is("view:element")){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new Mn(n,0);return this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}if(n&&n.is("view:$text")){if(this.singleCharacters)return e=new Mn(n,0),this._position=e,this._next();let i,s=n.data.length;return n==this._boundaryEndParent?(s=this.boundaries.end.offset,i=new hn(n,0,s),e=Mn._createAfter(i)):(i=new hn(n,0,n.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,s)}return e=Mn._createAfter(i),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,t,e)}_previous(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&0===e.offset)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let n;if(i.is("view:$text")){if(e.isAtStart)return this._position=Mn._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=e.offset-t}e.offset-=n;const s=new hn(i,e.offset,n);return this._position=e,this._formatReturnValue("text",s,t,e,n)}if(n&&n.is("view:element"))return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new Mn(n,n.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n&&n.is("view:$text")){if(this.singleCharacters)return e=new Mn(n,n.data.length),this._position=e,this._previous();let i,s=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new hn(n,t,n.data.length-t),s=i.data.length,e=Mn._createBefore(i)}else i=new hn(n,0,n.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,s)}return e=Mn._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,s){return t.is("view:$textProxy")&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Mn._createAfter(t.textNode):(n=Mn._createAfter(t.textNode),this._position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Mn._createBefore(t.textNode):(n=Mn._createBefore(t.textNode),this._position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}}class Mn extends cn{parent;offset;constructor(e,t){super(),this.parent=e,this.offset=t}get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return 0===this.offset}get isAtEnd(){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 On);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Mn._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 n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";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 n=qe(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]<i[n]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new Bn(e)}clone(){return new Mn(this.parent,this.offset)}toJSON(){return{parent:this.parent.toJSON(),offset:this.offset}}static _createAt(e,t){if(e instanceof Mn)return new this(e.parent,e.offset);{const i=e;if("end"==t)t=i.is("$text")?i.data.length:i.childCount;else{if("before"==t)return this._createBefore(i);if("after"==t)return this._createAfter(i);if(0!==t&&!t)throw new fe("view-createpositionat-offset-required",i)}return new Mn(i,t)}}static _createAfter(e){if(e.is("$textProxy"))return new Mn(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new fe("view-position-after-root",e,{root:e});return new Mn(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new Mn(e.textNode,e.offsetInText);if(!e.parent)throw new fe("view-position-before-root",e,{root:e});return new Mn(e.parent,e.index)}}Mn.prototype.is=function(e){return"position"===e||"view:position"===e};class Fn extends cn{start;end;constructor(e,t=null){super(),this.start=e.clone(),this.end=t?t.clone():e.clone()}*[Symbol.iterator](){yield*new Bn({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return this.start.parent===this.end.parent}get root(){return this.start.root}getEnlarged(){let e=this.start.getLastMatchingPosition(Nn,{direction:"backward"}),t=this.end.getLastMatchingPosition(Nn);return e.parent.is("$text")&&e.isAtStart&&(e=Mn._createBefore(e.parent)),t.parent.is("$text")&&t.isAtEnd&&(t=Mn._createAfter(t.parent)),new Fn(e,t)}getTrimmed(){let e=this.start.getLastMatchingPosition(Nn);if(e.isAfter(this.end)||e.isEqual(this.end))return new Fn(e,e);let t=this.end.getLastMatchingPosition(Nn,{direction:"backward"});const i=e.nodeAfter,n=t.nodeBefore;return i&&i.is("$text")&&(e=new Mn(i,0)),n&&n.is("$text")&&(t=new Mn(n,n.data.length)),new Fn(e,t)}isEqual(e){return this==e||this.start.isEqual(e.start)&&this.end.isEqual(e.end)}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),n=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&n}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new Fn(this.start,e.start)),this.containsPosition(e.end)&&t.push(new Fn(e.end,this.end))):t.push(this.clone()),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,i=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(i=e.end),new Fn(t,i)}return null}getWalker(e={}){return e.boundaries=this,new Bn(e)}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;let e=this.start.nodeAfter,t=this.end.nodeBefore;return this.start.parent.is("$text")&&this.start.isAtEnd&&this.start.parent.nextSibling&&(e=this.start.parent.nextSibling),this.end.parent.is("$text")&&this.end.isAtStart&&this.end.parent.previousSibling&&(t=this.end.parent.previousSibling),e&&e.is("element")&&e===t?e:null}clone(){return new Fn(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new Bn(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new Bn(e);yield t.position;for(const e of t)yield e.nextPosition}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static _createFromParentsAndOffsets(e,t,i,n){return new this(new Mn(e,t),new Mn(i,n))}static _createFromPositionAndShift(e,t){const i=e,n=e.getShiftedBy(t);return t>0?new this(i,n):new this(n,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(Mn._createBefore(e),t)}}function Nn(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}Fn.prototype.is=function(e){return"range"===e||"view:range"===e};class Ln extends(Ae(cn)){_ranges;_lastRangeBackward;_isFake;_fakeSelectionLabel;constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Ue(this.getRanges());if(t!=Ue(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),t.start.isEqual(n.start)&&t.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]),this._setFakeOptions(n);else if(t instanceof Ln||t instanceof Dn)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Fn)this._setRanges([t],n&&n.backward),this._setFakeOptions(n);else if(t instanceof Mn)this._setRanges([new Fn(t)]),this._setFakeOptions(n);else if(t instanceof dn){const e=!!n&&!!n.backward;let s;if(void 0===i)throw new fe("view-selection-setto-required-second-parameter",this);s="in"==i?Fn._createIn(t):"on"==i?Fn._createOn(t):new Fn(Mn._createAt(t,i)),this._setRanges([s],e),this._setFakeOptions(n)}else{if(!Ke(t))throw new fe("view-selection-setto-not-selectable",this);this._setRanges(t,n&&n.backward),this._setFakeOptions(n)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new fe("view-selection-setfocus-no-ranges",this);const i=Mn._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new Fn(i,n),!0):this._addRange(new Fn(n,i)),this.fire("change")}toJSON(){const e={ranges:Array.from(this.getRanges()).map(e=>e.toJSON())};return this.isBackward&&(e.isBackward=!0),this.isFake&&(e.isFake=!0),e}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof Fn))throw new fe("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 fe("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Fn(e.start,e.end))}}Ln.prototype.is=function(e){return"selection"===e||"view:selection"===e};class Dn extends(Ae(cn)){_selection;constructor(...e){super(),this._selection=new Ln,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}toJSON(){return this._selection.toJSON()}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}}Dn.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class zn extends de{startRange;_eventPhase;_currentTarget;constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const Hn=Symbol("bubblingEmitter"),$n=Symbol("bubblingCallbacks"),Wn=Symbol("bubblingContexts");function jn(e){return class extends e{fire(e,...t){try{const i=e instanceof de?e:new de(this,e),n=Kn(this),s=Jn(this);if(Un(i,"capturing",this),qn(n,"$capture",i,...t))return i.return;const o=i.startRange||this.selection.getFirstRange(),r=o?o.getContainedElement():null,a=!!r&&function(e,t){for(const i of e)if(i(t))return!0;return!1}(s,r);let l=r||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),s=i.getPath();return n.length>s.length?t:i}(o);if(Un(i,"atTarget",l),!a){if(qn(n,"$text",i,...t))return i.return;Un(i,"bubbling",l)}for(;l;){if(l.is("element")&&qn(n,l,i,...t))return i.return;l=l.parent,Un(i,"bubbling",l)}return Un(i,"bubbling",this),qn(n,"$document",i,...t),i.return}catch(e){fe.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){const n=ei(i.context||"$document"),s=Kn(this),o=Gn(this);for(const e of n)"function"==typeof e&&Jn(this).add(e);const r=function(e,t,i){return function(n,s){const{currentTarget:o,eventArgs:r}=s;if("string"!=typeof o){if(o.is("rootElement")&&t.includes("$root"))i.call(e,n,...r);else if(t.includes(o.name))i.call(e,n,...r);else for(const s of t)if("function"==typeof s&&s(o))return void i.call(e,n,...r)}else t.includes(o)&&i.call(e,n,...r)}}(this,n,t);o.set(t,r),this.listenTo(s,e,r,i)}_removeEventListener(e,t){const i=Kn(this),n=Gn(this),s=n.get(t);s&&(n.delete(t),this.stopListening(i,e,s))}}}function Un(e,t,i){e instanceof zn&&(e._eventPhase=t,e._currentTarget=i)}function qn(e,t,i,...n){return e.fire(i,{currentTarget:t,eventArgs:n}),!!i.stop.called}function Kn(e){return e[Hn]||(e[Hn]=new(Ae())),e[Hn]}function Gn(e){return e[$n]||(e[$n]=new Map),e[$n]}function Jn(e){return e[Wn]||(e[Wn]=new Set),e[Wn]}class Yn extends(jn(Le())){selection;roots;stylesProcessor;_postFixers=new Set;constructor(e){super(),this.selection=new Dn,this.roots=new ni({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(t=i(e),t)break}while(t)}}class Qn extends En{static DEFAULT_PRIORITY=10;_priority=10;_id=null;_clonesGroup=null;constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=Xn}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new fe("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}toJSON(){const e=super.toJSON();return e.type="AttributeElement",e}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return null===this.id&&null===e.id&&this.priority===e.priority&&super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return null===this.id&&null===e.id&&this.priority===e.priority&&super._canSubtractAttributesOf(e)}}function Xn(){if(Zn(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(Zn(e)>1)return null;e=e.parent}return!e||Zn(e)>1?null:this.childCount}function Zn(e){return Array.from(e.getChildren()).filter(e=>!e.is("uiElement")).length}Qn.prototype.is=function(e,t){return t?t===this.name&&("attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e):"attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class es extends En{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ts}toJSON(){const e=super.toJSON();return e.type="EmptyElement",e}_insertChild(e,t){if(t&&(t instanceof dn||Array.from(t).length>0))throw new fe("view-emptyelement-cannot-add",[this,t]);return 0}}function ts(){return null}es.prototype.is=function(e,t){return t?t===this.name&&("emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e):"emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class is extends En{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ss}_insertChild(e,t){if(t&&(t instanceof dn||Array.from(t).length>0))throw new fe("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 e of this.getAttributeKeys())t.setAttribute(e,this.getAttribute(e));return t}toJSON(){const e=super.toJSON();return e.type="UIElement",e}}function ns(e){e.document.on("arrowKey",(t,i)=>function(e,t,i){if(t.keyCode==Ut.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,s=e.focusOffset,o=i.domPositionToView(t,s);if(null===o)return;let r=!1;const a=o.getLastMatchingPosition(e=>(e.item.is("uiElement")&&(r=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement"))));if(r){const t=i.viewPositionToDom(a);n?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,i,e.domConverter),{priority:"low"})}function ss(){return null}is.prototype.is=function(e,t){return t?t===this.name&&("uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e):"uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class os extends En{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=rs}toJSON(){const e=super.toJSON();return e.type="RawElement",e}_insertChild(e,t){if(t&&(t instanceof dn||Array.from(t).length>0))throw new fe("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function rs(){return null}os.prototype.is=function(e,t){return t?t===this.name&&("rawElement"===e||"view:rawElement"===e||"element"===e||"view:element"===e):"rawElement"===e||"view:rawElement"===e||e===this.name||e==="view:"+this.name||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class as extends(Ae(cn)){document;_children=[];_customProperties=new Map;constructor(e,t){super(),this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this,{index:e});let i=0;const n=function(e,t){if("string"==typeof t)return[new un(e,t)];Ke(t)||(t=[t]);return Array.from(t).map(t=>"string"==typeof t?new un(e,t):t instanceof hn?new un(e,t.data):t)}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_fireChange(e,t,i){this.fire(`change:${e}`,t,i)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}as.prototype.is=function(e){return"documentFragment"===e||"view:documentFragment"===e};class ls{document;_cloneGroups=new Map;_slotFactory=null;constructor(e){this.document=e}setSelection(...e){this.document.selection._setTo(...e)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new as(this.document,e)}createText(e){return new un(this.document,e)}createAttributeElement(e,t,i={}){const n=new Qn(this.document,e,t);return"number"==typeof i.priority&&(n._priority=i.priority),i.id&&(n._id=i.id),i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createContainerElement(e,t,i={},n={}){let o;!function(e){return s(e)}(i)?o=i:n=i;const r=new Sn(this.document,e,t,o);return n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createEditableElement(e,t,i={}){const n=new On(this.document,e,t);return i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createEmptyElement(e,t,i={}){const n=new es(this.document,e,t);return i.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),n}createUIElement(e,t,i){const n=new is(this.document,e,t);return i&&(n.render=i),n}createRawElement(e,t,i,n={}){const s=new os(this.document,e,t);return i&&(s.render=i),n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}setAttribute(e,t,i,n){void 0!==n?n._setAttribute(e,t,i):i._setAttribute(e,t)}removeAttribute(e,t,i){void 0!==i?i._removeAttribute(e,t):t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){s(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof Mn?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new fe("view-writer-break-non-container-element",this.document);if(!t.parent)throw new fe("view-writer-break-root",this.document);if(e.isAtStart)return Mn._createBefore(t);if(!e.isAtEnd){const i=t._clone(!1);this.insert(Mn._createAfter(t),i);const n=new Fn(e,Mn._createAt(t,"end")),s=new Mn(i,0);this.move(n,s)}return Mn._createAfter(t)}mergeAttributes(e){const t=e.offset,i=e.parent;if(i.is("$text"))return e;if(i.is("attributeElement")&&0===i.childCount){const e=i.parent,t=i.index;return i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new Mn(e,t))}const n=i.getChild(t-1),s=i.getChild(t);if(!n||!s)return e;if(n.is("$text")&&s.is("$text"))return ms(n,s);if(n.is("attributeElement")&&s.is("attributeElement")&&n.isSimilar(s)){const e=n.childCount;return n._appendChild(s.getChildren()),s._remove(),this._removeFromClonedElementsGroup(s),this.mergeAttributes(new Mn(n,e))}return e}mergeContainers(e){const t=e.nodeBefore,i=e.nodeAfter;if(!(t&&i&&t.is("containerElement")&&i.is("containerElement")))throw new fe("view-writer-merge-containers-invalid-position",this.document);const n=t.getChild(t.childCount-1),s=n instanceof un?Mn._createAt(n,"end"):Mn._createAt(t,"end");return this.move(Fn._createIn(i),Mn._createAt(t,"end")),this.remove(Fn._createOn(i)),s}insert(e,t){fs(t=Ke(t)?[...t]:[t],this.document);const i=t.reduce((e,t)=>{const i=e[e.length-1],n=!t.is("uiElement");return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e},[]);let n=null,s=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(s,e,t);n||(n=i.start),s=i.end}return n?new Fn(n,s):new Fn(e)}remove(e){const t=e instanceof Fn?e:Fn._createOn(e);if(bs(t,this.document),t.isCollapsed)return new as(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),s=i.parent,o=n.offset-i.offset,r=s._removeChildren(i.offset,o);for(const e of r)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new as(this.document,r)}clear(e,t){bs(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let s;if(i.is("element")&&t.isSimilar(i))s=Fn._createOn(i);else if(!n.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find(e=>e.is("element")&&t.isSimilar(e));e&&(s=Fn._createIn(e))}s&&(s.end.isAfter(e.end)&&(s.end=e.end),s.start.isBefore(e.start)&&(s.start=e.start),this.remove(s))}}move(e,t){let i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,s=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-s}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof Qn))throw new fe("view-writer-wrap-invalid-attribute",this.document);if(bs(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some(e=>!e.is("uiElement")))&&(n=n.getLastMatchingPosition(e=>e.item.is("uiElement"))),n=this._wrapPosition(n,t);const s=this.document.selection;return s.isCollapsed&&s.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new Fn(n)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof Qn))throw new fe("view-writer-unwrap-invalid-attribute",this.document);if(bs(e,this.document),e.isCollapsed)return e;const{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=this._unwrapChildren(s,i.offset,n.offset,t),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new Fn(r,a)}rename(e,t){const i=new Sn(this.document,e,t.getAttributes());return this.insert(Mn._createAfter(t),i),this.move(Fn._createIn(t),Mn._createAt(i,0)),this.remove(Fn._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Mn._createAt(e,t)}createPositionAfter(e){return Mn._createAfter(e)}createPositionBefore(e){return Mn._createBefore(e)}createRange(e,t){return new Fn(e,t)}createRangeOn(e){return Fn._createOn(e)}createRangeIn(e){return Fn._createIn(e)}createSelection(...e){return new Ln(...e)}createSlot(e="children"){if(!this._slotFactory)throw new fe("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let n,s;if(n=i?cs(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new fe("view-writer-invalid-position-container",this.document);s=i?this._breakAttributes(e,!0):e.parent.is("$text")?hs(e):e;const o=n._insertChild(s.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const r=s.getShiftedBy(o),a=this.mergeAttributes(s);a.isEqual(s)||r.offset--;const l=this.mergeAttributes(r);return new Fn(a,l)}_wrapChildren(e,t,i,n){let s=t;const o=[];for(;s<i;){const t=e.getChild(s),i=t.is("$text"),r=t.is("attributeElement");if(r&&t._canMergeAttributesFrom(n))t._mergeAttributesFrom(n),o.push(new Mn(e,s));else if(i||!r||ds(n,t)){const i=n._clone();t._remove(),i._appendChild(t),e._insertChild(s,i),this._addToClonedElementsGroup(i),o.push(new Mn(e,s))}else this._wrapChildren(t,0,t.childCount,n);s++}let r=0;for(const e of o){if(e.offset-=r,e.offset==t)continue;this.mergeAttributes(e).isEqual(e)||(r++,i--)}return Fn._createFromParentsAndOffsets(e,t,e,i)}_unwrapChildren(e,t,i,n){let s=t;const o=[];for(;s<i;){const t=e.getChild(s);if(t.is("attributeElement")){if(t.isSimilar(n)){const n=t.getChildren(),r=t.childCount;t._remove(),e._insertChild(s,n),this._removeFromClonedElementsGroup(t),o.push(new Mn(e,s),new Mn(e,s+r)),s+=r,i+=r-1;continue}t._canSubtractAttributesOf(n)?(t._subtractAttributesOf(n),o.push(new Mn(e,s),new Mn(e,s+1)),s++):(this._unwrapChildren(t,0,t.childCount,n),s++)}else s++}let r=0;for(const e of o){if(e.offset-=r,e.offset==t||e.offset==i)continue;this.mergeAttributes(e).isEqual(e)||(r++,i--)}return Fn._createFromParentsAndOffsets(e,t,e,i)}_wrapRange(e,t){const{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=this._wrapChildren(s,i.offset,n.offset,t),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new Fn(r,a)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return us(e.clone());e.parent.is("$text")&&(e=hs(e));const i=this.createAttributeElement("_wrapPosition-fake-element");i._priority=Number.POSITIVE_INFINITY,i.isSimilar=()=>!1,e.parent._insertChild(e.offset,i);const n=new Fn(e,e.getShiftedBy(1));this.wrap(n,t);const s=new Mn(i.parent,i.index);i._remove();const o=s.nodeBefore,r=s.nodeAfter;return o&&o.is("view:$text")&&r&&r.is("view:$text")?ms(o,r):us(s)}_breakAttributesRange(e,t=!1){const i=e.start,n=e.end;if(bs(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new Fn(i,i)}const s=this._breakAttributes(n,t),o=s.parent.childCount,r=this._breakAttributes(i,t);return s.offset+=s.parent.childCount-o,new Fn(r,s)}_breakAttributes(e,t=!1){const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new fe("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new fe("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new fe("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&ps(n.parent))return e.clone();if(ps(n))return e.clone();if(n.is("$text"))return this._breakAttributes(hs(e),t);if(i==n.childCount){const e=new Mn(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new Mn(n.parent,n.index);return this._breakAttributes(e,t)}{const e=n.index+1,s=n._clone();n.parent._insertChild(e,s),this._addToClonedElementsGroup(s);const o=n.childCount-i,r=n._removeChildren(i,o);s._appendChild(r);const a=new Mn(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let 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 t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function cs(e){let t=e.parent;for(;!ps(t);){if(!t)return;t=t.parent}return t}function ds(e,t){return e.priority<t.priority||!(e.priority>t.priority)&&e.getIdentity()<t.getIdentity()}function us(e){const t=e.nodeBefore;if(t&&t.is("$text"))return new Mn(t,t.data.length);const i=e.nodeAfter;return i&&i.is("$text")?new Mn(i,0):e}function hs(e){if(e.offset==e.parent.data.length)return new Mn(e.parent.parent,e.parent.index+1);if(0===e.offset)return new Mn(e.parent.parent,e.parent.index);const t=e.parent.data.slice(e.offset);return e.parent._data=e.parent.data.slice(0,e.offset),e.parent.parent._insertChild(e.parent.index+1,new un(e.root.document,t)),new Mn(e.parent.parent,e.parent.index+1)}function ms(e,t){const i=e.data.length;return e._data+=t.data,t._remove(),new Mn(e,i)}const gs=[un,Qn,Sn,es,os,is];function fs(e,t){for(const i of e){if(!gs.some(e=>i instanceof e))throw new fe("view-writer-insert-invalid-node-type",t);i.is("$text")||fs(i.getChildren(),t)}}function ps(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function bs(e,t){const i=cs(e.start),n=cs(e.end);if(!i||!n||i!==n)throw new fe("view-writer-invalid-range-container",t)}const ws=e=>e.createTextNode(" "),_s=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},vs=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},ys="".repeat(7);function ks(e){return"string"==typeof e?e.substr(0,7)===ys:lt(e)&&e.data.substr(0,7)===ys}function Cs(e){return 7==e.data.length&&ks(e)}function As(e){const t="string"==typeof e?e:e.data;return ks(e)?t.slice(7):t}function Ts(e,t){if(t.keyCode==Ut.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;ks(t)&&i<=7&&e.collapse(t,0)}}}class Es extends(Le()){domDocuments=new Set;domConverter;markedAttributes=new Set;markedChildren=new Set;markedTexts=new Set;selection;_inlineFiller=null;_fakeSelectionContainer=null;constructor(e,t){super(),this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),Q.isBlink&&!Q.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else{if("children"!==e)throw new fe("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){if(this.isComposing&&!Q.isAndroid)return;let e=null;const t=!(Q.isBlink&&!Q.isAndroid)||!this.isSelecting;for(const e of this.markedChildren)this._updateChildrenMappings(e);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=Mn._createBefore(e.parent)));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;ks(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=xs(i,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.childNodes),n=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),s=this._diffNodeLists(i,n),o=this._findUpdateActions(s,i,n,Ps);if(-1!==o.indexOf("update")){const t={equal:0,insert:0,delete:0};for(const s of o)if("update"===s){const s=t.equal+t.insert,o=t.equal+t.delete,r=e.getChild(s);!r||r.is("uiElement")||r.is("rawElement")||this._updateElementMappings(r,i[o]),Ot(n[s]),t.equal++}else t[s]++}}_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")?Mn._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&<(t.parent)&&ks(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!ks(e))throw new fe("view-renderer-filler-was-lost",this);Cs(e)?e.remove():e.data=e.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor(e=>e.hasAttribute("contenteditable"));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;const n=e.nodeBefore,s=e.nodeAfter;return!(n instanceof un||s instanceof un)&&(!!(i!==t.getFillerOffset()||n&&n.is("element","br"))&&(!Q.isAndroid||!n&&!s))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let n=this.domConverter.viewToDom(e).data;const s=t.inlineFillerPosition;s&&s.parent==e.parent&&s.offset==e.index&&(n=ys+n),this._updateTextNode(i,n)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(t){for(const i of Array.from(t.attributes)){const n=i.name;e.hasAttribute(n)||this.domConverter.removeDomElementAttribute(t,n)}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(Q.isAndroid){let e=null;for(const t of Array.from(i.childNodes)){if(e&<(e)&<(t)){i.normalize();break}e=t}}const n=t.inlineFillerPosition,s=i.childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));n&&n.parent===e&&xs(i.ownerDocument,o,n.offset);const r=this._diffNodeLists(s,o),a=this._findUpdateActions(r,s,o,Ss);let l=0;const c=new Set;for(const e of a)"delete"===e?(c.add(s[l]),Ot(s[l])):"equal"!==e&&"update"!==e||l++;l=0;for(const e of a)"insert"===e?(Ct(i,l,o[l]),l++):"update"===e?(this._updateTextNode(s[l],o[l].data),l++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(o[l])),l++);for(const e of c)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return ce(e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;i[i.length-1]==t&&i.pop();return i}(e,this._fakeSelectionContainer),t,Is.bind(null,this.domConverter))}_findUpdateActions(e,t,i,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let s=[],o=[],r=[];const a={equal:0,insert:0,delete:0};for(const l of e)"insert"===l?r.push(i[a.equal+a.insert]):"delete"===l?o.push(t[a.equal+a.delete]):(s=s.concat(ce(o,r,n).map(e=>"equal"===e?"update":e)),s.push("equal"),o=[],r=[]),a[l]++;return s.concat(ce(o,r,n).map(e=>"equal"===e?"update":e))}_updateTextNode(e,t){const i=e.data;i!=t&&(Q.isAndroid&&this.isComposing&&i.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){const i=re(e.data,t);for(const t of i)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.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(Q.isBlink&&!Q.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const e=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&e?this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&Q.isAndroid||this._updateDomSelection(e):!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection()}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}(t));const 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 n=t.getSelection(),s=t.createRange();n.removeAllRanges(),s.selectNodeContents(i),n.addRange(s)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,n.parent,n.offset),Q.isGecko&&function(e,t){let i=e.parent,n=e.offset;lt(i)&&Cs(i)&&(n=kt(i)+1,i=i.parentNode);if(i.nodeType!=Node.ELEMENT_NODE||n!=i.childNodes.length-1)return;const s=i.childNodes[n];s&&"BR"==s.tagName&&t.addRange(t.getRangeAt(0))}(n,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)||t.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,n=this.domConverter.mapDomToView(i);i&&n&&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 xs(e,t,i){const n=t instanceof Array?t:t.childNodes,s=n[i];if(lt(s))return s.data=ys+s.data,s;{const s=e.createTextNode(ys);return Array.isArray(t)?n.splice(i,0,s):Ct(t,i,s),s}}function Ps(e,t){return Xe(e)&&Xe(t)&&!lt(e)&&!lt(t)&&!At(e)&&!At(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function Ss(e,t){return Xe(e)&&Xe(t)&<(e)&<(t)}function Is(e,t,i){return t===i||(lt(t)&<(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}const Os=vs(G.document),Rs=ws(G.document),Vs=_s(G.document),Bs="data-ck-unsafe-attribute-",Ms="data-ck-unsafe-element";class Fs{document;renderingMode;blockFillerMode;preElements;blockElements;inlineObjectElements;unsafeElements;_domDocument;_domToViewMapping=new WeakMap;_viewToDomMapping=new WeakMap;_fakeSelectionMapping=new WeakMap;_rawContentElementMatcher=new bn;_inlineObjectElementMatcher=new bn;_elementsWithTemporaryCustomProperties=new Set;constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){this.document=e,this.renderingMode=i,this.blockFillerMode=t||("editing"===i?"br":"nbsp"),this.preElements=["pre","textarea"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument="editing"===this.renderingMode?G.document:G.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Ln(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const t of e.children)this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&("srcdoc"!==e&&("img"===i&&("src"===e||"srcset"===e)||("source"===i&&"srcset"===e||!t.replace(/\s+/g,"").match(/^(javascript:|data:(image\/svg|text\/x?html))/i))))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const i=(new DOMParser).parseFromString(t,"text/html"),n=i.createDocumentFragment(),s=i.body.childNodes;for(;s.length>0;)n.appendChild(s[0]);const o=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r=[];let a;for(;a=o.nextNode();)r.push(a);for(const e of r){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(Ws(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e,t={}){if(e.is("$text")){const t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{const i=e;if(this.mapViewToDom(i)){if(!i.getCustomProperty("editingPipeline:doNotReuseOnce"))return this.mapViewToDom(i);this._elementsWithTemporaryCustomProperties.add(i)}let n;if(i.is("documentFragment"))n=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(n,i);else{if(i.is("uiElement"))return n="$comment"===i.name?this._domDocument.createComment(i.getCustomProperty("$rawContent")):i.render(this._domDocument,this),t.bind&&this.bindElements(n,i),n;this._shouldRenameElement(i.name)?(Ws(i.name),n=this._createReplacementDomElement(i.name)):n=i.hasAttribute("xmlns")?this._domDocument.createElementNS(i.getAttribute("xmlns"),i.name):this._domDocument.createElement(i.name),i.is("rawElement")&&i.render(n,this),t.bind&&this.bindElements(n,i);for(const e of i.getAttributeKeys())this.setDomElementAttribute(n,e,i.getAttribute(e),i)}if(!1!==t.withChildren)for(const e of this.viewChildrenToDom(i,t))n instanceof HTMLTemplateElement?n.content.appendChild(e):n.appendChild(e);return n}}setDomElementAttribute(e,t,i,n){const s=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);s||pe("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),Tt(t)?(e.hasAttribute(t)&&!s?e.removeAttribute(t):e.hasAttribute(Bs+t)&&s&&e.removeAttribute(Bs+t),e.setAttribute(s?t:Bs+t,i)):pe("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=Ms&&(e.removeAttribute(t),e.removeAttribute(Bs+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let n=0;for(const s of e.getChildren()){i===n&&(yield this._getBlockFiller());const e=s.is("element")&&!!s.getCustomProperty("dataPipeline:transparentRendering")&&!si(s.getAttributes());if(e&&"data"==this.renderingMode)if(s.is("rawElement")){const e=this._domDocument.createElement(s.name);s.render(e,this),yield*[...e.childNodes]}else yield*this.viewChildrenToDom(s,t);else e&&pe("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:s}),yield this.viewToDom(s,t);n++}i===n&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=this._domDocument.createRange();return n.setStart(t.parent,t.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let n=e.offset;return ks(i)&&(n+=7),i.data&&n>i.data.length&&(n=i.data.length),{parent:i,offset:n}}{let i,n,s;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;s=i.childNodes[0]}else{const t=e.nodeBefore;if(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!n)return null;i=n.parentNode,s=n.nextSibling}if(lt(s)&&ks(s))return{parent:s,offset:7};return{parent:i,offset:n?kt(n)+1:0}}}domToView(e,t={}){const i=[],n=this._domToView(e,t,i),s=n.next().value;return s?(n.next(),this._processDomInlineNodes(null,i,t),"br"==this.blockFillerMode&&Hs(s)||s.is("$text")&&0==s.data.length?null:s):null}*domChildrenToView(e,t={},i=[]){let n=[];n=e instanceof HTMLTemplateElement?[...e.content.childNodes]:[...e.childNodes];for(let s=0;s<n.length;s++){const o=n[s],r=this._domToView(o,t,i),a=r.next().value;null!==a&&(this._isBlockViewElement(a)&&this._processDomInlineNodes(e,i,t),"br"==this.blockFillerMode&&Hs(a)||(yield a),r.next())}this._processDomInlineNodes(e,i,t)}domSelectionToView(e){if(function(e){if(!Q.isGecko)return!1;if(!e.rangeCount)return!1;const t=e.getRangeAt(0).startContainer;try{Object.prototype.toString.call(t)}catch{return!0}return!1}(e))return new Ln([]);if(1===e.rangeCount){let t=e.getRangeAt(0).startContainer;lt(t)&&(t=t.parentNode);const i=this.fakeSelectionToView(t);if(i)return i}const t=this.isDomSelectionBackward(e),i=[];for(let t=0;t<e.rangeCount;t++){const n=e.getRangeAt(t),s=this.domRangeToView(n);s&&i.push(s)}return new Ln(i,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),i=this.domPositionToView(e.endContainer,e.endOffset);return t&&i?new Fn(t,i):null}domPositionToView(e,t=0){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,kt(e));const i=this.mapDomToView(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return Mn._createBefore(i);if(lt(e)){if(Cs(e))return this.domPositionToView(e.parentNode,kt(e));const i=this.findCorrespondingViewText(e);let n=t;return i?(ks(e)&&(n-=7,n=n<0?0:n),new Mn(i,n)):null}if(0===t){const t=this.mapDomToView(e);if(t)return new Mn(t,0)}else{const i=e.childNodes[t-1];if(lt(i)&&Cs(i)||i&&this.isBlockFiller(i))return this.domPositionToView(i.parentNode,kt(i));const n=lt(i)?this.findCorrespondingViewText(i):this.mapDomToView(i);if(n&&n.parent)return new Mn(n.parent,n.index+1)}return null}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(Cs(e))return null;const t=this.getHostViewElement(e);if(t)return t;const i=e.previousSibling;if(i){if(!this.isElement(i))return null;const e=this.mapDomToView(i);if(e){const t=e.nextSibling;return t instanceof un?t:null}}else{const t=this.mapDomToView(e.parentNode);if(t){const e=t.getChild(0);return e instanceof un?e:null}}return null}mapViewToDom(e){return this._viewToDomMapping.get(e)}findCorrespondingDomText(e){const t=e.previousSibling;return t&&this.mapViewToDom(t)?this.mapViewToDom(t).nextSibling:!t&&e.parent&&this.mapViewToDom(e.parent)?this.mapViewToDom(e.parent).childNodes[0]:null}focus(e){const t=this.mapViewToDom(e);if(!t||t.ownerDocument.activeElement===t)return;const{scrollX:i,scrollY:n}=G.window,s=[];Ns(t,e=>{const{scrollLeft:t,scrollTop:i}=e;s.push([t,i])}),t.focus({preventScroll:!0}),Ns(t,e=>{const[t,i]=s.shift();e.scrollLeft=t,e.scrollTop=i}),G.window.scrollTo(i,n)}_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"br"==this.blockFillerMode?e.isEqualNode(Os):!!$s(e,this.blockElements)||(e.isEqualNode(Vs)||function(e,t){const i=e.isEqualNode(Rs);return i&&Ls(e,t)&&1===e.parentNode.childNodes.length}(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=st(e);for(t.pop();t.length;){const e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return ws(this._domDocument);case"markedNbsp":return _s(this._domDocument);case"br":return vs(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(lt(e)&&ks(e)&&t<7)return!1;if(this.isElement(e)&&ks(e.childNodes[t]))return!1;const i=this.mapDomToView(e);return!i||!i.is("uiElement")&&!i.is("rawElement")}*_domToView(e,t,i){if("br"!=this.blockFillerMode&&$s(e,this.blockElements))return null;const n=this.getHostViewElement(e);if(n)return n;if(At(e)&&t.skipComments)return null;if(lt(e)){if(Cs(e))return null;{const t=e.data;if(""===t)return null;const n=new un(this.document,t);return i.push(n),n}}{let n=this.mapDomToView(e);if(n)return this._isInlineObjectElement(n)&&i.push(n),n;if(this.isDocumentFragment(e))n=new as(this.document),t.bind&&this.bindDocumentFragments(e,n);else{n=this._createViewElement(e,t),t.bind&&this.bindElements(e,n);const s=e.attributes;if(s)for(let e=s.length,t=0;t<e;t++)n._setAttribute(s[t].name,s[t].value);if(this._isViewElementWithRawContent(n,t))return n._setCustomProperty("$rawContent",e.innerHTML),this._isBlockViewElement(n)||i.push(n),n;if(At(e))return n._setCustomProperty("$rawContent",e.data),n}yield n;const s=[];if(!1!==t.withChildren)for(const i of this.domChildrenToView(e,t,s))n._appendChild(i);if(this._isInlineObjectElement(n))i.push(n),this._processDomInlineNodes(null,s,t);else for(const e of s)i.push(e)}}_processDomInlineNodes(e,t,i){if(!t.length)return;if(e&&!this.isDocumentFragment(e)&&!this._isBlockDomElement(e))return;let n=!1;for(let e=0;e<t.length;e++){const s=t[e];if(!s.is("$text")){n=!1;continue}let o,r=!1;if(this._isPreFormatted(s))o=As(s.data);else{o=s.data.replace(/[ \n\t\r]{1,}/g," "),r=/[^\S\u00A0]/.test(o.charAt(o.length-1));const a=e>0?t[e-1]:null,l=e+1<t.length?t[e+1]:null,c=!a||a.is("element")&&"br"==a.name||n,d=!l&&!ks(s.data);!1!==i.withChildren&&(c&&(o=o.replace(/^ /,"")),d&&(o=o.replace(/ $/,""))),o=As(o),"br"!=this.blockFillerMode&&s.parent&&(zs(s.parent,o)?(o="",s.parent.parent&&(s.parent.parent._setCustomProperty("$hasBlockFiller",!0),s.parent._remove())):Ds(s.parent,o,this.blockElements)&&(o="",s.parent._setCustomProperty("$hasBlockFiller",!0))),o=o.replace(/ \u00A0/g," ");const u=l&&l.is("element")&&"br"!=l.name,h=l&&l.is("$text")&&" "==l.data.charAt(0);(/[ \u00A0]\u00A0$/.test(o)||!l||u||h)&&(o=o.replace(/\u00A0$/," ")),(c||a&&a.is("element")&&"br"!=a.name)&&(o=o.replace(/^\u00A0/," "))}0==o.length&&s.parent?(s._remove(),t.splice(e,1),e--):(s._data=o,n=r)}t.length=0}_processDataFromViewText(e){let t=e.data;if(this._isPreFormatted(e))return t;if(" "==t.charAt(0)){const i=this._getTouchingInlineViewNode(e,!1);!(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i))&&i||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingInlineViewNode(e,!0),n=i&&i.is("$textProxy")&&" "==i.data.charAt(0);" "!=t.charAt(t.length-2)&&i&&!n||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g," ")}_nodeEndsWithSpace(e){if(this._isPreFormatted(e))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_isPreFormatted(e){if(function(e,t){return e.getAncestors().some(e=>e.is("element")&&t.includes(e.name))}(e,this.preElements))return!0;for(const t of e.getAncestors({parentFirst:!0}))if(t.is("element")&&t.hasStyle("white-space")&&"inherit"!==t.getStyle("white-space"))return["pre","pre-wrap","break-spaces"].includes(t.getStyle("white-space"));return!1}_getTouchingInlineViewNode(e,t){const i=new Bn({startPosition:t?Mn._createAfter(e):Mn._createBefore(e),direction:t?"forward":"backward"});for(const{item:e}of i){if(e.is("$textProxy"))return e;if(!e.is("element")||!e.getCustomProperty("dataPipeline:transparentRendering")){if(e.is("element","br"))return null;if(this._isInlineObjectElement(e))return e;if(e.is("containerElement")||this._isBlockViewElement(e))return null}}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return!!e.is("element")&&("br"==e.name||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e))}_createViewElement(e,t){if(At(e))return new is(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new En(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const i=this._domDocument.createElement("span");if(i.setAttribute(Ms,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function Ns(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function Ls(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function Ds(e,t,i){return" "==t&&e&&e.is("element")&&1==e.childCount&&i.includes(e.name)}function zs(e,t){return" "==t&&e&&e.is("element","span")&&1==e.childCount&&e.hasAttribute("data-cke-filler")}function Hs(e){return e.is("element","br")&&e.hasAttribute("data-cke-filler")}function $s(e,t){return"BR"===e.tagName&&Ls(e,t)&&1===e.parentNode.childNodes.length}function Ws(e){"script"===e&&pe("domconverter-unsafe-script-element-detected"),"style"===e&&pe("domconverter-unsafe-style-element-detected")}class js extends(tt()){view;document;_isEnabled=!1;constructor(e){super(),this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}class Us{view;document;domEvent;domTarget;constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,Ri(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class qs extends js{useCapture=!1;usePassive=!1;observe(e){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach(t=>{this.listenTo(e,t,(e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)},{useCapture:this.useCapture,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new Us(this.view,t,i))}}class Ks extends qs{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 Kt(this)}};this.fire(e.type,e,t)}}class Gs extends js{_fireSelectionChangeDoneDebounced;constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Ci(e=>{this.document.fire("selectionChangeDone",e)},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 Ln(t.getRanges(),{backward:t.isBackward,fake:!1});e!=Ut.arrowleft&&e!=Ut.arrowup||i.setTo(i.getFirstPosition()),e!=Ut.arrowright&&e!=Ut.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}class Js extends js{domConverter;_config;_domElements;_mutationObserver;constructor(e){super(e),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(0===e.length)return;const t=this.domConverter,i=new Set,n=new Set;for(const i of e){const e=t.mapDomToView(i.target);e&&(e.is("uiElement")||e.is("rawElement")||"childList"!==i.type||this._isBogusBrMutation(i)||n.add(e))}for(const s of e){const e=t.mapDomToView(s.target);if((!e||!e.is("uiElement")&&!e.is("rawElement"))&&"characterData"===s.type){const e=t.findCorrespondingViewText(s.target);e&&!n.has(e.parent)?i.add(e):!e&&ks(s.target)&&n.add(t.mapDomToView(s.target.parentNode))}}const s=[];for(const e of i)s.push({type:"text",node:e});for(const e of n){const i=t.mapViewToDom(e);Qi(Array.from(e.getChildren()),Array.from(t.domChildrenToView(i,{withChildren:!1})),Ys)||s.push({type:"children",node:e})}s.length&&this.document.fire("mutations",{mutations:s})}_isBogusBrMutation(e){let t=null;return null===e.nextSibling&&0===e.removedNodes.length&&1==e.addedNodes.length&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}function Ys(e,t){if(!Array.isArray(e))return e===t||!(!e.is("$text")||!t.is("$text"))&&e.data===t.data}class Qs extends qs{_renderTimeoutId=null;_isFocusChanging=!1;domEventType=["focus","blur"];constructor(e){super(e),this.useCapture=!0;const t=this.document;t.on("focus",()=>this._handleFocus()),t.on("blur",(e,t)=>this._handleBlur(t)),t.on("beforeinput",()=>{t.isFocused||this._handleFocus()},{priority:"highest"})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._clearTimeout(),super.destroy()}_handleFocus(){this._clearTimeout(),this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this._renderTimeoutId=null,this.flush(),this.view.change(()=>{})},50)}_handleBlur(e){const t=this.document.selection.editableElement;null!==t&&t!==e.target||(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class Xs extends js{mutationObserver;focusObserver;selection;domConverter;_documents=new WeakSet;_fireSelectionChangeDoneDebounced;_clearInfiniteLoopInterval;_documentIsSelectingInactivityTimeoutDebounced;_loopbackCounter=0;_pendingSelectionChange=new Set;constructor(e){super(e),this.mutationObserver=e.getObserver(Js),this.focusObserver=e.getObserver(Qs),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=Ci(e=>{this.document.fire("selectionChangeDone",e)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Ci(()=>this.document.isSelecting=!1,5e3),this.view.document.on("change:isFocused",(e,t,i)=>{if(i&&this._pendingSelectionChange.size){for(const e of Array.from(this._pendingSelectionChange))this._handleSelectionChange(e);this._pendingSelectionChange.clear()}})}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",()=>{this.document.isComposing&&!Q.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(0!=i.rangeCount)if(this.view.hasDomSelection=!0,this.focusObserver.flush(),this.view.document.isFocused||this.view.document.isReadOnly){if(this._pendingSelectionChange.delete(e),!this.selection.isEqual(i)||!this.domConverter.isDomSelectionCorrect(t))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(function(e){return Array.from(e.getRanges()).flatMap(e=>[e.start.root,e.end.root]).every(e=>e&&e.is("rootElement"))}(i))if(this.selection.isSimilar(i))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:i,domSelection:t};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}else this.view.forceRender()}else this._pendingSelectionChange.add(e);else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class Zs extends qs{domEventType=["compositionstart","compositionupdate","compositionend"];constructor(e){super(e);const t=this.document;t.on("compositionstart",()=>{t.isComposing=!0}),t.on("compositionend",()=>{t.isComposing=!1})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}class eo{_files;_native;constructor(e,t={}){this._files=t.cacheFiles?to(e):null,this._native=e}get files(){return this._files||(this._files=to(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}function to(e){const t=Array.from(e.files||[]),i=Array.from(e.items||[]);return t.length?t:i.filter(e=>"file"===e.kind).map(e=>e.getAsFile())}class io extends qs{domEventType="beforeinput";onDomEvent(e){const t=e.getTargetRanges(),i=this.view,n=i.document;let s=null,o=null,r=[];if(e.dataTransfer&&(s=new eo(e.dataTransfer)),null!==e.data?o=e.data:s&&(o=s.getData("text/plain")),n.selection.isFake)r=Array.from(n.selection.getRanges()),e.preventDefault();else if(t.length)r=t.map(t=>{let n=i.domConverter.domPositionToView(t.startContainer,t.startOffset);const s=i.domConverter.domPositionToView(t.endContainer,t.endOffset);if(n&&ks(t.startContainer)&&t.startOffset<7){e.preventDefault();let i=7-t.startOffset;n=n.getLastMatchingPosition(e=>!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))||!(!e.item.is("$textProxy")||!i--),{direction:"backward",singleCharacters:!0})}return function(e,t){for(;e.parentNode;){if(lt(e)){if(t!=e.data.length)return!1}else if(t!=e.childNodes.length)return!1;if((t=kt(e)+1)<(e=e.parentNode).childNodes.length&&ks(e.childNodes[t]))return!0}return!1}(t.endContainer,t.endOffset)&&e.preventDefault(),n?i.createRange(n,s):s?i.createRange(s):void 0}).filter(e=>!!e);else if(Q.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();r=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(Q.isAndroid&&"insertCompositionText"==e.inputType&&o&&o.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(r[0].end)]});else{if(["insertText","insertReplacementText"].includes(e.inputType)&&o&&o.includes("\n")){const t=o.split(/\n{1,2}/g);let i=r;e.preventDefault();for(let o=0;o<t.length;o++){const r=t[o];""!=r&&(this.fire(e.type,e,{data:r,dataTransfer:s,targetRanges:i,inputType:e.inputType,isComposing:e.isComposing}),i=[n.selection.getFirstRange()]),o+1<t.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:i}),i=[n.selection.getFirstRange()])}return}this.fire(e.type,e,{data:o,dataTransfer:s,targetRanges:r,inputType:e.inputType,isComposing:e.isComposing})}}}class no extends js{constructor(e){super(e),this.document.on("keydown",(e,t)=>{if(this.isEnabled&&((i=t.keyCode)==Ut.arrowright||i==Ut.arrowleft||i==Ut.arrowup||i==Ut.arrowdown)){const i=new zn(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}var i})}observe(){}stopObserving(){}}class so extends js{constructor(e){super(e);const t=this.document;t.on("keydown",(e,i)=>{if(!this.isEnabled||i.keyCode!=Ut.tab||i.ctrlKey)return;const n=new zn(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()})}observe(){}stopObserving(){}}class oo extends(Le()){document;domConverter;domRoots=new Map;_renderer;_initialDomRootAttributes=new WeakMap;_observers=new Map;_writer;_ongoingChange=!1;_postFixersInProgress=!1;_renderingDisabled=!1;_hasChangedSinceTheLastRendering=!1;constructor(e){super(),this.document=new Yn(e),this.domConverter=new Fs(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Es(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new ls(this.document),this.addObserver(Js),this.addObserver(Qs),this.addObserver(Xs),this.addObserver(Ks),this.addObserver(Gs),this.addObserver(Zs),this.addObserver(no),this.addObserver(io),this.addObserver(so),this.document.on("arrowKey",Ts,{priority:"low"}),ns(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}),Q.isiOS&&this.listenTo(this.document,"blur",(e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(e,{mutations:t})=>{t.forEach(e=>this._renderer.markToSync(e.type,e.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:s}of Array.from(e.attributes))n[t]=s,"class"===t?this._writer.addClass(s.split(" "),i):i.hasAttribute(t)||this._writer.setAttribute(t,s,i);this._initialDomRootAttributes.set(e,n);const s=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};s(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",(e,t)=>this._renderer.markToSync("children",t)),i.on("change:attributes",(e,t)=>this._renderer.markToSync("attributes",t)),i.on("change:text",(e,t)=>this._renderer.markToSync("text",t)),i.on("change:isReadOnly",()=>this.change(s)),i.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const i of this._observers.values())i.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach(({name:e})=>t.removeAttribute(e));const i=this._initialDomRootAttributes.get(t);for(const e in i)t.setAttribute(e,i[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const e of this._observers.values())e.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[e,i]of this.domRoots)t.observe(i,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:i=20,ancestorOffset:n=20}={}){const s=this.document.selection.getFirstRange();if(!s)return;const o=N({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:n});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});const r={target:this.domConverter.viewRangeToDom(s),viewportOffset:i,ancestorOffset:n,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",r,o),function({target:e,viewportOffset:t=0,ancestorOffset:i=0,alignToTop:n,forceScroll:s}){const o=Dt(e);let r=o,a=null;for(t=function(e){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:e}(t);r;){let l;l=zt(r==o?e:a),Bt({parent:l,getRect:()=>Ht(e,r),alignToTop:n,ancestorOffset:i,forceScroll:s});let c=Ht(e,r);const d=Ht(l,r);if(c.height>d.height){const e=c.getIntersection(d);e&&(c=e)}if(Vt({window:r,rect:c,viewportOffset:t,alignToTop:n,forceScroll:s}),r.parent!=r){if(a=r.frameElement,r=r.parent,!a)return}else r=null}}(r)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new fe("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;const t=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),t}catch(e){fe.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Qs).flush(),this.change(()=>{})}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Mn._createAt(e,t)}createPositionAfter(e){return Mn._createAfter(e)}createPositionBefore(e){return Mn._createBefore(e)}createRange(e,t){return new Fn(e,t)}createRangeOn(e){return Fn._createOn(e)}createRangeIn(e){return Fn._createIn(e)}createSelection(...e){return new Ln(...e)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}class ro{is(){throw new Error("is() method is abstract")}}class ao extends ro{textNode;data;offsetInText;constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new fe("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new fe("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){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()}}ao.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class lo{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;_visitedParent;constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new fe("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new fe("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=uo._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i,n,s;do{n=this.position,s=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this._position=n,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"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&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 n=ho(t,i),s=n||mo(t,i,n);if(s&&s.is("model:element")){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t.path.push(0),this._visitedParent=s;return this._position=t,co("elementStart",s,e,t,1)}if(s&&s.is("model:$text")){let n;if(this.singleCharacters)n=1;else{let e=s.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offset<e&&(e=this.boundaries.end.offset),n=e-t.offset}const o=t.offset-s.startOffset,r=new ao(s,o,n);return t.offset+=n,this._position=t,co("text",r,e,t,n)}return t.path.pop(),t.offset++,this._position=t,this._visitedParent=i.parent,this.ignoreElementEnd?this._next():co("elementEnd",i,e,t)}_previous(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&0===t.offset)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};const n=t.parent,s=ho(t,n),o=s||go(t,n,s);if(o&&o.is("model:element"))return t.offset--,this.shallow?(this._position=t,co("elementStart",o,e,t,1)):(t.path.push(o.maxOffset),this._position=t,this._visitedParent=o,this.ignoreElementEnd?this._previous():co("elementEnd",o,e,t));if(o&&o.is("model:$text")){let n;if(this.singleCharacters)n=1;else{let e=o.startOffset;this._boundaryStartParent==i&&this.boundaries.start.offset>e&&(e=this.boundaries.start.offset),n=t.offset-e}const s=t.offset-o.startOffset,r=new ao(o,s-n,n);return t.offset-=n,this._position=t,co("text",r,e,t,n)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,co("elementStart",i,e,t,1)}}function co(e,t,i,n,s){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:s}}}class uo extends ro{root;path;stickiness;constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new fe("model-position-root-invalid",e);if(!Array.isArray(t)||0===t.length)throw new fe("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)throw new fe("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new fe("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return ho(this,this.parent)}get nodeAfter(){const e=this.parent;return mo(this,e,ho(this,e))}get nodeBefore(){const e=this.parent;return go(this,e,ho(this,e))}get isAtStart(){return 0===this.offset}get isAtEnd(){return this.offset==this.parent.maxOffset}isValid(){if(this.offset<0)return!1;let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)return!1;return this.offset<=e.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=qe(this.path,e.path);switch(t){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[t]<e.path[t]?"before":"after"}}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new lo(t);return i.skip(e),i.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){const e=this.parent;return e.is("documentFragment")?[e]:e.getAncestors({includeSelf:!0})}findAncestor(e){const t=this.parent;return t.is("element")?t.findAncestor(e,{includeSelf:!0}):null}getCommonPath(e){if(this.root!=e.root)return[];const t=qe(this.path,e.path),i="string"==typeof t?Math.min(this.path.length,e.path.length):t;return this.path.slice(0,i)}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}getShiftedBy(e){const t=this.clone(),i=t.offset+e;return t.offset=i<0?0:i,t}isAfter(e){return"after"==this.compareWith(e)}isBefore(e){return"before"==this.compareWith(e)}isEqual(e){return"same"==this.compareWith(e)}isTouching(e){if(this.root!==e.root)return!1;const t=Math.min(this.path.length,e.path.length);for(let i=0;i<t;i++){const t=this.path[i]-e.path[i];if(t<-1||t>1)return!1;if(1===t)return fo(e,this,i);if(-1===t)return fo(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?po(this.path,t):po(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==qe(this.getParentPath(),e.getParentPath())}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=uo._createAt(this)}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange;let i;return t.containsPosition(this)||t.start.isEqual(this)?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):i=this.isEqual(e.deletionPosition)?uo._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=uo._createAt(this);if(this.root!=e.root)return i;if("same"==qe(e.getParentPath(),this.getParentPath())){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;i.offset-=t}}else if("prefix"==qe(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;if(e.offset<=this.path[n]){if(e.offset+t>this.path[n])return null;i.path[n]-=t}}return i}_getTransformedByInsertion(e,t){const i=uo._createAt(this);if(this.root!=e.root)return i;if("same"==qe(e.getParentPath(),this.getParentPath()))(e.offset<this.offset||e.offset==this.offset&&"toPrevious"!=this.stickiness)&&(i.offset+=t);else if("prefix"==qe(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;e.offset<=this.path[n]&&(i.path[n]+=t)}return i}_getTransformedByMove(e,t,i){if(t=t._getTransformedByDeletion(e,i),e.isEqual(t))return uo._createAt(this);const n=this._getTransformedByDeletion(e,i);return null===n||e.isEqual(this)&&"toNext"==this.stickiness||e.getShiftedBy(i).isEqual(this)&&"toPrevious"==this.stickiness?this._getCombined(e,t):n._getTransformedByInsertion(t,i)}_getCombined(e,t){const i=e.path.length-1,n=uo._createAt(t);return n.stickiness=this.stickiness,n.offset=n.offset+this.path[i]-e.offset,n.path=[...n.path,...this.path.slice(i+1)],n}toJSON(){return{root:this.root.toJSON(),path:Array.from(this.path),stickiness:this.stickiness}}clone(){return new this.constructor(this.root,this.path,this.stickiness)}static _createAt(e,t,i="toNone"){if(e.is("model:position"))return new uo(e.root,e.path,e.stickiness);{const n=e;if("end"==t)t=n.maxOffset;else{if("before"==t)return this._createBefore(n,i);if("after"==t)return this._createAfter(n,i);if(0!==t&&!t)throw new fe("model-createpositionat-offset-required",[this,e])}if(!n.is("element")&&!n.is("documentFragment"))throw new fe("model-position-parent-incorrect",[this,e]);const s=n.getPath();return s.push(t),new this(n.root,s,i)}}static _createAfter(e,t){if(!e.parent)throw new fe("model-position-after-root",[this,e],{root:e});return this._createAt(e.parent,e.endOffset,t)}static _createBefore(e,t){if(!e.parent)throw new fe("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,t)}static fromJSON(e,t){if("$graveyard"===e.root){const i=new uo(t.graveyard,e.path);return i.stickiness=e.stickiness,i}if(!t.getRoot(e.root))throw new fe("model-position-fromjson-no-root",t,{rootName:e.root});return new uo(t.getRoot(e.root),e.path,e.stickiness)}}function ho(e,t){const i=t.getChildAtOffset(e.offset);return i&&i.is("$text")&&i.startOffset<e.offset?i:null}function mo(e,t,i){return null!==i?null:t.getChildAtOffset(e.offset)}function go(e,t,i){return null!==i?null:t.getChild(t.offsetToIndex(e.offset)-1)}function fo(e,t,i){return i+1!==e.path.length&&(!!po(t.path,i+1)&&!!function(e,t){let i=e.parent,n=e.path.length-1,s=0;for(;n>=t;){if(e.path[n]+s!==i.maxOffset)return!1;s=1,n--,i=i.parent}return!0}(e,i+1))}function po(e,t){for(;t<e.length;){if(0!==e[t])return!1;t++}return!0}uo.prototype.is=function(e){return"position"===e||"model:position"===e};class bo extends ro{start;end;constructor(e,t){super(),this.start=uo._createAt(e),this.end=t?uo._createAt(t):uo._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new lo({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return"same"==qe(this.start.getParentPath(),this.end.getParentPath())}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),n=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&n}containsItem(e){const t=uo._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 bo(this.start,e.start)),this.containsPosition(e.end)&&t.push(new bo(e.end,this.end))):t.push(new bo(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 bo(t,i)}return null}getJoined(e,t=!1){let i=this.isIntersecting(e);if(i||(i=this.start.isBefore(e.start)?t?this.end.isTouching(e.start):this.end.isEqual(e.start):t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!i)return null;let n=this.start,s=this.end;return e.start.isBefore(n)&&(n=e.start),e.end.isAfter(s)&&(s=e.end),new bo(n,s)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,i=uo._createAt(this.start);let n=i.parent;for(;i.path.length>t+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new bo(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],n=t-i.offset;0!==n&&e.push(new bo(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new lo(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new lo(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new lo(e);yield t.position;for(const e of t)yield e.nextPosition}getTransformedByOperation(e){switch(e.type){case"insert":return this._getTransformedByInsertOperation(e);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(e);case"split":return[this._getTransformedBySplitOperation(e)];case"merge":return[this._getTransformedByMergeOperation(e)]}return[new bo(this.start,this.end)]}getTransformedByOperations(e){const t=[new bo(this.start,this.end)];for(const i of e)for(let e=0;e<t.length;e++){const n=t[e].getTransformedByOperation(i);t.splice(e,1,...n),e+=n.length-1}for(let e=0;e<t.length;e++){const i=t[e];for(let n=e+1;n<t.length;n++){const e=t[n];(i.containsRange(e)||e.containsRange(i)||i.isEqual(e))&&t.splice(n,1)}}return t}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;const e=this.start.nodeAfter,t=this.end.nodeBefore;return e&&e.is("element")&&e===t?e:null}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}clone(){return new this.constructor(this.start,this.end)}_getTransformedByInsertOperation(e,t=!1){return this._getTransformedByInsertion(e.position,e.howMany,t)}_getTransformedByMoveOperation(e,t=!1){const i=e.sourcePosition,n=e.howMany,s=e.targetPosition;return this._getTransformedByMove(i,s,n,t)}_getTransformedBySplitOperation(e){const t=this.start._getTransformedBySplitOperation(e);let i=this.end._getTransformedBySplitOperation(e);return this.end.isEqual(e.insertionPosition)&&(i=this.end.getShiftedBy(1)),t.root!=i.root&&(i=this.end.getShiftedBy(-1)),new bo(t,i)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new bo(this.start);let t=this.start._getTransformedByMergeOperation(e),i=this.end._getTransformedByMergeOperation(e);return t.root!=i.root&&(i=this.end.getShiftedBy(-1)),t.isAfter(i)?(e.sourcePosition.isBefore(e.targetPosition)?(t=uo._createAt(i),t.offset=0):(e.deletionPosition.isEqual(t)||(i=e.deletionPosition),t=e.targetPosition),new bo(t,i)):new bo(t,i)}_getTransformedByInsertion(e,t,i=!1){if(i&&this.containsPosition(e))return[new bo(this.start,e),new bo(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const i=new bo(this.start,this.end);return i.start=i.start._getTransformedByInsertion(e,t),i.end=i.end._getTransformedByInsertion(e,t),[i]}}_getTransformedByMove(e,t,i,n=!1){if(this.isCollapsed){const n=this.start._getTransformedByMove(e,t,i);return[new bo(n)]}const s=bo._createFromPositionAndShift(e,i),o=t._getTransformedByDeletion(e,i);if(this.containsPosition(t)&&!n&&(s.containsPosition(this.start)||s.containsPosition(this.end))){const n=this.start._getTransformedByMove(e,t,i),s=this.end._getTransformedByMove(e,t,i);return[new bo(n,s)]}let r;const a=this.getDifference(s);let l=null;const c=this.getIntersection(s);if(1==a.length?l=new bo(a[0].start._getTransformedByDeletion(e,i),a[0].end._getTransformedByDeletion(e,i)):2==a.length&&(l=new bo(this.start,this.end._getTransformedByDeletion(e,i))),r=l?l._getTransformedByInsertion(o,i,null!==c||n):[],c){const e=new bo(c.start._getCombined(s.start,o),c.end._getCombined(s.start,o));2==r.length?r.splice(1,0,e):r.push(e)}return r}_getTransformedByDeletion(e,t){let i=this.start._getTransformedByDeletion(e,t),n=this.end._getTransformedByDeletion(e,t);return null==i&&null==n?null:(null==i&&(i=e),null==n&&(n=e),new bo(i,n))}static _createFromPositionAndShift(e,t){const i=e,n=e.getShiftedBy(t);return t>0?new this(i,n):new this(n,i)}static _createIn(e){return new this(uo._createAt(e,0),uo._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(uo._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new fe("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort((e,t)=>e.start.isAfter(t.start)?1:-1);const i=e.indexOf(t),n=new this(t.start,t.end);for(let t=i-1;t>=0&&e[t].end.isEqual(n.start);t--)n.start=uo._createAt(e[t].start);for(let t=i+1;t<e.length&&e[t].start.isEqual(n.end);t++)n.end=uo._createAt(e[t].end);return n}static fromJSON(e,t){return new this(uo.fromJSON(e.start,t),uo.fromJSON(e.end,t))}}bo.prototype.is=function(e){return"range"===e||"model:range"===e};class wo extends(Ae()){_modelToViewMapping=new WeakMap;_viewToModelMapping=new WeakMap;_viewToModelLengthCallbacks=new Map;_markerNameToElements=new Map;_elementToMarkerNames=new Map;_deferredBindingRemovals=new Map;_unboundMarkerNames=new Set;_cache=new _o;constructor(){super(),this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new fe("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),n=this._viewToModelMapping.get(i),s=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=uo._createAt(n,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 t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);if(t.defer)this._deferredBindingRemovals.set(e,e.root);else{this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i)}}unbindModelElement(e){const t=this.toViewElement(e);if(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 n=this._elementToMarkerNames.get(e)||new Set;n.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,n)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const n=this._elementToMarkerNames.get(e);n&&(n.delete(t),0==n.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new bo(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Fn(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 e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e){return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e)}if(e.is("$text"))return t;let n=0;for(let i=0;i<t;i++)n+=this.getModelLength(e.getChild(i));return n}getModelLength(e){const t=[e];let i=0;for(;t.length>0;){const e=t.pop(),n=e.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(e.name);if(n)i+=n(e);else if(this._viewToModelMapping.has(e))i+=1;else if(e.is("$text"))i+=e.data.length;else{if(e.is("uiElement"))continue;for(const i of e.getChildren())t.push(i)}}return i}findPositionIn(e,t){if(0===t)return this._moveViewPositionToTextNode(new Mn(e,0));if(0==this._viewToModelLengthCallbacks.size&&this._viewToModelMapping.has(e)){const i=this._cache.getClosest(e,t);return this._findPositionStartingFrom(i.viewPosition,i.modelOffset,t,e,!0)}return this._findPositionStartingFrom(new Mn(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,i,n,s){let o,r=e.parent,a=e.offset;if(r.is("$text"))return new Mn(r,i-t);let l=t,c=0;for(;l<i;)if(o=r.getChild(a),o)c=s?this._getModelLengthAndCache(o,n,l):this.getModelLength(o),l+=c,a++;else{if(r==n)throw new fe("mapping-model-offset-not-found",this,{modelOffset:i,viewContainer:n});a=r.parent.getChildIndex(r)+1,r=r.parent,s&&this._cache.save(r,a,n,l)}let d=new Mn(r,a);if(s)for(;d.isAtEnd&&d.parent!==n&&d.parent.parent;){const e=d.parent.parent,t=e.getChildIndex(d.parent)+1;this._cache.save(e,t,n,l),d=new Mn(e,t)}return l==i?this._moveViewPositionToTextNode(d):this._findPositionStartingFrom(new Mn(o,0),l-c,i,n,s)}_getModelLengthAndCache(e,t,i){let n=0;if(this._viewToModelMapping.has(e))n=1;else if(e.is("$text"))n=e.data.length;else if(!e.is("uiElement"))for(const s of e.getChildren())n+=this._getModelLengthAndCache(s,t,i+n);return this._cache.save(e.parent,e.index+1,t,i+n),n}_moveViewPositionToTextNode(e){const t=e.nodeBefore,i=e.nodeAfter;return t&&t.is("view:$text")?new Mn(t,t.data.length):i&&i.is("view:$text")?new Mn(i,0):e}}class _o extends(Ae()){_cachedMapping=new WeakMap;_nodeToCacheListIndex=new WeakMap;_invalidateOnChildrenChangeCallback=(e,t,i)=>{this._clearCacheInsideParent(t,i.index)};_invalidateOnTextChangeCallback=(e,t)=>{this._clearCacheAfter(t)};save(e,t,i,n){const s=this._cachedMapping.get(i),o=s.cacheMap.get(n);if(o){const i=e.getChild(t-1),n=o.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(o.viewPosition.nodeBefore):0;return void this._nodeToCacheListIndex.set(i,n)}const r={viewPosition:new Mn(e,t),modelOffset:n};s.maxModelOffset=n>s.maxModelOffset?n:s.maxModelOffset,s.cacheMap.set(n,r);let a=s.cacheList.length-1;for(;a>=0&&s.cacheList[a].modelOffset>n;)a--;if(s.cacheList.splice(a+1,0,r),t>0){const i=e.getChild(t-1);this._nodeToCacheListIndex.set(i,a+1)}}getClosest(e,t){const i=this._cachedMapping.get(e);let n;if(i)if(t>i.maxModelOffset)n=i.cacheList[i.cacheList.length-1];else{const e=i.cacheMap.get(t);n=e||this._findInCacheList(i.cacheList,t)}else n=this.startTracking(e);return{modelOffset:n.modelOffset,viewPosition:n.viewPosition.clone()}}startTracking(e){const t={viewPosition:new Mn(e,0),modelOffset:0},i={maxModelOffset:0,cacheList:[t],cacheMap:new Map([[0,t]])};return this._cachedMapping.set(e,i),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),t}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(0==t)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheInsideParent(e.parent,e.index);else{const i=e.getChild(t-1);this._clearCacheAfter(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]))}_clearCacheAfter(e){const t=this._nodeToCacheListIndex.get(e);if(void 0===t){const t=e.parent;return void(this._cachedMapping.has(t)||this._clearCacheInsideParent(t.parent,t.index))}let i=e.parent;for(;!this._cachedMapping.has(i);)i=i.parent;this._clearCacheFromCacheIndex(i,t)}_clearCacheFromCacheIndex(e,t){0===t&&(t=1);const i=this._cachedMapping.get(e),n=i.cacheList[t-1];if(!n)return;i.maxModelOffset=n.modelOffset;const s=i.cacheList.splice(t);for(const e of s){i.cacheMap.delete(e.modelOffset);const t=e.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(t)}}_findInCacheList(e,t){let i=0,n=e.length-1,s=n-i>>1,o=e[s];for(;i<n;)o.modelOffset<t?i=s+1:n=s-1,s=i+(n-i>>1),o=e[s];return o.modelOffset<=t?o:e[s-1]}}class vo{_consumable=new Map;_textProxyRegistry=new Map;add(e,t){t=yo(t),e instanceof ao&&(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=yo(t),e instanceof ao&&(e=this._getSymbolForTextProxy(e)),!!this.test(e,t)&&(this._consumable.get(e).set(t,!1),!0)}test(e,t){t=yo(t),e instanceof ao&&(e=this._getSymbolForTextProxy(e));const i=this._consumable.get(e);if(void 0===i)return null;const n=i.get(t);return void 0===n?null:n}revert(e,t){t=yo(t),e instanceof ao&&(e=this._getSymbolForTextProxy(e));const i=this.test(e,t);return!1===i?(this._consumable.get(e).set(t,!0),!0):!0!==i&&null}verifyAllConsumed(e){const t=[];for(const[i,n]of this._consumable)for(const[s,o]of n){const n=s.split(":")[0];o&&e==n&&t.push({event:s,item:i.name||i.description})}if(t.length)throw new fe("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const i=this._textProxyRegistry.get(e.startOffset);if(i){const n=i.get(e.endOffset);n&&(t=n.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,i=e.endOffset,n=e.parent,s=Symbol("$textProxy:"+e.data);let o,r;return o=this._textProxyRegistry.get(t),o||(o=new Map,this._textProxyRegistry.set(t,o)),r=o.get(i),r||(r=new Map,o.set(i,r)),r.set(n,s),s}}function yo(e){const t=e.split(":");return"insert"==t[0]?t[0]:"addMarker"==t[0]||"removeMarker"==t[0]?e:t.length>1?t[0]+":"+t[1]:t[0]}class ko extends(Ae()){_conversionApi;_firedEventsMap;constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const n=e.getRefreshedItems(),s=this._createConversionApi(i,n);for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,s);const o=this._reduceChanges(e.getChanges(),n);for(const e of o)"insert"===e.type?this._convertInsert(bo._createFromPositionAndShift(e.position,e.length),s):"reinsert"===e.type?this._convertReinsert(bo._createFromPositionAndShift(e.position,e.length),s):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,s):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,s);s.mapper.flushDeferredBindings();for(const e of s.mapper.flushUnboundMarkerNames()){const i=t.get(e).getRange();this._convertMarkerRemove(e,i,s),this._convertMarkerAdd(e,i,s)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,s);s.consumable.verifyAllConsumed("insert")}convert(e,t,i,n={}){const s=this._createConversionApi(i,void 0,n);this._convertInsert(e,s);for(const[e,i]of t)this._convertMarkerAdd(e,i,s);s.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},n);const s=e.getFirstPosition().root;if(!n.mapper.toViewElement(s))return;const o=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(n.consumable,e,o),this.fire("selection",{selection:e},n),e.isCollapsed){for(const t of o)if(n.consumable.test(e,"addMarker:"+t.name)){const i=t.getRange();if(!Co(e.getFirstPosition(),t,n.mapper))continue;const s={item:e,markerName:t.name,markerRange:i};this.fire(`addMarker:${t.name}`,s,n)}for(const t of e.getAttributeKeys())if(n.consumable.test(e,"attribute:"+t)){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire(`attribute:${t}:$text`,i,n)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const i of e.getWalker({shallow:!0}))this._testAndFire("insert",Ao(i),t)}_convertRemove(e,t,i,n){this.fire(`remove:${i}`,{position:e,length:t},n)}_convertAttribute(e,t,i,n,s){this._addConsumablesForRange(s.consumable,e,`attribute:${t}`);for(const o of e){const e={item:o.item,range:bo._createFromPositionAndShift(o.previousPosition,o.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${t}`,e,s)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(Ao))this.fire(`remove:${e.item.is("element")?e.item.name:"$text"}`,{position:e.range.start,length:e.item.offsetSize,reconversion:!0},t),this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const n=`addMarker:${e}`;if(i.consumable.add(t,n),this.fire(n,{markerName:e,markerRange:t},i),i.consumable.consume(t,n)){this._addConsumablesForRange(i.consumable,t,n);for(const s of t.getItems()){if(!i.consumable.test(s,n))continue;const o={item:s,range:bo._createOn(s),markerName:e,markerRange:t};this.fire(n,o,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e,t){const i={changes:e,refreshedItems:t};return this.fire("reduceChanges",i),i.changes}_addConsumablesForInsert(e,t){for(const i of t){const t=i.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,i){for(const n of t.getItems())e.add(n,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const n of i)e.add(t,"addMarker:"+n.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){const n=function(e,t){const i=t.item.is("element")?t.item.name:"$text";return`${e}:${i}`}(e,t),s=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,o=this._firedEventsMap.get(i),r=o.get(s);if(r){if(r.has(n))return;r.add(n)}else o.set(s,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:bo._createOn(e)};for(const e of i.item.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(e),this._testAndFire(`attribute:${e}`,i,t)}_createConversionApi(e,t=new Set,i={}){const n={...this._conversionApi,consumable:new vo,writer:e,options:i,convertItem:e=>this._convertInsert(bo._createOn(e),n),convertChildren:e=>this._convertInsert(bo._createIn(e),n,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,n),canReuseView:e=>!t.has(n.mapper.toModelElement(e))};return this._firedEventsMap.set(n,new Map),n}}function Co(e,t,i){const n=t.getRange(),s=Array.from(e.getAncestors());s.shift(),s.reverse();return!s.some(e=>{if(n.containsItem(e)){return!!i.toViewElement(e).getCustomProperty("addHighlight")}})}function Ao(e){return{item:e.item,range:bo._createFromPositionAndShift(e.previousPosition,e.length)}}class To extends ro{parent=null;_attrs;_index=null;_startOffset=null;constructor(e){super(),this._attrs=di(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return null===this.startOffset?null:this.startOffset+this.offsetSize}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return null!==this.parent&&this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=qe(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]<i[n]}}isAfter(e){return this!=e&&(this.root===e.root&&!this.isBefore(e))}hasAttribute(e){return this._attrs.has(e)}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){const e={};return this._attrs.size&&(e.attributes=Array.from(this._attrs).reduce((e,t)=>(e[t[0]]=t[1],e),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=di(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}To.prototype.is=function(e){return"node"===e||"model:node"===e};class Eo extends(Ae(ro)){_lastRangeBackward=!1;_attrs=new Map;_ranges=[];constructor(...e){super(),e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new bo(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 bo(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 bo(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,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]);else if(t instanceof Eo)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof bo)this._setRanges([t],!!n&&!!n.backward);else if(t instanceof uo)this._setRanges([new bo(t)]);else if(t instanceof To){const e=!!n&&!!n.backward;let s;if("in"==i)s=bo._createIn(t);else if("on"==i)s=bo._createOn(t);else{if(void 0===i)throw new fe("model-selection-setto-required-second-parameter",[this,t]);s=new bo(uo._createAt(t,i))}this._setRanges([s],e)}else{if(!Ke(t))throw new fe("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,n&&!!n.backward)}}_setRanges(e,t=!1){const i=Array.from(e),n=i.some(t=>{if(!(t instanceof bo))throw new fe("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(e=>!e.isEqual(t))});(i.length!==this._ranges.length||n)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new fe("model-selection-setfocus-no-ranges",[this,e]);const i=uo._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new bo(i,n)),this._lastRangeBackward=!0):(this._pushRange(new bo(n,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=So(t.start,e);Oo(i,t)&&(yield i);const n=t.getWalker();for(const i of n){const s=i.item;"elementEnd"==i.type&&Po(s,e,t)?yield s:"elementStart"==i.type&&s.is("model:element")&&s.root.document.model.schema.isBlock(s)&&n.jumpTo(uo._createAt(s,"end"))}const s=So(t.end,e);Ro(s,t)&&(yield s)}}containsEntireContent(e=this.anchor.root){const t=uo._createAt(e,0),i=uo._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}toJSON(){const e={ranges:Array.from(this.getRanges()).map(e=>e.toJSON())},t=Object.fromEntries(this.getAttributes());return Object.keys(t).length&&(e.attributes=t),this.isBackward&&(e.isBackward=!0),e}_pushRange(e){this._checkRange(e),this._ranges.push(new bo(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new fe("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[t]})}_replaceAllRanges(e){this._removeAllRanges();for(const t of e)this._pushRange(t)}_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}function xo(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function Po(e,t,i){return xo(e,t)&&Io(e,i)}function So(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let s=!1;const o=n.find(e=>!s&&(s=i.isLimit(e),!s&&xo(e,t)));return n.forEach(e=>t.add(e)),o}function Io(e,t){const i=function(e){const t=e.root.document.model.schema;let i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}(e);if(!i)return!0;return!t.containsRange(bo._createOn(i),!0)}function Oo(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(uo._createAt(e,e.maxOffset))&&Io(e,t))}function Ro(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(uo._createAt(e,0))&&Io(e,t))}Eo.prototype.is=function(e){return"selection"===e||"model:selection"===e};class Vo extends(Ae(bo)){constructor(e,t){super(e,t),Bo.call(this)}detach(){this.stopListening()}toRange(){return new bo(this.start,this.end)}static fromRange(e){return new Vo(e.start,e.end)}}function Bo(){this.listenTo(this.root.document.model,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&Mo.call(this,i)},{priority:"low"})}function Mo(e){const t=this.getTransformedByOperation(e),i=bo._createFromRanges(t),n=!i.isEqual(this),s=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let o=null;if(n){"$graveyard"==i.root.rootName&&(o="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:o})}else s&&this.fire("change:content",this.toRange(),{deletionPosition:o})}Vo.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};class Fo extends To{_data;constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new Fo(this.data,this.getAttributes())}static fromJSON(e){return new Fo(e.data,e.attributes)}}Fo.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};const No="selection:";class Lo extends(Ae(ro)){_selection;constructor(e){super(),this._selection=new Do(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}toJSON(){return this._selection.toJSON()}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return No+e}static _isStoreAttributeKey(e){return e.startsWith(No)}}Lo.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class Do extends Eo{markers=new ni({idProperty:"name"});_model;_document;_attributePriority=new Map;_selectionRestorePosition=null;_hasChangedRange=!1;_overriddenGravityRegister=new Set;_observedMarkers=new Set;constructor(e){super(),this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))},{priority:"lowest"}),this.on("change:range",()=>{this._validateSelectionRanges(this.getRanges())}),this.listenTo(this._model.markers,"update",(e,t,i,n)=>{this._updateMarker(t,n)}),this.listenTo(this._document,"change",(e,t)=>{!function(e,t){const i=e.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&e.enqueueChange(t,e=>{const t=Array.from(i.getAttributeKeys()).filter(e=>e.startsWith(No));for(const n of t)e.removeAttribute(n,i)})}}(this._model,t)})}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e<this._ranges.length;e++)this._ranges[e].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(...e){super.setTo(...e),this._updateAttributes(!0),this.updateMarkers()}setFocus(e,t){super.setFocus(e,t),this._updateAttributes(!0),this.updateMarkers()}setAttribute(e,t){if(this._setAttribute(e,t)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}removeAttribute(e){if(this._removeAttribute(e)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}overrideGravity(){const e=he();return this._overriddenGravityRegister.add(e),1===this._overriddenGravityRegister.size&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new fe("document-selection-gravity-wrong-restore",this,{uid:e});this._overriddenGravityRegister.delete(e),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(e){this._observedMarkers.add(e),this.updateMarkers()}_replaceAllRanges(e){this._validateSelectionRanges(e),super._replaceAllRanges(e)}_popRange(){this._ranges.pop().detach()}_pushRange(e){const t=this._prepareRange(e);t&&this._ranges.push(t)}toJSON(){const e=super.toJSON();return this.markers.length&&(e.markers=this.markers.map(e=>e.toJSON())),e}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new fe("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=Vo.fromRange(e);return t.on("change:range",(e,i,n)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=n.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}}),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const n=t.getRange();for(const i of this.getRanges())n.containsRange(i,!i.isCollapsed)&&e.push(t)}const i=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let n=!1;const s=Array.from(this.markers),o=this.markers.has(e);if(t){let i=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!o?(this.markers.add(e),n=!0):!i&&o&&(this.markers.remove(e),n=!0)}else o&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:s,directChange:!1})}_updateAttributes(e){const t=di(this._getSurroundingAttributes()),i=di(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);const n=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||n.push(e);for(const[e]of i)this.hasAttribute(e)||n.push(e);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t,i=!0){const n=i?"normal":"low";if("low"==n&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,n),!0)}_removeAttribute(e,t=!0){const i=t?"normal":"low";return("low"!=i||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,i),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(const[i,n]of e){this._setAttribute(i,n,!1)&&t.add(i)}return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(No)){const i=t.substr(10);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if("$graveyard"==e.root.rootName)return null;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,s=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=zo(n,t)),i||(i=zo(s,t)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!i;)e=e.previousSibling,i=zo(e,t)}if(!i){let e=s;for(;e&&!i;)e=e.nextSibling,i=zo(e,t)}i||(i=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item)){i=zo(n.item,t);break}if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function zo(e,t){if(!e)return null;if(e instanceof ao||e instanceof Fo)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[n,s]of e.getAttributes())t.checkAttribute("$text",n)&&!1!==t.getAttributeProperties(n).copyFromObject&&i.push([n,s]);return i}class Ho{_nodes=[];_offsetToNode=[];constructor(e){e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._offsetToNode.length}getNode(e){return this._nodes[e]||null}getNodeAtOffset(e){return this._offsetToNode[e]||null}getNodeIndex(e){return e.index}getNodeStartOffset(e){return e.startOffset}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new fe("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 fe("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}_insertNodes(e,t){const i=[];for(const e of t){if(!(e instanceof To))throw new fe("model-nodelist-insertnodes-not-node",this);i.push(e)}let n=this.indexToOffset(e);ui(this._nodes,i,e),ui(this._offsetToNode,function(e){const t=[];let i=0;for(const n of e)for(let e=0;e<n.offsetSize;e++)t[i++]=n;return t}(i),n);for(let t=e;t<this._nodes.length;t++)this._nodes[t]._index=t,this._nodes[t]._startOffset=n,n+=this._nodes[t].offsetSize}_removeNodes(e,t=1){if(0==t)return[];let i=this.indexToOffset(e);const n=this._nodes.splice(e,t),s=n[n.length-1],o=s.startOffset+s.offsetSize-i;this._offsetToNode.splice(i,o);for(const e of n)e._index=null,e._startOffset=null;for(let t=e;t<this._nodes.length;t++)this._nodes[t]._index=t,this._nodes[t]._startOffset=i,i+=this._nodes[t].offsetSize;return n}_removeNodesArray(e){if(0==e.length)return;for(const t of e)t._index=null,t._startOffset=null;this._nodes=this._nodes.filter(e=>null!==e.index),this._offsetToNode=this._offsetToNode.filter(e=>null!==e.index);let t=0;for(let e=0;e<this._nodes.length;e++)this._nodes[e]._index=e,this._nodes[e]._startOffset=t,t+=this._nodes[e].offsetSize}toJSON(){return this._nodes.map(e=>e.toJSON())}}class $o extends To{name;_children=new Ho;constructor(e,t,i){super(t),this.name=e,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const i of e)t=t.getChildAtOffset(i);return t}findAncestor(e,t={}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?function(e){const t=[];for(const i of e)t.push(i._clone(!0));return t}(this._children):void 0;return new $o(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Fo(e)];Ke(e)||(e=[e]);const t=[];for(const i of e)"string"==typeof i?t.push(new Fo(i)):i instanceof ao?t.push(new Fo(i.data,i.getAttributes())):t.push(i);return t}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.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($o.fromJSON(i)):t.push(Fo.fromJSON(i))}return new $o(e.name,e.attributes,t)}}$o.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e};class Wo{_dispatchers;constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class jo extends Wo{elementToElement(e){return this.add(function(e){const t=Xo(e.model),i=Zo(e.view,"container");t.attributes.length&&(t.children=!0);return n=>{n.on(`insert:${t.name}`,Ko(i,sr(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",nr(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Xo(e.model),i=Zo(e.view,"container");return t.children=!0,n=>{if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new fe("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});var s,o;n.on(`insert:${t.name}`,(s=i,o=sr(t),(e,t,i)=>{if(!o(t.item,i.consumable,{preflight:!0}))return;const n=new Map;i.writer._registerSlotFactory(function(e,t,i){return(n,s)=>{const o=n.createContainerElement("$slot");let r=null;if("children"===s)r=Array.from(e.getChildren());else{if("function"!=typeof s)throw new fe("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:s});r=Array.from(e.getChildren()).filter(e=>s(e))}return t.set(o,r),o}}(t.item,n,i));const r=s(t.item,i,t);if(i.writer._clearSlotFactory(),!r)return;!function(e,t,i){const n=Array.from(t.values()).flat(),s=new Set(n);if(s.size!=n.length)throw new fe("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(s.size!=e.childCount)throw new fe("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,n,i),o(t.item,i.consumable);const a=t.reconversion&&Yo(t.item,i)||i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,r),i.writer.insert(a,r),i.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",r,{priority:"highest"});let s=null,o=null;for([s,o]of t)or(e,o,i,n),i.writer.setCustomProperty("$structureSlotParent",!0,s.parent),i.writer.move(i.writer.createRangeIn(s),i.writer.createPositionBefore(s)),i.writer.remove(s);function r(e,t){const i=t.modelPosition.nodeAfter,n=o.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(s,n))}i.mapper.off("modelToViewPosition",r)}(r,n,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),n.on("reduceChanges",nr(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=N(e);let t=e.model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;t.name&&(i+=":"+t.name);if(t.values)for(const i of t.values)e.view[i]=Zo(e.view[i],"attribute");else e.view=Zo(e.view,"attribute");const n=er(e);return t=>{t.on(i,qo(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=N(e);let t=e.model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;t.name&&(i+=":"+t.name);if(t.values)for(const i of t.values)e.view[i]=tr(e.view[i]);else e.view=tr(e.view);const n=er(e);return t=>{var s;t.on(i,(s=n,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=s(t.attributeOldValue,i,t),o=s(t.attributeNewValue,i,t);if(!n&&!o)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new fe("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&n){let e=n.value;"style"==n.key&&(e="string"==typeof n.value?new vn(a.document.stylesProcessor).setTo(n.value).getStylesEntries().map(([e])=>e):Object.keys(n.value)),a.removeAttribute(n.key,e,r)}if(null!==t.attributeNewValue&&o){let e=o.value;"style"==o.key&&"string"==typeof o.value&&(e=Object.fromEntries(new vn(a.document.stylesProcessor).setTo(o.value).getStylesEntries())),a.setAttribute(o.key,e,!1,r)}}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=Zo(e.view,"ui");return i=>{i.on(`addMarker:${e.model}`,Go(t),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${e.model}`,(e,t,i)=>{const n=i.mapper.markerNameToElements(t.markerName);if(n){for(const e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}},{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var i;t.on(`addMarker:${e.model}`,(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof Eo||t.item instanceof Lo||t.item.is("$textProxy")))return;const s=ir(i,t,n);if(!s)return;if(!n.consumable.consume(t.item,e.name))return;const o=n.writer,r=Uo(o,s),a=o.document.selection;if(t.item instanceof Eo||t.item instanceof Lo)o.wrap(a.getFirstRange(),r);else{const e=n.mapper.toViewRange(t.range),i=o.wrap(e,r);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(r)){n.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof $o))return;const s=ir(e,i,n);if(!s)return;if(!n.consumable.test(i.item,t.name))return;const o=n.mapper.toViewElement(i.item);if(o&&o.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of bo._createIn(i.item))n.consumable.consume(e.item,t.name);o.getCustomProperty("addHighlight")(o,s,n.writer),n.mapper.bindElementToMarker(o,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const s=ir(e,i,n);if(!s)return;const o=Uo(n.writer,s),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)if(n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement"))n.writer.unwrap(n.writer.createRangeOn(e),o);else{e.getCustomProperty("removeHighlight")(e,s.id,n.writer)}n.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){e=N(e);const t=e.model;let i=e.view;i||(i=i=>({group:t,name:i.substr(e.model.length+1)}));return n=>{var s;n.on(`addMarker:${t}`,(s=i,(e,t,i)=>{const n=s(t.markerName,i);if(!n)return;const o=t.markerRange;i.consumable.consume(o,e.name)&&(Qo(o,!1,i,t,n),Qo(o,!0,i,t,n),e.stop())}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${t}`,function(e){return(t,i,n)=>{const s=e(i.markerName,n);if(!s)return;const o=n.mapper.markerNameToElements(i.markerName);if(o){for(const e of o)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(r(`data-${s.group}-start-before`,e),r(`data-${s.group}-start-after`,e),r(`data-${s.group}-end-before`,e),r(`data-${s.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function r(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(s.name),0==i.size?n.writer.removeAttribute(e,t):n.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(i),{priority:e.converterPriority||"normal"})}}(e))}}function Uo(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"==typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function qo(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const s=e(i.attributeOldValue,n,i),o=e(i.attributeNewValue,n,i);if(!s&&!o)return;n.consumable.consume(i.item,t.name);const r=n.writer,a=r.document.selection;if(i.item instanceof Eo||i.item instanceof Lo)r.wrap(a.getFirstRange(),o);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&s&&(e=r.unwrap(e,s)),null!==i.attributeNewValue&&o&&r.wrap(e,o)}}}function Ko(e,t=ar){return(i,n,s)=>{if(!t(n.item,s.consumable,{preflight:!0}))return;const o=e(n.item,s,n);if(!o)return;t(n.item,s.consumable);const r=n.reconversion&&Yo(n.item,s)||s.mapper.toViewPosition(n.range.start);s.mapper.bindElements(n.item,o),s.writer.insert(r,o),s.convertAttributes(n.item),or(o,n.item.getChildren(),s,{reconversion:n.reconversion})}}function Go(e){return(t,i,n)=>{i.isOpening=!0;const s=e(i,n);i.isOpening=!1;const o=e(i,n);if(!s||!o)return;const r=i.markerRange;if(r.isCollapsed&&!n.consumable.consume(r,t.name))return;for(const e of r)if(!n.consumable.consume(e.item,t.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(r.start),s),n.mapper.bindElementToMarker(s,i.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),o),n.mapper.bindElementToMarker(o,i.markerName)),t.stop()}}function Jo(e,t){const i=t.writer.remove(e);for(const e of t.writer.createRangeIn(i).getItems())t.mapper.unbindViewElement(e,{defer:!0});return e.start}function Yo(e,t){const i=t.mapper.toViewElement(e);return i&&Jo(t.writer.createRangeOn(i),t)}function Qo(e,t,i,n,s){const o=t?e.start:e.end,r=o.nodeAfter&&o.nodeAfter.is("element")?o.nodeAfter:null,a=o.nodeBefore&&o.nodeBefore.is("element")?o.nodeBefore:null;if(r||a){let e,o;t&&r||!t&&!a?(e=r,o=!0):(e=a,o=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,s,o){const r=`data-${o.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(r)?e.getAttribute(r).split(","):[];a.unshift(o.name),n.writer.setAttribute(r,a.join(","),e),n.mapper.bindElementToMarker(e,s.markerName)}(l,t,o,i,n,s)}!function(e,t,i,n,s){const o=`${s.group}-${t?"start":"end"}`,r=s.name?{name:s.name}:null,a=i.writer.createUIElement(o,r);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(o),t,i,n,s)}function Xo(e){return"string"==typeof e&&(e={name:e}),{name:e.name,attributes:e.attributes?ei(e.attributes):[],children:!!e.children}}function Zo(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){"string"==typeof e&&(e={name:e});let n;const s=t.writer,o=Object.assign({},e.attributes);if("container"==i)n=s.createContainerElement(e.name,o);else if("attribute"==i){const t={priority:e.priority||Qn.DEFAULT_PRIORITY};n=s.createAttributeElement(e.name,o,t)}else n=s.createUIElement(e.name,o);if(e.styles){const t=Object.keys(e.styles);for(const i of t)s.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)s.addClass(t,n);else for(const e of t)s.addClass(e,n)}return n}(e,n,t)}function er(e){return e.model.values?(t,i,n)=>{const s=e.view[t];return s?s(t,i,n):null}:e.view}function tr(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function ir(e,t,i){const n="function"==typeof e?e(t,i):{...e};return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}function nr(e){const t=function(e){return(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,i)=>{const n=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const e of i.changes){const s="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(s&&t(s,e)&&"reinsert"!=e.type){if("insert"==e.type&&"rename"==e.action&&i.refreshedItems.add(e.position.nodeAfter),!i.reconvertedElements.has(s)){i.reconvertedElements.add(s);const e=uo._createBefore(s);let t=n.length;for(let i=n.length-1;i>=0;i--){const s=n[i],o=("attribute"==s.type?s.range.start:s.position).compareWith(e);if("before"==o||"remove"==s.type&&"same"==o)break;t=i}n.splice(t,0,{type:"reinsert",name:s.name,position:e,length:1})}}else n.push(e)}i.changes=n}}function sr(e){return(t,i,n={})=>{const s=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&s.push(`attribute:${i}`);return!!s.every(e=>i.test(t,e))&&(n.preflight||s.forEach(e=>i.consume(t,e)),!0)}}function or(e,t,i,n){for(const s of t)rr(e.root,s,i,n)||i.convertItem(s)}function rr(e,t,i,n){const{writer:s,mapper:o}=i;if(!n.reconversion)return!1;const r=o.toViewElement(t);return!(!r||r.root==e)&&(!!i.canReuseView(r)&&(s.move(s.createRangeOn(r),o.toViewPosition(uo._createBefore(t))),!0))}function ar(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function lr(e){const{schema:t,document:i}=e.model;for(const n of i.getRoots())if(n.isEmpty&&!t.checkChild(n,"$text")&&t.checkChild(n,"paragraph"))return e.insertElement("paragraph",n),!0;return!1}function cr(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function dr(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class ur extends Wo{elementToElement(e){return this.add(hr(e))}elementToAttribute(e){return this.add(function(e){e=N(e),fr(e);const t=pr(e,!1),i=mr(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=N(e);let t=null;("string"==typeof e.view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key,i=void 0===e.view.value?/[\s\S]*/:e.view.value;let n;if("class"==t||"style"==t){const e="class"==t?"classes":"styles";n={[e]:i}}else n={attributes:{[t]:i}};e.view.name&&(n.name=e.view.name);return e.view=n,t}(e));fr(e,t);const i=pr(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,i)=>{const n="string"==typeof e?e:e(t,i);return i.writer.createElement("$marker",{"data-name":n})}}(e.model);return hr({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){e=N(e),e.model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=gr(br(t,"start")),n=gr(br(t,"end"));return s=>{s.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),s.on(`element:${e.view}-end`,n,{priority:e.converterPriority||"normal"});const o=me.low,r=me.highest,a=me.get(e.converterPriority)/r;s.on("element",function(e){return(t,i,n)=>{const s=`data-${e.view}`;function o(t,s){for(const o of s){const s=e.model(o,n),r=n.writer.createElement("$marker",{"data-name":s});n.writer.insert(r,t),i.modelCursor.isEqual(t)?i.modelCursor=i.modelCursor.getShiftedBy(1):i.modelCursor=i.modelCursor._getTransformedByInsertion(t,1),i.modelRange=i.modelRange._getTransformedByInsertion(t,1)[0]}}(n.consumable.test(i.viewItem,{attributes:s+"-end-after"})||n.consumable.test(i.viewItem,{attributes:s+"-start-after"})||n.consumable.test(i.viewItem,{attributes:s+"-end-before"})||n.consumable.test(i.viewItem,{attributes:s+"-start-before"}))&&(i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor)),n.consumable.consume(i.viewItem,{attributes:s+"-end-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(s+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-start-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(s+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-end-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(s+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:s+"-start-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(s+"-start-before").split(",")))}}(t),{priority:o+a})}}(e))}}function hr(e){const t=gr(e=N(e)),i=mr(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function mr(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function gr(e){const t=new bn(e.view);return(i,n,s)=>{const o=t.match(n.viewItem);if(!o)return;const r=o.match;if(r.name=!0,!s.consumable.test(n.viewItem,r))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,s);a&&s.safeInsert(a,n.modelCursor)&&(s.consumable.consume(n.viewItem,r),s.convertChildren(n.viewItem,a),s.updateConversionResult(a,n))}}function fr(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,s="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:s}}function pr(e,t){const i=new bn(e.view);return(n,s,o)=>{if(!s.modelRange&&t)return;const r=i.match(s.viewItem);if(!r)return;if(!function(e,t){const i="function"==typeof e?e(t):e;if("object"==typeof i&&!mr(i))return!1;return!i.classes&&!i.attributes&&!i.styles}(e.view,s.viewItem)?delete r.match.name:r.match.name=!0,!o.consumable.test(s.viewItem,r.match))return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(s.viewItem,o,s):e.model.value;if(null==l)return;s.modelRange||Object.assign(s,o.convertChildren(s.viewItem,s.modelCursor));const c=function(e,t,i,n){let s=!1;for(const o of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(o,t.key)&&(s=!0,o.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,o));return s}(s.modelRange,{key:a,value:l},t,o);c&&(o.consumable.test(s.viewItem,{name:!0})&&(r.match.name=!0),o.consumable.consume(s.viewItem,r.match))}}function br(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{const n=t.getAttribute("name"),s=e.model(n,i);return i.writer.createElement("$marker",{"data-name":s})}}}class wr extends(Le()){model;view;mapper;downcastDispatcher;constructor(e,t){super(),this.model=e,this.view=new oo(t),this.mapper=new wo,this.downcastDispatcher=new ko({mapper:this.mapper,schema:e.schema});const i=this.model.document,n=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(e=>{this.downcastDispatcher.convertChanges(i.differ,s,e),this.downcastDispatcher.convertSelection(n,s,e)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const s=n.newSelection,o=[];for(const e of s.getRanges())o.push(t.toModelRange(e));const r=e.createSelection(o,{backward:s.isBackward});r.isEqual(e.document.selection)||e.change(e=>{e.setSelection(r)})}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewPosition(t.range.start),o=n.createText(t.item.data);n.insert(s,o)},{priority:"lowest"}),this.downcastDispatcher.on("insert",(e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)},{priority:"lowest"}),this.downcastDispatcher.on("remove",(e,t,i)=>{if(t.reconversion)return;const n=i.mapper.toViewPosition(t.position),s=t.position.getShiftedBy(t.length),o=i.mapper.toViewPosition(s,{isPhantom:!0});Jo(i.writer.createRange(n,o).getTrimmed(),i)},{priority:"low"}),this.downcastDispatcher.on("cleanSelection",(e,t,i)=>{const n=i.writer,s=n.document.selection;for(const e of s.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)}),this.downcastDispatcher.on("selection",(e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=[];for(const e of n.getRanges())s.push(i.mapper.toViewRange(e));i.writer.setSelection(s,{backward:n.isBackward})},{priority:"low"}),this.downcastDispatcher.on("selection",(e,t,i)=>{const n=t.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=i.writer,o=n.getFirstPosition(),r=i.mapper.toViewPosition(o),a=s.breakAttributes(r);s.setSelection(a)},{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(e=>{if("$graveyard"==e.rootName)return null;const t=new Vn(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new fe("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(i)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}class _r extends(Le()){_sourceDefinitions={};_attributeProperties=Object.create(null);_customChildChecks=new Map;_customAttributeChecks=new Map;_genericCheckSymbol=Symbol("$generic");_compiledDefinitions;constructor(){super(),this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,t)=>{t[0]=new vr(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new vr(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new fe("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 fe("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return t="string"==typeof e?e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!(!t||!t.isBlock)}isLimit(e){const t=this.getDefinition(e);return!!t&&!(!t.isLimit&&!t.isObject)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!!t&&!(!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!!t&&!(!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(e,t)}checkAttribute(e,t){const i=this.getDefinition(e.last);if(!i)return!1;const n=this._evaluateAttributeChecks(e,t);return void 0!==n?n:i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof uo){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof $o))throw new fe("schema-check-merge-no-element-before",this);if(!(i instanceof $o))throw new fe("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}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=void 0!==t?t:this._genericCheckSymbol,n=this._customChildChecks.get(i)||[];n.push(e),this._customChildChecks.set(i,n)}addAttributeCheck(e,t){const i=void 0!==t?t:this._genericCheckSymbol,n=this._customAttributeChecks.get(i)||[];n.push(e),this._customAttributeChecks.set(i,n)}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;if(e instanceof uo)t=e.parent;else{t=(e instanceof bo?[e]:Array.from(e.getRanges())).reduce((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i},null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Fo("",e.getAttributes())];return this.checkAttribute(i,t)}{const i=e.getRanges();for(const e of i)for(const i of e)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t,i={}){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const n of e)yield*this._getValidRangesForRange(n,t,i)}getNearestSelectionRange(e,t="both"){if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new bo(e);let i,n;const s=e.getAncestors().reverse().find(e=>this.isLimit(e))||e.root;"both"!=t&&"backward"!=t||(i=new lo({boundaries:bo._createIn(s),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new lo({boundaries:bo._createIn(s),startPosition:e}));for(const e of function*(e,t){let i=!1;for(;!i;){if(i=!0,e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,n)){const t=e.walker==i?"elementEnd":"elementStart",n=e.value;if(n.type==t&&this.isObject(n.item))return bo._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new bo(n.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 n=i.model;for(const[s,o]of Object.entries(t))n.schema.checkAttribute(e,s)&&i.setAttribute(s,o,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))Vr(this,i,t);else{const e=bo._createIn(i).getPositions();for(const i of e){Vr(this,i.nodeBefore||i.parent,t)}}}getAttributesWithProperty(e,t,i){const n={};for(const[s,o]of e.getAttributes()){const e=this.getAttributeProperties(s);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[s]=o))}return n}createContext(e){return new vr(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=yr(t[n],n);const n=Object.values(e);for(const t of n)kr(e,t),Cr(e,t),Ar(e,t),Tr(e,t);for(const t of n)Er(e,t);for(const t of n)xr(e,t);for(const t of n)Pr(e,t);for(const t of n)Sr(e,t);for(const t of n)Ir(e,t);this._compiledDefinitions=function(e){const t={};for(const i of Object.values(e))t[i.name]={name:i.name,isBlock:!!i.isBlock,isContent:!!i.isContent,isInline:!!i.isInline,isLimit:!!i.isLimit,isObject:!!i.isObject,isSelectable:!!i.isSelectable,allowIn:Array.from(i.allowIn).filter(t=>!!e[t]),allowChildren:Array.from(i.allowChildren).filter(t=>!!e[t]),allowAttributes:Array.from(i.allowAttributes)};return t}(e)}_checkContextMatch(e,t){const i=e.last;let n=this._evaluateChildChecks(e,t);if(n=void 0!==n?n:t.allowIn.includes(i.name),!n)return!1;const s=this.getDefinition(i),o=e.trimLast();return!!s&&(0==o.length||this._checkContextMatch(o,s))}_evaluateChildChecks(e,t){const i=this._customChildChecks.get(this._genericCheckSymbol)||[],n=this._customChildChecks.get(t.name)||[];for(const s of[...i,...n]){const i=s(e,t);if(void 0!==i)return i}}_evaluateAttributeChecks(e,t){const i=this._customAttributeChecks.get(this._genericCheckSymbol)||[],n=this._customAttributeChecks.get(t)||[];for(const s of[...i,...n]){const i=s(e,t);if(void 0!==i)return i}}*_getValidRangesForRange(e,t,i){let n=e.start,s=e.start;for(const o of e.getItems({shallow:!0})){if(o.is("element"))if(i.includeEmptyRanges&&o.isEmpty){const e=this.createContext(o);this.checkChild(e,"$text")&&this.checkAttribute(e.push("$text"),t)&&(yield bo._createIn(o))}else yield*this._getValidRangesForRange(bo._createIn(o),t,i);this.checkAttribute(o,t)||(n.isEqual(s)||(yield new bo(n,s)),n=uo._createAfter(o)),s=uo._createAfter(o)}n.isEqual(s)||(yield new bo(n,s))}findOptimalInsertionRange(e,t){const i=e.getSelectedElement();if(i&&this.isObject(i)&&!this.isInline(i))return"before"==t||"after"==t?new bo(uo._createAt(i,t)):bo._createOn(i);const n=si(e.getSelectedBlocks());if(!n)return new bo(e.focus);if(n.isEmpty)return new bo(uo._createAt(n,0));const s=uo._createAfter(n);return e.focus.isTouching(s)?new bo(s):new bo(uo._createBefore(n))}}class vr{_items;constructor(e){if(e instanceof vr)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(Rr)}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 vr([e]);return t._items=[...this._items,...t._items],t}trimLast(){const e=new vr([]);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 yr(e,t){const i={name:t,allowIn:new Set,allowChildren:new Set,disallowIn:new Set,disallowChildren:new Set,allowContentOf:new Set,allowWhere:new Set,allowAttributes:new Set,disallowAttributes:new Set,allowAttributesOf:new Set,inheritTypesFrom:new Set};return function(e,t){for(const i of e){const e=Object.keys(i).filter(e=>e.startsWith("is"));for(const n of e)t[n]=!!i[n]}}(e,i),Or(e,i,"allowIn"),Or(e,i,"allowChildren"),Or(e,i,"disallowIn"),Or(e,i,"disallowChildren"),Or(e,i,"allowContentOf"),Or(e,i,"allowWhere"),Or(e,i,"allowAttributes"),Or(e,i,"disallowAttributes"),Or(e,i,"allowAttributesOf"),Or(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.add(e),t.allowWhere.add(e),t.allowAttributesOf.add(e),t.inheritTypesFrom.add(e))}}(e,i),i}function kr(e,t){for(const i of t.allowIn){const n=e[i];n?n.allowChildren.add(t.name):t.allowIn.delete(i)}}function Cr(e,t){for(const i of t.allowChildren){const n=e[i];n?n.allowIn.add(t.name):t.allowChildren.delete(i)}}function Ar(e,t){for(const i of t.disallowIn){const n=e[i];n?n.disallowChildren.add(t.name):t.disallowIn.delete(i)}}function Tr(e,t){for(const i of t.disallowChildren){const n=e[i];n?n.disallowIn.add(t.name):t.disallowChildren.delete(i)}}function Er(e,t){for(const e of t.disallowChildren)t.allowChildren.delete(e);for(const e of t.disallowIn)t.allowIn.delete(e);for(const e of t.disallowAttributes)t.allowAttributes.delete(e)}function xr(e,t){for(const i of t.allowContentOf){const n=e[i];n&&(n.disallowChildren.forEach(i=>{t.allowChildren.has(i)||(t.disallowChildren.add(i),e[i].disallowIn.add(t.name))}),n.allowChildren.forEach(i=>{t.disallowChildren.has(i)||(t.allowChildren.add(i),e[i].allowIn.add(t.name))}))}}function Pr(e,t){for(const i of t.allowWhere){const n=e[i];n&&(n.disallowIn.forEach(i=>{t.allowIn.has(i)||(t.disallowIn.add(i),e[i].disallowChildren.add(t.name))}),n.allowIn.forEach(i=>{t.disallowIn.has(i)||(t.allowIn.add(i),e[i].allowChildren.add(t.name))}))}}function Sr(e,t){for(const i of t.allowAttributesOf){const n=e[i];if(!n)return;n.allowAttributes.forEach(e=>{t.disallowAttributes.has(e)||t.allowAttributes.add(e)})}}function Ir(e,t){for(const i of t.inheritTypesFrom){const n=e[i];if(n){const e=Object.keys(n).filter(e=>e.startsWith("is"));for(const i of e)i in t||(t[i]=n[i])}}}function Or(e,t,i){for(const n of e){let e=n[i];"string"==typeof e&&(e=[e]),Array.isArray(e)&&e.forEach(e=>t[i].add(e))}}function Rr(e){return"string"==typeof e||e.is("documentFragment")?{name:"string"==typeof e?e:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:e.is("element")?e.name:"$text",*getAttributeKeys(){yield*e.getAttributeKeys()},getAttribute:t=>e.getAttribute(t)}}function Vr(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class Br extends(Ae()){conversionApi;_splitParts=new Map;_cursorParents=new Map;_modelCursor=null;_emptyElementsToKeep=new Set;constructor(e){super(),this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(e,t)=>this._convertItem(e,t),convertChildren:(e,t)=>this._convertChildren(e,t),safeInsert:(e,t)=>this._safeInsert(e,t),updateConversionResult:(e,t)=>this._updateConversionResult(e,t),splitToAllowedParent:(e,t)=>this._splitToAllowedParent(e,t),getSplitParts:e=>this._getSplitParts(e),keepEmptyElement:e=>this._keepEmptyElement(e)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new vr(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const s=t.createElement(n.name,e);i&&t.insert(s,i),i=uo._createAt(s,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=mn.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),s=t.createDocumentFragment();if(n){this._removeEmptyElements();const e=this._modelCursor.parent,i=e._removeChildren(0,e.childCount);s._insertChild(0,i),s.markers=function(e,t){const i=new Set,n=new Map,s=bo._createIn(e).getItems();for(const e of s)e.is("element","$marker")&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),s=t.createPositionBefore(e);n.has(i)?n.get(i).end=s.clone():n.set(i,new bo(s.clone())),t.remove(e)}return n}(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 bo))throw new fe("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:uo._createAt(t,0);const n=new bo(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof bo&&(n.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:n,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){const i=this._getSplitParts(e),n=this.conversionApi.writer;t.modelRange||(t.modelRange=n.createRange(n.createPositionBefore(e),n.createPositionAfter(i[i.length-1])));const s=this._cursorParents.get(e);t.modelCursor=s?n.createPositionAt(s,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=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 cr(t,e,i)?{position:dr(t,n)}:null;const o=this.conversionApi.writer.split(t,s),r=[];for(const e of o.range.getWalker())if("elementEnd"==e.type)r.push(e.item);else{const t=r.pop(),i=e.item;this._registerSplitPair(t,i)}const a=o.range.end.parent;return this._cursorParents.set(e,a),{position:o.position,cursorParent:a}}_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 t=this._splitParts.has(e)?this._splitParts.get(e):[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()}}class Mr{getHtml(e){const t=G.document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class Fr{domParser;domConverter;htmlWriter;skipComments=!0;constructor(e){this.domParser=new DOMParser,this.domConverter=new Fs(e,{renderingMode:"data"}),this.htmlWriter=new Mr}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="marked"==e?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`<body>${e}</body>`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}}class Nr extends(Ae()){model;mapper;downcastDispatcher;upcastDispatcher;viewDocument;stylesProcessor;htmlProcessor;processor;_viewWriter;constructor(e,t){super(),this.model=e,this.mapper=new wo,this.downcastDispatcher=new ko({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewPosition(t.range.start),o=n.createText(t.item.data);n.insert(s,o)},{priority:"lowest"}),this.downcastDispatcher.on("insert",(e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)},{priority:"lowest"}),this.upcastDispatcher=new Br({schema:e.schema}),this.viewDocument=new Yn(t),this.stylesProcessor=t,this.htmlProcessor=new Fr(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new ls(this.viewDocument),this.upcastDispatcher.on("text",(e,t,{schema:i,consumable:n,writer:s})=>{let o=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(o,"$text")){if(!cr(o,"$text",i))return;if(0==t.viewItem.data.trim().length)return;o=dr(o,s)}n.consume(t.viewItem);const r=s.createText(t.viewItem.data);s.insert(r,o),t.modelRange=s.createRange(o,o.getShiftedBy(r.offsetSize)),t.modelCursor=t.modelRange.end},{priority:"lowest"}),this.upcastDispatcher.on("element",(e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}},{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",(e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}},{priority:"lowest"}),Le().prototype.decorate.call(this,"init"),Le().prototype.decorate.call(this,"set"),Le().prototype.decorate.call(this,"get"),Le().prototype.decorate.call(this,"toView"),Le().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},lr)},{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new fe("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return n.isAttached()||pe("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const s=bo._createIn(e),o=new as(i);this.mapper.bindElements(e,o);const r=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=bo._createIn(e);for(const e of i.model.markers){const i=e.getRange(),s=i.isCollapsed,o=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(s&&o)t.push([e.name,i]);else{const s=n.getIntersection(i);s&&t.push([e.name,s])}}return t.sort(([e,t],[i,n])=>{if("after"!==t.end.compareWith(n.start))return 1;if("before"!==t.start.compareWith(n.end))return-1;switch(t.start.compareWith(n.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(n.end)){case"before":return 1;case"after":return-1;default:return i.localeCompare(e)}}}),new Map(t)}(e);return this.downcastDispatcher.convert(s,r,n,t),o}init(e){if(this.model.document.version)throw new fe("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new fe("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},e=>{for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.insert(this.parse(t[i],n),n,0)}}),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new fe("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(i)){const n=this.model.document.getRoot(t);e.remove(e.createRangeIn(n)),e.insert(this.parse(i[t],n),n,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}}class Lr{_helpers=new Map;_downcast;_upcast;constructor(e,t){this._downcast=ei(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=ei(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 fe("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new fe("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of Dr(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 Dr(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 Dr(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new fe("conversion-group-exists",this);const n=i?new jo(t):new ur(t);this._helpers.set(e,n)}}function*Dr(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],s=e.upcastAlso?e.upcastAlso[t]:void 0;yield*zr(i,n,s)}else yield*zr(e.model,e.view,e.upcastAlso)}function*zr(e,t,i){if(yield{model:e,view:t},i)for(const t of ei(i))yield{model:e,view:t}}class Hr{baseVersion;isDocumentOperation;batch;constructor(e){this.baseVersion=e,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}_validate(){}toJSON(){const e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e,t){return new this(e.baseVersion)}}function $r(e,t){const i=Ur(t),n=i.reduce((e,t)=>e+t.offsetSize,0),s=e.parent;Kr(e);const o=e.index;return s._insertChild(o,i),qr(s,o+i.length),qr(s,o),new bo(e,e.getShiftedBy(n))}function Wr(e){if(!e.isFlat)throw new fe("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Kr(e.start),Kr(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return qr(t,e.start.index),i}function jr(e,t){if(!e.isFlat)throw new fe("operation-utils-move-range-not-flat",this);const i=Wr(e);return $r(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function Ur(e){const t=[];!function e(i){if("string"==typeof i)t.push(new Fo(i));else if(i instanceof ao)t.push(new Fo(i.data,i.getAttributes()));else if(i instanceof To)t.push(i);else if(Ke(i))for(const t of i)e(t)}(e);for(let e=1;e<t.length;e++){const i=t[e],n=t[e-1];i instanceof Fo&&n instanceof Fo&&Gr(i,n)&&(t.splice(e-1,2,new Fo(n.data+i.data,n.getAttributes())),e--)}return t}function qr(e,t){const i=e.getChild(t-1),n=e.getChild(t);if(i&&n&&i.is("$text")&&n.is("$text")&&Gr(i,n)){const s=new Fo(i.data+n.data,i.getAttributes());e._removeChildren(t-1,2),e._insertChild(t-1,s)}}function Kr(e){const t=e.textNode,i=e.parent;if(t){const n=e.offset-t.startOffset,s=t.index;i._removeChildren(s,1);const o=new Fo(t.data.substr(0,n),t.getAttributes()),r=new Fo(t.data.substr(n),t.getAttributes());i._insertChild(s,[o,r])}}function Gr(e,t){const i=e.getAttributes(),n=t.getAttributes();for(const e of i){if(e[1]!==t.getAttribute(e[0]))return!1;n.next()}return n.next().done}class Jr extends Hr{sourcePosition;howMany;targetPosition;constructor(e,t,i,n){super(n),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toNext",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNone"}get type(){return this.targetPosition.root.rootName==this.sourcePosition.root.rootName?"move":"$graveyard"==this.targetPosition.root.rootName?"remove":"$graveyard"==this.sourcePosition.root.rootName?"reinsert":"move"}get affectedSelectable(){return[bo._createFromPositionAndShift(this.sourcePosition,this.howMany),bo._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new Jr(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){const e=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new Jr(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent,i=this.sourcePosition.offset,n=this.targetPosition.offset;if(i+this.howMany>e.maxOffset)throw new fe("move-operation-nodes-do-not-exist",this);if(e===t&&i<n&&n<i+this.howMany)throw new fe("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&"prefix"==qe(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())){const e=this.sourcePosition.path.length-1;if(this.targetPosition.path[e]>=i&&this.targetPosition.path[e]<i+this.howMany)throw new fe("move-operation-node-into-itself",this)}}_execute(){jr(bo._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e.targetPosition=this.targetPosition.toJSON(),e}static get className(){return"MoveOperation"}static fromJSON(e,t){const i=uo.fromJSON(e.sourcePosition,t),n=uo.fromJSON(e.targetPosition,t);return new this(i,e.howMany,n,e.baseVersion)}}class Yr extends Hr{position;nodes;shouldReceiveAttributes;constructor(e,t,i){super(i),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new Ho(Ur(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new Ho([...this.nodes].map(e=>e._clone(!0))),t=new Yr(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new uo(e,[0]);return new Jr(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new fe("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new Ho([...e].map(e=>e._clone(!0))),$r(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 t of e.nodes)t.name?i.push($o.fromJSON(t)):i.push(Fo.fromJSON(t));const n=new Yr(uo.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}class Qr extends Hr{splitPosition;howMany;insertionPosition;graveyardPosition;constructor(e,t,i,n,s){super(s),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=n?n.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 uo(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new bo(this.splitPosition,e)}get affectedSelectable(){const e=[bo._createFromPositionAndShift(this.splitPosition,0),bo._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(bo._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new Qr(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new uo(e,[0]);return new Xr(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset<t)throw new fe("split-operation-position-invalid",this);if(!e.parent)throw new fe("split-operation-split-in-root",this);if(this.howMany!==Number.NEGATIVE_INFINITY&&this.howMany!=e.maxOffset-this.splitPosition.offset)throw new fe("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new fe("split-operation-graveyard-position-invalid",this);this.howMany=this.splitPosition.parent.maxOffset-this.splitPosition.offset}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)jr(bo._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const t=e._clone();$r(this.insertionPosition,t)}jr(new bo(uo._createAt(e,this.splitPosition.offset),uo._createAt(e,e.maxOffset)),this.moveTargetPosition)}toJSON(){const e=super.toJSON();return e.splitPosition=this.splitPosition.toJSON(),e.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(e.graveyardPosition=this.graveyardPosition.toJSON()),e}static get className(){return"SplitOperation"}static getInsertionPosition(e){const t=e.path.slice(0,-1);return t[t.length-1]++,new uo(e.root,t,"toPrevious")}static fromJSON(e,t){const i=uo.fromJSON(e.splitPosition,t),n=uo.fromJSON(e.insertionPosition,t),s=e.graveyardPosition?uo.fromJSON(e.graveyardPosition,t):null;return new this(i,e.howMany,n,s,e.baseVersion)}}class Xr extends Hr{sourcePosition;howMany;targetPosition;graveyardPosition;constructor(e,t,i,n,s){super(s),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=n.clone()}get type(){return"merge"}get deletionPosition(){return new uo(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new bo(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[bo._createOn(e),bo._createFromPositionAndShift(this.targetPosition,0),bo._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new Xr(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),i=new uo(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new Qr(e,this.howMany,i,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(!e.parent)throw new fe("merge-operation-source-position-invalid",this);if(!t.parent)throw new fe("merge-operation-target-position-invalid",this);if(this.howMany!==Number.NEGATIVE_INFINITY&&this.howMany!=e.maxOffset)throw new fe("merge-operation-how-many-invalid",this);this.howMany=this.sourcePosition.parent.maxOffset}_execute(){const e=this.sourcePosition.parent;jr(bo._createIn(e),this.targetPosition),jr(bo._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const i=uo.fromJSON(e.sourcePosition,t),n=uo.fromJSON(e.targetPosition,t),s=uo.fromJSON(e.graveyardPosition,t);return new this(i,e.howMany,n,s,e.baseVersion)}}class Zr extends Hr{name;oldRange;newRange;affectsData;_markers;constructor(e,t,i,n,s,o){super(o),this.name=e,this.oldRange=t?t.clone():null,this.newRange=i?i.clone():null,this.affectsData=s,this._markers=n}get type(){return"marker"}get affectedSelectable(){const e=[];return this.oldRange&&e.push(this.oldRange.clone()),this.newRange&&(this.oldRange?e.push(...this.newRange.getDifference(this.oldRange)):e.push(this.newRange.clone())),e}clone(){return new Zr(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new Zr(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new Zr(e.name,e.oldRange?bo.fromJSON(e.oldRange,t):null,e.newRange?bo.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}class ea extends Hr{range;key;oldValue;newValue;constructor(e,t,i,n,s){super(s),this.range=e.clone(),this.key=t,this.oldValue=void 0===i?null:i,this.newValue=void 0===n?null:n}get type(){return null===this.oldValue?"addAttribute":null===this.newValue?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new ea(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new ea(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new fe("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(null!==this.oldValue&&!Xi(e.getAttribute(this.key),this.oldValue))throw new fe("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(null===this.oldValue&&null!==this.newValue&&e.hasAttribute(this.key))throw new fe("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){Xi(this.oldValue,this.newValue)||function(e,t,i){Kr(e.start),Kr(e.end);for(const n of e.getItems({shallow:!0})){const e=n.is("$textProxy")?n.textNode:n;null!==i?e._setAttribute(t,i):e._removeAttribute(t),qr(e.parent,e.index)}qr(e.end.parent,e.end.index)}(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new ea(bo.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}class ta extends Hr{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new ta(this.baseVersion)}getReversed(){return new ta(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class ia extends Hr{position;oldName;newName;constructor(e,t,i,n){super(n),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=i}get type(){return"rename"}get affectedSelectable(){return this.position.nodeAfter}clone(){return new ia(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new ia(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(!(e instanceof $o))throw new fe("rename-operation-wrong-position",this);if(""!==this.oldName&&e.name!==this.oldName)throw new fe("rename-operation-wrong-name",this);this.oldName=e.name}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new ia(uo.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class na extends Hr{root;key;oldValue;newValue;constructor(e,t,i,n,s){super(s),this.root=e,this.key=t,this.oldValue=void 0===i?null:i,this.newValue=void 0===n?null:n}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new na(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new na(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new fe("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(null!==this.oldValue&&!Xi(this.root.getAttribute(this.key),this.oldValue))throw new fe("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(null===this.oldValue&&null!==this.newValue&&this.root.hasAttribute(this.key))throw new fe("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){null!==this.newValue?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new fe("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new na(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class sa extends Hr{rootName;elementName;isAdd;_document;constructor(e,t,i,n,s){if(super(s),this.rootName=e,this.elementName=t,this.isAdd=i,this._document=n,!this._document.getRoot(this.rootName)){this._document.createRoot(this.elementName,this.rootName)._isAttached=!1}}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new sa(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new sa(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_execute(){this._document.getRoot(this.rootName)._isAttached=this.isAdd}toJSON(){const e=super.toJSON();return delete e._document,e}static get className(){return"RootOperation"}static fromJSON(e,t){return new sa(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}}const oa={};oa[ea.className]=ea,oa[Yr.className]=Yr,oa[Zr.className]=Zr,oa[Jr.className]=Jr,oa[ta.className]=ta,oa[Hr.className]=Hr,oa[ia.className]=ia,oa[na.className]=na,oa[sa.className]=sa,oa[Qr.className]=Qr,oa[Xr.className]=Xr;class ra{static fromJSON(e,t){return oa[e.__className].fromJSON(e,t)}}const aa=new Map;function la(e,t,i){let n=aa.get(e);n||(n=new Map,aa.set(e,n)),n.set(t,i)}function ca(e){return[e]}function da(e,t,i={}){const n=function(e,t){const i=aa.get(e);return i&&i.has(t)?i.get(t):ca}(e.constructor,t.constructor);try{return n(e=e.clone(),t,i)}catch(e){throw e}}function ua(e,t,i){e=e.slice(),t=t.slice();const n=new ha(i.document,i.useRelations,i.forceWeakRemove);n.setOriginalOperations(e),n.setOriginalOperations(t);const s=n.originalOperations;if(0==e.length||0==t.length)return{operationsA:e,operationsB:t,originalOperations:s};const o=new WeakMap;for(const t of e)o.set(t,0);const r={nextBaseVersionA:e[e.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:e.length,originalOperationsBCount:t.length};let a=0;for(;a<e.length;){const i=e[a],s=o.get(i);if(s==t.length){a++;continue}const r=t[s],l=da(i,r,n.getContext(i,r,!0)),c=da(r,i,n.getContext(r,i,!1));n.updateRelation(i,r),n.setOriginalOperations(l,i),n.setOriginalOperations(c,r);for(const e of l)o.set(e,s+c.length);e.splice(a,1,...l),t.splice(s,1,...c)}if(fa(e),fa(t),i.padWithNoOps){const i=e.length-r.originalOperationsACount,n=t.length-r.originalOperationsBCount;ga(e,n-i),ga(t,i-n)}return ma(e,r.nextBaseVersionB),ma(t,r.nextBaseVersionA),{operationsA:e,operationsB:t,originalOperations:s}}class ha{originalOperations;_history;_useRelations;_forceWeakRemove;_relations;constructor(e,t,i=!1){this.originalOperations=new Map,this._history=e.history,this._useRelations=t,this._forceWeakRemove=!!i,this._relations=new Map}setOriginalOperations(e,t=null){const i=t?this.originalOperations.get(t):null;for(const t of e)this.originalOperations.set(t,i||t)}updateRelation(e,t){if(e instanceof Jr)t instanceof Xr?e.targetPosition.isEqual(t.sourcePosition)||t.movedRange.containsPosition(e.targetPosition)?this._setRelation(e,t,"insertAtSource"):e.targetPosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"insertBetween"):e.targetPosition.isAfter(t.sourcePosition)?this._setRelation(e,t,"moveTargetAfter"):e.howMany>1&&e.sourcePosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"firstToMoveMerged"):e.howMany>1&&e.sourcePosition.getShiftedBy(e.howMany-1).isEqual(t.deletionPosition)&&this._setRelation(e,t,"lastToMoveMerged"):t instanceof Jr&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof Qr){if(t instanceof Xr)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof Jr)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const i=bo._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=i.end.offset-e.splitPosition.offset,s=e.splitPosition.offset-i.start.offset;this._setRelation(e,t,{howMany:n,offset:s})}}}else if(e instanceof Xr)t instanceof Xr?(e.targetPosition.isEqual(t.sourcePosition)||this._setRelation(e,t,"mergeTargetNotMoved"),e.sourcePosition.isEqual(t.targetPosition)&&this._setRelation(e,t,"mergeSourceNotMoved"),e.sourcePosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeSameElement")):t instanceof Qr?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof Jr&&t.howMany>0&&(e.sourcePosition.isEqual(t.sourcePosition.getShiftedBy(t.howMany))&&this._setRelation(e,t,"mergeSourceAffected"),e.targetPosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeTargetWasBefore"));else if(e instanceof Zr){const i=e.newRange;if(!i)return;if(t instanceof Xr){const n=i.start.isEqual(t.targetPosition),s=i.start.isEqual(t.deletionPosition),o=i.end.isEqual(t.deletionPosition),r=i.end.isEqual(t.sourcePosition);(n||s||o||r)&&this._setRelation(e,t,{wasInLeftElement:n,wasStartBeforeMergedElement:s,wasEndBeforeMergedElement:o,wasInRightElement:r})}}}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),n=this._history.getUndoneOperation(i);if(!n)return null;const s=this.originalOperations.get(e),o=this._relations.get(s);return o&&o.get(n)||null}_setRelation(e,t,i){const n=this.originalOperations.get(e),s=this.originalOperations.get(t);let o=this._relations.get(n);o||(o=new Map,this._relations.set(n,o)),o.set(s,i)}}function ma(e,t){for(const i of e)i.baseVersion=t++}function ga(e,t){for(let i=0;i<t;i++)e.push(new ta(0))}function fa(e){const t=new Map;for(let i=0;i<e.length;i++){const n=e[i];if(n instanceof Zr)if(-1!==n.baseVersion)t.set(n.name,{op:n,ranges:n.newRange?[n.newRange]:[]});else{if(n.newRange){const e=t.get(n.name).ranges;e[0].containsRange(n.newRange,!0)||e.push(n.newRange)}e.splice(i,1),i--}}for(const{op:e,ranges:i}of t.values())i.length?e.newRange=bo._createFromRanges(i):e.newRange=null}function pa(e,t,i){const n=e.nodes.getNode(0).getAttribute(t);if(n==i)return null;const s=new bo(e.position,e.position.getShiftedBy(e.howMany));return new ea(s,t,n,i,0)}function ba(e,t){return null===e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany)}function wa(e,t){const i=[];for(let n=0;n<e.length;n++){const s=e[n],o=new Jr(s.start,s.end.offset-s.start.offset,t,0);i.push(o);for(let t=n+1;t<e.length;t++)e[t]=e[t]._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)[0];t=t._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)}return i}la(ea,ea,(e,t,i)=>{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const n=e.range.getDifference(t.range).map(t=>new ea(t,e.key,e.oldValue,e.newValue,0)),s=e.range.getIntersection(t.range);return s&&i.aIsStrong&&n.push(new ea(s,t.key,t.newValue,e.newValue,0)),0==n.length?[new ta(0)]:n}return[e]}),la(ea,Yr,(e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map(t=>new ea(t,e.key,e.oldValue,e.newValue,e.baseVersion));if(t.shouldReceiveAttributes){const n=pa(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]}),la(ea,Xr,(e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(bo._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map(t=>new ea(t,e.key,e.oldValue,e.newValue,e.baseVersion))}),la(ea,Jr,(e,t)=>{const i=function(e,t){const i=bo._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,s=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(s=e.getDifference(i),n=e.getIntersection(i)):s=[e];const o=[];for(let e of s){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i),s=e._getTransformedByInsertion(i,t.howMany,n);o.push(...s)}n&&o.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return o}(e.range,t);return i.map(t=>new ea(t,e.key,e.oldValue,e.newValue,e.baseVersion))}),la(ea,Qr,(e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const i=e.clone();return i.range=new bo(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]}),la(Yr,ea,(e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=pa(e,t.key,t.newValue);n&&i.push(n)}return i}),la(Yr,Yr,(e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e])),la(Yr,Jr,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),la(Yr,Qr,(e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e])),la(Yr,Xr,(e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e])),la(Zr,Yr,(e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e])),la(Zr,Zr,(e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new ta(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]}),la(Zr,Xr,(e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e])),la(Zr,Jr,(e,t)=>{const i=[e];if(e.oldRange&&(e.oldRange=bo._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){const n=e.newRange._getTransformedByMoveOperation(t);e.newRange=n[0];for(let t=1;t<n.length;t++){const s=e.clone();s.oldRange=null,s.newRange=n[t],s.baseVersion=-1,i.push(s)}}return i}),la(Zr,Qr,(e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const n=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)?i.abRelation.wasStartBeforeMergedElement?e.newRange.start=uo._createAt(t.insertionPosition):i.abRelation.wasInLeftElement?e.newRange.start=uo._createAt(e.newRange.start):e.newRange.start=uo._createAt(t.moveTargetPosition):e.newRange.start=n.start,e.newRange.end.isEqual(t.splitPosition)?e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=uo._createAt(t.insertionPosition):i.abRelation.wasInRightElement?e.newRange.end=uo._createAt(t.moveTargetPosition):e.newRange.end=uo._createAt(e.newRange.end):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]}),la(Xr,Yr,(e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e])),la(Xr,Xr,(e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(i.bWasUndone){const i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new uo(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new ta(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,s="$graveyard"==t.targetPosition.root.rootName;if(s&&!n||!(n&&!s)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new Jr(i,e.howMany,n,0)]}return[new ta(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]}),la(Xr,Jr,(e,t,i)=>{const n=bo._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new ta(0)]:(t.sourcePosition.getShiftedBy(t.howMany).isEqual(e.sourcePosition)?e.sourcePosition.stickiness="toNone":t.targetPosition.isEqual(e.sourcePosition)&&"mergeSourceAffected"==i.abRelation?e.sourcePosition.stickiness="toNext":t.sourcePosition.isEqual(e.targetPosition)?(e.targetPosition.stickiness="toNone",e.howMany-=t.howMany):t.targetPosition.isEqual(e.targetPosition)&&"mergeTargetWasBefore"==i.abRelation?(e.targetPosition.stickiness="toPrevious",e.howMany+=t.howMany):(e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition.hasSameParentAs(t.sourcePosition)&&(e.howMany-=t.howMany)),e.sourcePosition=e.sourcePosition._getTransformedByMoveOperation(t),e.targetPosition=e.targetPosition._getTransformedByMoveOperation(t),e.sourcePosition.stickiness="toPrevious",e.targetPosition.stickiness="toNext",e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])}),la(Xr,Qr,(e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){if(t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition)||"mergeTargetNotMoved"==i.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}),la(Jr,Yr,(e,t)=>{const i=bo._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]}),la(Jr,Jr,(e,t,i)=>{const n=bo._createFromPositionAndShift(e.sourcePosition,e.howMany),s=bo._createFromPositionAndShift(t.sourcePosition,t.howMany);let o,r=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),o=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),ba(e,t)&&ba(t,e))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(s,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),wa([n],o);if(s.containsPosition(e.targetPosition)&&s.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),wa([n],o);const l=qe(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),wa([n],o);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(r=!1):r=!0;const c=[],d=n.getDifference(s);for(const e of d){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const i="same"==qe(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);c.push(...n)}const u=n.getIntersection(s);return null!==u&&r&&(u.start=u.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),u.end=u.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===c.length?c.push(u):1==c.length?s.start.isBefore(n.start)||s.start.isEqual(n.start)?c.unshift(u):c.push(u):c.splice(1,0,u)),0===c.length?[new ta(e.baseVersion)]:wa(c,o)}),la(Jr,Qr,(e,t,i)=>{let n=e.targetPosition.clone();if(e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t)),e.sourcePosition.isEqual(t.insertionPosition)&&"firstToMoveMerged"==i.abRelation)return e.howMany++,e.targetPosition=n,[e];const s=bo._createFromPositionAndShift(e.sourcePosition,e.howMany);if(s.end.isEqual(t.insertionPosition))return t.graveyardPosition&&"lastToMoveMerged"!=i.abRelation||e.howMany++,e.targetPosition=n,[e];if(s.start.hasSameParentAs(t.splitPosition)&&s.containsPosition(t.splitPosition)){let e=new bo(t.splitPosition,s.end);e=e._getTransformedBySplitOperation(t);return wa([new bo(s.start,t.splitPosition),e],n)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(n=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(n=e.targetPosition);const o=[s._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=s.start.isEqual(t.graveyardPosition)||s.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&o.push(bo._createFromPositionAndShift(t.insertionPosition,1))}return wa(o,n)}),la(Jr,Xr,(e,t,i)=>{const n=bo._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition))if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)return i.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new ta(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),s=t.targetPosition._getTransformedByMergeOperation(t);const o=e.targetPosition.getTransformedByOperation(t);e.howMany>1&&(i.push(new Jr(e.sourcePosition,e.howMany-1,o,0)),n=n._getTransformedByMove(e.sourcePosition,o,e.howMany-1),s=s._getTransformedByMove(e.sourcePosition,o,e.howMany-1));const r=t.deletionPosition._getCombined(e.sourcePosition,o),a=new Jr(n,1,r,0),l=a.getMovedRangeStart().path.slice();l.push(0);const c=new uo(a.targetPosition.root,l);s=s._getTransformedByMove(n,r,1);const d=new Jr(s,t.howMany,c,0);return i.push(a),i.push(d),i}const s=bo._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=s.start,e.howMany=s.end.offset-s.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]}),la(ia,Yr,(e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e])),la(ia,Xr,(e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e])),la(ia,Jr,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),la(ia,ia,(e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new ta(0)];e.oldName=t.newName}return[e]}),la(ia,Qr,(e,t)=>{if("same"==qe(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new ia(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]}),la(na,na,(e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong)return[new ta(0)];e.oldValue=t.newValue}return[e]}),la(sa,sa,(e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new ta(0)]:[e]),la(Qr,Yr,(e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset<t.position.offset&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByInsertOperation(t),e.insertionPosition=e.insertionPosition._getTransformedByInsertOperation(t),[e])),la(Qr,Xr,(e,t,i)=>{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new uo(t.graveyardPosition.root,i),s=Qr.getInsertionPosition(new uo(t.graveyardPosition.root,i)),o=new Qr(n,0,s,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Qr.getInsertionPosition(e.splitPosition),e.graveyardPosition=o.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[o,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Qr.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]}),la(Qr,Jr,(e,t,i)=>{const n=bo._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const s=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&s){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),s=n.path.slice();s.push(0);const o=new uo(n.root,s);return[new Jr(i,e.howMany,o,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const s=e.splitPosition.isEqual(t.targetPosition);if(s&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Qr.getInsertionPosition(e.splitPosition),[e];if(s&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:n}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(n),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset<t.targetPosition.offset&&(e.howMany+=t.howMany),e.splitPosition=t.sourcePosition.clone(),e.insertionPosition=Qr.getInsertionPosition(e.splitPosition),[e]}return t.sourcePosition.isEqual(t.targetPosition)||(e.splitPosition.hasSameParentAs(t.sourcePosition)&&e.splitPosition.offset<=t.sourcePosition.offset&&(e.howMany-=t.howMany),e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset<t.targetPosition.offset&&(e.howMany+=t.howMany)),e.splitPosition.stickiness="toNone",e.splitPosition=e.splitPosition._getTransformedByMoveOperation(t),e.splitPosition.stickiness="toNext",e.graveyardPosition?e.insertionPosition=e.insertionPosition._getTransformedByMoveOperation(t):e.insertionPosition=Qr.getInsertionPosition(e.splitPosition),[e]}),la(Qr,Qr,(e,t,i)=>{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new ta(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new ta(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const n="$graveyard"==e.splitPosition.root.rootName,s="$graveyard"==t.splitPosition.root.rootName;if(s&&!n||!(n&&!s)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new Jr(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new Jr(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new ta(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){const i=t.insertionPosition.path.slice();i.push(0);const n=new uo(t.insertionPosition.root,i);return[e,new Jr(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset<t.splitPosition.offset&&(e.howMany-=t.howMany),e.splitPosition=e.splitPosition._getTransformedBySplitOperation(t),e.insertionPosition=Qr.getInsertionPosition(e.splitPosition),[e]});class _a extends(Ae(uo)){constructor(e,t,i="toNone"){if(super(e,t,i),!this.root.is("rootElement"))throw new fe("model-liveposition-root-not-rootelement",e);va.call(this)}detach(){this.stopListening()}toPosition(){return new uo(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}function va(){this.listenTo(this.root.document.model,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&ya.call(this,i)},{priority:"low"})}function ya(e){const t=this.getTransformedByOperation(e);if(!this.isEqual(t)){const e=this.toPosition();this.path=t.path,this.root=t.root,this.fire("change",e)}}_a.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class ka{operations;isUndoable;isLocal;isUndo;isTyping;constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},pe("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:s=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=s}get baseVersion(){for(const e of this.operations)if(null!==e.baseVersion)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}class Ca{static _statesPriority=[void 0,"refresh","rename","move"];_markerCollection;_changesInElement=new Map;_elementsSnapshots=new Map;_elementChildrenSnapshots=new Map;_elementState=new Map;_changedMarkers=new Map;_changedRoots=new Map;_changeCount=0;_cachedChanges=null;_cachedChangesWithGraveyard=null;_refreshedItems=new Set;constructor(e){this._markerCollection=e}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size&&0==this._changedRoots.size}bufferOperation(e){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 e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),i=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);const n=bo._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const e of n.getItems({shallow:!0}))this._setElementState(e,"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 e=bo._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getData();this.bufferMarkerChange(t.name,e,e)}this._setElementState(t.position.nodeAfter,"rename");break}case"split":{const e=t.splitPosition.parent;if(!this._isInInsertedElement(e)){this._markRemove(e,t.splitPosition.offset,t.howMany);const i=bo._createFromPositionAndShift(t.splitPosition,t.howMany);for(const e of i.getItems({shallow:!0}))this._setElementState(e,"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 e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1),this._setElementState(e,"move");const n=t.targetPosition.parent;if(!this._isInInsertedElement(n)){this._markInsert(n,t.targetPosition.offset,e.maxOffset);const i=bo._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const e of i.getItems({shallow:!0}))this._setElementState(e,"move")}break}case"detachRoot":case"addRoot":{const e=t.affectedSelectable;if(!e._isLoaded)return;if(e.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const e=t.root.rootName;this._bufferRootAttributeChange(e,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 n=this._changedMarkers.get(e);n?n.newMarkerData=i:(n={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,n)),null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}}))}hasDataChanges(){if(this.getChanges().length)return!0;if(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,n=!e.range&&t.range,s=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||s)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const i=this._changesInElement.get(e).sort((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offset<t.offset?-1:1),n=this._elementChildrenSnapshots.get(e),s=Ta(e.getChildren()),o=Ea(n.length,i);let r=0,a=0;for(const i of o)if("i"===i){const i=this._getDiffActionForNode(s[r].node,"insert"),n=this._elementsSnapshots.get(s[r].node),o=this._getInsertDiff(e,r,i,s[r],n);t.push(o),r++}else if("r"===i){const i=this._getDiffActionForNode(n[a].node,"remove"),s=this._getRemoveDiff(e,r,i,n[a]);t.push(s),a++}else if("a"===i){const i=n[a].attributes,o=s[r].attributes;let l;if("$text"==s[r].name)l=new bo(uo._createAt(e,r),uo._createAt(e,r+1));else{const t=e.offsetToIndex(r);l=new bo(uo._createAt(e,r),uo._createAt(e.getChild(t),0))}const c=this._getAttributesDiff(l,i,o);t.push(...c),r++,a++}else r++,a++}t.sort((e,t)=>e.position.root!=t.position.root?e.position.root.rootName<t.position.root.rootName?-1:1:e.position.isEqual(t.position)?e.changeCount-t.changeCount:e.position.isBefore(t.position)?-1:1);for(let e=1,i=0;e<t.length;e++){const n=t[i],s=t[e],o="remove"==n.type&&"remove"==s.type&&"$text"==n.name&&"$text"==s.name&&n.position.isEqual(s.position),r="insert"==n.type&&"insert"==s.type&&"$text"==n.name&&"$text"==s.name&&n.position.parent==s.position.parent&&n.position.offset+n.length==s.position.offset,a="attribute"==n.type&&"attribute"==s.type&&n.position.parent==s.position.parent&&n.range.isFlat&&s.range.isFlat&&n.position.offset+n.length==s.position.offset&&n.attributeKey==s.attributeKey&&n.attributeOldValue==s.attributeOldValue&&n.attributeNewValue==s.attributeNewValue;o||r||a?(n.length++,a&&(n.range.end=n.range.end.getShiftedBy(1)),t[e]=null):i=e}t=t.filter(e=>e);for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(xa),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{const t={...e};return void 0!==t.state&&delete t.attributes,t})}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementChildrenSnapshots.clear(),this._elementsSnapshots.clear(),this._elementState.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems.clear(),this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e),this._setElementState(e,"refresh");const t=bo._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}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 e=t.getData();this.bufferMarkerChange(t.name,{...e,range:null},e)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e))return void this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});const i=this._changedRoots.get(e);void 0!==i.state?(delete i.state,void 0===i.attributes&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,n){const s=this._changedRoots.get(e)||{name:e},o=s.attributes||{};if(o[t]){const e=o[t];n===e.oldValue?delete o[t]:e.newValue=n}else o[t]={oldValue:i,newValue:n};0===Object.entries(o).length?(delete s.attributes,void 0===s.state&&this._changedRoots.delete(e)):(s.attributes=o,this._changedRoots.set(e,s))}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),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 e=0;e<i.length;e++)i[e].howMany<1&&(i.splice(e,1),e--)}_setElementState(e,t){if(!e.is("element"))return;const i=Ca._statesPriority.indexOf(this._elementState.get(e));Ca._statesPriority.indexOf(t)>i&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element"))return t;if(!this._elementsSnapshots.has(e))return t;const i=this._elementState.get(e);return i&&"move"!=i?i:t}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshots(e){if(this._elementChildrenSnapshots.has(e))return;const t=Ta(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(const e of t)this._elementsSnapshots.set(e.node,e)}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const i of t){const n=e.offset+e.howMany,s=i.offset+i.howMany;if("insert"==e.type&&("insert"==i.type&&(e.offset<=i.offset?i.offset+=e.howMany:e.offset<s&&(i.howMany+=e.nodesToHandle,e.nodesToHandle=0)),"remove"==i.type&&e.offset<i.offset&&(i.offset+=e.howMany),"attribute"==i.type))if(e.offset<=i.offset)i.offset+=e.howMany;else if(e.offset<s){const s=i.howMany;i.howMany=e.offset-i.offset,t.unshift({type:"attribute",offset:n,howMany:s-i.howMany,count:this._changeCount++})}if("remove"==e.type){if("insert"==i.type)if(n<=i.offset)i.offset-=e.howMany;else if(n<=s)if(e.offset<i.offset){const t=n-i.offset;i.offset=e.offset,i.howMany-=t,e.nodesToHandle-=t}else i.howMany-=e.nodesToHandle,e.nodesToHandle=0;else if(e.offset<=i.offset)e.nodesToHandle-=i.howMany,i.howMany=0;else if(e.offset<s){const t=s-e.offset;i.howMany-=t,e.nodesToHandle-=t}if("remove"==i.type&&(n<=i.offset?i.offset-=e.howMany:e.offset<i.offset&&(e.nodesToHandle+=i.howMany,i.howMany=0)),"attribute"==i.type)if(n<=i.offset)i.offset-=e.howMany;else if(e.offset<i.offset){const t=n-i.offset;i.offset=e.offset,i.howMany-=t}else if(e.offset<s)if(n<=s){const n=i.howMany;i.howMany=e.offset-i.offset;const s=n-i.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:s,count:this._changeCount++})}else i.howMany-=s-e.offset}if("attribute"==e.type){if("insert"==i.type)if(e.offset<i.offset&&n>i.offset){if(n>s){const e={type:"attribute",offset:s,howMany:n-s,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offset<s&&(n>s?(e.nodesToHandle=n-s,e.offset=s):e.nodesToHandle=0);if("remove"==i.type&&e.offset<i.offset&&n>i.offset){const s={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(s,t),t.push(s),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=s?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=s&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i,n,s){const o={type:"insert",position:uo._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++,action:i};return"insert"!=i&&s&&(o.before={name:s.name,attributes:new Map(s.attributes)}),o}_getRemoveDiff(e,t,i,n){return{type:"remove",action:i,position:uo._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[s,o]of t){const t=i.has(s)?i.get(s):null;t!==o&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:o,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(s)}for(const[t,s]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:s,changeCount:this._changeCount++});return n}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),n=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&n>=e.offset&&n<e.offset+e.howMany)return!0;return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,i){const n=new bo(uo._createAt(e,t),uo._createAt(e,t+i));for(const e of n.getItems({shallow:!0}))e.is("element")&&(this._changesInElement.delete(e),this._removeAllNestedChanges(e,0,e.maxOffset))}}function Aa(e){return{node:e,name:e.is("$text")?"$text":e.name,attributes:new Map(e.getAttributes())}}function Ta(e){const t=[];for(const i of e)if(i.is("$text"))for(let e=0;e<i.data.length;++e)t.push(Aa(i));else t.push(Aa(i));return t}function Ea(e,t){const i=[];let n=0,s=0;for(const e of t){if(e.offset>n){for(let t=0;t<e.offset-n;t++)i.push("e");s+=e.offset-n}if("insert"==e.type){for(let t=0;t<e.howMany;t++)i.push("i");n=e.offset+e.howMany}else if("remove"==e.type){for(let t=0;t<e.howMany;t++)i.push("r");n=e.offset,s+=e.howMany}else{if(e.howMany>1500)for(let t=0;t<e.howMany;t++)i.push("a");else i.push(..."a".repeat(e.howMany).split(""));n=e.offset+e.howMany,s+=e.howMany}}if(s<e)for(let t=0;t<e-s-n;t++)i.push("e");return i}function xa(e){const t="position"in e&&"$graveyard"==e.position.root.rootName,i="range"in e&&"$graveyard"==e.range.root.rootName;return!t&&!i}class Pa{_operations=[];_undoPairs=new Map;_undoneOperations=new Set;_baseVersionToOperationIndex=new Map;_version=0;_gaps=new Map;get version(){return this._version}set version(e){this._operations.length&&e>this._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new fe("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];void 0===e&&(e=i.baseVersion);let n=t-1;for(const[t,i]of this._gaps)e>t&&e<i&&(e=i),n>t&&n<i&&(n=t-1);if(n<i.baseVersion||e>this.lastOperation.baseVersion)return[];let s=this._baseVersionToOperationIndex.get(e);void 0===s&&(s=0);let o=this._baseVersionToOperationIndex.get(n);return void 0===o&&(o=this._operations.length-1),this._operations.slice(s,o+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class Sa extends $o{rootName;_document;_isAttached=!0;_isLoaded=!0;constructor(e,t,i="main"){super(t),this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}Sa.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e):"rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e||"node"===e||"model:node"===e};const Ia="$graveyard";class Oa extends(Ae()){model;history;selection;roots;differ;isReadOnly;_postFixers;_hasSelectionChangedFromTheLastChangeBlock;constructor(e){super(),this.model=e,this.history=new Pa,this.selection=new Lo(this),this.roots=new ni({idProperty:"rootName"}),this.differ=new Ca(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",Ia),this.listenTo(e,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)},{priority:"high"}),this.listenTo(e,"applyOperation",(e,t)=>{const i=t[0];i.isDocumentOperation&&this.history.addOperation(i)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(e,t,i,n,s)=>{const o={...t.getData(),range:n};this.differ.bufferMarkerChange(t.name,s,o),null===i&&t.on("change",(e,i)=>{const n=t.getData();this.differ.bufferMarkerChange(t.name,{...n,range:i},n)})}),this.registerPostFixer(e=>{let t=!1;for(const i of this.roots)i.isAttached()||i.isEmpty||(e.remove(e.createRangeIn(i)),t=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(e.removeMarker(i),t=!0);return t})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(Ia)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new fe("model-document-createroot-name-exists",this,{name:t});const i=new Sa(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(e=>e.rootName)}getRoots(e=!1){return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=Zi(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,n=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(n)||t.createRange(n)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&Ra(e.start)&&Ra(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 Ra(e){const t=e.textNode;if(t){const i=t.data,n=e.offset-t.startOffset;return!pi(i,n)&&!bi(i,n)}return!0}class Va extends(Ae()){_markers=new Map;[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Ba?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,n=!1){const s=e instanceof Ba?e.name:e;if(s.includes(","))throw new fe("markercollection-incorrect-marker-name",this);const o=this._markers.get(s);if(o){const e=o.getData(),r=o.getRange();let a=!1;return r.isEqual(t)||(o._attachLiveRange(Vo.fromRange(t)),a=!0),i!=o.managedUsingOperations&&(o._managedUsingOperations=i,a=!0),"boolean"==typeof n&&n!=o.affectsData&&(o._affectsData=n,a=!0),a&&this.fire(`update:${s}`,o,r,t,e),o}const r=Vo.fromRange(t),a=new Ba(s,r,i,n);return this._markers.set(s,a),this.fire(`update:${s}`,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof Ba?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof Ba?e.name:e,i=this._markers.get(t);if(!i)throw new fe("markercollection-refresh-marker-not-exists",this);const n=i.getRange();this.fire(`update:${t}`,i,n,n,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class Ba extends(Ae(ro)){name;_managedUsingOperations;_affectsData;_liveRange;constructor(e,t,i,n){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new fe("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new fe("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new fe("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new fe("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new fe("marker-destroyed",this);return this._liveRange.toRange()}toJSON(){return{name:this.name,range:this._liveRange?.toJSON(),usingOperations:this._managedUsingOperations,affectsData:this._affectsData}}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}Ba.prototype.is=function(e){return"marker"===e||"model:marker"===e};class Ma extends Hr{sourcePosition;howMany;constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new fe("detach-operation-on-document-node",this)}_execute(){Wr(bo._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class Fa extends ro{markers=new Map;_children=new Ho;constructor(e){super(),e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(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($o.fromJSON(i)):t.push(Fo.fromJSON(i));return new Fa(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Fo(e)];Ke(e)||(e=[e]);return Array.from(e).map(e=>"string"==typeof e?new Fo(e):e instanceof ao?new Fo(e.data,e.getAttributes()):e)}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}}Fa.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class Na{model;batch;constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new Fo(e,t)}createElement(e,t){return new $o(e,t)}createDocumentFragment(){return new Fa}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Fo&&""==e.data)return;const n=uo._createAt(t,i);if(e.parent){if($a(e.root,n.root))return void this.move(bo._createOn(e),n);if(e.root.document)throw new fe("model-writer-insert-forbidden-move",this);this.remove(e)}const s=n.root.document?n.root.document.version:null,o=e instanceof Fa?e._removeChildren(0,e.childCount):e,r=new Yr(n,o,s);if(e instanceof Fo&&(r.shouldReceiveAttributes=!0),this.batch.addOperation(r),this.model.applyOperation(r),e instanceof Fa)for(const[t,i]of e.markers){const e=uo._createAt(i.root,0),s={range:new bo(i.start._getCombined(e,n),i.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,s):this.addMarker(t,s)}}insertText(e,t,i,n){t instanceof Fa||t instanceof $o||t instanceof uo?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof Fa||t instanceof $o||t instanceof uo?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,n)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof Fa||t instanceof $o?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof Fa||t instanceof $o?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof bo){const n=i.getMinimalFlatRanges();for(const i of n)La(this,e,t,i)}else Da(this,e,t,i)}setAttributes(e,t){for(const[i,n]of di(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof bo){const i=t.getMinimalFlatRanges();for(const t of i)La(this,e,null,t)}else Da(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof bo)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof bo))throw new fe("writer-move-invalid-range",this);if(!e.isFlat)throw new fe("writer-move-range-not-flat",this);const n=uo._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!$a(e.root,n.root))throw new fe("writer-move-different-document",this);const s=e.root.document?e.root.document.version:null,o=new Jr(e.start,e.end.offset-e.start.offset,n,s);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof bo?e:bo._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Ha(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof $o))throw new fe("writer-merge-no-element-before",this);if(!(i instanceof $o))throw new fe("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(bo._createIn(i),uo._createAt(t,"end")),this.remove(i)}_merge(e){const t=uo._createAt(e.nodeBefore,"end"),i=uo._createAt(e.nodeAfter,0),n=e.root.document.graveyard,s=new uo(n,[0]),o=e.root.document.version,r=new Xr(i,e.nodeAfter.maxOffset,t,s,o);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof $o))throw new fe("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new ia(uo._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){this._assertWriterUsedCorrectly();let i,n,s=e.parent;if(!s.parent)throw new fe("writer-split-element-no-parent",this);if(t||(t=s.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new fe("writer-split-invalid-limit-element",this);do{const t=s.root.document?s.root.document.version:null,o=s.maxOffset-e.offset,r=Qr.getInsertionPosition(e),a=new Qr(e,o,r,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=s,n=e.parent.nextSibling),s=(e=this.createPositionAfter(e.parent)).parent}while(s!==t);return{position:e,range:new bo(uo._createAt(i,"end"),uo._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new fe("writer-wrap-range-not-flat",this);const i=t instanceof $o?t:new $o(t);if(i.childCount>0)throw new fe("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new fe("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new bo(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,uo._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new fe("writer-unwrap-element-no-parent",this);this.move(bo._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new fe("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,n=t.range,s=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new fe("writer-addmarker-marker-exists",this);if(!n)throw new fe("writer-addmarker-no-range",this);return i?(za(this,e,null,n,s),this.model.markers.get(e)):this.model.markers._set(e,n,i,s)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new fe("writer-updatemarker-marker-not-exists",this);if(!t)return pe("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(n);const s="boolean"==typeof t.usingOperation,o="boolean"==typeof t.affectsData,r=o?t.affectsData:n.affectsData;if(!s&&!t.range&&!o)throw new fe("writer-updatemarker-wrong-options",this);const a=n.getRange(),l=t.range?t.range:a;s&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?za(this,i,null,l,r):(za(this,i,a,null,r),this.model.markers._set(i,l,void 0,r)):n.managedUsingOperations?za(this,i,a,l,r):this.model.markers._set(i,l,void 0,r)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new fe("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);za(this,t,i.getRange(),null,i.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new fe("writer-addroot-root-exists",this);const n=this.model.document,s=new sa(e,t,!0,n,n.version);return this.batch.addOperation(s),this.model.applyOperation(s),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new fe("writer-detachroot-no-root",this);for(const e of this.model.markers)e.getRange().root===t&&this.removeMarker(e);for(const e of t.getAttributeKeys())this.removeAttribute(e,t);this.remove(this.createRangeIn(t));const i=this.model.document,n=new sa(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(n),this.model.applyOperation(n)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of di(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=Lo._getStoreAttributeKey(e);this.setAttribute(n,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=Lo._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new fe("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let s=!1;if("move"===e){const e=t;s=e.containsPosition(n.start)||e.start.isEqual(n.start)||e.containsPosition(n.end)||e.end.isEqual(n.end)}else{const e=t,i=e.nodeBefore,o=e.nodeAfter,r=n.start.parent==i&&n.start.isAtEnd,a=n.end.parent==o&&0==n.end.offset,l=n.end.nodeAfter==o,c=n.start.nodeAfter==o;s=r||a||l||c}s&&this.updateMarker(i.name,{range:n})}}}function La(e,t,i,n){const s=e.model,o=s.document;let r,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),r&&a!=l&&(a!=i&&d(),c=r),r=e.nextPosition,a=l;function d(){const n=new bo(c,r),l=n.root.document?o.version:null,d=new ea(n,t,a,i,l);e.batch.addOperation(d),s.applyOperation(d)}r instanceof uo&&r!=c&&a!=i&&d()}function Da(e,t,i,n){const s=e.model,o=s.document,r=n.getAttribute(t);let a,l;if(r!=i){if(n.root===n){const e=n.document?o.version:null;l=new na(n,t,r,i,e)}else{a=new bo(uo._createBefore(n),e.createPositionAfter(n));const s=a.root.document?o.version:null;l=new ea(a,t,r,i,s)}e.batch.addOperation(l),s.applyOperation(l)}}function za(e,t,i,n,s){const o=e.model,r=o.document,a=new Zr(t,i,n,o.markers,!!s,r.version);e.batch.addOperation(a),o.applyOperation(a)}function Ha(e,t,i,n){let s;if(e.root.document){const i=n.document,o=new uo(i.graveyard,[0]);s=new Jr(e,t,o,i.version)}else s=new Ma(e,t);i.addOperation(s),n.applyOperation(s)}function $a(e,t){return e===t||e instanceof Sa&&t instanceof Sa}function Wa(e){e.document.registerPostFixer(t=>function(e,t){const i=t.document.selection,n=t.schema,s=[];let o=!1;for(const e of i.getRanges()){const t=ja(e,n);t&&!t.isEqual(e)?(s.push(t),o=!0):s.push(e)}o&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n<t.length;){const e=t[n],s=t.slice(0,n);for(const[o,r]of s.entries())if(!i.has(o))if(e.isEqual(r))i.add(o);else if(e.isIntersecting(r)){i.add(o),i.add(n);const s=e.getJoined(r);t.push(s)}n++}return t.filter((e,t)=>!i.has(t))}(s),{backward:i.isBackward});return!1}(t,e))}function ja(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n){const e=i.getAncestors().reverse().find(e=>t.isObject(e));return e?bo._createOn(e):null}if(!n.isCollapsed)return n;const s=n.start;if(i.isEqual(s))return null;return new bo(s)}(e,t):function(e,t){const{start:i,end:n}=e,s=t.checkChild(i,"$text"),o=t.checkChild(n,"$text"),r=t.getLimitElement(i),a=t.getLimitElement(n);if(r===a){if(s&&o)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),s=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||s}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),s=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),o=e?e.start:i,r=s?s.end:n;return new bo(o,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,s=l&&(!e||!qa(i.nodeAfter,t)),o=c&&(!e||!qa(n.nodeBefore,t));let d=i,u=n;return s&&(d=uo._createBefore(Ua(r,t))),o&&(u=uo._createAfter(Ua(a,t))),new bo(d,u)}return null}(e,t)}function Ua(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function qa(e,t){return e&&t.isSelectable(e)}function Ka(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const s=e.schema;e.change(e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const n=t.getFirstRange();if(n.start.parent==n.end.parent)return!1;return e.checkChild(i,"paragraph")}(s,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),Qa(e,e.createPositionAt(i,0),t)}(e,t);const o={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(o,s.getAttributesWithProperty(e,"copyOnReplace",!0))}let r,a;i.doNotFixSelection?(r=_a.fromPosition(n.start,"toPrevious"),a=_a.fromPosition(n.end,"toNext")):[r,a]=function(e){const t=e.root.document.model,i=e.start;let n=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of n){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const s=i.getLastPosition(),o=t.createRange(s,n);t.hasContent(o,{ignoreMarkers:!0})||(n=s)}}return[_a.fromPosition(i,"toPrevious"),_a.fromPosition(n,"toNext")]}(n),r.isTouching(a)||e.remove(e.createRange(r,a)),i.leaveUnmerged||(!function(e,t,i){const n=e.model;if(!Ya(e.model.schema,t,i))return;const[s,o]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let s=0;for(;i[s]&&i[s]==n[s];)s++;return[i[s],n[s]]}(t,i);if(!s||!o)return;!n.hasContent(s,{ignoreMarkers:!0})&&n.hasContent(o,{ignoreMarkers:!0})?Ja(e,t,i,s.parent):Ga(e,t,i,s.parent)}(e,r,a),s.removeDisallowedAttributes(r.parent.getChildren(),e)),Xa(e,t,r),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(s,r)&&Qa(e,r,t,o),r.detach(),a.detach()})}function Ga(e,t,i,n){const s=t.parent,o=i.parent;if(s!=n&&o!=n){for(t=e.createPositionAfter(s),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(o,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}Ya(e.model.schema,t,i)&&Ga(e,t,i,n)}}function Ja(e,t,i,n){const s=t.parent,o=i.parent;if(s!=n&&o!=n){for(t=e.createPositionAfter(s),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(s,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(o),function(e,t){const i=t.nodeBefore,n=t.nodeAfter;i.name!=n.name&&e.rename(i,n.name);e.clearAttributes(i),e.setAttributes(Object.fromEntries(n.getAttributes()),i),e.merge(t)}(e,i),Ya(e.model.schema,t,i)&&Ja(e,t,i,n)}}function Ya(e,t,i){const n=t.parent,s=i.parent;return n!=s&&(!e.isLimit(n)&&!e.isLimit(s)&&function(e,t,i){const n=new bo(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e))}function Qa(e,t,i,n={}){const s=e.createElement("paragraph");e.model.schema.setAllowedAttributes(s,n,e),e.insert(s,t),Xa(e,i,e.createPositionAt(s,0))}function Xa(e,t,i){t instanceof Lo?e.setSelection(i):t.setTo(i)}function Za(e,t){const i=[];Array.from(e.getItems({direction:"backward"})).map(e=>t.createRangeOn(e)).filter(t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end))).forEach(e=>{i.push(e.start.parent),t.remove(e)}),i.forEach(e=>{let i=e;for(;i.parent&&i.isEmpty;){const e=t.createRangeOn(i);i=i.parent,t.remove(e)}})}class el{model;writer;position;canMergeWith;schema;_documentFragment;_documentFragmentPosition;_firstNode=null;_lastNode=null;_lastAutoParagraph=null;_filterAttributesAndChildrenOf=[];_affectedStart=null;_affectedEnd=null;_nodeToSelect=null;constructor(e,t,i){this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const t of Array.from(e))t.offsetSize>0&&this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesAndChildrenOf,this.writer),!1!==this.model._config?.get("experimentalFlags.modelInsertContentDeepSchemaVerification")&&this._removeDisallowedChildren(this._filterAttributesAndChildrenOf),this._filterAttributesAndChildrenOf=[]}_removeDisallowedChildren(e){const t=Array.from(e);for(const e of t){if(!e.is("element"))continue;const i=[],n=[],s=this.writer.createRangeIn(e).getWalker({ignoreElementEnd:!0});for(const{item:e}of s){const o=e.parent;this.schema.checkChild(o,e)||(e.is("element")&&!this.schema.isObject(e)?(n.push(e),t.push(o)):i.push(e),s.jumpTo(this.writer.createPositionAfter(e)))}for(const e of n)this.writer.unwrap(e);for(const e of i)this.writer.remove(e)}}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new fe("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?bo._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new bo(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){this._checkAndSplitToAllowedPosition(e)?(e=this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e):this.schema.isObject(e)||this._handleDisallowedNode(e)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=_a.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleDisallowedNode(e){e.is("element")&&this.handleNodes(e.getChildren())}_appendToFragment(e){if(!this.schema.checkChild(this.position,e))throw new fe("insertcontent-wrong-position",this,{node:e,position:this.position});return this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),e.parent||(e=this._documentFragmentPosition.nodeBefore),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesAndChildrenOf.push(e),e}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=_a.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=_a.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof $o))return;if(!this._canMergeLeft(e))return;const t=_a._createBefore(e);t.stickiness="toNext";const i=_a.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=_a._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=_a._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof $o))return;if(!this._canMergeRight(e))return;const t=_a._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new fe("insertcontent-invalid-insertion-position",this);this.position=uo._createAt(t.nodeBefore,"end");const i=_a.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=_a._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=_a._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof $o&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof $o&&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 e=this.position.parent;this.position=this.writer.createPositionBefore(e),e.isEmpty&&e.parent===t&&this.writer.remove(e)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const e=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=e,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){const i=this.schema.createContext(e);return this.schema.checkChild(i,t)||this.schema.checkChild(i,"paragraph")&&this.schema.checkChild(i.push("paragraph"),t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function tl(e,t,i,n={}){if(!e.schema.isObject(t))throw new fe("insertobject-element-not-an-object",e,{object:t});const s=i||e.document.selection;let o=s;n.findOptimalPosition&&e.schema.isBlock(t)&&(o=e.createSelection(e.schema.findOptimalInsertionRange(s,n.findOptimalPosition)));const r=si(s.getSelectedBlocks()),a={};return r&&Object.assign(a,e.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),e.change(i=>{o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});let s=t;const r=o.anchor.parent,l=e.schema.createContext(r);!e.schema.checkChild(l,t)&&e.schema.checkChild(l,"paragraph")&&e.schema.checkChild(l.push("paragraph"),t)&&(s=i.createElement("paragraph"),i.insert(t,s)),e.schema.setAllowedAttributes(s,a,i);const c=e.insertContent(s,o);return c.isCollapsed||n.setSelection&&function(e,t,i,n){const s=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new fe("insertobject-invalid-place-parameter-value",s);let o=t.nextSibling;if(s.schema.isInline(t))return void e.setSelection(t,"after");const r=o&&s.schema.checkChild(o,"$text");!r&&s.schema.checkChild(t.parent,"paragraph")&&(o=e.createElement("paragraph"),s.schema.setAllowedAttributes(o,n,e),s.insertContent(o,e.createPositionAfter(t)));o&&e.setSelection(o,0)}(i,t,n.setSelection,a),c})}function il(e,t){const{isForward:i,walker:n,unit:s,schema:o,treatEmojiAsSingleUnit:r}=e,{type:a,item:l,nextPosition:c}=t;if("text"==a)return"word"===e.unit?function(e,t){let i=e.position.textNode;i||(i=t?e.position.nodeAfter:e.position.nodeBefore);for(;i&&i.is("$text");){const n=e.position.offset-i.startOffset;if(ol(i,n,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(sl(i.data,n,t))break;e.next()}}return e.position}(n,i):function(e,t,i){const n=e.position.textNode;if(n){const s=n.data;let o=e.position.offset-n.startOffset;for(;pi(s,o)||"character"==t&&bi(s,o)||i&&_i(s,o);)e.next(),o=e.position.offset-n.startOffset}return e.position}(n,s,r);if(a==(i?"elementStart":"elementEnd")){if(o.isSelectable(l))return uo._createAt(l,i?"after":"before");if(o.checkChild(c,"$text"))return c}else{if(o.isLimit(l))return void n.skip(()=>!0);if(o.checkChild(c,"$text"))return c}}function nl(e,t){const i=e.root,n=uo._createAt(i,t?"end":0);return t?new bo(e,n):new bo(n,e)}function sl(e,t,i){const n=t+(i?0:-1);return' ,.?!:;"-()'.includes(e.charAt(n))}function ol(e,t,i){return t===(i?e.offsetSize:0)}class rl extends(Le()){markers;document;schema;_config;_pendingChanges;_currentWriter;constructor(e){super(),this.markers=new Va,this.document=new Oa(this),this.schema=new _r,this._config=e,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(e=>this.decorate(e)),this.on("applyOperation",(e,t)=>{t[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(()=>!0,"$marker"),Wa(this),this.document.registerPostFixer(lr),this.on("insertContent",(e,[t,i])=>{e.return=function(e,t,i){return e.change(n=>{const s=i||e.document.selection;s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});const o=new el(e,n,s.anchor),r=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,n]of t.markers){const{start:t,end:s}=n,o=t.isEqual(s);e.push({position:t,name:i,isCollapsed:o},{position:s,name:i,isCollapsed:o})}e.sort(({position:e},{position:t})=>e.isBefore(t)?1:-1);for(const{position:i,name:s,isCollapsed:o}of e){let e=null,a=null;const l=i.parent===t&&i.isAtStart,c=i.parent===t&&i.isAtEnd;l||c?o&&(a=l?"start":"end"):(e=n.createElement("$marker"),n.insert(e,i)),r.push({name:s,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];o.handleNodes(a);let l=o.getSelectionRange();if(t.is("documentFragment")&&r.length){const e=l?Vo.fromRange(l):null,t={};for(let e=r.length-1;e>=0;e--){const{name:i,element:s,collapsed:a}=r[e],l=!t[i];if(l&&(t[i]=[]),s){const e=n.createPositionAt(s,"before");t[i].push(e),n.remove(s)}else{const e=o.getAffectedRange();if(!e){a&&t[i].push(o.position);continue}a?t[i].push(e[a]):t[i].push(l?e.start:e.end)}}for(const[e,[i,s]]of Object.entries(t))i&&s&&i.root===s.root&&i.root.document&&!n.model.markers.has(e)&&n.addMarker(e,{usingOperation:!0,affectsData:!0,range:new bo(i,s)});e&&(l=e.toRange(),e.detach())}l&&(s instanceof Lo?n.setSelection(l):s.setTo(l));const c=o.getAffectedRange()||e.createRange(s.anchor);return o.destroy(),c})}(this,t,i)}),this.on("insertObject",(e,[t,i,n])=>{e.return=tl(this,t,i,n)}),this.on("canEditAt",e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()})}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new ka,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){fe.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new ka):e instanceof ka||(e=new ka(e)):e=new ka,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){fe.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...n){const s=al(t,i);return this.fire("insertContent",[e,s,i,...n])}insertObject(e,t,i,n,...s){const o=al(t,i);return this.fire("insertObject",[e,o,n,n,...s])}deleteContent(e,t){Ka(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,s="backward"!=i.direction,o=i.unit?i.unit:"character",r=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new lo({boundaries:nl(a,s),singleCharacters:!0,direction:s?"forward":"backward"}),c={walker:l,schema:n,isForward:s,unit:o,treatEmojiAsSingleUnit:r};let d;for(;d=l.next();){if(d.done)return;const i=il(c,d.value);if(i)return void(t instanceof Lo?e.change(e=>{e.setSelectionFocus(i)}):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change(e=>{const i=e.createDocumentFragment(),n=t.getFirstRange();if(!n||n.isCollapsed)return i;const s=n.start.root,o=n.start.getCommonPath(n.end),r=s.getNodeByPath(o);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(r,n.start.path[o.length]),e.createPositionAt(r,n.end.path[o.length]+1));const l=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),i):e.append(e.cloneElement(t,!0),i);if(a!=n){const t=n._getTransformedByMove(a.start,e.createPositionAt(i,0),l)[0],s=e.createRange(e.createPositionAt(i,0),t.start);Za(e.createRange(t.end,e.createPositionAt(i,"end")),e),Za(s,e)}return i})}(this,e)}hasContent(e,t={}){let i;i=e.is("selection")?Array.from(e.getRanges()):e.is("range")?[e]:[bo._createIn(e)];for(const e of i)if(this._rangeHasContent(e,t))return!0;return!1}_rangeHasContent(e,t){if(e.isCollapsed)return!1;const{ignoreWhitespaces:i=!1,ignoreMarkers:n=!1}=t;if(!n)for(const t of this.markers.getMarkersIntersectingRange(e))if(t.affectsData)return!0;for(const t of e.getItems())if(this.schema.isContent(t)){if(!t.is("$textProxy"))return!0;if(!i)return!0;if(-1!==t.data.search(/\S/))return!0}return!1}canEditAt(e){const t=al(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new uo(e,t,i)}createPositionAt(e,t){return uo._createAt(e,t)}createPositionAfter(e){return uo._createAfter(e)}createPositionBefore(e){return uo._createBefore(e)}createRange(e,t){return new bo(e,t)}createRangeIn(e){return bo._createIn(e)}createRangeOn(e){return bo._createOn(e)}createSelection(...e){return new Eo(...e)}createBatch(e){return new ka(e)}createOperationFromJSON(e){return ra.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new Na(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}function al(e,t){if(e)return e instanceof Eo||e instanceof Lo?e:e instanceof To?t||0===t?new Eo(e,t):e.is("rootElement")?new Eo(e,"in"):new Eo(e,"on"):new Eo(e)}class ll extends qs{domEventType="click";onDomEvent(e){this.fire(e.type,e)}}class cl extends qs{domEventType=["mousedown","mouseup","mouseover","mouseout"];onDomEvent(e){this.fire(e.type,e)}}class dl extends qs{domEventType=["touchstart","touchend","touchmove"];onDomEvent(e){this.fire(e.type,e)}}class ul extends qs{domEventType=["pointerdown","pointerup","pointermove"];onDomEvent(e){this.fire(e.type,e)}}class hl{document;constructor(e){this.document=e}createDocumentFragment(e){return new as(this.document,e)}createElement(e,t,i){return new En(this.document,e,t,i)}createText(e){return new un(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 n=i.getChildIndex(e);return this.removeChildren(n,1,i),this.insertChild(n,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 En(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){s(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return Mn._createAt(e,t)}createPositionAfter(e){return Mn._createAfter(e)}createPositionBefore(e){return Mn._createBefore(e)}createRange(e,t){return new Fn(e,t)}createRangeOn(e){return Fn._createOn(e)}createRangeIn(e){return Fn._createIn(e)}createSelection(...e){return new Ln(...e)}}const ml=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,gl=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,fl=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,pl=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,bl=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,wl=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,_l=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 vl(e){return e.startsWith("#")?ml.test(e):e.startsWith("rgb")?gl.test(e)||fl.test(e):e.startsWith("hsl")?pl.test(e)||bl.test(e):_l.has(e.toLowerCase())}const yl=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function kl(e){return yl.includes(e)}const Cl=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function Al(e){return Cl.test(e)}const Tl=/^[+-]?[0-9]*([.][0-9]+)?%$/;function El(e){return Tl.test(e)}const xl=["auto","cover","contain"];function Pl(e){return xl.includes(e)||Al(e)||El(e)}const Sl=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function Il(e){return Sl.includes(e)}const Ol=["center","top","bottom","left","right"];function Rl(e){return Ol.includes(e)}const Vl=["fixed","scroll","local"];function Bl(e){return Vl.includes(e)}const Ml=["border-box","padding-box","content-box"];function Fl(e){return Ml.includes(e)}const Nl=["border-box","padding-box","content-box","text"];function Ll(e){return Nl.includes(e)}function Dl(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=Wl(e),i=t[0],n=t[2]||i,s=t[1]||i;return{top:i,bottom:n,right:s,left:t[3]||s}}function zl(e){return t=>{const{top:i,right:n,bottom:s,left:o}=t,r=[];return[i,n,o,s].every(e=>!!e)?r.push([e,Hl(t)]):(i&&r.push([e+"-top",i]),n&&r.push([e+"-right",n]),s&&r.push([e+"-bottom",s]),o&&r.push([e+"-left",o])),r}}function Hl({top:e,right:t,bottom:i,left:n}){const s=[];return n!==t?s.push(e,t,i,n):i!==e?s.push(e,t,i):t!==e?s.push(e,t):s.push(e),s.join(" ")}function $l(e){return t=>({path:e,value:Dl(t)})}function Wl(e){const t=e.trim().slice(0,1500).matchAll(wl);return Array.from(t).map(e=>e[0])}const jl={image:"none",repeat:"repeat",position:"0% 0%",size:"auto",origin:"padding-box",clip:"border-box",attachment:"scroll"},Ul=["linear-gradient","repeating-linear-gradient","radial-gradient","repeating-radial-gradient","conic-gradient","repeating-conic-gradient","url"];function ql(e){e.setNormalizer("background-color",e=>({path:"background.color",value:e}));for(const t in jl)e.setNormalizer(`background-${t}`,Kl(`background.${t}`)),e.setReducer(`background-${t}`,Gl(`background-${t}`));e.setNormalizer("background",e=>{const t=function(e){return Ql(e).map(Jl).filter(e=>null!==e)}(e);t.length||t.push({...Yl(),color:e});const i=function(e){const t={image:[],position:[],size:[],repeat:[],attachment:[],origin:[],clip:[]};for(const i of e)t.position.push(i.position.join(" ")),t.size.push(i.size.join(" ")),t.repeat.push(i.repeat.join(" ")),t.image.push(i.image),t.attachment.push(i.attachment),t.origin.push(i.origin),t.clip.push(i.clip);return e.at(-1)?.color&&(t.color=e.at(-1).color),t}(t);return{path:"background",value:i}}),e.setReducer("background",e=>{const t=e,i=Object.keys(jl).every(e=>{const i=t[e];return void 0!==i&&(!Array.isArray(i)||i.length>0)});return i?function(e){const t=[],i=function(e){const t=function(e){let t=0;for(const i of Object.values(e))Array.isArray(i)&&i.length>t&&(t=i.length);return t}(e),i=Array.from({length:t},(t,i)=>{const n=Yl();return e.image?.[i]&&(n.image=e.image[i]),e.position?.[i]&&(n.position=e.position[i].split(" ")),e.size?.[i]&&(n.size=e.size[i].split(" ")),e.repeat?.[i]&&(n.repeat=e.repeat[i].split(" ")),e.attachment?.[i]&&(n.attachment=e.attachment[i]),e.origin?.[i]&&(n.origin=e.origin[i]),e.clip?.[i]&&(n.clip=e.clip[i]),n});return e.color&&(i.at(-1).color=e.color),i}(e).map(e=>function(e){const t=[];e.image&&e.image!==jl.image&&t.push(e.image);const i=e.position.join(" "),n=!i||i===jl.position;n||t.push(i);const s=e.size.join(" ");s&&s!==jl.size&&(n&&t.push("0% 0%"),t.push("/",s));const o=e.repeat.join(" ");o&&o!==jl.repeat&&t.push(o),e.attachment&&e.attachment!==jl.attachment&&t.push(e.attachment);const r=e.origin===jl.origin,a=e.clip===jl.clip;return r&&a||(t.push(e.origin),e.clip!==e.origin&&t.push(e.clip)),e.color&&t.push(e.color),t.join(" ")}(e).trim()).filter(Boolean).join(", ");return i&&t.push(["background",i]),t}(t):function(e){const t=[];for(const i in jl){const n=e[i];Array.isArray(n)&&t.push([`background-${i}`,n.join(", ")])}return void 0!==e.color&&t.push(["background-color",e.color]),t}(t)}),e.setStyleRelation("background",["background-color","background-image","background-repeat","background-position","background-size","background-attachment","background-origin","background-clip"])}function Kl(e){return t=>({path:e,value:Ql(t)})}function Gl(e){return t=>{const i=t.join(", ");return[[e,i]]}}function Jl(e){const t={},{value:i,image:n}=function(e){for(const t of Ul){const i=t+"(",n=e.indexOf(i);if(n<0)continue;let s=t,o=0;for(let i=n+t.length;i<e.length;i++){const t=e[i];if("("===t?o++:")"===t&&o--,s+=t,0===o)return{value:e.slice(0,n)+e.slice(i+1),image:s}}}if(e.includes("none"))return{value:e.replace("none",""),image:"none"};return{value:e,image:null}}(e),s=Wl(i);n&&(t.image=n);for(let e=0;e<s.length;e++){const i=s[e];if("/"===i)for(t.size=[];e+1<s.length&&Pl(s[e+1]);)t.size.push(s[++e]);else Il(i)?(t.repeat||=[],t.repeat.push(i)):Rl(i)||El(i)?(t.position||=[],t.position.push(i),e+1<s.length&&El(i)&&El(s[e+1])&&t.position.push(s[++e])):Bl(i)?t.attachment=i:Ll(i)?Fl(i)&&!t.origin?(t.origin=i,t.clip=i):t.clip=i:vl(i)&&(t.color=i)}return function(e){if(null==e)return!0;if(z(e))return!!("function"==typeof e.splice||"string"==typeof e||"undefined"!=typeof Buffer&&Buffer.isBuffer(e)||W(e)||D(e))&&0===e.length;if("object"==typeof e){if(e instanceof Map||e instanceof Set)return 0===e.size;const t=Object.keys(e);return Ti(e)?0===t.filter(e=>"constructor"!==e).length:0===t.length}return!0}(t)?null:{...Yl(),...t}}function Yl(){return{attachment:jl.attachment,image:jl.image,origin:jl.origin,clip:jl.clip,position:jl.position.split(" "),repeat:jl.repeat.split(" "),size:jl.size.split(" ")}}function Ql(e){const t=[];let i="",n=0;for(const s of e){if("("===s)n++;else if(")"===s)n--;else if(","===s&&0===n){t.push(i.trim()),i="";continue}i+=s}return i.trim()&&t.push(i.trim()),t}function Xl(e){e.setNormalizer("border",e=>{const{color:t,style:i,width:n}=oc(e);return{path:"border",value:{color:Dl(t),style:Dl(i),width:Dl(n)}}}),e.setNormalizer("border-top",Zl("top")),e.setNormalizer("border-right",Zl("right")),e.setNormalizer("border-bottom",Zl("bottom")),e.setNormalizer("border-left",Zl("left")),e.setNormalizer("border-color",ec("color")),e.setNormalizer("border-width",ec("width")),e.setNormalizer("border-style",ec("style")),e.setNormalizer("border-top-color",ic("color","top")),e.setNormalizer("border-top-style",ic("style","top")),e.setNormalizer("border-top-width",ic("width","top")),e.setNormalizer("border-right-color",ic("color","right")),e.setNormalizer("border-right-style",ic("style","right")),e.setNormalizer("border-right-width",ic("width","right")),e.setNormalizer("border-bottom-color",ic("color","bottom")),e.setNormalizer("border-bottom-style",ic("style","bottom")),e.setNormalizer("border-bottom-width",ic("width","bottom")),e.setNormalizer("border-left-color",ic("color","left")),e.setNormalizer("border-left-style",ic("style","left")),e.setNormalizer("border-left-width",ic("width","left")),e.setExtractor("border-top",nc("top")),e.setExtractor("border-right",nc("right")),e.setExtractor("border-bottom",nc("bottom")),e.setExtractor("border-left",nc("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",zl("border-color")),e.setReducer("border-style",zl("border-style")),e.setReducer("border-width",zl("border-width")),e.setReducer("border-top",rc("top")),e.setReducer("border-right",rc("right")),e.setReducer("border-bottom",rc("bottom")),e.setReducer("border-left",rc("left")),e.setReducer("border",function(){return t=>{const i=sc(t,"top"),n=sc(t,"right"),s=sc(t,"bottom"),o=sc(t,"left"),r=[i,n,s,o],a={width:e(r,"width"),style:e(r,"style"),color:e(r,"color")},l=ac(a,"all");if(l.length)return l;const c=Object.entries(a).reduce((e,[t,i])=>(i&&(e.push([`border-${t}`,i]),r.forEach(e=>delete e[t])),e),[]);return[...c,...ac(i,"top"),...ac(n,"right"),...ac(s,"bottom"),...ac(o,"left")]};function e(e,t){return e.map(e=>e[t]).reduce((e,t)=>e==t?e:null)}}()),e.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Zl(e){return t=>{const{color:i,style:n,width:s}=oc(t),o={};return void 0!==i&&(o.color={[e]:i}),void 0!==n&&(o.style={[e]:n}),void 0!==s&&(o.width={[e]:s}),{path:"border",value:o}}}function ec(e){return t=>({path:"border",value:tc(t,e)})}function tc(e,t){return{[t]:Dl(e)}}function ic(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function nc(e){return(t,i)=>{if(i.border)return sc(i.border,e)}}function sc(e,t){const i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function oc(e){const t={},i=Wl(e);for(const e of i)Al(e)||/thin|medium|thick/.test(e)?t.width=e:kl(e)?t.style=e:t.color=e;return t}function rc(e){return t=>ac(t,e)}function ac(e,t){const i=[];if(e&&e.width&&i.push("width"),e&&e.style&&i.push("style"),e&&e.color&&i.push("color"),3==i.length){const n=i.map(t=>e[t]).join(" ");return["all"==t?["border",n]:[`border-${t}`,n]]}return"all"==t?[]:i.map(i=>[`border-${t}-${i}`,e[i]])}function lc(e){e.setNormalizer("margin",$l("margin")),e.setNormalizer("margin-top",e=>({path:"margin.top",value:e})),e.setNormalizer("margin-right",e=>({path:"margin.right",value:e})),e.setNormalizer("margin-bottom",e=>({path:"margin.bottom",value:e})),e.setNormalizer("margin-left",e=>({path:"margin.left",value:e})),e.setReducer("margin",zl("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function cc(e){e.setNormalizer("padding",$l("padding")),e.setNormalizer("padding-top",e=>({path:"padding.top",value:e})),e.setNormalizer("padding-right",e=>({path:"padding.right",value:e})),e.setNormalizer("padding-bottom",e=>({path:"padding.bottom",value:e})),e.setNormalizer("padding-left",e=>({path:"padding.left",value:e})),e.setReducer("padding",zl("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}Symbol("_treeDump");class dc{crashes=[];state="initializing";_crashNumberLimit;_now=Date.now;_minimumNonErrorTimePeriod;_boundErrorHandler;_listeners;constructor(e){if(this.crashes=[],this._crashNumberLimit="number"==typeof e.crashNumberLimit?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod="number"==typeof e.minimumNonErrorTimePeriod?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=e=>{const t="error"in e?e.error:e.reason;t instanceof Error&&this._handleError(t,e)},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(e=>e!==t)}_fire(e,...t){const i=this._listeners[e]||[];for(const e of i)e.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")&&void 0!==e.context&&null!==e.context&&"ready"===this.state&&this._isErrorComingFromThisItem(e)}_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;return(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}function uc(e,t=new Set){const i=[e],n=new Set;let s=0;for(;i.length>s;){const e=i[s++];if(!n.has(e)&&hc(e)&&!t.has(e))if(n.add(e),Symbol.iterator in e)try{for(const t of e)i.push(t)}catch{}else for(const t in e)"defaultValue"!==t&&i.push(e[t])}return n}function hc(e){const t=Object.prototype.toString.call(e),i=typeof e;return!("number"===i||"boolean"===i||"string"===i||"symbol"===i||"function"===i||"[object Date]"===t||"[object RegExp]"===t||"[object Module]"===t||null==e||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function mc(e,t,i=new Set){if(e===t&&("object"==typeof(n=e)&&null!==n))return!0;var n;const s=uc(e,i),o=uc(t,i);for(const e of s)if(o.has(e))return!0;return!1}function gc(e,t,i){const n=t.root,s=t.roots||Object.create(null);i&&!s[i]&&(s[i]=n||Object.create(null));const o=function(e){return!!e&&"object"==typeof e&&!Array.isArray(e)&&(t=e,!M(t));var t}(e),r=function(e,t,i){return t||!i?e.initialData||Object.create(null):{[i]:e.initialData}}(t,o,i),a=Array.from(new Set([...o?Object.keys(e):[],...Object.keys(s),...Object.keys(r)]));for(const e of a){const i=s[e]||Object.create(null);i.initialData="",i.placeholder??=fc(t,"placeholder",e),i.label??=fc(t,"label",e),s[e]=i}t.roots=s}function fc(e,t,i){const n=e[t];if(n)return"string"==typeof n?n:n[i]}class pc extends dc{_editor=null;_lifecyclePromise=null;_throttledSave;_data;_lastDocumentVersion;_elementOrData;_editorAttachTo=null;_isSingleRootEditor=!0;_isUsingConfigBasedCreator=!1;_editables={};_config;_excludedProps;constructor(e,t={}){super(t),this._throttledSave=Ai(this._save.bind(this),"number"==typeof t.saveInterval?t.saveInterval:5e3),e&&(this._creator=(t,i)=>void 0===i?e.create(t):e.create(t,i)),this._destructor=e=>e.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(()=>{this._isUsingConfigBasedCreator?gc(this._isSingleRootEditor?"":{},this._config,!!this._isSingleRootEditor&&"main"):gc(this._isSingleRootEditor?this._editorAttachTo||"":this._editables,this._config,!!this._isSingleRootEditor&&"main");const e={...this._config,extraPlugins:this._config.extraPlugins||[],_watchdogInitialData:this._data};e.extraPlugins.push(bc);const t={};for(const[i,n]of Object.entries(this._data.roots)){const s=e.roots[i]||Object.create(null);s.initialData="",n.isLoaded?s.lazyLoad=!1:delete s.modelAttributes,t[i]=s}if(e.roots=t,delete e.initialData,delete e.root,this._isUsingConfigBasedCreator)return this.create(e,e.context);const i=this._isSingleRootEditor?this._editorAttachTo||"":this._editables;return this.create(i,e,e.context)}).then(()=>{this._fire("restart")})}create(e=(this._isUsingConfigBasedCreator?this._config:this._elementOrData),t=(this._isUsingConfigBasedCreator?void 0:this._config),i){const n=this._detectConfigBasedCreator(e,t),s=n?void 0:e,o=n?e:t,r=n?t:i;return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>{if(super._startErrorHandling(),this._isUsingConfigBasedCreator=n,this._elementOrData=s,this._config=this._cloneEditorConfiguration(o||{}),this._config.context=r,n){this._editorAttachTo=null;const e=this._config.roots?Object.keys(this._config.roots).length:0,t=this._config.initialData,i=t&&"object"==typeof t;this._isSingleRootEditor=!i&&e<=1}else this._editorAttachTo=wc(s)?s:null,this._isSingleRootEditor=wc(s)||"string"==typeof s;return n?this._creator(this._config):this._creator(s,this._config)}).then(e=>{this._editor=e,e.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=e.model.document.version,this._data=this._getData(),this._editorAttachTo||(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._editorAttachTo||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(e){console.error(e,"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(e=>e.isAttached()&&"$graveyard"!=e.rootName),{plugins:i}=e,n=i.has("CommentsRepository")&&i.get("CommentsRepository"),s=i.has("TrackChanges")&&i.get("TrackChanges"),o={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach(e=>{o.roots[e.rootName]={content:JSON.stringify(Array.from(e.getChildren())),attributes:JSON.stringify(Array.from(e.getAttributes())),isLoaded:e._isLoaded}});for(const t of e.model.markers)t._affectsData&&(o.markers[t.name]={rangeJSON:t.getRange().toJSON(),usingOperation:t._managedUsingOperations,affectsData:t._affectsData});return n&&(o.commentThreads=JSON.stringify(n.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),s&&(o.suggestions=JSON.stringify(s.getSuggestions({toJSON:!0,skipNotAttached:!0}))),o}_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 mc(this._editor,e.context,this._excludedProps)}_detectConfigBasedCreator(e,t){if("string"==typeof e||wc(e))return!1;if(t&&"object"==typeof t&&!("destroy"in t)&&Object.keys(t).length>0)return!1;if(e&&"object"==typeof e){const t=Object.values(e);if(t.length>0&&t.every(e=>"string"==typeof e||wc(e)))return!1}return!0}_cloneEditorConfiguration(e){return V(e,(e,t)=>wc(e)||"context"===t?e:void 0)}}class bc{editor;_data;constructor(e){this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},e=>{this._restoreCollaborationData(),this._restoreEditorData(e)}),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 n of t.children)i._appendChild(this._createNode(e,n));return i}return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach(([i,{content:n,attributes:s}])=>{const o=JSON.parse(n),r=JSON.parse(s),a=t.model.document.getRoot(i);for(const[t,i]of r)e.setAttribute(t,i,a);for(const t of o){const i=this._createNode(e,t);e.insert(i,a,"end")}}),Object.entries(this._data.markers).forEach(([i,n])=>{const{document:s}=t.model,{rangeJSON:{start:o,end:r},...a}=n,l=s.getRoot(o.root),c=e.createPositionFromPath(l,o.path,o.stickiness),d=e.createPositionFromPath(l,r.path,r.stickiness),u=e.createRange(c,d);e.addMarker(i,{range:u,...a})})}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);if(this.editor.plugins.has("CommentsRepository")){const t=this.editor.plugins.get("CommentsRepository");for(const e of t.getCommentThreads())t._removeCommentThread({threadId:e.id});e.forEach(e=>{const t=this.editor.config.get("collaboration.channelId");this.editor.plugins.get("CommentsRepository").addCommentThread({channelId:t,...e})})}if(this.editor.plugins.has("TrackChangesEditing")){const e=this.editor.plugins.get("TrackChangesEditing");for(const t of e.getSuggestions())e._removeSuggestion(t);t.forEach(t=>{e.addSuggestionData(t)})}}}function wc(e){return M(e)}const _c=Symbol("MainQueueId");class vc extends dc{_watchdogs=new Map;_watchdogConfig;_context=null;_contextProps=new Set;_actionQueues=new yc;_contextConfig;_item;constructor(e,t={}){super(t),this._watchdogConfig=t,this._creator=t=>e.create(t),this._destructor=e=>e.destroy(),this._actionQueues.onEmpty(()=>{"initializing"===this.state&&(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(_c,()=>(this._contextConfig=e,this._create()))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=kc(e);return Promise.all(t.map(e=>this._actionQueues.enqueue(e.id,()=>{if("destroyed"===this.state)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 t;if(this._watchdogs.has(e.id))throw new Error(`Item with the given id is already added: '${e.id}'.`);if("editor"===e.type)return t=new pc(null,this._watchdogConfig),t.setCreator(e.creator),t._setExcludedProperties(this._contextProps),e.destructor&&t.setDestructor(e.destructor),this._watchdogs.set(e.id,t),t.on("error",(i,{error:n,causesRestart:s})=>{this._fire("itemError",{itemId:e.id,error:n}),s&&this._actionQueues.enqueue(e.id,()=>new Promise(i=>{const n=()=>{t.off("restart",n),this._fire("itemRestart",{itemId:e.id}),i()};t.on("restart",n)}))}),void 0!==e.sourceElementOrData?t.create(e.sourceElementOrData,e.config,this._context):t.create(e.config,this._context);throw new Error(`Not supported item type: '${e.type}'.`)})))}remove(e){const t=kc(e);return Promise.all(t.map(e=>this._actionQueues.enqueue(e,()=>{const t=this._getWatchdog(e);return this._watchdogs.delete(e),t.destroy()})))}destroy(){return this._actionQueues.enqueue(_c,()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))}_restart(){return this._actionQueues.enqueue(_c,()=>(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=uc(this._context),Promise.all(Array.from(this._watchdogs.values()).map(e=>(e._setExcludedProperties(this._contextProps),e._isUsingConfigBasedCreator?e.create(void 0,this._context):e.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(e=>e.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 mc(this._context,e.context)}}class yc{_onEmptyCallbacks=[];_queues=new Map;_activeActions=0;onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===_c;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const n=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(_c),this._queues.get(e)])).then(t),s=n.catch(()=>{});return this._queues.set(e,s),n.finally(()=>{this._activeActions--,this._queues.get(e)===s&&0===this._activeActions&&this._onEmptyCallbacks.forEach(e=>e())})}}function kc(e){return Array.isArray(e)?e:[e]}class Cc extends(Le()){editor;_disableStack=new Set;constructor(e){super(),this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Ac,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Ac),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}function Ac(e){e.return=!1,e.stop()}class Tc extends(Le()){editor;_isEnabledBasedOnSelection;_affectsData;_disableStack;static get _throwErrorWhenUsedAsAPlugin(){return!0}constructor(e){super(),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.listenTo(e,"change:isReadOnly",()=>{this.refresh()}),this.on("set:isEnabled",t=>{if(!this.affectsData)return;const i=e.model.document.selection,n=!("$graveyard"==i.getFirstPosition().root.rootName)&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!n)&&(t.return=!1,t.stop())},{priority:"highest"}),this.on("execute",e=>{this.isEnabled||e.stop()},{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Ec,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Ec),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function Ec(e){e.return=!1,e.stop()}class xc extends Tc{_childCommandsDefinitions=[];refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){ge(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:e})=>e.isEnabled);return e&&e.command}}class Pc{_commands;constructor(){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 fe("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 Sc extends(Ae()){_context;_plugins=new Map;_availablePlugins;_contextPlugins;constructor(e,t=[],i=[]){super(),this._context=e,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of i)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new fe("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}async init(e,t=[],i=[]){const n=this,s=this._context;!function e(t,i=new Set){t.forEach(t=>{a(t)&&(i.has(t)||(i.add(t),t.pluginName&&!n._availablePlugins.has(t.pluginName)&&n._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))})}(e),u(e);const o=[...function e(t,i=new Set){return t.map(e=>a(e)?e:n._availablePlugins.get(e)).reduce((t,n)=>i.has(n)?t:(i.add(n),n.requires&&(u(n.requires,n),e(n.requires,i).forEach(e=>t.add(e))),t.add(n)),new Set)}(e.filter(e=>!c(e,t)))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new fe("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new fe("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new fe("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const s=n._availablePlugins.get(t);if(!s)throw new fe("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const o=e.indexOf(s);if(-1===o){if(n._contextPlugins.has(s))return;throw new fe("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(s.requires&&s.requires.length)throw new fe("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(o,1,i),n._availablePlugins.set(t,i)}}(o,i);const r=function(e){return e.map(e=>{let t=n._contextPlugins.get(e);return t=t||new e(s),n._add(e,t),t})}(o);return await h(r,"init"),await h(r,"afterInit"),r;function a(e){return"function"==typeof e}function l(e){return a(e)&&!!e.isContextPlugin}function c(e,t){return t.some(t=>t===e||(d(e)===t||d(t)===e))}function d(e){return a(e)?e.pluginName||e.name:e}function u(e,i=null){e.map(e=>a(e)?e:n._availablePlugins.get(e)||e).forEach(e=>{!function(e){if("function"!=typeof e)return;if(e._throwErrorWhenUsedAsAPlugin)throw new fe("plugincollection-plugin-invalid-constructor",s,{name:e.name})}(e),function(e,t){if(a(e))return;if(t)throw new fe("plugincollection-soft-required",s,{missingPlugin:e,requiredBy:d(t)});throw new fe("plugincollection-plugin-not-found",s,{plugin:e})}(e,i),function(e,t){if(!l(t))return;if(l(e))return;throw new fe("plugincollection-context-required",s,{plugin:d(e),requiredBy:d(t)})}(e,i),function(e,i){if(!i)return;if(!c(e,t))return;throw new fe("plugincollection-required",s,{plugin:d(e),requiredBy:d(i)})}(e,i)})}function h(e,t){return e.reduce((e,i)=>i[t]?n._contextPlugins.has(i)?e:e.then(i[t].bind(i)):e,Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new fe("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class Ic{config;plugins;locale;t;editors;static defaultConfig;static builtinPlugins;_contextOwner=null;constructor(e){const{translations:t,...i}=e||{};this.config=new Je(i,this.constructor.defaultConfig);const n=this.constructor.builtinPlugins;this.config.define("plugins",n),this.plugins=new Sc(this,n);const s=this.config.get("language")||{};this.locale=new ii({uiLanguage:"string"==typeof s?s:s.ui,contentLanguage:this.config.get("language.content"),translations:t}),this.t=this.locale.t,this.editors=new ni}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if("function"!=typeof i)throw new fe("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new fe("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 fe("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))})}static get _throwErrorWhenUsedAsAPlugin(){return!0}}class Oc extends(Le()){context;constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}class Rc extends ci{editor;constructor(e){super(),this.editor=e}set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}const Vc="contentEditing",Bc="common";class Mc{keystrokeInfos=new Map;_editor;constructor(e){this._editor=e;const t=e.config.get("menuBar.isVisible"),i=e.locale.t;this.addKeystrokeInfoCategory({id:Vc,label:i("Content editing keystrokes"),description:i("These keyboard shortcuts allow for quick access to content editing features.")});const n=[{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&&n.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:n}]})}addKeystrokeInfoCategory({id:e,label:t,description:i,groups:n}){this.keystrokeInfos.set(e,{id:e,label:t,description:i,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:e,id:Bc}),n&&n.forEach(t=>{this.addKeystrokeInfoGroup({categoryId:e,...t})})}addKeystrokeInfoGroup({categoryId:e=Vc,id:t,label:i,keystrokes:n}){const s=this.keystrokeInfos.get(e);if(!s)throw new fe("accessibility-unknown-keystroke-info-category",this._editor,{groupId:t,categoryId:e});s.groups.set(t,{id:t,label:i,keystrokes:n||[]})}addKeystrokeInfos({categoryId:e=Vc,groupId:t=Bc,keystrokes:i}){if(!this.keystrokeInfos.has(e))throw new fe("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:e,keystrokes:i});const n=this.keystrokeInfos.get(e);if(!n.groups.has(t))throw new fe("accessibility-unknown-keystroke-info-group",this._editor,{groupId:t,categoryId:e,keystrokes:i});n.groups.get(t).keystrokes.push(...i)}}function Fc(e){return Object.getPrototypeOf(e).constructor.editorName}function Nc(e){if(!e)return;const t=Array.isArray(e)?{items:e}:e,i=function e(t){return t.flatMap(t=>"string"==typeof t?[t]:e(t.items))}(t.items||[]);return{isMultiline:i.includes("-"),shouldNotGroupWhenFull:!!t.shouldNotGroupWhenFull,items:(n=i,n.filter(e=>"|"!==e&&"-"!==e))};var n}function Lc(){let e="unknown",t="unknown";return Q.isMac?e="mac":Q.isWindows?e="windows":Q.isiOS?e="ios":Q.isAndroid&&(e="android"),Q.isGecko?t="gecko":Q.isBlink?t="blink":Q.isSafari&&(t="safari"),{os:e,browser:t}}function Dc(){return localStorage.getItem("__ckeditor-session-id")||localStorage.setItem("__ckeditor-session-id",he()),localStorage.getItem("__ckeditor-session-id")}function zc(){return G.window.CKEDITOR_PAGE_SESSION_ID=G.window.CKEDITOR_PAGE_SESSION_ID||he(),G.window.CKEDITOR_PAGE_SESSION_ID}class Hc extends(Le()){static get editorName(){return"Editor"}accessibility;commands;config;conversion;data;editing;locale;model;plugins;keystrokes;t;static defaultConfig;static builtinPlugins;_context;_readOnlyLocks;static get _throwErrorWhenUsedAsAPlugin(){return!0}constructor(e={}){if(super(),"object"!=typeof e||Array.isArray(e))throw new fe("editor-config-invalid-type");if("sanitizeHtml"in e)throw new fe("editor-config-sanitizehtml-not-supported");const t=this.constructor,{translations:i,...n}=t.defaultConfig||{},{translations:s=i,...o}=e,r=e.language||n.language;this._context=e.context||new Ic({language:r,translations:s}),this._context._addEditor(this,!e.context);const a=Array.from(t.builtinPlugins||[]);this.config=new Je(o,n),this.config.define("plugins",a),this.config.define(this._context._getEditorConfig()),function(e){let t=e.get("licenseKey");!t&&window.CKEDITOR_GLOBAL_LICENSE_KEY&&(t=window.CKEDITOR_GLOBAL_LICENSE_KEY,e.set("licenseKey",t));if(!t)throw new fe("license-key-missing")}(this.config),this.plugins=new Sc(this,a,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new Pc,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.model=new rl(this.config),this.on("change:isReadOnly",()=>{this.model.document.isReadOnly=this.isReadOnly});const l=new yn;this.data=new Nr(this.model,l),this.editing=new wr(this.model,l),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new Lr([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 Rc(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new Mc(this),function(e){const t=e.config.get("licenseKey"),i=window[Symbol.for("cke distribution")]||"sh";function n(t,i){e.enableReadOnlyMode(Symbol("invalidLicense")),e._showLicenseError(t,i)}if("GPL"==t)return void("cloud"==i&&n("distributionChannel"));const s=yi(t);if(!s)return void n("invalid");if(!function(e){return["exp","jti","vc"].every(t=>t in e)}(s))return void n("invalid");if(s.distributionChannel&&!ei(s.distributionChannel).includes(i))return void n("distributionChannel");if(function(e){const t=Array.isArray(e)?e:[e],i=function(){const e=[];for(let t=0;t<256;t++){let i=t;for(let e=0;e<8;e++)1&i?i=3988292384^i>>>1:i>>>=1;e[t]=i}return e}();let n=-1;const s=t.map(e=>Array.isArray(e)?e.join(""):String(e)).join("");for(let e=0;e<s.length;e++)n=n>>>8^i[255&(n^s.charCodeAt(e))];return n=(-1^n)>>>0,n.toString(16).padStart(8,"0")}(function(e){return Object.getOwnPropertyNames(e).sort().filter(t=>"vc"!=t&&null!=e[t]).map(t=>e[t])}(s))!=s.vc.toLowerCase())return void n("invalid");if(new Date(1e3*s.exp)<_e)return void n("expired");const o=s.licensedHosts;if(o&&o.length>0&&!function(e){const{hostname:t}=new URL(window.location.href);if(e.includes(t))return!0;const i=t.split(".");return e.filter(e=>e.includes("*")).map(e=>e.split(".")).filter(e=>e.length<=i.length).map(e=>Array(i.length-e.length).fill("*"===e[0]?"*":"").concat(e)).some(e=>i.every((t,i)=>e[i]===t||"*"===e[i]))}(o))return void n("domainLimit");if(["evaluation","trial"].includes(s.licenseType)&&1e3*s.exp<Date.now())return void n("expired");if(["development","evaluation","trial"].includes(s.licenseType)){const{licenseType:e}=s;window.CKEDITOR_WARNING_SUPPRESSIONS=window.CKEDITOR_WARNING_SUPPRESSIONS||{},window.CKEDITOR_WARNING_SUPPRESSIONS[e]||(!function(e){const t=e[0].toUpperCase()+e.slice(1),i="evaluation"===e?"an":"a";console.info(`%cCKEditor 5 ${t} License`,"color: #ffffff; background: #743CCD; font-size: 14px; padding: 4px 8px; border-radius: 4px;"),console.warn(`⚠️ You are using ${i} ${e} license of CKEditor 5`+("trial"===e?" which is for evaluation purposes only":"")+". For production usage, please obtain a production license at https://portal.ckeditor.com/")}(e),window.CKEDITOR_WARNING_SUPPRESSIONS[e]=!0)}if("evaluation"===s.licenseType){const t=setTimeout(()=>{n("evaluationLimit")},6e5);e.on("destroy",()=>{clearTimeout(t)})}s.usageEndpoint&&e.once("ready",()=>{const i={requestId:he(),requestTime:Math.round(Date.now()/1e3),license:t,editor:$c(e)};e._sendUsageRequest(s.usageEndpoint,i).then(e=>{const{status:t,message:i}=e;i&&console.warn(i),"ok"!=t&&n("usageLimit")},()=>{var e,t;e="license-key-validation-endpoint-not-reachable",t={url:s.usageEndpoint},console.error(...we(e,t))})},{priority:"high"})}(this)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new fe("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new fe("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),1===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new fe("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}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")||[],n=e.get("extraPlugins")||[],s=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,s).then(e=>(function(e){const t=e.config.get("licenseKey");if("GPL"===t)return;const i=yi(t);if(!i)return;const n=[...e.plugins].map(([e])=>e).find(e=>{return!!e.pluginName&&(!!e.licenseFeatureCode&&(t=i,n=e.licenseFeatureCode,(t.removeFeatures||[]).includes(n)));var t,n});n&&(e.enableReadOnlyMode(Symbol("invalidLicense")),e._showLicenseError("pluginNotAllowed",n.pluginName))}(this),e))}destroy(){let e=Promise.resolve();return"initializing"==this.state&&(e=new Promise(e=>this.once("ready",e))),e.then(()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()}).then(()=>this.plugins.destroy()).then(()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()}).then(()=>this._context._removeEditor(this))}execute(e,...t){try{return this.commands.execute(e,...t)}catch(e){fe.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}static Context=Ic;static EditorWatchdog=pc;static ContextWatchdog=vc;_showLicenseError(e,t){setTimeout(()=>{if("invalid"==e)throw new fe("invalid-license-key");if("expired"==e)throw new fe("license-key-expired");if("domainLimit"==e)throw new fe("license-key-domain-limit");if("pluginNotAllowed"==e){const e=t.replace(/(Editing|UI)$/,""),i=this.plugins.has(e);throw new fe("license-key-plugin-not-allowed",null,{pluginName:i?e:t})}if("featureNotAllowed"==e)throw new fe("license-key-feature-not-allowed",null,{featureName:t});if("evaluationLimit"==e)throw new fe("license-key-evaluation-limit");if("trialLimit"==e)throw new fe("license-key-trial-limit");if("developmentLimit"==e)throw new fe("license-key-development-limit");if("usageLimit"==e)throw new fe("license-key-usage-limit");if("distributionChannel"==e)throw new fe("license-key-invalid-distribution-channel")},0),this._showLicenseError=()=>{}}async _sendUsageRequest(e,t){const i=new Headers({"Content-Type":"application/json"}),n=await fetch(new URL(e),{method:"POST",headers:i,body:JSON.stringify(t)});if(!n.ok)throw new Error(`HTTP Response: ${n.status}`);return n.json()}}function $c(e){const t=function(e){return{sessionId:Dc(),pageSessionId:zc(),hostname:window.location.hostname,version:globalThis.CKEDITOR_VERSION,type:Fc(e),plugins:(t=e.plugins,Array.from(t).filter(([e])=>!!e.pluginName).map(([e])=>{const{pluginName:t,isContextPlugin:i,isOfficialPlugin:n,isPremiumPlugin:s}=e;return{isContext:!!i,isOfficial:!!n,isPremium:!!s,name:t}})),distribution:{channel:window[Symbol.for("cke distribution")]||"sh"},env:Lc(),integration:Object.create(null),menuBar:{isVisible:!!e.config.get("menuBar.isVisible")},language:{ui:e.locale.uiLanguage,content:e.locale.contentLanguage},toolbar:{main:Nc(e.config.get("toolbar")),block:Nc(e.config.get("blockToolbar")),balloon:Nc(e.config.get("balloonToolbar"))}};var t}(e);return e.fire("collectUsageData",{setUsageData:function(e,i){if(void 0!==Li(t,e))throw new fe("editor-usage-data-path-already-set",{path:e});Ui(t,e,i)}}),t}function Wc(e){return class extends e{sourceElement;updateSourceElement(e){if(!this.sourceElement)throw new fe("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;if(!t&&!i)return void vt(this.sourceElement,"");const n="string"==typeof e?e:this.data.get();vt(this.sourceElement,n)}}}function jc(e,t,i="main",n=!1){const s=t.get("root"),o=t.get("roots")||Object.create(null);if(s){if(!i)throw new fe("editor-create-multi-root-with-main",null);if(i in o)throw new fe("editor-create-roots-with-main",null)}i&&!o[i]&&(o[i]=s||Object.create(null));const r=function(e){return!!e&&"object"==typeof e&&!Array.isArray(e)&&!Kc(e)}(e),a=function(e,t,i){return t||!i?e.get("initialData")||Object.create(null):{[i]:e.get("initialData")}}(t,r,i),l=Array.from(new Set([...r?Object.keys(e):[],...Object.keys(o),...Object.keys(a)]));for(const i of l){const s=o[i]||Object.create(null),l=r?e[i]:e;if(!n&&Kc(l)){if(s.element)throw new fe("editor-create-root-element-overspecified",null);s.element=l}if(n&&Kc(s.element)&&pe("editor-create-root-element-not-supported"),void 0===s.initialData)if(void 0===a[i])s.initialData=Uc(l||s.element||n&&t.get("attachTo")||"");else{if(l&&!Kc(l))throw new fe("editor-create-initial-data-overspecified",null);s.initialData=a[i]}else{if(l&&!Kc(l))throw new fe("editor-create-root-initial-data-overspecified",null);if(void 0!==a[i])throw new fe("editor-create-legacy-initial-data-overspecified",null)}s.placeholder??=qc(t,"placeholder",i),s.label??=qc(t,"label",i),o[i]=s}if(n&&Kc(e)){if(t.get("attachTo"))throw new fe("editor-create-attachto-overspecified",null);t.set("attachTo",e)}if(!n&&t.get("attachTo"))throw new fe("editor-create-attachto-ignored",null);t.set("roots",o)}function Uc(e){return Kc(e)?(t=e)instanceof HTMLTextAreaElement?t.value:t.innerHTML:e;var t}function qc(e,t,i){const n=e.get(t);if(n)return"string"==typeof n?n:n[i]}function Kc(e){return M(e)}class Gc extends Oc{_actions;static get pluginName(){return"PendingActions"}static get isOfficialPlugin(){return!0}init(){this.set("hasAny",!1),this._actions=new ni({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new fe("pendingactions-add-invalid-message",this);const t=new(Le());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]()}}var Jc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10 6.628a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3M8.5 9.125a.3.3 0 0 0-.253-.296L5.11 8.327a.75.75 0 1 1 .388-1.449l4.04.716c.267.072.624.08.893.009l4.066-.724a.75.75 0 1 1 .388 1.45l-3.132.5a.3.3 0 0 0-.253.296v1.357a.3.3 0 0 0 .018.102l1.615 4.438a.75.75 0 0 1-1.41.513l-1.35-3.71a.3.3 0 0 0-.281-.197h-.209a.3.3 0 0 0-.282.198l-1.35 3.711a.75.75 0 0 1-1.41-.513l1.64-4.509a.3.3 0 0 0 .019-.103z"/><path d="M10 18.5a8.5 8.5 0 1 1 0-17 8.5 8.5 0 0 1 0 17m0 1.5c5.523 0 10-4.477 10-10S15.523 0 10 0 0 4.477 0 10s4.477 10 10 10" clip-rule="evenodd"/></svg>',Yc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m2.286 4c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75m0-8c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75"/></svg>',Qc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m0-8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75"/></svg>',Xc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m0-8c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75"/></svg>',Zc='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M18 3.75a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75m0 8a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75m0 4a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75m0-8a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75"/></svg>',ed='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10.187 17H5.773q-.956 0-1.364-.415-.41-.416-.409-1.323V4.738q0-.926.419-1.332.418-.405 1.354-.406h4.68q1.035 0 1.793.124.76.124 1.36.478.512.296.906.75a3.26 3.26 0 0 1 .808 2.162q0 2.102-2.167 3.075 2.846.879 2.847 3.421a3.76 3.76 0 0 1-2.296 3.504 6 6 0 0 1-1.517.377q-.857.11-2 .11zm-.217-6.217H7v4.087h3.069q2.965 0 2.965-2.072 0-1.061-.768-1.537-.768-.478-2.296-.478M7 5.13v3.619h2.606q1.093 0 1.69-.2a1.6 1.6 0 0 0 .91-.765q.247-.4.247-.897 0-1.06-.778-1.409-.778-.348-2.375-.348z"/></svg>',td='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m11.591 10.177 4.243 4.242a1 1 0 0 1-1.415 1.415l-4.242-4.243-4.243 4.243a1 1 0 0 1-1.414-1.415l4.243-4.242L4.52 5.934A1 1 0 0 1 5.934 4.52l4.243 4.243 4.242-4.243a1 1 0 1 1 1.415 1.414z"/></svg>',id='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 16h9a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2"/><path fill-opacity=".6" d="M17 1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2zm0 1.5H3a.5.5 0 0 0-.492.41L2.5 3v9a.5.5 0 0 0 .41.492L3 12.5h14a.5.5 0 0 0 .492-.41L17.5 12V3a.5.5 0 0 0-.41-.492z"/></svg>',nd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M6.972 16.615a1 1 0 0 1-.744-.292l-4.596-4.596a1 1 0 1 1 1.414-1.414l3.926 3.926 9.937-9.937a1 1 0 0 1 1.414 1.415L7.717 16.323a1 1 0 0 1-.745.292"/></svg>',sd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M12.87 12.61a.75.75 0 0 1-.089.976l-.085.07-3.154 2.254 3.412 2.414a.75.75 0 0 1 .237.95l-.057.095a.75.75 0 0 1-.95.237l-.096-.058-4.272-3.022-.003-1.223 4.01-2.867a.75.75 0 0 1 1.047.174m2.795-.231.095.057 4.011 2.867-.003 1.223-4.272 3.022-.095.058a.75.75 0 0 1-.88-.151l-.07-.086-.058-.095a.75.75 0 0 1 .15-.88l.087-.07 3.412-2.414-3.154-2.253-.085-.071a.75.75 0 0 1 .862-1.207M16 0a2 2 0 0 1 2 2v9.354l-.663-.492-.837-.001V2a.5.5 0 0 0-.5-.5H2a.5.5 0 0 0-.5.5v15a.5.5 0 0 0 .5.5h3.118L7.156 19H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zM5.009 15l.003 1H3v-1zm2.188-2-1.471 1H5v-1zM10 11v.095L8.668 12H7v-1zm4-2v1H7V9zm0-2v1H7V7zm-4-2v1H5V5zM6 3v1H3V3z"/></svg>',od='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M4 0v1H1v3H0V.5A.5.5 0 0 1 .5 0zm8 0h3.5a.5.5 0 0 1 .5.5V4h-1V1h-3zM4 16H.5a.5.5 0 0 1-.5-.5V12h1v3h3zm8 0v-1h3v-3h1v3.5a.5.5 0 0 1-.5.5z"/><path fill-opacity=".256" d="M1 1h14v14H1z"/><g class="ck-icon__selected-indicator"><path d="M7 0h2v1H7zM0 7h1v2H0zm15 0h1v2h-1zm-8 8h2v1H7z"/><path fill-opacity=".254" d="M1 1h14v14H1z"/></g></svg>',rd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><path d="M.941 4.523a.75.75 0 1 1 1.06-1.06l3.006 3.005 3.005-3.005a.75.75 0 1 1 1.06 1.06l-3.549 3.55a.75.75 0 0 1-1.168-.136z"/></svg>',ad='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m8.636 9.531-2.758 3.94a.5.5 0 0 0 .122.696l3.224 2.284h1.314l2.636-3.736L8.636 9.53zm.288 8.451L5.14 15.396a2 2 0 0 1-.491-2.786l6.673-9.53a2 2 0 0 1 2.785-.49l3.742 2.62a2 2 0 0 1 .491 2.785l-7.269 10.053z"/><path d="M4 18h5.523v-1H4zm-2 0h1v-1H2z"/></svg>',ld='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M11.03 3h6.149a.75.75 0 1 1 0 1.5h-5.514zm1.27 3h4.879a.75.75 0 1 1 0 1.5h-4.244zm1.27 3h3.609a.75.75 0 1 1 0 1.5h-2.973zm-2.754 2.5L8.038 4.785 5.261 11.5zm.62 1.5H4.641l-1.666 4.028H1.312l5.789-14h1.875l5.789 14h-1.663z"/></svg>',cd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.816 11.5 7.038 4.785 4.261 11.5zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663zm7.55 2.279.779-.779.707.707-2.265 2.265-2.193-2.265.707-.707.765.765V4.825q0-.063.002-.123l-.77.77-.707-.707L17.207 2.5l2.265 2.265-.707.707-.782-.782q.003.065.003.135z"/></svg>',dd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75M2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5M1.632 6.95 5.02 9.358a.4.4 0 0 1-.013.661l-3.39 2.207A.4.4 0 0 1 1 11.892V7.275a.4.4 0 0 1 .632-.326z"/></svg>',ud='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M8.537 14.813a.888.888 0 1 1-1.254-1.255L10.84 10 7.283 6.442a.888.888 0 1 1 1.254-1.255L12.74 9.39a.888.888 0 0 1-.16 1.382z"/></svg>',hd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3h16v1.5H2zm0 12h16v1.5H2z" opacity=".5"/><path d="M15.003 7v5.5a1 1 0 0 1-1 1H5.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1m-1.506.5H6.5V12h6.997z"/></svg>',md='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3h16v1.5H2zm11.5 9H18v1.5h-4.5zm0-3H18v1.5h-4.5zm0-3H18v1.5h-4.5zM2 15h16v1.5H2z" opacity=".5"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1m-1.506.5H3.5V12h6.997z"/></svg>',gd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3h16v1.5H2zm0 12h16v1.5H2zm0-9h5v1.5H2zm0 3h5v1.5H2zm0 3h5v1.5H2z" opacity=".5"/><path d="M18.003 7v5.5a1 1 0 0 1-1 1H8.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1m-1.506.5H9.5V12h6.997z"/></svg>',fd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3h16v1.5H2zm11.5 9H18v1.5h-4.5zM2 15h16v1.5H2z" opacity=".5"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1m-1.506.5H3.5V12h6.997z"/></svg>',pd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3h16v1.5H2zm0 12h16v1.5H2z" opacity=".5"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1m-1.506.5H3.5V12h6.997z"/></svg>',bd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3h16v1.5H2zm0 12h16v1.5H2z" opacity=".5"/><path d="M18.003 7v5.5a1 1 0 0 1-1 1H8.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1m-1.506.5H9.5V12h6.997z"/></svg>',wd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75m5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75M2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5m1.618-9.55L.98 9.358a.4.4 0 0 0 .013.661l3.39 2.207A.4.4 0 0 0 5 11.892V7.275a.4.4 0 0 0-.632-.326z"/></svg>',_d='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M11.463 5.187a.888.888 0 1 1 1.254 1.255L9.16 10l3.557 3.557a.888.888 0 1 1-1.254 1.255L7.26 10.61a.888.888 0 0 1 .16-1.382l4.043-4.042z"/></svg>',vd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m14.958 9.367-2.189 1.837a.75.75 0 0 0 .965 1.149l3.788-3.18a.75.75 0 0 0 .21-.284.75.75 0 0 0-.17-.945L13.77 4.762a.75.75 0 1 0-.964 1.15l2.331 1.955H6.22A.8.8 0 0 0 6 7.9a4 4 0 1 0 1.477 7.718l-.344-1.489A2.5 2.5 0 1 1 6.039 9.4l-.008-.032z"/></svg>',yd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M3 5.5v3h4v-3zm0 4v3h4v-3zm0 4v3h4v-3zm5 3h4v-3H8zm5 0h4v-3h-4zm4-4v-3h-4v3zm0-4v-3h-4v3zm1.5 8A1.5 1.5 0 0 1 17 18H3a1.5 1.5 0 0 1-1.5-1.5V3c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5zm-6.5-4v-3H8v3zm0-4v-3H8v3z"/></svg>',kd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><circle cx="9.5" cy="4.5" r="1.5"/><circle cx="9.5" cy="10.5" r="1.5"/><circle cx="9.5" cy="16.5" r="1.5"/></svg>',Cd='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m5.042 9.367 2.189 1.837a.75.75 0 0 1-.965 1.149l-3.788-3.18a.75.75 0 0 1-.21-.284.75.75 0 0 1 .17-.945L6.23 4.762a.75.75 0 1 1 .964 1.15L4.863 7.866h8.917A.8.8 0 0 1 14 7.9a4 4 0 1 1-1.477 7.718l.344-1.489a2.5 2.5 0 1 0 1.094-4.73l.008-.032z"/></svg>';const Ad={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]};for(const e in Ad)Object.freeze(Ad[e]);const Td=Object.freeze(Ad),Ed=function(e){var t,i,n=[],s=1;if("number"==typeof e)return{space:"rgb",values:[e>>>16,(65280&e)>>>8,255&e],alpha:1};if("number"==typeof e)return{space:"rgb",values:[e>>>16,(65280&e)>>>8,255&e],alpha:1};if(e=String(e).toLowerCase(),Td[e])n=Td[e].slice(),i="rgb";else if("transparent"===e)s=0,i="rgb",n=[0,0,0];else if("#"===e[0]){var o=e.slice(1),r=o.length;s=1,r<=4?(n=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],4===r&&(s=parseInt(o[3]+o[3],16)/255)):(n=[parseInt(o[0]+o[1],16),parseInt(o[2]+o[3],16),parseInt(o[4]+o[5],16)],8===r&&(s=parseInt(o[6]+o[7],16)/255)),n[0]||(n[0]=0),n[1]||(n[1]=0),n[2]||(n[2]=0),i="rgb"}else if(t=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(e)){var a=t[1],l="cmyk"===(i=a.replace(/a$/,""))?4:"gray"===i?1:3;n=t[2].trim().split(/\s*[,\/]\s*|\s+/),"color"===i&&(i=n.shift()),s=(n=n.map(function(e,t){if("%"===e[e.length-1])return e=parseFloat(e)/100,3===t?e:"rgb"===i?255*e:"h"===i[0]?100*e:"l"!==i[0]||t?"lab"===i?125*e:"lch"===i?t<2?150*e:360*e:"o"!==i[0]||t?"oklab"===i?.4*e:"oklch"===i?t<2?.4*e:360*e:e:e:100*e;if("h"===i[t]||2===t&&"h"===i[i.length-1]){if(void 0!==xd[e])return xd[e];if(e.endsWith("deg"))return parseFloat(e);if(e.endsWith("turn"))return 360*parseFloat(e);if(e.endsWith("grad"))return 360*parseFloat(e)/400;if(e.endsWith("rad"))return 180*parseFloat(e)/Math.PI}return"none"===e?0:parseFloat(e)})).length>l?n.pop():1}else/[0-9](?:\s|\/|,)/.test(e)&&(n=e.match(/([0-9]+)/g).map(function(e){return parseFloat(e)}),i=e.match(/([a-z])/gi)?.join("")?.toLowerCase()||"rgb");return{space:i,values:n,alpha:s}};var xd={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};const Pd={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]};for(const e in Pd)Object.freeze(Pd[e]);const Sd=Object.freeze(Pd),Id={};for(const e of Object.keys(Sd))Id[Sd[e]]=e;const Od={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"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},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"]}},Rd=Od,Vd=(6/29)**3;function Bd(e){const t=e>.0031308?1.055*e**(1/2.4)-.055:12.92*e;return Math.min(Math.max(0,t),1)}function Md(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(const e of Object.keys(Od)){if(!("channels"in Od[e]))throw new Error("missing channels property: "+e);if(!("labels"in Od[e]))throw new Error("missing channel labels property: "+e);if(Od[e].labels.length!==Od[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=Od[e];delete Od[e].channels,delete Od[e].labels,Object.defineProperty(Od[e],"channels",{value:t}),Object.defineProperty(Od[e],"labels",{value:i})}function Fd(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}function Nd(e){const t=function(){const e={},t=Object.keys(Rd);for(let{length:i}=t,n=0;n<i;n++)e[t[n]]={distance:-1,parent:null};return e}(),i=[e];for(t[e].distance=0;i.length>0;){const e=i.pop(),n=Object.keys(Rd[e]);for(let{length:s}=n,o=0;o<s;o++){const s=n[o],r=t[s];-1===r.distance&&(r.distance=t[e].distance+1,r.parent=e,i.unshift(s))}}return t}function Ld(e,t){return function(i){return t(e(i))}}function Dd(e,t){const i=[t[e].parent,e];let n=Rd[t[e].parent][e],s=t[e].parent;for(;t[s].parent;)i.unshift(t[s].parent),n=Ld(Rd[t[s].parent][s],n),s=t[s].parent;return n.conversion=i,n}Od.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.min(t,i,n),o=Math.max(t,i,n),r=o-s;let a,l;switch(o){case s:a=0;break;case t:a=(i-n)/r;break;case i:a=2+(n-t)/r;break;case n:a=4+(t-i)/r}a=Math.min(60*a,360),a<0&&(a+=360);const c=(s+o)/2;return l=o===s?0:c<=.5?r/(o+s):r/(2-o-s),[a,100*l,100*c]},Od.rgb.hsv=function(e){let t,i,n,s,o;const r=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(r,a,l),d=c-Math.min(r,a,l),u=function(e){return(c-e)/6/d+.5};if(0===d)s=0,o=0;else{switch(o=d/c,t=u(r),i=u(a),n=u(l),c){case r:s=n-i;break;case a:s=1/3+t-n;break;case l:s=2/3+i-t}s<0?s+=1:s>1&&(s-=1)}return[360*s,100*o,100*c]},Od.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const s=Od.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[s,100*o,100*n]},Od.rgb.oklab=function(e){const t=Md(e[0]/255),i=Md(e[1]/255),n=Md(e[2]/255),s=Math.cbrt(.4122214708*t+.5363325363*i+.0514459929*n),o=Math.cbrt(.2119034982*t+.6806995451*i+.1073969566*n),r=Math.cbrt(.0883024619*t+.2817188376*i+.6299787005*n);return[100*(.2104542553*s+.793617785*o-.0040720468*r),100*(1.9779984951*s-2.428592205*o+.4505937099*r),100*(.0259040371*s+.7827717662*o-.808675766*r)]},Od.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.min(1-t,1-i,1-n);return[100*((1-t-s)/(1-s)||0),100*((1-i-s)/(1-s)||0),100*((1-n-s)/(1-s)||0),100*s]},Od.rgb.keyword=function(e){const t=Id[e];if(t)return t;let i,n=Number.POSITIVE_INFINITY;for(const t of Object.keys(Sd)){const s=Fd(e,Sd[t]);s<n&&(n=s,i=t)}return i},Od.keyword.rgb=function(e){return Sd[e]},Od.rgb.xyz=function(e){const t=Md(e[0]/255),i=Md(e[1]/255),n=Md(e[2]/255);return[100*(.4124564*t+.3575761*i+.1804375*n),100*(.2126729*t+.7151522*i+.072175*n),100*(.0193339*t+.119192*i+.9503041*n)]},Od.rgb.lab=function(e){const t=Od.rgb.xyz(e);let i=t[0],n=t[1],s=t[2];i/=95.047,n/=100,s/=108.883,i=i>Vd?i**(1/3):7.787*i+16/116,n=n>Vd?n**(1/3):7.787*n+16/116,s=s>Vd?s**(1/3):7.787*s+16/116;return[116*n-16,500*(i-n),200*(n-s)]},Od.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let s,o;if(0===i)return o=255*n,[o,o,o];const r=n<.5?n*(1+i):n+i-n*i,a=2*n-r,l=[0,0,0];for(let e=0;e<3;e++)s=t+1/3*-(e-1),s<0&&s++,s>1&&s--,o=6*s<1?a+6*(r-a)*s:2*s<1?r:3*s<2?a+(r-a)*(2/3-s)*6:a,l[e]=255*o;return l},Od.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,s=i;const o=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,s*=o<=1?o:2-o;return[t,100*(0===n?2*s/(o+s):2*i/(n+i)),100*((n+i)/2)]},Od.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const s=Math.floor(t)%6,o=t-Math.floor(t),r=255*n*(1-i),a=255*n*(1-i*o),l=255*n*(1-i*(1-o));switch(n*=255,s){case 0:return[n,l,r];case 1:return[a,n,r];case 2:return[r,n,l];case 3:return[r,a,n];case 4:return[l,r,n];case 5:return[n,r,a]}},Od.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,s=Math.max(n,.01);let o,r;r=(2-i)*n;const a=(2-i)*s;return o=i*s,o/=a<=1?a:2-a,o=o||0,r/=2,[t,100*o,100*r]},Od.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const s=i+n;let o;s>1&&(i/=s,n/=s);const r=Math.floor(6*t),a=1-n;o=6*t-r,1&r&&(o=1-o);const l=i+o*(a-i);let c,d,u;switch(r){default:case 6:case 0:c=a,d=l,u=i;break;case 1:c=l,d=a,u=i;break;case 2:c=i,d=a,u=l;break;case 3:c=i,d=l,u=a;break;case 4:c=l,d=i,u=a;break;case 5:c=a,d=i,u=l}return[255*c,255*d,255*u]},Od.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,s=e[3]/100;return[255*(1-Math.min(1,t*(1-s)+s)),255*(1-Math.min(1,i*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s))]},Od.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let s,o,r;return s=3.2404542*t+-1.5371385*i+-.4985314*n,o=-.969266*t+1.8760108*i+.041556*n,r=.0556434*t+-.2040259*i+1.0572252*n,s=Bd(s),o=Bd(o),r=Bd(r),[255*s,255*o,255*r]},Od.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>Vd?t**(1/3):7.787*t+16/116,i=i>Vd?i**(1/3):7.787*i+16/116,n=n>Vd?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},Od.xyz.oklab=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,s=Math.cbrt(.8189330101*t+.3618667424*i-.1288597137*n),o=Math.cbrt(.0329845436*t+.9293118715*i+.0361456387*n),r=Math.cbrt(.0482003018*t+.2643662691*i+.633851707*n);return[100*(.2104542553*s+.793617785*o-.0040720468*r),100*(1.9779984951*s-2.428592205*o+.4505937099*r),100*(.0259040371*s+.7827717662*o-.808675766*r)]},Od.oklab.oklch=function(e){return Od.lab.lch(e)},Od.oklab.xyz=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,s=(.999999998*t+.396337792*i+.215803758*n)**3,o=(1.000000008*t-.105561342*i-.063854175*n)**3,r=(1.000000055*t-.089484182*i-1.291485538*n)**3;return[100*(1.227013851*s-.55779998*o+.281256149*r),100*(-.040580178*s+1.11225687*o-.071676679*r),100*(-.076381285*s-.421481978*o+1.58616322*r)]},Od.oklab.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,s=(t+.3963377774*i+.2158037573*n)**3,o=(t-.1055613458*i-.0638541728*n)**3,r=(t-.0894841775*i-1.291485548*n)**3;return[255*Bd(4.0767416621*s-3.3077115913*o+.2309699292*r),255*Bd(-1.2684380046*s+2.6097574011*o-.3413193965*r),255*Bd(-.0041960863*s-.7034186147*o+1.707614701*r)]},Od.oklch.oklab=function(e){return Od.lch.lab(e)},Od.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const s=i**3,o=t**3,r=n**3;return i=s>Vd?s:(i-16/116)/7.787,t=o>Vd?o:(t-16/116)/7.787,n=r>Vd?r:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},Od.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let s;s=360*Math.atan2(n,i)/2/Math.PI,s<0&&(s+=360);return[t,Math.sqrt(i*i+n*n),s]},Od.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},Od.rgb.ansi16=function(e,t=null){const[i,n,s]=e;let o=null===t?Od.rgb.hsv(e)[2]:t;if(o=Math.round(o/50),0===o)return 30;let r=30+(Math.round(s/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===o&&(r+=60),r},Od.hsv.ansi16=function(e){return Od.rgb.ansi16(Od.hsv.rgb(e),e[2])},Od.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];if(t>>4==i>>4&&i>>4==n>>4)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},Od.ansi16.rgb=function(e){let t=(e=e[0])%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(Math.trunc(e>50)+1);return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},Od.ansi256.rgb=function(e){if((e=e[0])>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},Od.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".slice(t.length)+t},Od.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=[...i].map(e=>e+e).join(""));const n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},Od.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,s=Math.max(Math.max(t,i),n),o=Math.min(Math.min(t,i),n),r=s-o;let a;return a=r<=0?0:s===t?(i-n)/r%6:s===i?2+(n-t)/r:4+(t-i)/r,a/=6,a%=1,[360*a,100*r,100*(r<1?o/(1-r):0)]},Od.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let s=0;return n<1&&(s=(i-.5*n)/(1-n)),[e[0],100*n,100*s]},Od.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let s=0;return n<1&&(s=(i-n)/(1-n)),[e[0],100*n,100*s]},Od.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const s=[0,0,0],o=t%1*6,r=o%1,a=1-r;let l=0;switch(Math.floor(o)){case 0:s[0]=1,s[1]=r,s[2]=0;break;case 1:s[0]=a,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=r;break;case 3:s[0]=0,s[1]=a,s[2]=1;break;case 4:s[0]=r,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=a}return l=(1-i)*n,[255*(i*s[0]+l),255*(i*s[1]+l),255*(i*s[2]+l)]},Od.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},Od.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},Od.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},Od.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let s=0;return n<1&&(s=(i-n)/(1-n)),[e[0],100*n,100*s]},Od.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},Od.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},Od.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},Od.gray.hsl=function(e){return[0,0,e[0]]},Od.gray.hsv=Od.gray.hsl,Od.gray.hwb=function(e){return[0,100,e[0]]},Od.gray.cmyk=function(e){return[0,0,0,e[0]]},Od.gray.lab=function(e){return[e[0],0,0]},Od.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(i.length)+i},Od.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const zd=function(e){const t=Nd(e),i={},n=Object.keys(t);for(let{length:e}=n,s=0;s<e;s++){const e=n[s];null!==t[e].parent&&(i[e]=Dd(e,t))}return i},Hd={},$d=Object.keys(Rd);function Wd(e){const t=function(...t){const i=t[0];return null==i?i:(i.length>1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function jd(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let{length:e}=n,t=0;t<e;t++)n[t]=Math.round(n[t]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}for(const e of $d){Hd[e]={},Object.defineProperty(Hd[e],"channels",{value:Rd[e].channels}),Object.defineProperty(Hd[e],"labels",{value:Rd[e].labels});const t=zd(e),i=Object.keys(t);for(const n of i){const i=t[n];Hd[e][n]=jd(i),Hd[e][n].raw=Wd(i)}}const Ud=Hd,qd=(e,t=0,i=1)=>e>i?i:e<t?t:e,Kd=(e,t=0,i=Math.pow(10,t))=>Math.round(i*e)/i;Math.PI;const Gd=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?Kd(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?Kd(parseInt(e.substring(6,8),16)/255,2):1}),Jd=({h:e,s:t,v:i,a:n})=>{const s=(200-t)*i/100;return{h:Kd(e),s:Kd(s>0&&s<200?t*i/100/(s<=100?s:200-s)*100:0),l:Kd(s/2),a:Kd(n,2)}},Yd=e=>{const{h:t,s:i,l:n}=Jd(e);return`hsl(${t}, ${i}%, ${n}%)`},Qd=({h:e,s:t,v:i,a:n})=>{e=e/360*6,t/=100,i/=100;const s=Math.floor(e),o=i*(1-t),r=i*(1-(e-s)*t),a=i*(1-(1-e+s)*t),l=s%6;return{r:Kd(255*[i,r,o,o,a,i][l]),g:Kd(255*[a,i,i,r,o,o][l]),b:Kd(255*[o,o,a,i,i,r][l]),a:Kd(n,2)}},Xd=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},Zd=({r:e,g:t,b:i,a:n})=>{const s=n<1?Xd(Kd(255*n)):"";return"#"+Xd(e)+Xd(t)+Xd(i)+s},eu=({r:e,g:t,b:i,a:n})=>{const s=Math.max(e,t,i),o=s-Math.min(e,t,i),r=o?s===e?(t-i)/o:s===t?2+(i-e)/o:4+(e-t)/o:0;return{h:Kd(60*(r<0?r+6:r)),s:Kd(s?o/s*100:0),v:Kd(s/255*100),a:n}},tu=(e,t)=>{if(e===t)return!0;for(const i in e)if(e[i]!==t[i])return!1;return!0},iu={},nu=e=>{let t=iu[e];return t||(t=document.createElement("template"),t.innerHTML=e,iu[e]=t),t},su=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))};let ou=!1;const ru=e=>"touches"in e,au=(e,t)=>{const i=ru(t)?t.touches[0]:t,n=e.el.getBoundingClientRect();su(e.el,"move",e.getMove({x:qd((i.pageX-(n.left+window.pageXOffset))/n.width),y:qd((i.pageY-(n.top+window.pageYOffset))/n.height)}))};class lu{constructor(e,t,i,n){const s=nu(`<div role="slider" tabindex="0" part="${t}" ${i}><div part="${t}-pointer"></div></div>`);e.appendChild(s.content.cloneNode(!0));const o=e.querySelector(`[part=${t}]`);o.addEventListener("mousedown",this),o.addEventListener("touchstart",this),o.addEventListener("keydown",this),this.el=o,this.xy=n,this.nodes=[o.firstChild,o]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(ou?"touchmove":"mousemove",this),t(ou?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(ou&&!ru(e)||(ou||(ou=ru(e)),0)))(e)||!ou&&0!=e.button)return;this.el.focus(),au(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),au(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const i=t.keyCode;i>40||e.xy&&i<37||i<33||(t.preventDefault(),su(e.el,"move",e.getMove({x:39===i?.01:37===i?-.01:34===i?.05:33===i?-.05:35===i?1:36===i?-1:0,y:40===i?.01:38===i?-.01:0},!0)))})(this,e)}}style(e){e.forEach((e,t)=>{for(const i in e)this.nodes[t].style.setProperty(i,e[i])})}}class cu extends lu{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:Yd({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${Kd(e)}`)}getMove(e,t){return{h:t?qd(this.h+360*e.x,0,360):360*e.x}}}class du extends lu{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:Yd(e)},{"background-color":Yd({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${Kd(e.s)}%, Brightness ${Kd(e.v)}%`)}getMove(e,t){return{s:t?qd(this.hsva.s+100*e.x,0,100):100*e.x,v:t?qd(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}}const uu=Symbol("same"),hu=Symbol("color"),mu=Symbol("hsva"),gu=Symbol("update"),fu=Symbol("parts"),pu=Symbol("css"),bu=Symbol("sliders");class wu extends HTMLElement{static get observedAttributes(){return["color"]}get[pu](){return[':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)}',"[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}","[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}"]}get[bu](){return[du,cu]}get color(){return this[hu]}set color(e){if(!this[uu](e)){const t=this.colorModel.toHsva(e);this[gu](t),this[hu]=e}}constructor(){super();const e=nu(`<style>${this[pu].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[fu]=this[bu].map(e=>new e(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 n=this.colorModel.fromAttr(i);this[uu](n)||(this.color=n)}handleEvent(e){const t=this[mu],i={...t,...e.detail};let n;this[gu](i),tu(i,t)||this[uu](n=this.colorModel.fromHsva(i))||(this[hu]=n,su(this,"color-changed",{value:n}))}[uu](e){return this.color&&this.colorModel.equal(e,this.color)}[gu](e){this[mu]=e,this[fu].forEach(t=>t.update(e))}}const _u={defaultColor:"#000",toHsva:e=>eu(Gd(e)),fromHsva:({h:e,s:t,v:i})=>Zd(Qd({h:e,s:t,v:i,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||tu(Gd(e),Gd(t)),fromAttr:e=>e};class vu extends wu{get colorModel(){return _u}}class yu extends ni{_parentElement;constructor(e=[]){super(e,{idProperty:"viewUid"}),this.on("add",(e,t,i)=>{this._renderViewIntoCollectionParent(t,i)}),this.on("remove",(e,t)=>{t.element&&this._parentElement&&t.element.remove()}),this._parentElement=null}destroy(){this.map(e=>e.destroy())}setParent(e){this._parentElement=e;for(const e of this)this._renderViewIntoCollectionParent(e)}delegate(...e){if(!e.length||!e.every(e=>"string"==typeof e))throw new fe("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const n of e)i.delegate(n).to(t);this.on("add",(i,n)=>{for(const i of e)n.delegate(i).to(t)}),this.on("remove",(i,n)=>{for(const i of e)n.stopDelegating(i,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)}}class ku extends(Ae()){ns;tag;text;attributes;children;eventListeners;_isRendered;_revertData;constructor(e){super(),Object.assign(this,Vu(Ru(e))),this._isRendered=!1,this._revertData=null}render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:e,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new fe("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){yield*function*e(t){if(t.children)for(const i of t.children)Du(i)?yield i:zu(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,n)=>new Au({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:n}),if:(i,n,s)=>new Tu({observable:e,emitter:t,attribute:i,valueIfTrue:n,callback:s})}}static extend(e,t){if(e._isRendered)throw new fe("template-extend-render",[this,e]);Nu(e,Vu(Ru(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new fe("ui-template-wrong-syntax",this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return t||(t=e.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(e),this._renderElementChildren(e),this._setUpListeners(e),t}_renderText(e){let t=e.node;return t?e.revertData.text=t.textContent:t=e.node=document.createTextNode(""),Eu(this.text)?this._bindToObservable({schema:this.text,updater:Su(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,i=e.revertData;for(const n in this.attributes){const s=t.getAttribute(n),o=this.attributes[n];i&&(i.attributes[n]=s);const r=$u(o)?o[0].ns:null;if(Eu(o)){const a=$u(o)?o[0].value:o;i&&ju(n)&&a.unshift(s),this._bindToObservable({schema:a,updater:Iu(t,n,r),data:e})}else if("style"==n&&"string"!=typeof o[0])this._renderStyleAttribute(o[0],e);else{i&&s&&ju(n)&&o.unshift(s);const e=o.map(e=>e&&e.value||e).reduce((e,t)=>e.concat(t),[]).reduce(Mu,"");Lu(e)||t.setAttributeNS(r,n,e)}}}_renderStyleAttribute(e,t){const i=t.node;for(const n in e){const s=e[n];Eu(s)?this._bindToObservable({schema:[s],updater:Ou(i,n),data:t}):xu(n)?i.style.setProperty(n,s):i.style[n]=s}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,n=e.isApplying;let s=0;for(const o of this.children)if(Hu(o)){if(!n){o.setParent(t);for(const e of o)i.appendChild(e.element)}}else if(Du(o))n||(o.isRendered||o.render(),i.appendChild(o.element));else if(Xe(o))i.appendChild(o);else if(n){const t=e.revertData,n=Wu();t.children.push(n),o._renderNode({intoFragment:!1,node:i.childNodes[s++],isApplying:!0,revertData:n})}else i.appendChild(o.render());e.intoFragment&&t.appendChild(i)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const i=this.eventListeners[t].map(i=>{const[n,s]=t.split("@");return i.activateDomEventListener(n,s,e)});e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const n=i.revertData;Pu(e,t,i);const s=e.filter(e=>!Lu(e)).filter(e=>e.observable).map(n=>n.activateAttributeListener(e,t,i));n&&n.bindings.push(s)}_revertTemplateFromNode(e,t){for(const e of t.bindings)for(const t of e)t();if(t.text)return void(e.textContent=t.text);const i=e;for(const e in t.attributes){const n=t.attributes[e];null===n?i.removeAttribute(e):i.setAttribute(e,n)}for(let e=0;e<t.children.length;++e)this._revertTemplateFromNode(i.childNodes[e],t.children[e])}}class Cu{attribute;observable;emitter;callback;constructor(e){this.attribute=e.attribute,this.observable=e.observable,this.emitter=e.emitter,this.callback=e.callback}getValue(e){const t=this.observable[this.attribute];return this.callback?this.callback(t,e):t}activateAttributeListener(e,t,i){const n=()=>Pu(e,t,i);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,n),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,n)}}}class Au extends Cu{eventNameOrFunction;constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,i){const n=(e,i)=>{t&&!i.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(i):this.observable.fire(this.eventNameOrFunction,i))};return this.emitter.listenTo(i.node,e,n),()=>{this.emitter.stopListening(i.node,e,n)}}}class Tu extends Cu{valueIfTrue;constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){return!Lu(super.getValue(e))&&(this.valueIfTrue||!0)}}function Eu(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(Eu):e instanceof Cu)}function xu(e){return/^--[a-zA-Z_-][\w-]*$/.test(e)}function Pu(e,t,{node:i}){const n=function(e,t){return e.map(e=>e instanceof Cu?e.getValue(t):e)}(e,i);let s;s=1==e.length&&e[0]instanceof Tu?n[0]:n.reduce(Mu,""),Lu(s)?t.remove():t.set(s)}function Su(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function Iu(e,t,i){return{set(n){e.setAttributeNS(i,t,n)},remove(){e.removeAttributeNS(i,t)}}}function Ou(e,t){return{set(i){xu(t)?e.style.setProperty(t,i):e.style[t]=i},remove(){xu(t)?e.style.removeProperty(t):e.style[t]=null}}}function Ru(e){return V(e,e=>{if(e&&(e instanceof Cu||zu(e)||Du(e)||Hu(e)))return e})}function Vu(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=ei(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)Bu(e,t);return e}(e.on),delete e.on),!e.text){e.attributes&&function(e){for(const t in e)e[t].value&&(e[t].value=ei(e[t].value)),Bu(e,t)}(e.attributes);const t=[];if(e.children)if(Hu(e.children))t.push(e.children);else for(const i of e.children)zu(i)||Du(i)||Xe(i)?t.push(i):t.push(new ku(i));e.children=t}return e}function Bu(e,t){e[t]=ei(e[t])}function Mu(e,t){return Lu(t)?e:Lu(e)?t:`${e} ${t}`}function Fu(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function Nu(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),Fu(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),Fu(e.eventListeners,t.eventListeners)),t.text&&e.text.push(...t.text),t.children&&t.children.length){if(e.children.length!=t.children.length)throw new fe("ui-template-extend-children-mismatch",e);let i=0;for(const n of t.children)Nu(e.children[i++],n)}}function Lu(e){return!e&&0!==e}function Du(e){return e instanceof Uu}function zu(e){return e instanceof ku}function Hu(e){return e instanceof yu}function $u(e){return i(e[0])&&e[0].ns}function Wu(){return{children:[],bindings:[],attributes:{}}}function ju(e){return"class"==e||"style"==e}class Uu extends(tt(Le())){element;isRendered;locale;t;template;_viewCollections;_unboundChildren;_bindTemplate;constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new ni,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=ku.bind(this,this)}createCollection(e){const t=new yu(e);return this._viewCollections.add(t),t}registerChild(e){Ke(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){Ke(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new ku(e)}extendTemplate(e){ku.extend(this.template,e)}render(){if(this.isRendered)throw new fe("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)}}const qu={POLITE:"polite",ASSERTIVE:"assertive"};class Ku{editor;view;constructor(e){this.editor=e,e.once("ready",()=>{for(const e of Object.values(qu))this.announce("",e)})}announce(e,t=qu.POLITE){const i=this.editor;if(!i.ui.view)return;this.view||(this.view=new Gu(i.locale),i.ui.view.body.add(this.view));const{politeness:n,isUnsafeHTML:s}="string"==typeof t?{politeness:t}:t;let o=this.view.regionViews.find(e=>e.politeness===n);o||(o=new Ju(i,n),this.view.regionViews.add(o)),o.announce({announcement:e,isUnsafeHTML:s})}}class Gu extends Uu{regionViews;constructor(e){super(e),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class Ju extends Uu{politeness;_domConverter;_pruneAnnouncementsInterval;constructor(e,t){super(e.locale),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",()=>{null!==this._pruneAnnouncementsInterval&&(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")}}function Yu({emitter:e,activator:t,callback:i,contextElements:n,listenerOptions:s}){e.listenTo(document,"mousedown",(e,s)=>{if(!t())return;const o="function"==typeof s.composedPath?s.composedPath():[],r="function"==typeof n?n():n;for(const e of r)if(e.contains(s.target)||o.includes(e))return;i()},s)}function Qu(e){return class extends e{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...e){super(...e),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.template&&this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}}function Xu(e){return class extends e{_onDragBound=this._onDrag.bind(this);_onDragEndBound=this._onDragEnd.bind(this);_lastDraggingCoordinates={x:0,y:0};constructor(...e){super(...e),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(G.document,"mouseup",this._onDragEndBound),this.listenTo(G.document,"touchend",this._onDragEndBound),this.listenTo(G.document,"mousemove",this._onDragBound),this.listenTo(G.document,"touchmove",this._onDragBound)}_detachDragListeners(){this.stopListening(G.document,"mouseup",this._onDragEndBound),this.stopListening(G.document,"touchend",this._onDragEndBound),this.stopListening(G.document,"mousemove",this._onDragBound),this.stopListening(G.document,"touchmove",this._onDragBound)}_onDragStart(e,t){if(!this._isHandleElementPressed(t))return;this._attachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),this._lastDraggingCoordinates={x:i,y:n},this.isDragging=!0}_onDrag(e,t){if(!this.isDragging)return void this._detachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),t.preventDefault(),this.fire("drag",{deltaX:Math.round(i-this._lastDraggingCoordinates.x),deltaY:Math.round(n-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:i,y:n}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(e){return!!this.dragHandleElement&&(this.dragHandleElement===e.target||e.target instanceof HTMLElement&&this.dragHandleElement.contains(e.target))}}}function Zu({view:e}){e.listenTo(e.element,"submit",(t,i)=>{i.preventDefault(),e.fire("submit")},{useCapture:!0})}function eh({keystrokeHandler:e,focusTracker:t,gridItems:i,numberOfColumns:n,uiLanguageDirection:s}){const o="number"==typeof n?()=>n:n;function r(e){return n=>{const s=i.find(e=>e.element===t.focusedElement),o=i.getIndex(s),r=e(o,i);i.get(r).focus(),n.stopPropagation(),n.preventDefault()}}function a(e,t){return e===t-1?0:e+1}function l(e,t){return 0===e?t-1:e-1}e.set("arrowright",r((e,t)=>"rtl"===s?l(e,t.length):a(e,t.length))),e.set("arrowleft",r((e,t)=>"rtl"===s?a(e,t.length):l(e,t.length))),e.set("arrowup",r((e,t)=>{let i=e-o();return i<0&&(i=e+o()*Math.floor(t.length/o()),i>t.length-1&&(i-=o())),i})),e.set("arrowdown",r((e,t)=>{let i=e+o();return i>t.length-1&&(i=e%o()),i}))}class th extends Uu{id;constructor(e){super(e),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${he()}`;const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}class ih extends Uu{constructor(e,t){super(e);const i=e.t,n=new th;n.text=i("Help Contents. To close this dialog press ESC."),this.setTemplate({tag:"div",attributes:{class:["ck","ck-accessibility-help-dialog__content"],"aria-labelledby":n.id,role:"document",tabindex:-1},children:[Ge(document,"p",{},i("Below, you can find a list of keyboard shortcuts that can be used in the editor.")),...this._createCategories(Array.from(t.values())),n]})}focus(){this.element.focus()}_createCategories(e){return e.map(e=>{const t=[Ge(document,"h3",{},e.label),...Array.from(e.groups.values()).map(e=>this._createGroup(e)).flat()];return e.description&&t.splice(1,0,Ge(document,"p",{},e.description)),Ge(document,"section",{},t)})}_createGroup(e){const t=e.keystrokes.sort((e,t)=>e.label.localeCompare(t.label)).map(e=>this._createGroupRow(e)).flat(),i=[Ge(document,"dl",{},t)];return e.label&&i.unshift(Ge(document,"h4",{},e.label)),i}_createGroupRow(e){const t=this.locale.t,i=Ge(document,"dt"),n=Ge(document,"dd"),s=function(e){if("string"==typeof e)return[[e]];if("string"==typeof e[0])return[e];return e}(e.keystroke),o=[];for(const e of s)o.push(e.map(nh).join(""));return i.innerHTML=e.label,n.innerHTML=o.join(", ")+(e.mayRequireFn&&Q.isMac?` ${t("(may require <kbd>Fn</kbd>)")}`:""),[i,n]}}function nh(e){return Jt(e).split("+").map(e=>`<kbd>${e}</kbd>`).join("+")}class sh extends Uu{static 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"];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",e=>!e),"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 fe("ui-iconview-invalid-svg",this);const t=e.getAttribute("viewBox");t&&(this.viewBox=t);for(const{name:t,value:i}of Array.from(e.attributes))sh.presentationalAttributeNames.includes(t)&&this.element.setAttribute(t,i);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})}}class oh extends Uu{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 rh extends Uu{children;labelView;iconView;keystrokeView;_focusDelayed=null;constructor(e,t=new oh){super(e);const i=this.bindTemplate,n=he();this.set("_ariaPressed",!1),this.set("_ariaChecked",!1),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${n}`),this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke",void 0),this.set("label",void 0),this.set("role",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.labelView=this._setupLabelView(t),this.iconView=new sh,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",e=>!e),i.if("isVisible","ck-hidden",e=>!e),i.to("isOn",e=>e?"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",e=>e||"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,e=>!e),"data-cke-tooltip-text":i.to("_tooltipString"),"data-cke-tooltip-position":i.to("tooltipPosition")},children:this.children,on:{click:i.to(e=>{this.isEnabled?this.fire("execute"):e.preventDefault()})}};this.bind("_ariaPressed").to(this,"isOn",this,"isToggleable",this,"role",(e,t,i)=>!(!t||ah(i))&&String(!!e)),this.bind("_ariaChecked").to(this,"isOn",this,"isToggleable",this,"role",(e,t,i)=>!(!t||!ah(i))&&String(!!e)),Q.isSafari&&(this._focusDelayed||(this._focusDelayed=hi(()=>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,n)=>{i&&!n?this.children.add(this.iconView,0):!i&&n&&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 Uu;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",e=>Jt(e))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=Jt(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}function ah(e){switch(e){case"radio":case"checkbox":case"option":case"switch":case"menuitemcheckbox":case"menuitemradio":return!0;default:return!1}}class lh extends Uu{children;iconView;constructor(e,t={}){super(e);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 sh,this.iconView.content=t.icon,this.children.add(this.iconView));const n=new Uu(e);n.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"],role:"presentation"},children:[{text:i.to("label")}]}),this.children.add(n)}}class ch extends(Ae()){focusables;focusTracker;keystrokeHandler;actions;constructor(e){if(super(),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];"string"==typeof i&&(i=[i]);for(const n of i)e.keystrokeHandler.set(n,(e,i)=>{this[t](),i()},e.keystrokeHandlerOptions)}this.on("forwardCycle",()=>this.focusFirst(),{priority:"low"}),this.on("backwardCycle",()=>this.focusLast(),{priority:"low"})}get first(){return this.focusables.find(dh)||null}get last(){return this.focusables.filter(dh).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-1)}get current(){let e=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find((t,i)=>{const n=t.element===this.focusTracker.focusedElement;return n&&(e=i),n}),e)}focusFirst(){this._focus(this.first,1)}focusLast(){this._focus(this.last,-1)}focusNext(){const e=this.next;e&&this.focusables.getIndex(e)===this.current||e===this.first?this.fire("forwardCycle"):this._focus(e,1)}focusPrevious(){const e=this.previous;e&&this.focusables.getIndex(e)===this.current||e===this.last?this.fire("backwardCycle"):this._focus(e,-1)}chain(e){const t=()=>null===this.current?null:this.focusables.get(this.current);this.listenTo(e,"forwardCycle",e=>{const i=t();this.focusNext(),i!==t()&&e.stop()},{priority:"low"}),this.listenTo(e,"backwardCycle",e=>{const i=t();this.focusPrevious(),i!==t()&&e.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(null===i)return this[1===e?"first":"last"];let n=this.focusables.get(i),s=(i+t+e)%t;do{const i=this.focusables.get(s);if(dh(i)){n=i;break}s=(s+t+e)%t}while(s!==i);return n}}function dh(e){return uh(e)&&Et(e.element)}function uh(e){return!(!("focus"in e)||"function"!=typeof e.focus)}class hh extends Uu{children;keystrokes;focusCycler;_focusTracker;_focusables;constructor(e){super(e),this.children=this.createCollection(),this.keystrokes=new ci,this._focusTracker=new oi,this._focusables=new yu,this.focusCycler=new ch({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 e=new rh(this.locale);let i;for(i in e.on("execute",()=>t.onExecute()),t.onCreate&&t.onCreate(e),t)"onExecute"!=i&&"onCreate"!=i&&e.set(i,t[i]);this.children.add(e)}this._updateFocusCyclableItems()}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}}class mh extends Uu{children;constructor(e){super(e),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 gh="screen-center",fh="editor-center",ph="editor-top-side",bh="editor-top-center",wh="editor-bottom-center",_h="editor-above-center",vh="editor-below-center",yh=yt("px");class kh extends(Xu(Uu)){parts;headerView;closeButtonView;actionsView;static defaultOffset=15;contentView;keystrokes;focusTracker;wasMoved=!1;_getCurrentDomRoot;_getViewportOffset;_focusables;_focusCycler;constructor(e,{getCurrentDomRoot:t,getViewportOffset:i,keystrokeHandlerOptions:n}){super(e);const s=this.bindTemplate,o=e.t;this.set("className",""),this.set("ariaLabel",o("Editor dialog")),this.set("isModal",!1),this.set("position",gh),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 ci,this.focusTracker=new oi,this._focusables=new yu,this._focusCycler=new ch({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"},keystrokeHandlerOptions:n}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog-overlay",s.if("isModal","ck-dialog-overlay__transparent",e=>!e),s.if("_isVisible","ck-hidden",e=>!e)],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",e=>yh(e)),left:s.to("_left",e=>yh(e)),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(G.window,"resize",()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.listenTo(G.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:n,actionButtons:s}){t&&(this.headerView=new lh(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)),n&&(n instanceof Uu&&(n=[n]),this.contentView=new mh(this.locale),this.contentView.children.addMany(n),this.parts.add(this.contentView)),s&&(this.actionsView=new hh(this.locale),this.actionsView.setButtons(s),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(e,t){const i=this._getViewportRect(),n=this._getDialogRect();e+n.width>i.right&&(e=i.right-n.width),e<i.left&&(e=i.left),t<i.top&&(t=i.top),this._moveTo(e,t)}_moveTo(e,t){this._left=e,this._top=t}moveBy(e,t){this.moveTo(this._left+e,this._top+t)}_moveOffScreen(){this._moveTo(-9999,-9999)}updatePosition(){if(!this.element||!this.element.parentNode)return;const e=this._getViewportRect();let t,i=this.position;this._getCurrentDomRoot()?t=this._getVisibleDomRootRect(e):i=gh;const n=kh.defaultOffset,s=this._getDialogRect();if(null!=this.position){if("function"==typeof this.position){const e=this.position(s,t);return null==e?void this._moveOffScreen():void this._moveTo(e.left,e.top)}switch(i){case ph:if(t){const e="ltr"===this.locale.contentLanguageDirection?t.right-s.width-n:t.left+n;this.moveTo(e,t.top+n)}else this._moveOffScreen();break;case fh:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),Math.round(t.top+t.height/2-s.height/2)):this._moveOffScreen();break;case gh:this.moveTo(Math.round((e.width-s.width)/2),Math.round((e.height-s.height)/2));break;case bh:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.top+n):this._moveOffScreen();break;case wh:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.bottom-s.height-n):this._moveOffScreen();break;case _h:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.top-s.height-n):this._moveOffScreen();break;case vh:t?this.moveTo(Math.round(t.left+t.width/2-s.width/2),t.bottom+n):this._moveOffScreen()}}}_getVisibleDomRootRect(e){let t=new ht(this._getCurrentDomRoot()).getVisible();return t?(t=e.getIntersection(t),t||null):null}_getDialogRect(){return new ht(this.element.firstElementChild)}_getViewportRect(){const e=new ht(G.window);return this.isModal?e:St(this._getViewportOffset())}_updateFocusCyclableItems(){const e=[];if(this.contentView)for(const t of this.contentView.children)uh(t)&&e.push(t);this.actionsView&&e.push(this.actionsView),this.closeButtonView&&e.push(this.closeButtonView),e.forEach(e=>{var t;this._focusables.add(e),this.focusTracker.add(e.element),uh(t=e)&&"focusCycler"in t&&t.focusCycler instanceof ch&&this._focusCycler.chain(e.focusCycler)})}_createCloseButton(){const e=new rh(this.locale),t=this.locale.t;return e.set({label:t("Close"),tooltip:!0,icon:td}),e.on("execute",()=>this.fire("close",{source:"closeButton"})),e}}class Ch extends Cc{view;static _visibleDialogPlugin;_onHide;static get pluginName(){return"Dialog"}static get isOfficialPlugin(){return!0}constructor(e){super(e);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}]})}destroy(){super.destroy(),Ch._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",()=>{Ch._visibleDialogPlugin&&Ch._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 e of t)e.state&&this.view.updatePosition()})}show(e){this.hide(),this.fire(`show:${e.id}`,e)}_show({id:e,icon:t,title:i,hasCloseButton:n=!0,content:s,actionButtons:o,className:r,isModal:a,position:l,onHide:c,keystrokeHandlerOptions:d}){const u=this.editor;this.view=new kh(u.locale,{getCurrentDomRoot:()=>u.editing.view.getDomRoot(u.model.document.selection.anchor.root.rootName),getViewportOffset:()=>u.ui.viewportOffset,keystrokeHandlerOptions:d});const h=this.view;h.on("close",()=>{this.hide()}),u.ui.view.body.add(h),u.keystrokes.listenTo(h.element),l||(l=a?gh:fh),a&&this._lockBodyScroll(),h.set({position:l,_isVisible:!0,className:r,isModal:a}),h.setupParts({icon:t,title:i,hasCloseButton:n,content:s,actionButtons:o}),this.id=e,c&&(this._onHide=c),this.isOpen=!0,Ch._visibleDialogPlugin=this}hide(){Ch._visibleDialogPlugin&&Ch._visibleDialogPlugin.fire(`hide:${Ch._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,Ch._visibleDialogPlugin=null}_lockBodyScroll(){document.documentElement.classList.add("ck-dialog-scroll-locked")}_unlockBodyScroll(){document.documentElement.classList.remove("ck-dialog-scroll-locked")}}class Ah extends rh{_checkIconHolderView=new Th;constructor(e,t=new oh){super(e,t),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",(e,t)=>e||t)}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:n,_checkIconHolderView:s}=this;i?n.add(s,0):n.remove(s)})}}class Th extends Uu{children;_checkIconView=this._createCheckIconView();constructor(){super();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",e=>e?"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:n,_checkIconView:s}=this;i&&!n.has(s)?n.add(s):!i&&n.has(s)&&n.remove(s)})}_createCheckIconView(){const e=new sh;return e.content=nd,e.extendTemplate({attributes:{class:"ck-list-item-button__check-icon"}}),e}}class Eh extends Ah{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 xh extends Cc{contentView=null;static get requires(){return[Ch]}static get pluginName(){return"AccessibilityHelp"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("accessibilityHelp",()=>{const e=this._createButton(rh);return e.set({tooltip:!0,withText:!1,label:t("Accessibility help")}),e}),e.ui.componentFactory.add("menuBar:accessibilityHelp",()=>{const e=this._createButton(Eh);return e.label=t("Accessibility"),e}),e.keystrokes.set("Alt+0",(e,t)=>{this._toggleDialog(),t()}),this._setupRootLabels()}_createButton(e){const t=this.editor,i=t.plugins.get("Dialog"),n=new e(t.locale);return n.set({keystroke:"Alt+0",icon:Jc,isToggleable:!0}),n.on("execute",()=>this._toggleDialog()),n.bind("isOn").to(i,"id",e=>"accessibilityHelp"===e),n}_setupRootLabels(){const e=this.editor,t=e.editing.view,i=e.t;function n(e,t){const n=[t.getAttribute("aria-label"),i("Press %0 for help.",[Jt("Alt+0")])].filter(e=>e).join(". ");e.setAttribute("aria-label",n,t)}e.ui.on("ready",()=>{t.change(e=>{for(const i of t.document.roots)n(e,i)}),e.on("addRoot",(i,s)=>{const o=e.editing.view.document.getRoot(s.rootName);t.change(e=>n(e,o))},{priority:"low"})})}_toggleDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.contentView||(this.contentView=new ih(e.locale,e.accessibility.keystrokeInfos)),"accessibilityHelp"===t.id?t.hide():t.show({id:"accessibilityHelp",className:"ck-accessibility-help-dialog",title:i("Accessibility help"),icon:Jc,hasCloseButton:!0,content:this.contentView})}}class Ph extends yu{locale;_bodyCollectionContainer;static _bodyWrapper;constructor(e,t=[]){super(t),this.locale=e}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new ku({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection,role:"application"},children:this}).render(),Ph._bodyWrapper&&Ph._bodyWrapper.isConnected||(Ph._bodyWrapper=Ge(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(Ph._bodyWrapper)),Ph._bodyWrapper.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove(),Ph._bodyWrapper&&!Ph._bodyWrapper.childElementCount&&(Ph._bodyWrapper.remove(),delete Ph._bodyWrapper)}}const Sh=yt("px"),Ih={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}};class Oh extends Uu{content;_pinWhenIsVisibleCallback;_resizeObserver;constructor(e){super(e);const t=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class",void 0),this._pinWhenIsVisibleCallback=null,this._resizeObserver=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",e=>`ck-balloon-panel_${e}`),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Sh),left:t.to("left",Sh)}},children:this.content})}destroy(){this.hide(),super.destroy()}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){const t=Rh(e.target);if(t&&!Et(t))return!1;this.show();const i=Oh.defaultPositions,n=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:G.document.body,fitInViewport:!0},e),s=Oh._getOptimalPosition(n)||Ih,o=parseInt(s.left),r=parseInt(s.top),a=s.name,l=s.config||{},{withArrow:c=!0}=l;return this.top=r,this.left=o,this.position=a,this.withArrow=c,!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=Rh(e.target);const i=e.limiter?Rh(e.limiter):G.document.body;if(this.listenTo(G.document,"scroll",(n,s)=>{const o=s.target,r=t&&o.contains(t),a=i&&o.contains(i);!r&&!a&&t&&i||this.attachTo(e)},{useCapture:!0}),this.listenTo(G.window,"resize",()=>{this.attachTo(e)}),!this._resizeObserver&&(t&<(t)&&(t=t.parentElement),t)){const e=()=>{Et(t)||this.unpin()};this._resizeObserver=new _t(t,e)}return!0}_stopPinning(){this.stopListening(G.document,"scroll"),this.stopListening(G.window,"resize"),this._resizeObserver&&(this._resizeObserver.destroy(),this._resizeObserver=null)}static generatePositions(e={}){const{sideOffset:t=Oh.arrowSideOffset,heightOffset:i=Oh.arrowHeightOffset,stickyVerticalOffset:n=Oh.stickyVerticalOffset,config:s}=e;return{northWestArrowSouthWest:(e,i)=>({top:o(e,i),left:e.left-t,name:"arrow_sw",...s&&{config:s}}),northWestArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.left-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northWestArrowSouth:(e,t)=>({top:o(e,t),left:e.left-t.width/2,name:"arrow_s",...s&&{config:s}}),northWestArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.left-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northWestArrowSouthEast:(e,i)=>({top:o(e,i),left:e.left-i.width+t,name:"arrow_se",...s&&{config:s}}),northArrowSouthWest:(e,i)=>({top:o(e,i),left:e.left+e.width/2-t,name:"arrow_sw",...s&&{config:s}}),northArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.left+e.width/2-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northArrowSouth:(e,t)=>({top:o(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...s&&{config:s}}),northArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.left+e.width/2-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northArrowSouthEast:(e,i)=>({top:o(e,i),left:e.left+e.width/2-i.width+t,name:"arrow_se",...s&&{config:s}}),northEastArrowSouthWest:(e,i)=>({top:o(e,i),left:e.right-t,name:"arrow_sw",...s&&{config:s}}),northEastArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.right-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northEastArrowSouth:(e,t)=>({top:o(e,t),left:e.right-t.width/2,name:"arrow_s",...s&&{config:s}}),northEastArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.right-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northEastArrowSouthEast:(e,i)=>({top:o(e,i),left:e.right-i.width+t,name:"arrow_se",...s&&{config:s}}),southWestArrowNorthWest:e=>({top:r(e),left:e.left-t,name:"arrow_nw",...s&&{config:s}}),southWestArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.left-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southWestArrowNorth:(e,t)=>({top:r(e),left:e.left-t.width/2,name:"arrow_n",...s&&{config:s}}),southWestArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.left-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southWestArrowNorthEast:(e,i)=>({top:r(e),left:e.left-i.width+t,name:"arrow_ne",...s&&{config:s}}),southArrowNorthWest:e=>({top:r(e),left:e.left+e.width/2-t,name:"arrow_nw",...s&&{config:s}}),southArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.left+e.width/2-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southArrowNorth:(e,t)=>({top:r(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...s&&{config:s}}),southArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.left+e.width/2-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southArrowNorthEast:(e,i)=>({top:r(e),left:e.left+e.width/2-i.width+t,name:"arrow_ne",...s&&{config:s}}),southEastArrowNorthWest:e=>({top:r(e),left:e.right-t,name:"arrow_nw",...s&&{config:s}}),southEastArrowNorthMiddleWest:(e,i)=>({top:r(e),left:e.right-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southEastArrowNorth:(e,t)=>({top:r(e),left:e.right-t.width/2,name:"arrow_n",...s&&{config:s}}),southEastArrowNorthMiddleEast:(e,i)=>({top:r(e),left:e.right-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southEastArrowNorthEast:(e,i)=>({top:r(e),left:e.right-i.width+t,name:"arrow_ne",...s&&{config:s}}),westArrowEast:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.left-t.width-i,name:"arrow_e",...s&&{config:s}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+i,name:"arrow_w",...s&&{config:s}}),viewportStickyNorth:(e,t,i)=>{const o=new ht(G.document.body).getIntersection(i.getVisible());if(!o)return null;const r=o.getVisible();return e.getIntersection(r)&&r.top-e.top-n<t.height&&r.bottom-e.bottom<t.height?{top:r.top+n,left:e.left+e.width/2-t.width/2,name:"arrowless",config:{withArrow:!1,...s}}:null}};function o(e,t){return e.top-t.height-i}function r(e){return e.bottom+i}}static arrowSideOffset=25;static arrowHeightOffset=10;static stickyVerticalOffset=20;static _getOptimalPosition=xt;static defaultPositions=Oh.generatePositions()}function Rh(e){return M(e)?e:ct(e)?e.commonAncestorContainer:"function"==typeof e?Rh(e()):null}class Vh extends(tt()){editor;_balloonView=null;_showBalloonThrottled=Ai(()=>this._showBalloon(),50,{leading:!0});_lastFocusedEditableElement=null;_balloonClass;constructor(e,t={}){super(),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",(e,t,i)=>{this._updateLastFocusedEditableElement(),i?this._showBalloon():this._hideBalloon()}),e.ui.focusTracker.on("change:focusedElement",(e,t,i)=>{this._updateLastFocusedEditableElement(),i&&this._showBalloon()}),e.ui.on("update",()=>{this._showBalloonThrottled()}))}_getNormalizedConfig(){return{side:"ltr"===this.editor.locale.contentLanguageDirection?"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 Oh,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="right"===e.side?Bh(this._lastFocusedEditableElement,i=e,(e,t)=>e.left+e.width-t.width-i.horizontalOffset):function(e,t){return Bh(e,t,e=>e.left+t.horizontalOffset)}(this._lastFocusedEditableElement,e);var i;return{target:this._lastFocusedEditableElement,positions:[t]}}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,i=e.ui.focusTracker.focusedElement;if(!t||!i)return void(this._lastFocusedEditableElement=null);const n=Array.from(e.ui.getEditableElementsNames()).map(t=>e.ui.getEditableElement(t));n.includes(i)?this._lastFocusedEditableElement=i:this._lastFocusedEditableElement=n[0]}}function Bh(e,t,i){return(n,s)=>{const o=new ht(e);if(o.width<350||o.height<50)return null;let r;r="inside"===t.position?o.bottom-s.height:o.bottom-s.height/2,r-=t.verticalOffset;const a=i(o,s),l=n.clone().moveTo(a,r).getIntersection(s.clone().moveTo(a,r)).getVisible();return!l||l.getArea()<s.getArea()?null:{top:r,left:a,name:`position_${t.position}-side_${t.side}`,config:{withArrow:!1}}}}class Mh extends Vh{constructor(e){super(e,{balloonClass:"ck-powered-by-balloon"})}_isEnabled(){const e=this.editor;if(e.config.get("ui.poweredBy.forceVisible"))return!0;const t=e.config.get("licenseKey");if("GPL"==t)return!0;const i=mi(t.split(".")[1]);return!i||!i.whiteLabel}_createBadgeContent(){return new Fh(this.editor.locale,this._getNormalizedConfig().label)}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{},i=t.position||e.position,n="inside"===i?5:e.verticalOffset;return{position:i,side:t.side||e.side,label:void 0===t.label?"Powered by":t.label,verticalOffset:void 0!==t.verticalOffset?t.verticalOffset:n,horizontalOffset:void 0!==t.horizontalOffset?t.horizontalOffset:e.horizontalOffset,forceVisible:!!t.forceVisible}}}class Fh extends Uu{constructor(e,t){super(e);const i=new sh,n=this.bindTemplate;i.set({content:'<svg xmlns="http://www.w3.org/2000/svg" width="53" height="10" viewBox="0 0 53 10"><path fill="#1C2331" d="M31.724 1.492a15.139 15.139 0 0 0 .045 1.16 2.434 2.434 0 0 0-.687-.34 3.68 3.68 0 0 0-1.103-.166 2.332 2.332 0 0 0-1.14.255 1.549 1.549 0 0 0-.686.87c-.15.41-.225.98-.225 1.712 0 .939.148 1.659.444 2.161.297.503.792.754 1.487.754.452.015.9-.094 1.294-.316.296-.174.557-.4.771-.669l.14.852h1.282V.007h-1.623v1.485ZM31 6.496a1.77 1.77 0 0 1-.494.061.964.964 0 0 1-.521-.127.758.758 0 0 1-.296-.466 3.984 3.984 0 0 1-.093-.992 4.208 4.208 0 0 1 .098-1.052.753.753 0 0 1 .307-.477 1.08 1.08 0 0 1 .55-.122c.233-.004.466.026.69.089l.483.144v2.553c-.11.076-.213.143-.307.2a1.73 1.73 0 0 1-.417.189ZM35.68 0l-.702.004c-.322.002-.482.168-.48.497l.004.581c.002.33.164.493.486.49l.702-.004c.322-.002.481-.167.48-.496L36.165.49c-.002-.33-.164-.493-.486-.491ZM36.145 2.313l-1.612.01.034 5.482 1.613-.01-.035-5.482ZM39.623.79 37.989.8 38 2.306l-.946.056.006 1.009.949-.006.024 2.983c.003.476.143.844.419 1.106.275.26.658.39 1.148.387.132 0 .293-.01.483-.03.19-.02.38-.046.57-.08.163-.028.324-.068.482-.119l-.183-1.095-.702.004a.664.664 0 0 1-.456-.123.553.553 0 0 1-.14-.422l-.016-2.621 1.513-.01-.006-1.064-1.514.01-.01-1.503ZM46.226 2.388c-.41-.184-.956-.274-1.636-.27-.673.004-1.215.101-1.627.29-.402.179-.72.505-.888.91-.18.419-.268.979-.264 1.68.004.688.1 1.24.285 1.655.172.404.495.724.9.894.414.18.957.268 1.63.264.68-.004 1.224-.099 1.632-.284.4-.176.714-.501.878-.905.176-.418.263-.971.258-1.658-.004-.702-.097-1.261-.28-1.677a1.696 1.696 0 0 0-.888-.9Zm-.613 3.607a.77.77 0 0 1-.337.501 1.649 1.649 0 0 1-1.317.009.776.776 0 0 1-.343-.497 4.066 4.066 0 0 1-.105-1.02 4.136 4.136 0 0 1 .092-1.03.786.786 0 0 1 .337-.507 1.59 1.59 0 0 1 1.316-.008.79.79 0 0 1 .344.502c.078.337.113.683.105 1.03.012.343-.019.685-.092 1.02ZM52.114 2.07a2.67 2.67 0 0 0-1.128.278c-.39.191-.752.437-1.072.73l-.157-.846-1.273.008.036 5.572 1.623-.01-.024-3.78c.35-.124.646-.22.887-.286.26-.075.53-.114.8-.118l.45-.003.144-1.546-.286.001ZM22.083 7.426l-1.576-2.532a2.137 2.137 0 0 0-.172-.253 1.95 1.95 0 0 0-.304-.29.138.138 0 0 1 .042-.04 1.7 1.7 0 0 0 .328-.374l1.75-2.71c.01-.015.025-.028.024-.048-.01-.01-.021-.007-.031-.007L20.49 1.17a.078.078 0 0 0-.075.045l-.868 1.384c-.23.366-.46.732-.688 1.099a.108.108 0 0 1-.112.06c-.098-.005-.196-.001-.294-.002-.018 0-.038.006-.055-.007.002-.02.002-.039.005-.058a4.6 4.6 0 0 0 .046-.701V1.203c0-.02-.009-.032-.03-.03h-.033L16.93 1.17c-.084 0-.073-.01-.073.076v6.491c-.001.018.006.028.025.027h1.494c.083 0 .072.007.072-.071v-2.19c0-.055-.003-.11-.004-.166a3.366 3.366 0 0 0-.05-.417h.06c.104 0 .209.002.313-.002a.082.082 0 0 1 .084.05c.535.913 1.07 1.824 1.607 2.736a.104.104 0 0 0 .103.062c.554-.003 1.107-.002 1.66-.002l.069-.003-.019-.032-.188-.304ZM27.112 6.555c-.005-.08-.004-.08-.082-.08h-2.414c-.053 0-.106-.003-.159-.011a.279.279 0 0 1-.246-.209.558.558 0 0 1-.022-.15c0-.382 0-.762-.002-1.143 0-.032.007-.049.042-.044h2.504c.029.003.037-.012.034-.038V3.814c0-.089.013-.078-.076-.078h-2.44c-.07 0-.062.003-.062-.06v-.837c0-.047.004-.093.013-.14a.283.283 0 0 1 .241-.246.717.717 0 0 1 .146-.011h2.484c.024.002.035-.009.036-.033l.003-.038.03-.496c.01-.183.024-.365.034-.548.005-.085.003-.087-.082-.094-.218-.018-.437-.038-.655-.05a17.845 17.845 0 0 0-.657-.026 72.994 72.994 0 0 0-1.756-.016 1.7 1.7 0 0 0-.471.064 1.286 1.286 0 0 0-.817.655c-.099.196-.149.413-.145.633v3.875c0 .072.003.144.011.216a1.27 1.27 0 0 0 .711 1.029c.228.113.48.167.734.158.757-.005 1.515.002 2.272-.042.274-.016.548-.034.82-.053.03-.002.043-.008.04-.041-.008-.104-.012-.208-.019-.312a69.964 69.964 0 0 1-.05-.768ZM16.14 7.415l-.127-1.075c-.004-.03-.014-.04-.044-.037a13.125 13.125 0 0 1-.998.073c-.336.01-.672.02-1.008.016-.116-.001-.233-.014-.347-.039a.746.746 0 0 1-.45-.262c-.075-.1-.132-.211-.167-.33a3.324 3.324 0 0 1-.126-.773 9.113 9.113 0 0 1-.015-.749c0-.285.022-.57.065-.852.023-.158.066-.312.127-.46a.728.728 0 0 1 .518-.443 1.64 1.64 0 0 1 .397-.048c.628-.001 1.255.003 1.882.05.022.001.033-.006.036-.026l.003-.031.06-.55c.019-.177.036-.355.057-.532.004-.034-.005-.046-.04-.056a5.595 5.595 0 0 0-1.213-.21 10.783 10.783 0 0 0-.708-.02c-.24-.003-.48.01-.719.041a3.477 3.477 0 0 0-.625.14 1.912 1.912 0 0 0-.807.497c-.185.2-.33.433-.424.688a4.311 4.311 0 0 0-.24 1.096c-.031.286-.045.572-.042.86-.006.43.024.86.091 1.286.04.25.104.497.193.734.098.279.26.53.473.734.214.205.473.358.756.446.344.11.702.17 1.063.177a8.505 8.505 0 0 0 1.578-.083 6.11 6.11 0 0 0 .766-.18c.03-.008.047-.023.037-.057a.157.157 0 0 1-.003-.025Z"/><path fill="#AFE229" d="M6.016 6.69a1.592 1.592 0 0 0-.614.21c-.23.132-.422.32-.56.546-.044.072-.287.539-.287.539l-.836 1.528.009.006c.038.025.08.046.123.063.127.046.26.07.395.073.505.023 1.011-.007 1.517-.003.29.009.58.002.869-.022a.886.886 0 0 0 .395-.116.962.962 0 0 0 .312-.286c.056-.083.114-.163.164-.249.24-.408.48-.816.718-1.226.075-.128.148-.257.222-.386l.112-.192a1.07 1.07 0 0 0 .153-.518l-1.304.023s-1.258-.005-1.388.01Z"/><path fill="#771BFF" d="m2.848 9.044.76-1.39.184-.352c-.124-.067-.245-.14-.367-.21-.346-.204-.706-.384-1.045-.6a.984.984 0 0 1-.244-.207c-.108-.134-.136-.294-.144-.46-.021-.409-.002-.818-.009-1.227-.003-.195 0-.39.003-.585.004-.322.153-.553.427-.713l.833-.488c.22-.13.44-.257.662-.385.05-.029.105-.052.158-.077.272-.128.519-.047.76.085l.044.028c.123.06.242.125.358.196.318.178.635.357.952.537.095.056.187.117.275.184.194.144.254.35.266.578.016.284.007.569.006.853-.001.28.004.558 0 .838.592-.003 1.259 0 1.259 0l.723-.013c-.003-.292-.007-.584-.007-.876 0-.524.015-1.048-.016-1.571-.024-.42-.135-.8-.492-1.067a5.02 5.02 0 0 0-.506-.339A400.52 400.52 0 0 0 5.94.787C5.722.664 5.513.524 5.282.423 5.255.406 5.228.388 5.2.373 4.758.126 4.305-.026 3.807.21c-.097.046-.197.087-.29.14A699.896 699.896 0 0 0 .783 1.948c-.501.294-.773.717-.778 1.31-.004.36-.009.718-.001 1.077.016.754-.017 1.508.024 2.261.016.304.07.6.269.848.127.15.279.28.448.382.622.4 1.283.734 1.92 1.11l.183.109Z"/></svg>\n',isColorInherited:!1}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-powered-by"],"aria-hidden":!0},children:[{tag:"a",attributes:{href:"https://ckeditor.com/powered-by-ckeditor/?utm_source=ckeditor&utm_medium=referral&utm_campaign=701Dn000000hVgmIAE_powered_by_ckeditor_logo",target:"_blank",tabindex:"-1"},children:[...t?[{tag:"span",attributes:{class:["ck","ck-powered-by__label"]},children:[t]}]:[],i],on:{dragstart:n.to(e=>e.preventDefault())}}]})}}class Nh extends rh{toggleSwitchView;constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new Uu;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}class Lh extends(zh(rh)){}class Dh extends(zh(Ah)){}function zh(e){return class extends e{_fileInputView;constructor(...e){super(...e),this._fileInputView=new Hh(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)}}}class Hh extends Uu{constructor(e){super(e),this.set("acceptedType",void 0),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to(()=>{this.element?.files?.length&&this.fire("done",this.element.files),this.element.value=""})}})}open(){this.element.click()}}class $h extends Uu{buttonView;children;constructor(e,t){super(e);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 rh(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:rd}),e.extendTemplate({attributes:{"aria-expanded":t.to("isOn",e=>String(e))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",e=>!e),e.on("execute",()=>{this.isCollapsed=!this.isCollapsed}),e}}function Wh(e,t){const i=e.t,n={Black:i("Black"),"Dim grey":i("Dim grey"),Grey:i("Grey"),"Light grey":i("Light grey"),White:i("White"),Red:i("Red"),Orange:i("Orange"),Yellow:i("Yellow"),"Light green":i("Light green"),Green:i("Green"),Aquamarine:i("Aquamarine"),Turquoise:i("Turquoise"),"Light blue":i("Light blue"),Blue:i("Blue"),Purple:i("Purple")};return t.map(e=>{const t=n[e.label];return t&&t!=e.label&&(e.label=t),e})}function jh(e){return e.map(Uh).filter(e=>!!e)}function Uh(e){return"string"==typeof e?{model:e,label:e,hasBorder:!1,view:{name:"span",styles:{color:e}}}:{model:e.color,label:e.label||e.color,hasBorder:void 0!==e.hasBorder&&e.hasBorder,view:{name:"span",styles:{color:`${e.color}`}}}}class qh extends rh{constructor(e){super(e);const t=this.bindTemplate;this.set("color",void 0),this.set("hasBorder",!1),this.icon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M16.935 5.328a2 2 0 0 1 0 2.829l-7.778 7.778a2 2 0 0 1-2.829 0L3.5 13.107a1.999 1.999 0 1 1 2.828-2.829l.707.707a1 1 0 0 0 1.414 0l5.658-5.657a2 2 0 0 1 2.828 0" class="ck-icon__fill"/><path d="M14.814 6.035 8.448 12.4a1 1 0 0 1-1.414 0l-1.413-1.415A1 1 0 1 0 4.207 12.4l2.829 2.829a1 1 0 0 0 1.414 0l7.778-7.778a1 1 0 1 0-1.414-1.415z"/></svg>',this.extendTemplate({attributes:{style:{backgroundColor:t.to("color",e=>Q.isMediaForcedColors?null:e)},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 Kh extends Uu{columns;items;focusTracker;keystrokes;constructor(e,t){super(e);const i=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t?.columns||5;const n={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new oi,this.keystrokes=new ci,this.items.on("add",(e,t)=>{t.isOn=t.color===this.selectedColor}),i.forEach(e=>{const t=new qh;t.set({color:e.color,label:e.label,tooltip:!0,hasBorder:e.options.hasBorder}),t.on("execute",()=>{this.fire("execute",{value:e.color,hasBorder:e.options.hasBorder,label:e.label})}),this.items.add(t)}),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:n}}),this.on("change:selectedColor",(e,t,i)=>{for(const e of this.items)e.isOn=e.color===i})}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",(e,t)=>{this.focusTracker.add(t.element)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t.element)}),this.keystrokes.listenTo(this.element),eh({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:this.locale?.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}function Gh(e,t){if(!e)return"";const i=Jh(e);if(!i)return"";if(i.space===t)return e;if(n=i,!Object.keys(Ud).includes(n.space))return"";var n;const s=Ud[i.space][t];if(!s)return"";return function(e,t){switch(t){case"hex":return`#${e}`;case"rgb":return`rgb(${e[0]}, ${e[1]}, ${e[2]})`;case"hsl":return`hsl(${e[0]}, ${e[1]}%, ${e[2]}%)`;case"hwb":return`hwb(${e[0]}, ${e[1]}, ${e[2]})`;case"lab":return`lab(${e[0]}% ${e[1]} ${e[2]})`;case"lch":return`lch(${e[0]}% ${e[1]} ${e[2]})`;default:return""}}(s("hex"===i.space?i.hexValue:i.values),t)}function Jh(e){if(e.startsWith("#")){const t=Ed(e);return{space:"hex",values:t.values,hexValue:e,alpha:t.alpha}}const t=Ed(e);return t.space?t:null}class Yh extends Uu{fieldView;labelView;statusView;fieldWrapperChildren;constructor(e,t){super(e);const i=`ck-labeled-field-view-${he()}`,n=`ck-labeled-field-view-status-${he()}`;this.fieldView=t(this,i,n),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(n),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",(e,t)=>e||t);const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",s.to("class"),s.if("isEnabled","ck-disabled",e=>!e),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 th(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Uu(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",e=>!e)],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}focus(e){this.fieldView.focus(e)}}class Qh extends Uu{focusTracker;constructor(e){super(e),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 oi,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((...e)=>{this.fire("input",...e),this._updateIsEmpty()}),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",(e,t,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=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}class Xh extends Qh{constructor(e){super(e),this.set("inputMode","text");const t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to("inputMode")}})}}class Zh extends Xh{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class em extends Xh{constructor(e,{min:t,max:i,step:n}={}){super(e);const s=this.bindTemplate;this.set("min",t),this.set("max",i),this.set("step",n),this.extendTemplate({attributes:{type:"number",class:["ck-input-number"],min:s.to("min"),max:s.to("max"),step:s.to("step")}})}}class tm extends Uu{children;constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-dropdown__panel",t.to("position",e=>`ck-dropdown__panel_${e}`),t.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:t.to(e=>{const t=e.target;t instanceof Element&&"input"===t.tagName.toLocaleLowerCase()||e.preventDefault()})}})}focus(){if(this.children.length){const e=this.children.first;"function"==typeof e.focus?e.focus():pe("ui-dropdown-panel-focus-child-missing-focus",{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){const e=this.children.last;"function"==typeof e.focusLast?e.focusLast():e.focus()}}}class im extends Uu{buttonView;panelView;focusTracker;keystrokes;listView;toolbarView;menuView;constructor(e,t,i){super(e);const n=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 ci,this.focusTracker=new oi,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",n.to("class"),n.if("isEnabled","ck-disabled",e=>!e)],id:n.to("id"),"aria-describedby":n.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":n.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",(e,t,i)=>{if(i)if("auto"===this.panelPosition){const e=im._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=e?e.name:this._defaultPanelPositionName}else this.panelView.position=this.panelPosition}),this.keystrokes.listenTo(this.element);const e=(e,t)=>{this.isOpen&&(this.isOpen=!1,t())};this.keystrokes.set("arrowdown",(e,t)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,t())}),this.keystrokes.set("arrowright",(e,t)=>{this.isOpen&&t()}),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:i,southWest:n,northEast:s,northWest:o,southMiddleEast:r,southMiddleWest:a,northMiddleEast:l,northMiddleWest:c}=im.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[i,n,r,a,e,s,o,l,c,t]:[n,i,a,r,e,o,s,c,l,t]}get _defaultPanelPositionName(){return"rtl"===this.locale.uiLanguageDirection?"sw":"se"}static defaultPanelPositions={south:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/2,name:"s"}),southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),southMiddleEast:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/4,name:"sme"}),southMiddleWest:(e,t)=>({top:e.bottom,left:e.left-3*(t.width-e.width)/4,name:"smw"}),north:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/2,name:"n"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),northMiddleEast:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/4,name:"nme"}),northMiddleWest:(e,t)=>({top:e.top-t.height,left:e.left-3*(t.width-e.width)/4,name:"nmw"})};static _getOptimalPosition=xt}class nm extends rh{arrowView;constructor(e){super(e),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",e=>String(e))}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new sh;return e.content=rd,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class sm extends Uu{children;constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!0),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item",t.if("isVisible","ck-hidden",e=>!e)],role:"presentation"},children:this.children})}focus(){this.children.first&&this.children.first.focus()}}class om extends Uu{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class rm extends Uu{labelView;items;children;constructor(e,t=new th){super(e);const i=this.bindTemplate,n=new am(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,n]),n.set({role:"group",ariaLabelledBy:t.id}),n.focusTracker.destroy(),n.keystrokes.destroy(),this.items=n.items,this.setTemplate({tag:"li",attributes:{role:"presentation",class:["ck","ck-list__group",i.if("isVisible","ck-hidden",e=>!e)]},children:this.children})}focus(){if(this.items){const e=this.items.find(e=>!(e instanceof om));e&&e.focus()}}}class am extends Uu{focusables;items;focusTracker;keystrokes;_focusCycler;_listItemGroupToChangeListeners=new WeakMap;constructor(e){super(e);const t=this.bindTemplate;this.focusables=new yu,this.items=this.createCollection(),this.focusTracker=new oi,this.keystrokes=new ci,this._focusCycler=new ch({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 rm?this._registerFocusableItemsGroup(e):e instanceof sm&&this._registerFocusableListItem(e);this.items.on("change",(e,t)=>{for(const e of t.removed)e instanceof rm?this._deregisterFocusableItemsGroup(e):e instanceof sm&&this._deregisterFocusableListItem(e);for(const e of Array.from(t.added).reverse())e instanceof rm?this._registerFocusableItemsGroup(e,t.index):this._registerFocusableListItem(e,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 e of i.removed)this._deregisterFocusableListItem(e);for(const t of Array.from(i.added).reverse())this._registerFocusableListItem(t,this.items.getIndex(e)+i.index)}}_registerFocusableItemsGroup(e,t){Array.from(e.items).forEach((e,i)=>{const n=void 0!==t?t+i:void 0;this._registerFocusableListItem(e,n)});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)}}class lm extends Uu{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class cm extends Uu{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function dm(e){if(Array.isArray(e))return{items:e,removeItems:[]};const t={items:[],removeItems:[]};return e?{...t,...e}:t}const um=(()=>({alignLeft:Xc,bold:ed,importExport:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M19 4.5 14 0H3v12.673l.868-1.041c.185-.222.4-.402.632-.54V1.5h8v5h5v7.626a2.24 2.24 0 0 1 1.5.822zM14 5V2l3.3 3zm-3.692 12.5q.093.157.213.303L11.52 19H8v-.876a2.24 2.24 0 0 0 1.82-.624zm7.518-.657a.75.75 0 0 0-1.152-.96L15.5 17.29V12H14v5.29l-1.174-1.408a.75.75 0 0 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0zm-15.056-.38a.75.75 0 0 1-.096-1.056l2.346-2.815a.95.95 0 0 1 1.46 0l2.346 2.815a.75.75 0 1 1-1.152.96L6.5 14.96V20H5v-5.04l-1.174 1.408a.75.75 0 0 1-1.056.096Z"/></svg>',paragraph:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10.5 5.5H7v5h3.5a2.5 2.5 0 1 0 0-5M5 3h6.5v.025a5 5 0 0 1 0 9.95V13H7v4a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1"/></svg>',plus:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10 2a1 1 0 0 0-1 1v6H3a1 1 0 1 0 0 2h6v6a1 1 0 1 0 2 0v-6h6a1 1 0 1 0 0-2h-6V3a1 1 0 0 0-1-1"/></svg>',text:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.816 11.5 7.038 4.785 4.261 11.5zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663z"/><path d="m12.09 17-.534-1.292.848-1.971.545 1.319L12.113 17zm1.142-5.187.545 1.319L15.5 9.13l1.858 4.316h-3.45l.398.965h3.467L18.887 17H20l-3.873-9h-1.254z"/></svg>',threeVerticalDots:kd,pilcrow:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M6.999 2H15a1 1 0 0 1 0 2h-1.004v13a1 1 0 1 1-2 0V4H8.999v13a1 1 0 1 1-2 0v-7A4 4 0 0 1 3 6a4 4 0 0 1 3.999-4"/></svg>',dragIndicator:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M5 3.25a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 0a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 0a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m-7 6.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0m7 0a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/></svg>'}))();class hm extends Uu{options;items;focusTracker;keystrokes;itemsView;children;focusables;_focusCycler;_behavior;constructor(e,t){super(e);const i=this.bindTemplate,n=this.t;this.options=t||{},this.set("ariaLabel",n("Editor toolbar")),this.set("maxWidth","auto"),this.set("role","toolbar"),this.set("isGrouping",!!this.options.shouldGroupWhenFull),this.items=this.createCollection(),this.focusTracker=new oi,this.keystrokes=new ci,this.set("class",void 0),this.set("isCompact",!1),this.set("isVertical",!1),this.itemsView=new mm(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const s="rtl"===e.uiLanguageDirection;this._focusCycler=new ch({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[s?"arrowright":"arrowleft","arrowup"],focusNext:[s?"arrowleft":"arrowright","arrowdown"]}});const o=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact"),i.if("isGrouping","ck-toolbar_grouping"),i.if("isVertical","ck-toolbar_vertical")];var r;this.options.shouldGroupWhenFull&&this.options.isFloating&&o.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:o,role:i.to("role"),"aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:(r=this,r.bindTemplate.to(e=>{e.target===r.element&&e.preventDefault()}))}}),this._behavior=this.options.shouldGroupWhenFull?new fm(this):new gm(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(),"dynamic"===e?(this._behavior=new fm(this),this._behavior.render(this),this._behavior.refreshItems()):(this._behavior=new gm(this),this._behavior.render(this)))}_buildItemsFromConfig(e,t,n){const s=dm(e),o=n||s.removeItems;return this._cleanItemsConfiguration(s.items,t,o).map(e=>i(e)?this._createNestedToolbarDropdown(e,t,o):"|"===e?new lm:"-"===e?new cm:t.create(e)).filter(e=>!!e)}_cleanItemsConfiguration(e,t,n){const s=e.filter((e,s,o)=>"|"===e||-1===n.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(pe("toolbarview-line-break-ignored-when-grouping-items",o),!1):!(!i(e)&&!t.has(e))||(pe("toolbarview-item-unavailable",{item:e}),!1)));return this._cleanSeparatorsAndLineBreaks(s)}_cleanSeparatorsAndLineBreaks(e){const t=e=>"-"!==e&&"|"!==e,i=e.length,n=e.findIndex(t);if(-1===n)return[];const s=i-e.slice().reverse().findIndex(t);return e.slice(n,s).filter((e,i,n)=>{if(t(e))return!0;return!(i>0&&n[i-1]===e)})}_createNestedToolbarDropdown(e,t,i){let{label:n,icon:s,items:o,tooltip:r=!0,withText:a=!1}=e;if(o=this._cleanItemsConfiguration(o,t,i),!o.length)return null;const l=bm(this.locale);return n||pe("toolbarview-nested-toolbar-dropdown-missing-label",e),l.class="ck-toolbar__nested-toolbar-dropdown",l.buttonView.set({label:n,tooltip:r,withText:!!a}),!1!==s?l.buttonView.icon=um[s]||s||kd:l.buttonView.withText=!0,wm(l,()=>l.toolbarView._buildItemsFromConfig(o,t,i)),l}}class mm extends Uu{children;constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class gm{type="static";constructor(e){e.isGrouping=!1,e.itemsView.children.bindTo(e.items).using(e=>e),e.focusables.bindTo(e.items).using(e=>uh(e)?e:null)}render(){}destroy(){}}class fm{type="dynamic";view;viewChildren;viewFocusables;viewItemsView;viewFocusTracker;viewLocale;ungroupedItems;groupedItems;groupedItemsDropdown;resizeObserver=null;cachedPadding=null;shouldUpdateGroupingOnNextResize=!1;viewElement;constructor(e){this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.view.isGrouping=!0,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),e.itemsView.children.bindTo(this.ungroupedItems).using(e=>e),this.ungroupedItems.on("change",this._updateFocusCyclableItems.bind(this)),e.children.on("change",this._updateFocusCyclableItems.bind(this)),e.items.on("change",(e,t)=>{const i=t.index,n=Array.from(t.added);for(const e of t.removed)i>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=i;e<i+n.length;e++){const t=n[e-i];e>this.ungroupedItems.length?this.groupedItems.add(t,e-this.ungroupedItems.length):this.ungroupedItems.add(t,e)}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;t<e.items.length;t++){const i=[...e.items][t];this.ungroupedItems.add(i,t)}this._updateGrouping()}}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!Et(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,t=this.viewLocale.uiLanguageDirection,i=new ht(e.lastChild),n=new ht(e);if(!this.cachedPadding){const i=G.window.getComputedStyle(e),n="ltr"===t?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(i[n])}return"ltr"===t?i.right>n.right-this.cachedPadding:i.left<n.left+this.cachedPadding}_enableGroupingOnResize(){let e;this.resizeObserver=new _t(this.viewElement,t=>{e&&e===t.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)}),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",()=>{this._updateGrouping()})}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new lm),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=bm(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",wm(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:kd}),i}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map(e=>{uh(e)&&this.viewFocusables.add(e)}),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class pm extends Uu{children;actionView;arrowView;keystrokes;focusTracker;constructor(e,t){super(e);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 ci,this.focusTracker=new oi,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",i.to("class"),i.if("isVisible","ck-hidden",e=>!e),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",(e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())}),this.keystrokes.set("arrowleft",(e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(e){const t=e||new rh;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 rh,t=e.bindTemplate;return e.icon=rd,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",e=>String(e))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}}function bm(e,t=nm){const i="function"==typeof t?new t(e):t,n=new tm(e),s=new im(e,i,n);return i.bind("isEnabled").to(s),i instanceof pm?i.arrowView.bind("isOn").to(s,"isOpen"):i.bind("isOn").to(s,"isOpen"),function(e){(function(e){Yu({emitter:e,activator:()=>e.isRendered&&e.isOpen,callback:()=>{e.isOpen=!1},contextElements:()=>[e.element,...Cm(e.focusTracker).filter(t=>!e.element.contains(t))]})})(e),function(e){e.on("execute",t=>{t.source instanceof Nh||(e.isOpen=!1)})}(e),function(e){e.focusTracker.on("change:isFocused",(t,i,n)=>{!n&&e.isOpen&&(e.isOpen=!1)})}(e),function(e){e.keystrokes.set("arrowdown",(t,i)=>{e.isOpen&&(e.panelView.focus(),i())}),e.keystrokes.set("arrowup",(t,i)=>{e.isOpen&&(e.panelView.focusLast(),i())})}(e),function(e){e.on("change:isOpen",(t,i,n)=>{if(n)return;e.focusTracker.elements.some(e=>e.contains(G.document.activeElement))&&e.buttonView.focus()})}(e),function(e){e.on("change:isOpen",(t,i,n)=>{n&&e.panelView.focus()},{priority:"low"})}(e)}(s),s}function wm(e,t,i={}){e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.isOpen?_m(e,t,i):e.once("change:isOpen",()=>_m(e,t,i),{priority:"highest"}),i.enableActiveItemFocusOnDropdownOpen&&km(e,()=>e.toolbarView.items.find(e=>e.isOn))}function _m(e,t,i){const n=e.locale,s=n.t,o=e.toolbarView=new hm(n),r="function"==typeof t?t():t;o.ariaLabel=i.ariaLabel||s("Dropdown toolbar"),i.maxWidth&&(o.maxWidth=i.maxWidth),i.class&&(o.class=i.class),i.isCompact&&(o.isCompact=i.isCompact),i.isVertical&&(o.isVertical=!0),r instanceof yu?o.items.bindTo(r).using(e=>e):o.items.addMany(r),e.panelView.children.add(o),e.focusTracker.add(o),o.items.delegate("execute").to(e)}function vm(e,t,i={}){e.isOpen?ym(e,t,i):e.once("change:isOpen",()=>ym(e,t,i),{priority:"highest"}),km(e,()=>e.listView.items.find(e=>e instanceof sm&&e.children.first.isOn))}function ym(e,t,i){const n=e.locale,s=e.listView=new am(n),o="function"==typeof t?t():t;s.ariaLabel=i.ariaLabel,s.role=i.role,Am(e,s.items,o,n),e.panelView.children.add(s),s.items.delegate("execute").to(e)}function km(e,t){e.on("change:isOpen",()=>{if(!e.isOpen)return;const i=t();i&&("function"==typeof i.focus?i.focus():pe("ui-dropdown-focus-child-on-open-child-missing-focus",{view:i}))},{priority:me.low-10})}function Cm(e){return[...e.elements,...e.externalViews.flatMap(e=>Cm(e.focusTracker))]}function Am(e,t,i,n){!function(e){let t=0;const i=e=>e instanceof sm&&e.children.first instanceof Ah?e.children.first:null,n=e=>{const t=i(e);return t&&t.isToggleable?t:null},s=t=>{for(const n of e){const e=i(n);e&&(e.hasCheckSpace=t)}};e.on("change",(e,o)=>{const r=t>0;for(const e of o.removed)n(e)&&t--;for(const e of o.added){const n=i(e);n&&(n.isToggleable&&t++,n.hasCheckSpace=t>0)}const a=t>0;r!==a&&s(a)})}(t),t.bindTo(i).using(t=>{if("separator"===t.type)return new om(n);if("group"===t.type){const i=new rm(n);return i.set({label:t.label}),Am(e,i.items,t.items,n),i.items.delegate("execute").to(e),i}if("button"===t.type||"switchbutton"===t.type){const e="menuitemcheckbox"===t.model.role||"menuitemradio"===t.model.role,i=new sm(n);let s;return"button"===t.type?(s=new Ah(n,t.labelView),s.set({isToggleable:e})):s=new Nh(n),s.bind(...Object.keys(t.model)).to(t.model),s.delegate("execute").to(i),i.children.add(s),i}return null})}const Tm=(e,t,i)=>{const n=new Zh(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isReadOnly").to(e,"isEnabled",e=>!e),n.bind("hasError").to(e,"errorText",e=>!!e),n.on("input",()=>{e.errorText=null}),e.bind("isEmpty","isFocused","placeholder").to(n),n},Em=(e,t,i)=>{const n=new em(e.locale);return n.set({id:t,ariaDescribedById:i,inputMode:"numeric"}),n.bind("isReadOnly").to(e,"isEnabled",e=>!e),n.bind("hasError").to(e,"errorText",e=>!!e),n.on("input",()=>{e.errorText=null}),e.bind("isEmpty","isFocused","placeholder").to(n),n},xm=(e,t,i)=>{const n=bm(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isEnabled").to(e),n};class Pm extends Uu{hexInputRow;_debounceColorPickerEvent;_config;constructor(e,t={}){super(e),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=Ci(e=>{this.set("color",e),this.fire("colorSelected",{color:this.color})},150,{leading:!0}),this.on("set:color",(e,t,i)=>{e.return=Gh(i,this._config.format||"hsl")}),this.on("change:color",()=>{this._hexColor=Sm(this.color)}),this.on("change:_hexColor",()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Sm(this.color)!=Sm(this._hexColor)&&(this.color=this._hexColor)})}render(){var e,t;if(super.render(),e="hex-color-picker",t=vu,void 0===customElements.get(e)&&customElements.define(e,t),this.picker=G.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(){if(!this._config.hideInput&&(Q.isGecko||Q.isiOS||Q.isSafari||Q.isBlink)){this.hexInputRow.children.get(1).focus()}this.slidersView.first.focus()}_createSlidersView(){const e=[...this.picker.shadowRoot.children].filter(e=>"slider"===e.getAttribute("role")).map(e=>new Im(e));this.slidersView=this.createCollection(),e.forEach(e=>{this.slidersView.add(e)})}_createInputRow(){const e=this._createColorInput();return new Rm(this.locale,e)}_createColorInput(){const e=new Yh(this.locale,Tm),{t}=this.locale;return e.set({label:t("HEX"),class:"color-picker-hex-input"}),e.fieldView.bind("value").to(this,"_hexColor",t=>e.isFocused?e.fieldView.value:t.startsWith("#")?t.substring(1):t),e.fieldView.on("input",()=>{const t=e.fieldView.element.value;if(t){const e=Vm(t);e&&this._debounceColorPickerEvent(e)}}),e}isValid(){const{t:e}=this.locale;return!!this._config.hideInput||(this.resetValidationStatus(),!!this.hexInputRow.getParsedColor()||(this.hexInputRow.inputView.errorText=e('Please enter a valid color (e.g. "ff0000").'),!1))}resetValidationStatus(){this.hexInputRow.inputView.errorText=null}}function Sm(e){let t=function(e){if(!e)return"";const t=Jh(e);return t?"hex"===t.space?t.hexValue:Gh(e,"hex"):"#000"}(e);return t||(t="#000"),4===t.length&&(t="#"+[t[1],t[1],t[2],t[2],t[3],t[3]].join("")),t.toLowerCase()}class Im extends Uu{constructor(e){super(),this.element=e}focus(){this.element.focus()}}class Om extends Uu{constructor(e){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class Rm extends Uu{children;inputView;constructor(e,t){super(e),this.inputView=t,this.children=this.createCollection([new Om,this.inputView]),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}getParsedColor(){return Vm(this.inputView.fieldView.element.value)}}function Vm(e){if(!e)return null;const t=e.trim().replace(/^#/,"");return[3,4,6,8].includes(t.length)&&/^(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})$/.test(t)?`#${t}`:null}class Bm extends(Le(ni)){constructor(e){super(e),this.set("isEmpty",!0),this.on("change",()=>{this.set("isEmpty",0===this.length)})}add(e,t){return this.find(t=>t.color===e.color)?this:super.add(e,t)}hasColor(e){return!!this.find(t=>t.color===e)}}class Mm extends Uu{items;colorDefinitions;focusTracker;columns;documentColors;documentColorsCount;staticColorsGrid;documentColorsGrid;colorPickerButtonView;removeColorButtonView;_focusables;_documentColorsLabel;_removeButtonLabel;_colorPickerLabel;constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o,colorPickerLabel:r,focusTracker:a,focusables:l}){super(e);const c=this.bindTemplate;this.set("isVisible",!0),this.focusTracker=a,this.items=this.createCollection(),this.colorDefinitions=t,this.columns=i,this.documentColors=new Bm,this.documentColorsCount=o,this._focusables=l,this._removeButtonLabel=n,this._colorPickerLabel=r,this._documentColorsLabel=s,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-fragment",c.if("isVisible","ck-hidden",e=>!e)]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}updateDocumentColors(e,t){const i=e.document,n=this.documentColorsCount;this.documentColors.clear();for(const s of i.getRoots()){const i=e.createRangeIn(s);for(const e of i.getItems())if(e.is("$textProxy")&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=n))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=ku.bind(this.documentColors,this.documentColors),t=new Uu(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 rh,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10.209 18.717A8.5 8.5 0 1 1 18.686 9.6h-.008l.002.12a3 3 0 0 1-2.866 2.997h-.268l-.046-.002v.002h-4.791a2 2 0 1 0 0 4 1 1 0 1 1-.128 1.992 9 9 0 0 1-.372.008m-3.918-7.01a1.25 1.25 0 1 0-2.415-.648 1.25 1.25 0 0 0 2.415.647ZM5.723 8.18a1.25 1.25 0 1 0 .647-2.414 1.25 1.25 0 0 0-.647 2.414M9.76 6.155a1.25 1.25 0 1 0 .647-2.415 1.25 1.25 0 0 0-.647 2.415m4.028 1.759a1.25 1.25 0 1 0 .647-2.415 1.25 1.25 0 0 0-.647 2.415"/></svg>',class:"ck-color-selector__color-picker"}),this.colorPickerButtonView.on("execute",()=>{this.fire("colorPicker:show")})}_createRemoveColorButton(){const e=new rh;return e.set({withText:!0,icon:ad,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 Kh(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.on("execute",(e,t)=>{this.fire("execute",{value:t.value,source:"staticColorsGrid"})}),e}_createDocumentColorsGrid(){const e=ku.bind(this.documentColors,this.documentColors),t=new Kh(this.locale,{columns:this.columns});return t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using(e=>{const t=new qh;return t.set({color:e.color,hasBorder:e.options?.hasBorder}),e.label&&t.set({label:e.label,tooltip:!0}),t.on("execute",()=>{this.fire("execute",{value:e.color,source:"documentColorsGrid"})}),t}),this.documentColors.on("change:isEmpty",(e,i,n)=>{n&&(t.selectedColor=null)}),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find(t=>t.color===e);t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}}class Fm extends Uu{items;colorPickerView;saveButtonView;cancelButtonView;actionBarView;focusTracker;keystrokes;_focusables;_colorPickerViewConfig;constructor(e,{focusTracker:t,focusables:i,keystrokes:n,colorPickerViewConfig:s}){super(e),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=n,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=i,this._colorPickerViewConfig=s;const o=this.bindTemplate,{saveButtonView:r,cancelButtonView:a}=this._createActionButtons();this.saveButtonView=r,this.cancelButtonView=a,this.actionBarView=this._createActionBarView({saveButtonView:r,cancelButtonView:a}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-fragment",o.if("isVisible","ck-hidden",e=>!e)]},children:this.items})}render(){super.render();const e=new Pm(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=e,this.colorPickerView.render(),this.selectedColor&&(e.color=this.selectedColor),this.listenTo(this,"change:selectedColor",(t,i,n)=>{e.color=n}),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=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}_addColorPickersElementsToFocusTracker(){for(const e of this.colorPickerView.slidersView)this.focusTracker.add(e.element),this._focusables.add(e);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 Uu,n=this.createCollection();return n.add(e),n.add(t),i.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector_action-bar"]},children:n}),i}_createActionButtons(){const e=this.locale,t=e.t,i=new rh(e),n=new rh(e);return i.set({icon:nd,class:"ck-button-save",type:"button",withText:!1,label:t("Accept")}),n.set({icon:td,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})}),n.on("execute",()=>{this.fire("colorPicker:cancel")}),{saveButtonView:i,cancelButtonView:n}}_executeUponColorChange(){this.colorPickerView.on("colorSelected",(e,t)=>{this.fire("execute",{value:t.color,source:"colorPicker"}),this.set("selectedColor",t.color)})}}class Nm extends Uu{focusTracker;keystrokes;items;colorGridsFragmentView;colorPickerFragmentView;_focusCycler;_focusables;_colorPickerViewConfig;constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o,colorPickerLabel:r,colorPickerViewConfig:a}){super(e),this.items=this.createCollection(),this.focusTracker=new oi,this.keystrokes=new ci,this._focusables=new yu,this._colorPickerViewConfig=a,this._focusCycler=new ch({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsFragmentView=new Mm(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o,colorPickerLabel:r,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new Fm(e,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerViewConfig:a}),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",(e,t,i)=>{this.colorGridsFragmentView.set("selectedColor",i),this.colorPickerFragmentView.set("selectedColor",i)}),this.colorGridsFragmentView.on("change:selectedColor",(e,t,i)=>{this.set("selectedColor",i)}),this.colorPickerFragmentView.on("change:selectedColor",(e,t,i)=>{this.set("selectedColor",i)}),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(){2!==this.items.length&&(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 Lm{editor;_components=new Map;constructor(e){this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(Dm(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new fe("componentfactory-item-missing",this,{name:e});return this._components.get(Dm(e)).callback(this.editor.locale)}has(e){return this._components.has(Dm(e))}}function Dm(e){return String(e).toLowerCase()}const zm="ck-tooltip";class Hm extends(tt()){tooltipTextView;balloonPanelView;static defaultBalloonPositions=Oh.generatePositions({heightOffset:5,sideOffset:13});_currentElementWithTooltip=null;_currentTooltipPosition=null;_mutationObserver=null;_pinTooltipDebounced;_unpinTooltipDebounced;_watchdogExcluded;static _editors=new Set;static _instance=null;constructor(e){if(super(),Hm._editors.add(e),Hm._instance)return Hm._instance;Hm._instance=this,this.tooltipTextView=new Uu(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 Oh(e.locale),this.balloonPanelView.class=zm,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=function(e){const t=new MutationObserver(()=>{e()});return{attach(e){t.observe(e,{attributes:!0,attributeFilter:["data-cke-tooltip-text","data-cke-tooltip-position"]})},detach(){t.disconnect()}}}(()=>{this._updateTooltipPosition()}),this._pinTooltipDebounced=Ci(this._pinTooltip,600),this._unpinTooltipDebounced=Ci(this._unpinTooltip,400),this.listenTo(G.document,"keydown",this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(G.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(G.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(G.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(G.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(G.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;Hm._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),Hm._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),Hm._instance=null)}static getPositioningFunctions(e){const t=Hm.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){"Escape"===t.key&&this._currentElementWithTooltip&&(this._unpinTooltip(),t.stopPropagation())}_onEnterOrFocus(e,{target:t}){const i=$m(t);i?i!==this._currentElementWithTooltip?(this._unpinTooltip(),"focus"===e.name&&!i.matches(":hover")||i.matches("[data-cke-tooltip-instant]")?this._pinTooltip(i,Wm(i)):this._pinTooltipDebounced(i,Wm(i))):this._unpinTooltipDebounced.cancel():"focus"===e.name&&this._unpinTooltip()}_onLeaveOrBlur(e,{target:t,relatedTarget:i}){if("mouseleave"===e.name){if(!M(t))return;const e=this.balloonPanelView.element,n=e&&(e===i||e.contains(i)),s=!n&&t===e;if(n)return void this._unpinTooltipDebounced.cancel();if(!s&&this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const o=$m(t),r=$m(i);(s||o&&o!==r)&&(this._pinTooltipDebounced.cancel(),this._currentElementWithTooltip&&this._currentElementWithTooltip.matches("[data-cke-tooltip-instant]")||o&&o.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:n}){this._unpinTooltip();const s=si(Hm._editors.values()).ui.view.body;s.has(this.balloonPanelView)||s.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.class=[zm,n].filter(e=>e).join(" "),this.balloonPanelView.pin({target:e,positions:Hm.getPositioningFunctions(i)}),this._mutationObserver.attach(e);for(const e of Hm._editors)this.listenTo(e.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 Hm._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=Wm(this._currentElementWithTooltip);Et(this._currentElementWithTooltip)&&e.text?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:Hm.getPositioningFunctions(e.position)}):this._unpinTooltip()}}function $m(e){return M(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function Wm(e){return{text:e.dataset.ckeTooltipText,position:e.dataset.ckeTooltipPosition||"s",cssClass:e.dataset.ckeTooltipClass||""}}class jm extends Vh{licenseTypeMessage={evaluation:"For evaluation purposes only",trial:"For evaluation purposes only",development:"For development purposes only"};constructor(e){super(e,{balloonClass:"ck-evaluation-badge-balloon"})}_isEnabled(){const e=qm(this.editor.config.get("licenseKey"));return Boolean(e&&this.licenseTypeMessage[e])}_createBadgeContent(){const e=qm(this.editor.config.get("licenseKey"));return new Um(this.editor.locale,this.licenseTypeMessage[e])}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{};return{position:t.position||e.position,side:"left"===(t.side||e.side)?"right":"left",verticalOffset:e.verticalOffset,horizontalOffset:e.horizontalOffset}}}class Um extends Uu{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 qm(e){if("GPL"==e)return"GPL";const t=mi(e.split(".")[1]);return t?t.licenseType||"production":null}class Km extends sm{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 Gm={toggleMenusAndFocusItemsOnHover(e){e.on("menu:mouseenter",t=>{if(e.isFocusBorderEnabled||e.isOpen){if(e.isOpen)for(const i of e.menus){const e=t.path[0],n=e instanceof Km&&e.children.first===i;i.isOpen=(t.path.includes(i)||n)&&i.isEnabled}t.source.focus()}})},focusCycleMenusOnArrows(e){const t="rtl"===e.locale.uiLanguageDirection;function i(t,i){const n=e.children.getIndex(t),s=t.isOpen,o=e.children.length,r=e.children.get((n+o+i)%o);t.isOpen=!1,s&&(r.isOpen=!0),r.buttonView.focus()}e.on("menu:arrowright",e=>{i(e.source,t?-1:1)}),e.on("menu:arrowleft",e=>{i(e.source,t?1:-1)})},closeMenusWhenTheBarCloses(e){e.on("change:isOpen",()=>{e.isOpen||e.menus.forEach(e=>{e.isOpen=!1})})},closeMenuWhenAnotherOnTheSameLevelOpens(e){e.on("menu:change:isOpen",(t,i,n)=>{n&&e.menus.filter(e=>t.source.parentMenuView===e.parentMenuView&&t.source!==e&&e.isOpen).forEach(e=>{e.isOpen=!1})})},closeOnClickOutside(e){Yu({emitter:e,activator:()=>e.isOpen,callback:()=>e.close(),contextElements:()=>e.children.map(e=>e.element)})},enableFocusHighlightOnInteraction(e){let t=!1;e.on("change:isOpen",(i,n,s)=>{s||(t||(e.isFocusBorderEnabled=!1),t=!1)}),e.listenTo(e.element,"keydown",()=>{t=!0},{useCapture:!0}),e.listenTo(e.element,"keyup",()=>{t=!1},{useCapture:!0}),e.listenTo(e.element,"focus",()=>{t&&(e.isFocusBorderEnabled=!0)},{useCapture:!0})}},Jm={openAndFocusPanelOnArrowDownKey(e){e.keystrokes.set("arrowdown",(t,i)=>{e.isEnabled&&e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())})},openOnArrowRightKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowleft":"arrowright";e.keystrokes.set(t,(t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&e.isEnabled&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())})},openOnButtonClick(e){e.buttonView.on("execute",()=>{e.isOpen=!0})},toggleOnButtonClick(e){e.buttonView.on("execute",()=>{e.isOpen=!e.isOpen})},openAndFocusOnEnterKeyPress(e){e.keystrokes.set("enter",(t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen=!0,e.panelView.focus(),i())})},closeOnArrowLeftKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowright":"arrowleft";e.keystrokes.set(t,(t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())})},closeOnEscKey(e){e.keystrokes.set("esc",(t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())})},closeOnParentClose(e){e.parentMenuView.on("change:isOpen",(t,i,n)=>{n||t.source!==e.parentMenuView||(e.isOpen=!1)})}},Ym={southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),eastSouth:e=>({top:e.top,left:e.right-5,name:"es"}),eastNorth:(e,t)=>({top:e.top-t.height,left:e.right-5,name:"en"}),westSouth:(e,t)=>({top:e.top,left:e.left-t.width+5,name:"ws"}),westNorth:(e,t)=>({top:e.top-t.height,left:e.left-t.width+5,name:"wn"})},Qm=[{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:insertFootnote","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:inline","menuBar:restrictedEditingException:block"]}]},{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:lineHeight","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","menuBar:toggleAi","menuBar:aiQuickActions"]},{groupId:"tools",items:["menuBar:trackChanges","menuBar:commentsArchive"]}]},{menuId:"help",label:"Help",groups:[{groupId:"help",items:["menuBar:accessibilityHelp"]}]}];function Xm({normalizedConfig:e,locale:t,componentFactory:i,extraItems:n}){const s=N(e);return Zm(e,s,n),function(e,t){const i=t.removeItems,n=[];t.items=t.items.filter(({menuId:e})=>!i.includes(e)||(n.push(e),!1)),ng(t.items,e=>{e.groups=e.groups.filter(({groupId:e})=>!i.includes(e)||(n.push(e),!1));for(const t of e.groups)t.items=t.items.filter(e=>{const t=lg(e);return!i.includes(t)||(n.push(t),!1)})});for(const t of i)n.includes(t)||pe("menu-bar-item-could-not-be-removed",{menuBarConfig:e,itemName:t})}(e,s),Zm(e,s,s.addItems),function(e,t,i){ng(t.items,n=>{for(const s of n.groups)s.items=s.items.filter(s=>{const o="string"==typeof s&&!i.has(s);return o&&!t.isUsingDefaultConfig&&pe("menu-bar-item-unavailable",{menuBarConfig:e,parentMenuConfig:N(n),componentName:s}),!o})})}(e,s,i),tg(e,s),function(e,t){const i=t.t,n={File:i({string:"File",id:"MENU_BAR_MENU_FILE"}),Edit:i({string:"Edit",id:"MENU_BAR_MENU_EDIT"}),View:i({string:"View",id:"MENU_BAR_MENU_VIEW"}),Insert:i({string:"Insert",id:"MENU_BAR_MENU_INSERT"}),Format:i({string:"Format",id:"MENU_BAR_MENU_FORMAT"}),Tools:i({string:"Tools",id:"MENU_BAR_MENU_TOOLS"}),Help:i({string:"Help",id:"MENU_BAR_MENU_HELP"}),Text:i({string:"Text",id:"MENU_BAR_MENU_TEXT"}),Font:i({string:"Font",id:"MENU_BAR_MENU_FONT"})};ng(e.items,e=>{e.label in n&&(e.label=n[e.label])})}(s,t),s}function Zm(e,t,i){const n=[];if(0!=i.length){for(const e of i){const i=rg(e.position),s=ag(e.position);if(sg(e))if(s){const o=t.items.findIndex(e=>e.menuId===s);if(-1!=o)"before"===i?(t.items.splice(o,0,e.menu),n.push(e)):"after"===i&&(t.items.splice(o+1,0,e.menu),n.push(e));else{eg(t,e.menu,s,i)&&n.push(e)}}else"start"===i?(t.items.unshift(e.menu),n.push(e)):"end"===i&&(t.items.push(e.menu),n.push(e));else if(og(e))ng(t.items,t=>{if(t.menuId===s)"start"===i?(t.groups.unshift(e.group),n.push(e)):"end"===i&&(t.groups.push(e.group),n.push(e));else{const o=t.groups.findIndex(e=>e.groupId===s);-1!==o&&("before"===i?(t.groups.splice(o,0,e.group),n.push(e)):"after"===i&&(t.groups.splice(o+1,0,e.group),n.push(e)))}});else{eg(t,e.item,s,i)&&n.push(e)}}for(const t of i)n.includes(t)||pe("menu-bar-item-could-not-be-added",{menuBarConfig:e,addedItemConfig:t})}}function eg(e,t,i,n){let s=!1;return ng(e.items,e=>{for(const{groupId:o,items:r}of e.groups){if(s)return;if(o===i)"start"===n?(r.unshift(t),s=!0):"end"===n&&(r.push(t),s=!0);else{const e=r.findIndex(e=>lg(e)===i);-1!==e&&("before"===n?(r.splice(e,0,t),s=!0):"after"===n&&(r.splice(e+1,0,t),s=!0))}}}),s}function tg(e,t){const i=t.isUsingDefaultConfig;let n=!1;t.items=t.items.filter(t=>!!t.groups.length||(ig(e,t,i),!1)),t.items.length?(ng(t.items,t=>{t.groups=t.groups.filter(e=>!!e.items.length||(n=!0,!1));for(const s of t.groups)s.items=s.items.filter(t=>!(cg(t)&&!t.groups.length)||(ig(e,t,i),n=!0,!1))}),n&&tg(e,t)):ig(e,e,i)}function ig(e,t,i){i||pe("menu-bar-menu-empty",{menuBarConfig:e,emptyMenuConfig:t})}function ng(e,t){if(Array.isArray(e))for(const t of e)i(t);function i(e){t(e);for(const t of e.groups)for(const e of t.items)cg(e)&&i(e)}}function sg(e){return"object"==typeof e&&"menu"in e}function og(e){return"object"==typeof e&&"group"in e}function rg(e){return e.startsWith("start")?"start":e.startsWith("end")?"end":e.startsWith("after")?"after":"before"}function ag(e){const t=e.match(/^[^:]+:(.+)/);return t?t[1]:null}function lg(e){return"string"==typeof e?e:e.menuId}function cg(e){return"object"==typeof e&&"menuId"in e}class dg extends(Le()){editor;componentFactory;focusTracker;tooltipManager;poweredBy;evaluationBadge;ariaLiveAnnouncer;isReady=!1;_editableElementsMap=new Map;_focusableToolbarDefinitions=[];_extraMenuBarElements=[];_lastFocusedForeignElement=null;_domEmitter;constructor(e){super();const t=e.editing.view;this.editor=e,this.componentFactory=new Lm(e),this.focusTracker=new oi,this.tooltipManager=new Hm(e),this.poweredBy=new Mh(e),this.evaluationBadge=new jm(e),this.ariaLiveAnnouncer=new Ku(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)}initMenuBar(e){const t=e.element;this.focusTracker.add(t),this.editor.keystrokes.listenTo(t);const i=function(e){let t;return t="items"in e&&e.items?{items:e.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1,...e}:{items:N(Qm),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0,...e},t}(this.editor.config.get("menuBar")||{});e.fillFromConfig(i,this.componentFactory,this._extraMenuBarElements),this.editor.keystrokes.set("Esc",(e,i)=>{t.contains(this.editor.ui.focusTracker.focusedElement)&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):this.editor.editing.view.focus(),i())}),this.editor.keystrokes.set("Alt+F9",(i,n)=>{t.contains(this.editor.ui.focusTracker.focusedElement)||(this._saveLastFocusedForeignElement(),e.isFocusBorderEnabled=!0,e.focus(),n())})}_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",(e,i)=>{this._saveLastFocusedForeignElement();const n=this._getCurrentFocusedToolbarDefinition();n&&t||(t=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e<t.length;e++){const e=t.shift();if(t.push(e),e!==n&&this._focusFocusableCandidateToolbar(e)){n&&n.options.afterBlur&&n.options.afterBlur();break}}i()}),e.keystrokes.set("Esc",(t,i)=>{const n=this._getCurrentFocusedToolbarDefinition();n&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):e.editing.view.focus(),n.options.afterBlur&&n.options.afterBlur(),i())})}_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:n}=t;(Et(i.element)||n.beforeFocus)&&e.push(t)}return e.sort((e,t)=>ug(e)-ug(t)),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(),!!Et(t.element)&&(t.focus(),!0)}_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",(e,t)=>{this.focusTracker.add(t.element)}),e.on("remove",(e,t)=>{this.focusTracker.remove(t.element)})}_initViewportOffset(e){this.on("set:viewportOffset",(e,t,i)=>{const n=this._getVisualViewportTopOffset(i);i.visualTop!==n&&(e.return={...i,visualTop:n})}),this.set("viewportOffset",e)}_initVisualViewportSupport(){if(!G.window.visualViewport)return;const e=()=>{const e=this._getVisualViewportTopOffset(this.viewportOffset);this.viewportOffset.visualTop!==e&&(this.viewportOffset={...this.viewportOffset,visualTop:e})};this._domEmitter=new(tt()),this._domEmitter.listenTo(G.window.visualViewport,"scroll",e),this._domEmitter.listenTo(G.window.visualViewport,"resize",e)}_getVisualViewportTopOffset(e){const t=Rt().top,i=e.top||0;return t>i?0:i-t}}function ug(e){const{toolbarView:t,options:i}=e;let n=10;return Et(t.element)&&n--,i.isContextual&&(n-=2),n}class hg extends Uu{body;menuBarView;toolbar;constructor(e){super(e),this.body=new Ph(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class mg extends hg{top;main;_voiceLabelView;constructor(e){super(e),this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createVoiceLabel(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-editor","ck-rounded-corners"],role:"application",dir:e.uiLanguageDirection,lang:e.uiLanguage,"aria-labelledby":this._voiceLabelView.id},children:[this._voiceLabelView,{tag:"div",attributes:{class:["ck","ck-editor__top","ck-reset_all"],role:"presentation"},children:this.top},{tag:"div",attributes:{class:["ck","ck-editor__main"],role:"presentation"},children:this.main}]})}_createVoiceLabel(){const e=this.t,t=new th;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class gg extends Uu{name=null;_editingView;_editableElement;_hasExternalElement;constructor(e,t,i){super(e),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;function t(t){e.change(i=>{const n=e.document.getRoot(t.name);i.addClass(t.isFocused?"ck-focused":"ck-blurred",n),i.removeClass(t.isFocused?"ck-blurred":"ck-focused",n)})}e.isRenderingInProgress?function i(n){e.once("change:isRenderingInProgress",(e,s,o)=>{o?i(n):t(n)})}(this):t(this)}}class fg extends gg{_options;constructor(e,t,i,n={}){super(e,t,i),this._options=n,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,n=this.name;if("string"==typeof t)return t;if("object"==typeof t)return t[n];if("function"==typeof t)return t(this);if(i){const e=i.getAttribute("aria-label");if(e)return e}return e("Rich Text Editor. Editing area: %0",n)}}class pg extends Uu{children;constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",["ck","ck-form__row",...ei(t.class||[])]),this.children=this.createCollection(),t.children&&t.children.forEach(e=>this.children.add(e)),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",e=>e.join(" ")),role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}class bg extends Oc{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 wg extends(Le()){constructor(e,t){super(),t&&Ri(this,t),e&&this.set(e)}}const _g=yt("px");class vg extends Cc{positionLimiter;visibleStack;_viewToStack=new Map;_idToStack=new Map;_view=null;_rotatorView=null;_fakePanelsView=null;static get pluginName(){return"ContextualBalloon"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.decorate("getPositionOptions"),this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}destroy(){super.destroy(),this._view&&this._view.destroy(),this._rotatorView&&this._rotatorView.destroy(),this._fakePanelsView&&this._fakePanelsView.destroy()}get view(){return this._view||this._createPanelView(),this._view}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this._view||this._createPanelView(),this.hasView(e.view))throw new fe("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t))return this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!e.singleViewMode||this.showStack(t));const 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 fe("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(1===t.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),1===t.size?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this.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 fe("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new Oh(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 yg(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",(e,t)=>!t&&e>1),e.on("change:isNavigationVisible",()=>this.updatePosition(),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",(e,i)=>{if(i<2)return"";const n=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[n,i])}),e.buttonNextView.on("execute",()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()}),e.buttonPrevView.on("execute",()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()}),e}_createFakePanelsView(){const e=new kg(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",(e,t)=>!t&&e>=2?Math.min(e-1,2):0),e.listenTo(this.view,"change:top",()=>e.updatePosition()),e.listenTo(this.view,"change:left",()=>e.updatePosition()),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:i=!0,singleViewMode:n=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition(),n&&(this._singleViewMode=!0)}}class yg extends Uu{focusTracker;buttonPrevView;buttonNextView;content;constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new oi,this.buttonPrevView=this._createButtonView(t("Previous"),_d),this.buttonNextView=this._createButtonView(t("Next"),ud),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",e=>e?"":"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 rh(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class kg extends Uu{content;_balloonPanelView;constructor(e,t){super(e);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",e=>e?"":"ck-hidden")],style:{top:i.to("top",_g),left:i.to("left",_g),width:i.to("width",_g),height:i.to("height",_g)}},children:this.content}),this.on("change:numberOfPanels",(e,t,i,n)=>{i>n?this._addPanels(i-n):this._removePanels(n-i),this.updatePosition()})}_addPanels(e){for(;e--;){const e=new Uu;e.setTemplate({tag:"div"}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){const e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:i,height:n}=new ht(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:n})}}}const Cg=yt("px");class Ag extends Uu{content;contentPanelElement;_contentPanelPlaceholder;constructor(e){super(e);const t=this.bindTemplate;this.set("isActive",!1),this.set("isSticky",!1),this.set("limiterElement",null),this.set("limiterBottomOffset",50),this.set("viewportTopOffset",0),this.set("_marginLeft",null),this.set("_isStickyToTheBottomOfLimiter",!1),this.set("_stickyTopOffset",null),this.set("_stickyBottomOffset",null),this.content=this.createCollection(),this._contentPanelPlaceholder=new ku({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",e=>e?"block":"none"),height:t.to("isSticky",e=>e?Cg(this._contentPanelRect.height):null)}}}).render(),this.contentPanelElement=new ku({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheBottomOfLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",e=>e?Cg(this._contentPanelPlaceholder.getBoundingClientRect().width):null),top:t.to("_stickyTopOffset",e=>e?Cg(e):e),bottom:t.to("_stickyBottomOffset",e=>e?Cg(e):e),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this.contentPanelElement]})}render(){super.render(),this.checkIfShouldBeSticky(),this.listenTo(G.document,"scroll",()=>{this.checkIfShouldBeSticky()},{useCapture:!0}),this.listenTo(this,"change:isActive",()=>{this.checkIfShouldBeSticky()}),G.window.visualViewport&&(this.listenTo(G.window.visualViewport,"scroll",()=>{this.checkIfShouldBeSticky()}),this.listenTo(G.window.visualViewport,"resize",()=>{this.checkIfShouldBeSticky()}))}checkIfShouldBeSticky(){if(!this.limiterElement||!this.isActive)return void this._unstick();const e=new ht(this.limiterElement);let t=e.getVisible();if(t){const e=new ht(G.window);e.top+=this.viewportTopOffset,e.height-=this.viewportTopOffset,t=t.getIntersection(e)}const{left:i,top:n}=Rt();if(e.moveBy(i,n),t&&t.moveBy(i,n),t&&e.top<t.top)if(this._contentPanelRect.height+this.limiterBottomOffset>t.height){const i=Math.max(e.bottom-t.bottom,0)+this.limiterBottomOffset;this._contentPanelRect.height+i+1<e.height?this._stickToBottomOfLimiter(i):this._unstick()}else this._contentPanelRect.height+this.limiterBottomOffset<e.height?this._stickToTopOfAncestors(t.top):this._unstick();else this._unstick()}_stickToTopOfAncestors(e){this.isSticky=!0,this._isStickyToTheBottomOfLimiter=!1,this._stickyTopOffset=e,this._stickyBottomOffset=null,this._marginLeft=Cg(-G.window.scrollX+Rt().left)}_stickToBottomOfLimiter(e){this.isSticky=!0,this._isStickyToTheBottomOfLimiter=!0,this._stickyTopOffset=null,this._stickyBottomOffset=e,this._marginLeft=Cg(-G.window.scrollX+Rt().left)}_unstick(){this.isSticky=!1,this._isStickyToTheBottomOfLimiter=!1,this._stickyTopOffset=null,this._stickyBottomOffset=null,this._marginLeft=null}get _contentPanelRect(){return new ht(this.contentPanelElement)}}class Tg extends Ah{arrowView;constructor(e){super(e);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",e=>String(e)),"data-cke-tooltip-disabled":t.to("isOn")},on:{mouseenter:t.to("mouseenter")}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new sh;return e.content=rd,e.extendTemplate({attributes:{class:"ck-menu-bar__menu__button__arrow"}}),e}}class Eg extends Uu{children;constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-menu-bar__menu__panel",t.to("position",e=>`ck-menu-bar__menu__panel_position_${e}`),t.if("isVisible","ck-hidden",e=>!e)],tabindex:"-1"},children:this.children,on:{selectstart:t.to(e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()})}})}focus(e=1){this.children.length&&(1===e?this.children.first.focus():this.children.last.focus())}}class xg extends Uu{buttonView;panelView;focusTracker;keystrokes;constructor(e){super(e);const t=this.bindTemplate;this.buttonView=new Tg(e),this.buttonView.delegate("mouseenter").to(this),this.buttonView.bind("isOn","isEnabled").to(this,"isOpen","isEnabled"),this.panelView=new Eg(e),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new ci,this.focusTracker=new oi,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",e=>!e),t.if("parentMenuView","ck-menu-bar__menu_top-level",e=>!e)]},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),Jm.closeOnEscKey(this),this._closeOnDisabled(),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(Jm.openOnButtonClick(this),Jm.openOnArrowRightKey(this),Jm.closeOnArrowLeftKey(this),Jm.openAndFocusOnEnterKeyPress(this),Jm.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),Jm.openAndFocusPanelOnArrowDownKey(this),Jm.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set("arrowright",(e,t)=>{this.fire("arrowright"),t()}),this.keystrokes.set("arrowleft",(e,t)=>{this.fire("arrowleft"),t()})}_closeOnDisabled(){this.on("change:isEnabled",(e,t,i)=>{i||(this.isOpen=!1)})}_repositionPanelOnOpen(){this.on("change:isOpen",(e,t,i)=>{if(!i)return;const n=xg._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=n?n.name:this._defaultMenuPositionName})}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:e,southWest:t,northEast:i,northWest:n,westSouth:s,eastSouth:o,westNorth:r,eastNorth:a}=Ym;return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?[o,a,s,r]:[e,t,i,n]:this.parentMenuView?[s,r,o,a]:[t,e,n,i]}get _defaultMenuPositionName(){return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?"es":"se":this.parentMenuView?"ws":"sw"}static _getOptimalPosition=xt}class Pg extends am{constructor(e){super(e),this.role="menu",this.items.on("change",this._setItemsCheckSpace.bind(this))}_setItemsCheckSpace(){const e=Array.from(this.items).some(e=>{const t=Sg(e);return t&&t.isToggleable});this.items.forEach(t=>{const i=Sg(t);i&&(i.hasCheckSpace=e)})}}function Sg(e){return e instanceof sm?e.children.map(e=>function(e){return"object"==typeof e&&"buttonView"in e&&e.buttonView instanceof rh}(e)?e.buttonView:e).find(e=>e instanceof Ah):null}class Ig extends Dh{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 Og=["mouseenter","arrowleft","arrowright","change:isOpen"];class Rg extends Uu{children;menus=[];constructor(e){super(e);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 n=Xm({normalizedConfig:e,locale:this.locale,componentFactory:t,extraItems:i}).items.map(e=>this._createMenu({componentFactory:t,menuDefinition:e}));this.children.addMany(n)}render(){super.render(),Gm.toggleMenusAndFocusItemsOnHover(this),Gm.closeMenusWhenTheBarCloses(this),Gm.closeMenuWhenAnotherOnTheSameLevelOpens(this),Gm.focusCycleMenusOnArrows(this),Gm.closeOnClickOutside(this),Gm.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(...Og).to(t),e.parentMenuView=t):e.delegate(...Og).to(this,e=>"menu:"+e),e._attachBehaviors(),this.menus.push(e)}_createMenu({componentFactory:e,menuDefinition:t,parentMenuView:i}){const n=this.locale,s=new xg(n);return this.registerMenu(s,i),s.buttonView.set({label:t.label}),s.once("change:isOpen",()=>{const i=new Pg(n);i.ariaLabel=t.label,s.panelView.children.add(i),i.items.addMany(this._createMenuItems({menuDefinition:t,parentMenuView:s,componentFactory:e}))}),s}_createMenuItems({menuDefinition:e,parentMenuView:t,componentFactory:n}){const s=this.locale,o=[];for(const r of e.groups){for(const e of r.items){const r=new Km(s,t);if(i(e))r.children.add(this._createMenu({componentFactory:n,menuDefinition:e,parentMenuView:t}));else{const i=this._createMenuItemContentFromFactory({componentName:e,componentFactory:n,parentMenuView:t});if(!i)continue;r.children.add(i)}o.push(r)}r!==e.groups[e.groups.length-1]&&o.push(new om(s))}return o}_createMenuItemContentFromFactory({componentName:e,parentMenuView:t,componentFactory:i}){const n=i.create(e);return n instanceof xg||n instanceof Eh||n instanceof Ig?(this._registerMenuTree(n,t),n.on("execute",()=>{this.close()}),n):(pe("menu-bar-component-unsupported",{componentName:e,componentView:n}),null)}_registerMenuTree(e,t){if(!(e instanceof xg))return void e.delegate("mouseenter").to(t);this.registerMenu(e,t);const i=e.panelView.children.filter(e=>e instanceof Pg)[0];if(!i)return void e.delegate("mouseenter").to(t);const n=i.items.filter(e=>e instanceof sm);for(const t of n)this._registerMenuTree(t.children.get(0),e)}_setupIsOpenUpdater(){let e;this.on("menu:change:isOpen",(t,i,n)=>{clearTimeout(e),n?this.isOpen=!0:e=setTimeout(()=>{this.isOpen=Array.from(this.children).some(e=>e.isOpen)},0)})}}class Vg extends dg{view;_toolbarConfig;_elementReplacer;constructor(e,t){super(e),this.view=t,this._toolbarConfig=dm(e.config.get("toolbar")),this._elementReplacer=new je,this.listenTo(e.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,s=i.editable,o=n.document.getRoot();s.name=o.rootName,i.render();const r=s.element;this.setEditableElement(s.name,r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),i.menuBarView&&this.initMenuBar(i.menuBarView),this._initDialogPluginIntegration(),this._initContextualBalloonIntegration(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",({visualTop:e})=>e||0),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let s;const o=e.config.get("roots")[this.view.editable.name].placeholder;o&&(s=o),!s&&n&&"textarea"===n.tagName.toLowerCase()&&(s=n.getAttribute("placeholder")),s&&(i.placeholder=s),sn({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_initContextualBalloonIntegration(){if(!this.editor.plugins.has("ContextualBalloon"))return;const{stickyPanel:e}=this.view,t=this.editor.plugins.get("ContextualBalloon");t.on("getPositionOptions",t=>{const i=t.return;if(!i||!e.isSticky||!e.element)return;const n=new ht(e.element).height,s="function"==typeof i.target?i.target():i.target,o="function"==typeof i.limiter?i.limiter():i.limiter;if(s&&o&&new ht(s).height>=new ht(o).height-n)return;const r={...i.viewportOffsetConfig},a=(r.top||0)+n;t.return={...i,viewportOffsetConfig:{...r,top:a}}},{priority:"low"});const i=()=>{t.visibleView&&t.updatePosition()};this.listenTo(e,"change:isSticky",i),this.listenTo(this.editor.ui,"change:viewportOffset",i)}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new ht(n.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(n,"change:isSticky",e),setTimeout(()=>{this.stopListening(n,"change:isSticky",e)},20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const e=this.view.stickyPanel,t=this.editor.plugins.get("Dialog");t.on("show",()=>{const i=t.view;i.on("moveTo",(t,n)=>{if(!e.isSticky||i.wasMoved||i.isModal)return;const s=new ht(e.contentPanelElement);n[1]<s.bottom+kh.defaultOffset&&(n[1]=s.bottom+kh.defaultOffset)},{priority:"high"})},{priority:"low"})}}class Bg extends mg{stickyPanel;toolbar;editable;constructor(e,t,i={}){super(e),this.stickyPanel=new Ag(e),this.toolbar=new hm(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),i.useMenuBar&&(this.menuBarView=new Rg(e)),this.editable=new fg(e,t,void 0,{label:i.label})}render(){super.render(),this.menuBarView?this.stickyPanel.content.addMany([this.menuBarView,this.toolbar]):this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class Mg extends(Wc(Hc)){static get editorName(){return"ClassicEditor"}ui;constructor(e,t={}){const{sourceElementOrData:i,editorConfig:n}=function(e,t){return"string"==typeof e||Kc(e)||t&&Object.keys(t).length?{sourceElementOrData:e,editorConfig:t}:{sourceElementOrData:"",editorConfig:e}}(e,t);super(n),jc(i,this.config,"main",!0);const s=this.config.get("attachTo");this.config.define("menuBar.isVisible",!1),M(s)&&(this.sourceElement=s),this.model.document.createRoot();const o=!this.config.get("toolbar.shouldNotGroupWhenFull"),r=this.config.get("menuBar"),a=new Bg(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:o,useMenuBar:r.isVisible,label:this.config.get("roots").main.label});this.ui=new Vg(this,a),function(e){if(!F(e.updateSourceElement))throw new fe("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let i;const n=t.form,s=()=>e.updateSourceElement();F(n.submit)&&(i=n.submit,n.submit=()=>{s(),i.apply(n)}),n.addEventListener("submit",s),e.on("destroy",()=>{n.removeEventListener("submit",s),i&&(n.submit=i)})}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise(i=>{const n=new this(e,t);i(n.initPlugins().then(()=>n.ui.init(n.config.get("attachTo")||null)).then(()=>n.data.init(n.config.get("roots").main.initialData)).then(()=>n.fire("ready")).then(()=>n))})}}const Fg=["left","right","center","justify"];function Ng(e){return Fg.includes(e)}function Lg(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function Dg(e){const t=e.map(e=>{let t;return t="string"==typeof e?{name:e}:e,t}).filter(e=>{const t=Fg.includes(e.name);return t||pe("alignment-config-name-not-recognized",{option:e}),t}),i=t.filter(e=>Boolean(e.className)).length;if(i&&i<t.length)throw new fe("alignment-config-classnames-are-missing",{configuredOptions:e});return t.forEach((t,i,n)=>{const s=n.slice(i+1);if(s.some(e=>e.name==t.name))throw new fe("alignment-config-name-already-defined",{option:t,configuredOptions:e});if(t.className){if(s.some(e=>e.className==t.className))throw new fe("alignment-config-classname-already-defined",{option:t,configuredOptions:e})}}),t}const zg="alignment";class Hg extends Tc{refresh(){const e=this.editor.locale,t=si(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=Boolean(t)&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,n=t.model,s=n.document,o=e.value;n.change(e=>{const t=Array.from(s.selection.getSelectedBlocks()).filter(e=>this._canBeAligned(e)),n=t[0].getAttribute("alignment");Lg(o,i)||n===o||!o?function(e,t){for(const i of e)t.removeAttribute(zg,i)}(t,e):function(e,t,i){for(const n of e)t.setAttribute(zg,i,n)}(t,e,o)})}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,zg)}}class $g extends Cc{static get pluginName(){return"AlignmentEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("alignment",{options:Fg.map(e=>({name:e}))})}init(){const e=this.editor,t=e.locale,i=e.model.schema,n=Dg(e.config.get("alignment.options")).filter(e=>Ng(e.name)&&!Lg(e.name,t)),s=n.some(e=>!!e.className);i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),s?e.conversion.attributeToAttribute(function(e){const t={};for(const i of e)t[i.name]={key:"class",value:i.className};const i={model:{key:"alignment",values:e.map(e=>e.name)},view:t};return i}(n)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={};for(const{name:i}of e)t[i]={key:"style",value:{"text-align":i}};const i={model:{key:"alignment",values:e.map(e=>e.name)},view:t};return i}(n));const o=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"style",value:{"text-align":i}},model:{key:"alignment",value:i}});return t}(n);for(const t of o)e.conversion.for("upcast").attributeToAttribute(t);const r=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"align",value:i},model:{key:"alignment",value:i}});return t}(n);for(const t of r)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new Hg(e))}}const Wg=(()=>new Map([["left",Xc],["right",Zc],["center",Yc],["justify",Qc]]))();class jg extends Cc{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=Dg(this.editor.config.get("alignment.options"));e.map(e=>e.name).filter(Ng).forEach(e=>this._addButton(e)),this._addToolbarDropdown(e),this._addMenuBarMenu(e)}_addButton(e){this.editor.ui.componentFactory.add(`alignment:${e}`,t=>this._createButton(t,e))}_createButton(e,t,i={}){const n=this.editor,s=n.commands.get("alignment"),o=new rh(e);return o.set({label:this.localizedOptionTitles[t],icon:Wg.get(t),tooltip:!0,isToggleable:!0,...i}),o.bind("isEnabled").to(s),o.bind("isOn").to(s,"value",e=>e===t),this.listenTo(o,"execute",()=>{n.execute("alignment",{value:t}),n.editing.view.focus()}),o}_addToolbarDropdown(e){const t=this.editor;t.ui.componentFactory.add("alignment",i=>{const n=bm(i),s="rtl"===i.uiLanguageDirection?"w":"e",o=i.t;wm(n,()=>e.map(e=>this._createButton(i,e.name,{tooltipPosition:s})),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:o("Text alignment toolbar")}),n.buttonView.set({label:o("Text alignment"),tooltip:!0}),n.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===i.contentLanguageDirection?Wg.get("right"):Wg.get("left"),a=t.commands.get("alignment");return n.buttonView.bind("icon").to(a,"value",e=>Wg.get(e)||r),n.bind("isEnabled").to(a,"isEnabled"),this.listenTo(n,"execute",()=>{t.editing.view.focus()}),n})}_addMenuBarMenu(e){const t=this.editor;t.ui.componentFactory.add("menuBar:alignment",i=>{const n=t.commands.get("alignment"),s=i.t,o=new xg(i),r=new Pg(i);o.bind("isEnabled").to(n),r.set({ariaLabel:s("Text alignment"),role:"menu"}),o.buttonView.set({label:s("Text alignment")});for(const s of e){const e=new Km(i,o),a=new Eh(i);a.delegate("execute").to(o),a.set({label:this.localizedOptionTitles[s.name],icon:Wg.get(s.name),role:"menuitemcheckbox",isToggleable:!0}),a.on("execute",()=>{t.execute("alignment",{value:s.name}),t.editing.view.focus()}),a.bind("isOn").to(n,"value",e=>e===s.name),a.bind("isEnabled").to(n,"isEnabled"),e.children.add(a),r.items.add(e)}return o.panelView.children.add(r),o})}}class Ug{model;limit;_isLocked;_size;_batch=null;_changeCallback;_selectionChangeCallback;constructor(e,t=20){this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(e,t)=>{t.isLocal&&t.isUndoable&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}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 qg extends Tc{_buffer;constructor(e,t){super(e),this._buffer=new Ug(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,n=e.text||"",s=n.length;let o=i.selection;if(e.selection?o=e.selection:e.range&&(o=t.createSelection(e.range)),!t.canEditAt(o))return;const r=e.resultRange;t.enqueueChange(this._buffer.batch,e=>{this._buffer.lock();const a=Array.from(i.selection.getAttributes());t.deleteContent(o),n&&t.insertContent(e.createText(n,a),o),r?e.setSelection(r):o.is("documentSelection")||e.setSelection(o),this._buffer.unlock(),this._buffer.input(s)})}}const Kg=["insertText","insertReplacementText"],Gg=[...Kg,"insertCompositionText"];class Jg extends js{focusObserver;constructor(e){super(e),this.focusObserver=e.getObserver(Qs);const t=Q.isAndroid?Gg:Kg,i=e.document;i.on("beforeinput",(n,s)=>{if(!this.isEnabled)return;const{data:o,targetRanges:r,inputType:a,domEvent:l,isComposing:c}=s;if(!t.includes(a))return;this.focusObserver.flush();const d=new de(i,"insertText");i.fire(d,new Us(e,l,{text:o,selection:e.createSelection(r),isComposing:c})),d.stop.called&&n.stop()}),Q.isAndroid||i.on("compositionend",(t,{data:n,domEvent:s})=>{this.isEnabled&&n&&i.fire("insertText",new Us(e,s,{text:n,isComposing:!0}))},{priority:"low"})}observe(){}stopObserving(){}}class Yg extends Cc{_typingQueue;static get pluginName(){return"Input"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.editing.mapper,s=t.document.selection;this._typingQueue=new Qg(e),i.addObserver(Jg);const o=new qg(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",o),e.commands.add("input",o),this.listenTo(i.document,"beforeinput",()=>{this._typingQueue.flush("next beforeinput")},{priority:"high"}),this.listenTo(i.document,"insertText",(e,r)=>{const{text:a,selection:l}=r;if(i.document.selection.isFake&&l&&i.document.selection.isSimilar(l)&&r.preventDefault(),l&&Array.from(l.getRanges()).some(e=>!e.isCollapsed)&&r.preventDefault(),!o.isEnabled)return void r.preventDefault();let c;l&&(c=Array.from(l.getRanges()).filter(e=>e.root.is("rootElement")).map(e=>n.toModelRange(e)).map(e=>ja(e,t.schema)||e)),c&&c.length||(c=Array.from(s.getRanges()));let d=a;if(Q.isAndroid){const e=Array.from(c[0].getItems()).reduce((e,t)=>e+(t.is("$textProxy")?t.data:""),"");if(e&&(e.length<=d.length?d.startsWith(e)&&(d=d.substring(e.length),c[0].start=c[0].start.getShiftedBy(e.length)):e.startsWith(d)&&(c[0].start=c[0].start.getShiftedBy(d.length),d="")),0==d.length&&c[0].isCollapsed)return}const u={text:d,selection:t.createSelection(c)};this._typingQueue.push(u,Boolean(r.isComposing)),r.domEvent.defaultPrevented&&this._typingQueue.flush("beforeinput default prevented")}),Q.isAndroid?this.listenTo(i.document,"keydown",(e,n)=>{!s.isCollapsed&&229==n.keyCode&&i.document.isComposing&&Xg(t,o)}):this.listenTo(i.document,"compositionstart",()=>{s.isCollapsed||Xg(t,o)},{priority:"high"}),this.listenTo(i.document,"mutations",(e,{mutations:t})=>{if(this._typingQueue.hasAffectedElements())for(const{node:e}of t){const t=Zg(e,n),i=n.toModelElement(t);if(this._typingQueue.isElementAffected(i))return void this._typingQueue.flush("mutations")}}),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 e=[];if(this._typingQueue.hasAffectedElements())for(const t of this._typingQueue.flushAffectedElements()){const i=n.toViewElement(t);i&&e.push({type:"children",node:i})}!e.length&&Q.isAndroid||i.document.fire("mutations",{mutations:e})},{priority:"lowest"})}destroy(){super.destroy(),this._typingQueue.destroy()}}class Qg{editor;flushDebounced=Ci(()=>this.flush("timeout"),50);_queue=[];_isComposing=!1;_affectedElements=new Set;constructor(e){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 t of e.selection.getRanges())i.selectionRanges.push(Vo.fromRange(t)),this._affectedElements.add(t.start.parent)}this._queue.push(i),this._isComposing||=t,this.flushDebounced()}shift(){const e=this._queue.shift(),t={text:e.text};if(e.selectionRanges){const i=e.selectionRanges.map(e=>function(e){const t=e.toRange();if(e.detach(),"$graveyard"==t.root.rootName)return null;return t}(e)).filter(e=>!!e);i.length&&(t.selection=this.editor.model.createSelection(i))}return t}flush(e){const t=this.editor,i=t.model,n=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 e=this.shift();t.execute("insertText",e)}s.unlock(),this._isComposing||this._affectedElements.clear(),this._isComposing=!1}),n.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 Xg(e,t){if(!t.isEnabled)return;const i=t.buffer;i.lock(),e.enqueueChange(i.batch,()=>{e.deleteContent(e.document.selection)}),i.unlock()}function Zg(e,t){let i=e.is("$text")?e.parent:e;for(;!t.toModelElement(i);)i=i.parent;return i}class ef extends Tc{direction;_buffer;constructor(e,t){super(e),this.direction=t,this._buffer=new Ug(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,n=>{this._buffer.lock();const s=n.createSelection(e.selection||i.selection);if(!t.canEditAt(s))return;const o=e.sequence||1,r=s.isCollapsed;if(s.isCollapsed&&t.modifySelection(s,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(o))return void this._replaceEntireContentWithParagraph(n);if(this._shouldReplaceFirstBlockWithParagraph(s,o))return void this.editor.execute("paragraph",{selection:s});if(s.isCollapsed)return;let a=0;s.getFirstRange().getMinimalFlatRanges().forEach(e=>{a+=Ue(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))}),t.deleteContent(s,{doNotResetEntireContent:r,direction:this.direction}),this._buffer.input(a),n.setSelection(s),this._buffer.unlock()})}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(n)))return!1;if(!t.schema.checkChild(n,"paragraph"))return!1;const s=n.getChild(0);return!s||!s.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i),s=e.createElement("paragraph");e.remove(e.createRangeIn(n)),e.insert(s,n),e.setSelection(s,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const n=e.getFirstPosition(),s=i.schema.getLimitElement(n),o=s.getChild(0);return n.parent==o&&(!!e.containsEntireContent(o)&&(!!i.schema.checkChild(s,"paragraph")&&"paragraph"!=o.name))}}const tf="word",nf="selection",sf="backward",of="forward",rf={deleteContent:{unit:nf,direction:sf},deleteContentBackward:{unit:"codePoint",direction:sf},deleteWordBackward:{unit:tf,direction:sf},deleteHardLineBackward:{unit:nf,direction:sf},deleteSoftLineBackward:{unit:nf,direction:sf},deleteContentForward:{unit:"character",direction:of},deleteWordForward:{unit:tf,direction:of},deleteHardLineForward:{unit:nf,direction:of},deleteSoftLineForward:{unit:nf,direction:of}};class af extends js{constructor(e){super(e);const t=e.document;let i=0;t.on("keydown",()=>{i++}),t.on("keyup",()=>{i=0}),t.on("beforeinput",(n,s)=>{if(!this.isEnabled)return;const{targetRanges:o,domEvent:r,inputType:a}=s,l=rf[a];if(!l)return;const c={direction:l.direction,unit:l.unit,sequence:i};c.unit==nf&&(c.selectionToRemove=e.createSelection(o[0])),"deleteContentBackward"===a&&(Q.isAndroid&&(c.sequence=1),function(e){if(1!=e.length||e[0].isCollapsed)return!1;const t=e[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let i=0;for(const{nextPosition:e,item:n}of t){if(e.parent.is("$text")){const t=e.parent.data,n=e.offset;if(pi(t,n)||bi(t,n)||_i(t,n))continue;i++}else(n.is("containerElement")||n.is("emptyElement"))&&i++;if(i>1)return!0}return!1}(o)&&(c.unit=nf,c.selectionToRemove=e.createSelection(o)));const d=new zn(t,"delete",o[0]);t.fire(d,new Us(e,r,c)),d.stop.called&&n.stop()}),Q.isBlink&&function(e){const t=e.view,i=t.document;let n=null,s=!1;function o(e){return e==Ut.backspace||e==Ut.delete}function r(e){return e==Ut.backspace?sf:of}i.on("keydown",(e,{keyCode:t})=>{n=t,s=!1}),i.on("keyup",(a,{keyCode:l,domEvent:c})=>{const d=i.selection,u=e.isEnabled&&l==n&&o(l)&&!d.isCollapsed&&!s;if(n=null,u){const e=d.getFirstRange(),n=new zn(i,"delete",e),s={unit:nf,direction:r(l),selectionToRemove:d};i.fire(n,new Us(t,c,s))}}),i.on("beforeinput",(e,{inputType:t})=>{const i=rf[t];o(n)&&i&&i.direction==r(n)&&(s=!0)},{priority:"high"}),i.on("beforeinput",(e,{inputType:t,data:i})=>{n==Ut.delete&&"insertText"==t&&""==i&&e.stop()},{priority:"high"})}(this)}observe(){}stopObserving(){}}class lf extends Cc{_undoOnBackspace;static get pluginName(){return"Delete"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.model.document;t.addObserver(af),this._undoOnBackspace=!1;const s=new ef(e,"forward");e.commands.add("deleteForward",s),e.commands.add("forwardDelete",s),e.commands.add("delete",new ef(e,"backward")),this.listenTo(i,"delete",(n,s)=>{i.isComposing||s.preventDefault();const{direction:o,sequence:r,selectionToRemove:a,unit:l}=s,c="forward"===o?"deleteForward":"delete",d={sequence:r};if("selection"==l){const t=Array.from(a.getRanges()).map(t=>e.editing.mapper.toModelRange(t)).map(t=>ja(t,e.model.schema)||t);d.selection=e.model.createSelection(t)}else d.unit=l;e.execute(c,d),t.scrollToTheSelection()},{priority:"low"}),this.listenTo(i,"keydown",(s,o)=>{if(i.isComposing||o.keyCode!=Ut.backspace||!n.selection.isCollapsed)return;const r=e.model.schema.getLimitElement(n.selection),a=e.model.createPositionAt(r,0);if(a.isTouching(n.selection.getFirstPosition())){o.preventDefault();const n=e.model.schema.getNearestSelectionRange(a,"forward");if(!n)return;const s=t.createSelection(e.editing.mapper.toViewRange(n)),r=s.getFirstRange(),l=new zn(document,"delete",r),c={unit:"selection",direction:"backward",selectionToRemove:s};i.fire(l,new Us(t,o.domEvent,c))}}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(i,"delete",(t,i)=>{this._undoOnBackspace&&"backward"==i.direction&&1==i.sequence&&"codePoint"==i.unit&&(this._undoOnBackspace=!1,e.execute("undo"),i.preventDefault(),t.stop())},{context:"$capture"}),this.listenTo(n,"change",()=>{this._undoOnBackspace=!1}))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class cf extends Cc{static get requires(){return[Yg,lf]}static get pluginName(){return"Typing"}static get isOfficialPlugin(){return!0}}function df(e,t){let i=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce((e,{item:n})=>n.is("$text")||n.is("$textProxy")?e+n.data:(i=t.createPositionAfter(n),""),""),range:t.createRange(i,e.end)}}class uf extends(Le()){model;testCallback;_hasMatch;constructor(e,t){super(),this.model=e,this.testCallback=t,this._hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))}),this._startListening()}get hasMatch(){return this._hasMatch}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",(t,{directChange:i})=>{i&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1))}),this.listenTo(e,"change:data",(e,t)=>{!t.isUndo&&t.isLocal&&this._evaluateTextBeforeSelection("data",{batch:t})})}_evaluateTextBeforeSelection(e,t={}){const i=this.model,n=i.document.selection,s=i.createRange(i.createPositionAt(n.focus.parent,0),n.focus),{text:o,range:r}=df(s,i),a=this.testCallback(o);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const i=Object.assign(t,{text:o,range:r});"object"==typeof a&&Object.assign(i,a),this.fire(`matched:${e}`,i)}}}class hf extends Cc{attributes;_overrideUid;_isNextGravityRestorationSkipped=!1;static get pluginName(){return"TwoStepCaretMovement"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.locale,s=t.document.selection;this.listenTo(i.document,"arrowKey",(e,t)=>{if(!s.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const i=t.keyCode==Ut.arrowright,o=t.keyCode==Ut.arrowleft;if(!i&&!o)return;const r=n.contentLanguageDirection;let a=!1;a="ltr"===r&&i||"rtl"===r&&o?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()},{context:"$text",priority:"highest"}),this.listenTo(s,"change:range",(e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&wf(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,n=i.document.selection,s=n.getFirstPosition();return!this._isGravityOverridden&&((!s.isAtStart||!mf(n,t))&&(!!wf(s,t)&&(e&&pf(e),mf(n,t)&&wf(s,t,!0)?ff(i,t):this._overrideGravity(),!0)))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,s=n.getFirstPosition();return this._isGravityOverridden?(e&&pf(e),this._restoreGravity(),wf(s,t,!0)?ff(i,t):gf(i,t,s),!0):s.isAtStart?!!mf(n,t)&&(e&&pf(e),gf(i,t,s),!0):!mf(n,t)&&wf(s,t,!0)?(e&&pf(e),gf(i,t,s),!0):!!bf(s,t)&&(s.isAtEnd&&!mf(n,t)&&wf(s,t)?(e&&pf(e),gf(i,t,s),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}_enableClickingAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view.document;e.editing.view.addObserver(cl),e.editing.view.addObserver(dl);let s=!1,o=!1;this.listenTo(n,"touchstart",()=>{o=!1,s=!0}),this.listenTo(n,"mousedown",()=>{o=!0}),this.listenTo(n,"selectionChange",()=>{const e=this.attributes;if(!o&&!s)return;if(o=!1,s=!1,!i.isCollapsed)return;if(!mf(i,e))return;const n=i.getFirstPosition();wf(n,e)&&(n.isAtStart||wf(n,e,!0)?ff(t,e):this._isGravityOverridden||this._overrideGravity())})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection,i=this.attributes;this.listenTo(e,"insertContent",()=>{const n=t.getFirstPosition();mf(t,i)&&wf(n,i)&&ff(e,i)},{priority:"low"})}_handleDeleteContentAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view;let s=!1,o=!1;this.listenTo(n.document,"delete",(e,t)=>{s="backward"===t.direction},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{if(!s)return;const e=i.getFirstPosition();o=mf(i,this.attributes)&&!bf(e,this.attributes)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{s&&(s=!1,o||e.model.enqueueChange(()=>{const e=i.getFirstPosition();mf(i,this.attributes)&&wf(e,this.attributes)&&(e.isAtStart||wf(e,this.attributes,!0)?ff(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 mf(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function gf(e,t,i){const n=i.nodeBefore;e.change(i=>{if(n){const t=[],s=e.schema.isObject(n)&&e.schema.isInline(n);for(const[i,o]of n.getAttributes())!e.schema.checkAttribute("$text",i)||s&&!1===e.schema.getAttributeProperties(i).copyFromObject||t.push([i,o]);i.setSelectionAttribute(t)}else i.removeSelectionAttribute(t)})}function ff(e,t){e.change(e=>{e.removeSelectionAttribute(t)})}function pf(e){e.preventDefault()}function bf(e,t){return wf(e.getShiftedBy(-1),t)}function wf(e,t,i=!1){const{nodeBefore:n,nodeAfter:s}=e;for(const e of t){const t=n?n.getAttribute(e):void 0,o=s?s.getAttribute(e):void 0;if((!i||void 0!==t&&void 0!==o)&&o!==t)return!0}return!1}_f('"'),_f("'"),_f("'"),_f('"'),_f('"'),_f("'");function _f(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function vf(e,t,i,n){return n.createRange(yf(e,t,i,!0,n),yf(e,t,i,!1,n))}function yf(e,t,i,n,s){let o=e.textNode||(n?e.nodeBefore:e.nodeAfter),r=null;for(;o&&o.getAttribute(t)==i;)r=o,o=n?o.previousSibling:o.nextSibling;return r?s.createPositionAt(r,n?"before":"after"):e}class kf extends Tc{attributeKey;constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change(e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey,{includeEmptyRanges:!0});for(const t of s){let i=t,s=this.attributeKey;t.isCollapsed&&(i=t.start.parent,s=Lo._getStoreAttributeKey(this.attributeKey)),n?e.setAttribute(s,n,i):e.removeAttribute(s,i)}}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}const Cf="bold";class Af extends Cc{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:Cf}),e.model.schema.setAttributeProperties(Cf,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Cf,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t&&("bold"==t||Number(t)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(Cf,new kf(e,Cf)),e.keystrokes.set("CTRL+B",Cf),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Bold text"),keystroke:"CTRL+B"}]})}}function Tf({editor:e,commandName:t,plugin:i,icon:n,label:s,keystroke:o}){return r=>{const a=e.commands.get(t),l=new r(e.locale);return l.set({label:s,icon:n,keystroke:o,isToggleable:!0}),l.bind("isEnabled").to(a,"isEnabled"),l.bind("isOn").to(a,"value"),l instanceof Eh?l.set({role:"menuitemcheckbox"}):l.set({tooltip:!0}),i.listenTo(l,"execute",()=>{e.execute(t),e.editing.view.focus()}),l}}const Ef="bold";class xf extends Cc{static get pluginName(){return"BoldUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Tf({editor:e,commandName:Ef,plugin:this,icon:ed,label:t("Bold"),keystroke:"CTRL+B"});e.ui.componentFactory.add(Ef,()=>i(rh)),e.ui.componentFactory.add("menuBar:"+Ef,()=>i(Eh))}}const Pf="italic";class Sf extends Cc{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:Pf}),e.model.schema.setAttributeProperties(Pf,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Pf,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(Pf,new kf(e,Pf)),e.keystrokes.set("CTRL+I",Pf),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Italic text"),keystroke:"CTRL+I"}]})}}const If="italic";class Of extends Cc{static get pluginName(){return"ItalicUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Tf({editor:e,commandName:If,plugin:this,icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m9.586 14.633.021.004q-.054.502.393.962.123.125.274.201h1.474a.6.6 0 1 1 0 1.2H5.304a.6.6 0 0 1 0-1.2h1.15q.711-.106 1.005-.334.235-.182.404-.597l2.416-9.55a1.05 1.05 0 0 0-.281-.823 1.1 1.1 0 0 0-.442-.296H8.15a.6.6 0 0 1 0-1.2h6.443a.6.6 0 1 1 0 1.2h-1.195q-.564.084-.823.296-.323.263-.623.79z"/></svg>',keystroke:"CTRL+I",label:t("Italic")});e.ui.componentFactory.add(If,()=>i(rh)),e.ui.componentFactory.add("menuBar:"+If,()=>i(Eh))}}const Rf="strikethrough";class Vf extends Cc{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:Rf}),e.model.schema.setAttributeProperties(Rf,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Rf,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(Rf,new kf(e,Rf)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Strikethrough text"),keystroke:"CTRL+SHIFT+X"}]})}}const Bf="strikethrough";class Mf extends Cc{static get pluginName(){return"StrikethroughUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Tf({editor:e,commandName:Bf,plugin:this,icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M7 16.4c-.8-.4-1.5-.9-2.2-1.5a.6.6 0 0 1-.2-.5l.3-.6h1c1 1.2 2.1 1.7 3.7 1.7 1 0 1.8-.3 2.3-.6.6-.4.6-1.2.6-1.3.2-1.2-.9-2.1-.9-2.1h2.1c.3.7.4 1.2.4 1.7v.8l-.6 1.2c-.6.8-1.1 1-1.6 1.2a6 6 0 0 1-2.4.6c-1 0-1.8-.3-2.5-.6M6.8 9 6 8.3c-.4-.5-.5-.8-.5-1.6 0-.7.1-1.3.5-1.8.4-.6 1-1 1.6-1.3a6.3 6.3 0 0 1 4.7 0 4 4 0 0 1 1.7 1l.3.7c0 .1.2.4-.2.7-.4.2-.9.1-1 0a3 3 0 0 0-1.2-1c-.4-.2-1-.3-2-.4-.7 0-1.4.2-2 .6-.8.6-1 .8-1 1.5 0 .8.5 1 1.2 1.5.6.4 1.1.7 1.9 1H6.8z"/><path d="M3 10.5V9h14v1.5z"/></svg>',keystroke:"CTRL+SHIFT+X",label:t("Strikethrough")});e.ui.componentFactory.add(Bf,()=>i(rh)),e.ui.componentFactory.add("menuBar:"+Bf,()=>i(Eh))}}const Ff="underline";class Nf extends Cc{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:Ff}),e.model.schema.setAttributeProperties(Ff,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Ff,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(Ff,new kf(e,Ff)),e.keystrokes.set("CTRL+U","underline"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Underline text"),keystroke:"CTRL+U"}]})}}const Lf="underline";class Df extends Cc{static get pluginName(){return"UnderlineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Tf({editor:e,commandName:Lf,plugin:this,icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M3 18v-1.5h14V18zm2.2-8V3.6c0-.4.4-.6.8-.6.3 0 .7.2.7.6v6.2c0 2 1.3 2.8 3.2 2.8s3.4-.9 3.4-2.9V3.6c0-.3.4-.5.8-.5.3 0 .7.2.7.5V10c0 2.7-2.2 4-4.9 4-2.6 0-4.7-1.2-4.7-4"/></svg>',label:t("Underline"),keystroke:"CTRL+U"});e.ui.componentFactory.add(Lf,()=>i(rh)),e.ui.componentFactory.add("menuBar:"+Lf,()=>i(Eh))}}function*zf(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class Hf extends Tc{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,n=t.schema,s=i.isCollapsed,o=i.getFirstRange(),r=o.start.parent,a=o.end.parent;if(n.isLimit(r)||n.isLimit(a))return s||r!=a||t.deleteContent(i),!1;if(s){const t=zf(e.model.schema,i.getAttributes());return $f(e,o.start),e.setSelectionAttribute(t),!0}{const n=!(o.start.isAtStart&&o.end.isAtEnd),s=r==a;if(t.deleteContent(i,{leaveUnmerged:n}),n){if(s)return $f(e,i.focus),!0;e.setSelection(a,0)}}return!1}}function $f(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const Wf={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class jf extends js{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",(e,t)=>{i=t.shiftKey}),t.on("beforeinput",(n,s)=>{if(!this.isEnabled)return;let o=s.inputType;Q.isSafari&&i&&"insertParagraph"==o&&(o="insertLineBreak");const r=s.domEvent,a=Wf[o];if(!a)return;const l=new zn(t,"enter",s.targetRanges[0]);t.fire(l,new Us(e,r,{isSoft:a.isSoft})),l.stop.called&&n.stop()})}observe(){}stopObserving(){}}class Uf extends Cc{static get pluginName(){return"Enter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,n=this.editor.t;t.addObserver(jf),e.commands.add("enter",new Hf(e)),this.listenTo(i,"enter",(n,s)=>{i.isComposing||s.preventDefault(),s.isSoft||(e.execute("enter"),t.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:n("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class qf extends Tc{execute(){const e=this.editor.model,t=e.document;e.change(i=>{!function(e,t,i){const n=i.isCollapsed,s=i.getFirstRange(),o=s.start.parent,r=s.end.parent,a=o==r;if(n){const n=zf(e.schema,i.getAttributes());Kf(e,t,s.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(s.start.isAtStart&&s.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),a?Kf(e,t,i.focus):n&&t.setSelection(r,0)}}(e,i,t.selection),this.fire("afterExecute",{writer:i})})}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const i=t.anchor;if(!i||!e.checkChild(i,"softBreak"))return!1;const n=t.getFirstRange(),s=n.start.parent,o=n.end.parent;if((Gf(s,e)||Gf(o,e))&&s!==o)return!1;return!0}(e.schema,t.selection)}}function Kf(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function Gf(e,t){return!e.is("rootElement")&&(t.isLimit(e)||Gf(e.parent,t))}class Jf extends Cc{static get pluginName(){return"ShiftEnter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,s=n.document,o=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:(e,{writer:t})=>t.createEmptyElement("br")}),n.addObserver(jf),e.commands.add("shiftEnter",new qf(e)),this.listenTo(s,"enter",(t,i)=>{s.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Insert a soft break (a <code><br></code> element)"),keystroke:"Shift+Enter"}]})}}class Yf extends Tc{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,s=Array.from(n.getSelectedBlocks()),o=void 0===e.forceValue?!this.value:e.forceValue;t.change(e=>{if(o){const t=s.filter(e=>Qf(e)||Zf(i,e));this._applyQuote(e,t)}else this._removeQuote(e,s.filter(Qf))})}_getValue(){const e=si(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!Qf(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=si(e.getSelectedBlocks());return!!i&&Zf(t,i)}_removeQuote(e,t){Xf(e,t).reverse().forEach(t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const i=e.createPositionBefore(t.start.parent);return void e.move(t,i)}t.end.isAtEnd||e.split(t.end);const i=e.createPositionAfter(t.end.parent);e.move(t,i)})}_applyQuote(e,t){const i=[];Xf(e,t).reverse().forEach(t=>{let n=Qf(t.start);n||(n=e.createElement("blockQuote"),e.wrap(t,n)),i.push(n)}),i.reverse().reduce((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i)}}function Qf(e){return"blockQuote"==e.parent.name?e.parent:null}function Xf(e,t){let i,n=0;const s=[];for(;n<t.length;){const o=t[n],r=t[n+1];i||(i=e.createPositionBefore(o)),r&&o.nextSibling==r||(s.push(e.createRange(i,e.createPositionAfter(o))),i=null),n++}return s}function Zf(e,t){const i=e.checkChild(t.parent,"blockQuote"),n=e.checkChild(["$root","blockQuote"],t);return i&&n}class ep extends Cc{static get pluginName(){return"BlockQuoteEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Uf,lf]}init(){const e=this.editor,t=e.model.schema;e.commands.add("blockQuote",new Yf(e)),t.register("blockQuote",{inheritAllFrom:"$container"}),e.conversion.elementToElement({model:"blockQuote",view:"blockquote"}),e.model.document.registerPostFixer(i=>{const n=e.model.document.differ.getChanges();for(const e of n)if("insert"==e.type){const n=e.position.nodeAfter;if(!n)continue;if(n.is("element","blockQuote")&&n.isEmpty)return i.remove(n),!0;if(n.is("element","blockQuote")&&!t.checkChild(e.position,n))return i.unwrap(n),!0;if(n.is("element")){const e=i.createRangeIn(n);for(const n of e.getItems())if(n.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(n),n))return i.unwrap(n),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return i.remove(t),!0}return!1});const i=this.editor.editing.view.document,n=e.model.document.selection,s=e.commands.get("blockQuote");this.listenTo(i,"enter",(t,i)=>{if(!n.isCollapsed||!s.value)return;n.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())},{context:"blockquote"}),this.listenTo(i,"delete",(t,i)=>{if("backward"!=i.direction||!n.isCollapsed||!s.value)return;const o=n.getLastPosition().parent;o.isEmpty&&!o.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())},{context:"blockquote"})}}class tp extends Cc{static get pluginName(){return"BlockQuoteUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("blockQuote",()=>{const e=this._createButton(rh);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:blockQuote",()=>{const e=this._createButton(Eh);return e.set({role:"menuitemcheckbox"}),e})}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("blockQuote"),s=new e(t.locale),o=i.t;return s.set({label:o("Block quote"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M3 10.423a6.5 6.5 0 0 1 6.056-6.408l.038.67C6.448 5.423 5.354 7.663 5.22 10H9c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003zm8 0a6.5 6.5 0 0 1 6.056-6.408l.038.67c-2.646.739-3.74 2.979-3.873 5.315H17c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003z"/></svg>',isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value"),this.listenTo(s,"execute",()=>{t.execute("blockQuote"),t.editing.view.focus()}),s}}function ip(e){return e}function np(e,t,i){return"function"!=typeof i?np(e,t,()=>{}):sp(e,t,function e(t,n,s,o,r,a){const l=i(t,n,s,o,r,a);return void 0!==l?Boolean(l):sp(t,n,e,a)},new Map)}function sp(e,t,n,s){if(t===e)return!0;switch(typeof t){case"object":return function(e,t,i,n){if(null==t)return!0;if(Array.isArray(t))return op(e,t,i,n);if(t instanceof Map)return function(e,t,i,n){if(0===t.size)return!0;if(!(e instanceof Map))return!1;for(const[s,o]of t.entries()){if(!1===i(e.get(s),o,s,e,t,n))return!1}return!0}(e,t,i,n);if(t instanceof Set)return function(e,t,i,n){if(0===t.size)return!0;if(!(e instanceof Set))return!1;return op([...e],[...t],i,n)}(e,t,i,n);const s=Object.keys(t);if(null==e||S(e))return 0===s.length;if(0===s.length)return!0;if(n?.has(t))return n.get(t)===e;n?.set(t,e);try{for(let o=0;o<s.length;o++){const r=s[o];if(!S(e)&&!(r in e))return!1;if(void 0===t[r]&&void 0!==e[r])return!1;if(null===t[r]&&null!==e[r])return!1;if(!i(e[r],t[r],r,e,t,n))return!1}return!0}finally{n?.delete(t)}}(e,t,n,s);case"function":return Object.keys(t).length>0?sp(e,{...t},n,s):Oi(e,t);default:return i(e)?"string"!=typeof t||""===t:Oi(e,t)}}function op(e,t,i,n){if(0===t.length)return!0;if(!Array.isArray(e))return!1;const s=new Set;for(let o=0;o<t.length;o++){const r=t[o];let a=!1;for(let l=0;l<e.length;l++){if(s.has(l))continue;let c=!1;if(i(e[l],r,o,e,t,n)&&(c=!0),c){s.add(l),a=!0;break}}if(!a)return!1}return!0}function rp(e,t){return np(e,t,()=>{})}function ap(e){var t;return e=O(t=e,void 0,t,new Map,void 0),t=>rp(t,e)}function lp(e,t){let i;if(i=Array.isArray(t)?t:"string"==typeof t&&Mi(t)&&null==e?.[t]?Ni(t):[t],0===i.length)return!1;let n=e;for(let e=0;e<i.length;e++){const t=i[e];if(null==n||!Object.hasOwn(n,t)){if(!((Array.isArray(n)||D(n))&&Hi(t)&&t<n.length))return!1}n=n[t]}return!0}function cp(e){if(null==e)return ip;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&2===e.length?function(e,t){switch(typeof e){case"object":Object.is(e?.valueOf(),-0)&&(e="-0");break;case"number":e=Fi(e)}return t=N(t),function(i){const n=Li(i,e);return void 0===n?lp(i,e):void 0===t?void 0===n:rp(n,t)}}(e[0],e[1]):ap(e);case"string":case"symbol":case"number":return t=e,function(e){return Li(e,t)}}var t}function dp(e,t=ip){return null==e?{}:function(e,t){const i={},n=Object.keys(e);for(let s=0;s<n.length;s++){const o=n[s],r=e[o];i[o]=t(r,o,e)}return i}(e,cp(t))}class up extends(Ae()){_stack=[];add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const s=i[0];n===s||hp(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:t})}remove(e,t){const i=this._stack,n=i[0];this._removeDescriptor(e);const s=i[0];n===s||hp(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex(t=>t.id===e.id);if(hp(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&mp(t[n],e);)n++;t.splice(n,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex(t=>t.id===e);i>-1&&t.splice(i,1)}}function hp(e,t){return e&&t&&e.priority==t.priority&&gp(e.classes)==gp(t.classes)}function mp(e,t){return e.priority>t.priority||!(e.priority<t.priority)&&gp(e.classes)>gp(t.classes)}function gp(e){return Array.isArray(e)?e.sort().join(","):e}const fp="ck-widget_selected";function pp(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function bp(e,t,i={}){if(!e.is("containerElement"))throw new fe("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass("ck-widget",e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=Cp,t.setCustomProperty("widgetLabel",[],e),i.label&&function(e,t){const i=e.getCustomProperty("widgetLabel");i.push(t)}(e,i.label),i.hasSelectionHandle&&function(e,t){const i=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},function(e){const t=this.toDomElement(e),i=new sh;return i.set("content",od),i.render(),t.appendChild(i.element),t});t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),vp(e,t),e}function wp(e,t,i){if(t.classes&&i.addClass(ei(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function _p(e,t,i){if(t.classes&&i.removeClass(ei(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function vp(e,t,i=wp,n=_p){const s=new up;s.on("change:top",(t,s)=>{s.oldDescriptor&&n(e,s.oldDescriptor,s.writer),s.newDescriptor&&i(e,s.newDescriptor,s.writer)});t.setCustomProperty("addHighlight",(e,t,i)=>s.add(t,i),e),t.setCustomProperty("removeHighlight",(e,t,i)=>s.remove(t,i),e)}function yp(e,t,i={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),!1!==i.withAriaRole&&t.setAttribute("role","textbox",e),e.isReadOnly||t.setAttribute("tabindex","-1",e),i.label&&t.setAttribute("aria-label",i.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",(i,n,s)=>{t.setAttribute("contenteditable",s?"false":"true",e),s?t.removeAttribute("tabindex",e):t.setAttribute("tabindex","-1",e)}),e.on("change:isFocused",(i,n,s)=>{s?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)}),vp(e,t),e}function kp(e,t){const i=e.getSelectedElement();if(i){const n=xp(e);if(n)return t.createRange(t.createPositionAt(i,n))}return t.schema.findOptimalInsertionRange(e)}function Cp(){return null}function Ap(e){const t=e=>{const{width:t,paddingLeft:i,paddingRight:n}=e.ownerDocument.defaultView.getComputedStyle(e);return parseFloat(t)-(parseFloat(i)||0)-(parseFloat(n)||0)},i=e.parentElement;if(!i)return 0;let n=t(i);let s=0,o=i;for(;isNaN(n);){if(o=o.parentElement,++s>5)return 0;n=t(o)}return n}const Tp="widget-type-around";function Ep(e,t,i){return!!e&&pp(e)&&!i.isInline(t)}function xp(e){return e.getAttribute(Tp)}const Pp=["before","after"],Sp=(new DOMParser).parseFromString('<svg viewBox="0 0 10 8" xmlns="http://www.w3.org/2000/svg"><path d="M9.055.263v3.972h-6.77M1 4.216l2-2.038m-2 2 2 2.038"/></svg>',"image/svg+xml").firstChild,Ip="ck-widget__type-around_disabled";class Op extends Cc{_currentFakeCaretModelElement=null;static get pluginName(){return"WidgetTypeAround"}static get isOfficialPlugin(){return!0}static get requires(){return[Uf,lf]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",(i,n,s)=>{t.change(e=>{for(const i of t.document.roots)s?e.removeClass(Ip,i):e.addClass(Ip,i)}),s||e.model.change(e=>{e.removeSelectionAttribute(Tp)})}),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,n=i.editing.view,s=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:s}),n.focus(),n.scrollToTheSelection()}_listenToIfEnabled(e,t,i,n){this.listenTo(e,t,(...e)=>{this.isEnabled&&i(...e)},n)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=xp(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,n={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",(e,s,o)=>{const r=o.mapper.toViewElement(s.item);if(r&&Ep(r,s.item,t)){!function(e,t,i){const n=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},function(e){const i=this.toDomElement(e);return function(e,t){for(const i of Pp){const n=new ku({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${i}`],title:t[i],"aria-hidden":"true"},children:[e.ownerDocument.importNode(Sp,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new ku({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i});e.insert(e.createPositionAt(i,"end"),n)}(o.writer,n,r);r.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,n=t.schema,s=e.editing.view;function o(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(s.document,"arrowKey",(e,t)=>{this._handleArrowKeyPress(e,t)},{context:[pp,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",(t,i)=>{i.directChange&&e.model.change(e=>{e.removeSelectionAttribute(Tp)})}),this._listenToIfEnabled(t.document,"change:data",()=>{const t=i.getSelectedElement();if(t){if(Ep(e.editing.mapper.toViewElement(t),t,n))return}e.model.change(e=>{e.removeSelectionAttribute(Tp)})}),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",(e,t,i)=>{const s=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(s.removeClass(Pp.map(o),e),this._currentFakeCaretModelElement=null)}const r=t.selection.getSelectedElement();if(!r)return;const a=i.mapper.toViewElement(r);if(!Ep(a,r,n))return;const l=xp(t.selection);l&&(s.addClass(o(l),a),this._currentFakeCaretModelElement=r)}),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",(t,i,n)=>{n||e.model.change(e=>{e.removeSelectionAttribute(Tp)})})}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,s=n.document.selection,o=n.schema,r=i.editing.view;if(t.shiftKey)return;const a=function(e,t){const i=Yt(e,t);return"down"===i||"right"===i}(t.keyCode,i.locale.contentLanguageDirection),l=r.document.selection.getSelectedElement();let c;Ep(l,i.editing.mapper.toModelElement(l),o)?c=this._handleArrowKeyPressOnSelectedWidget(a):s.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=xp(t.document.selection);return t.change(t=>{if(!i)return t.setSelectionAttribute(Tp,e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute(Tp),!0;return!1})}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,n=i.schema,s=t.plugins.get("Widget"),o=s._getObjectElementNextToSelection(e);return!!Ep(t.editing.mapper.toViewElement(o),o,n)&&(i.change(t=>{s._setSelectionOverElement(o),t.setSelectionAttribute(Tp,e?"before":"after")}),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,n=i.schema,s=t.editing.mapper,o=i.document.selection,r=e?o.getLastPosition().nodeBefore:o.getFirstPosition().nodeAfter;return!!Ep(s.toViewElement(r),r,n)&&(i.change(t=>{t.setSelection(r,"on"),t.setSelectionAttribute(Tp,e?"after":"before")}),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",(i,n)=>{const s=n.domTarget.closest(".ck-widget__type-around__button");if(!s)return;const o=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(s),r=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(s,t.domConverter),a=e.editing.mapper.toModelElement(r);this._insertParagraph(a,o),n.preventDefault(),i.stop()})}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",(i,n)=>{if("atTarget"!=i.eventPhase)return;const s=t.getSelectedElement(),o=e.editing.mapper.toViewElement(s),r=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:Ep(o,s,r)&&(this._insertParagraph(s,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())},{context:pp})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",(t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)},{priority:"high"}),Q.isAndroid?this._listenToIfEnabled(e,"keydown",(e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(e,"compositionstart",()=>{this._insertParagraphAccordingToFakeCaretPosition()},{priority:"highest"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,n=i.schema;this._listenToIfEnabled(t.document,"delete",(t,s)=>{if("atTarget"!=t.eventPhase)return;const o=xp(i.document.selection);if(!o)return;const r=s.direction,a=i.document.selection.getSelectedElement(),l="forward"==r;if("before"===o===l)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=n.getNearestSelectionRange(i.createPositionAt(a,o),r);if(t)if(t.isCollapsed){const s=i.createSelection(t.start);if(i.modifySelection(s,{direction:r}),s.focus.isEqual(t.start)){const e=function(e,t){let i=t;for(const n of t.getAncestors({parentFirst:!0})){if(n.childCount>1||e.isLimit(n))break;i=n}return i}(n,t.start.parent);i.deleteContent(i.createSelection(e,"on"),{doNotAutoparagraph:!0})}else i.change(i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")})}else i.change(i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")})}s.preventDefault(),t.stop()},{context:pp})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",(e,[n,s])=>{if(s&&!s.is("documentSelection"))return;const o=xp(i);return o?(e.stop(),t.change(e=>{const s=i.getSelectedElement(),r=t.createPositionAt(s,o),a=e.createSelection(r),l=t.insertContent(n,a);return e.setSelection(a),l})):void 0},{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",(e,i)=>{const[,n,s={}]=i;if(n&&!n.is("documentSelection"))return;const o=xp(t);o&&(s.findOptimalPosition=o,i[3]=s)},{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",(e,[i])=>{if(i&&!i.is("documentSelection"))return;xp(t)&&e.stop()},{priority:"high"})}}function Rp(e){const t=e.model;return(i,n)=>{const s=n.keyCode==Ut.arrowup,o=n.keyCode==Ut.arrowdown,r=n.shiftKey,a=t.document.selection;if(!s&&!o)return;const l=o,c=function(e,t,i){const n=e.model;if(i){const e=t.focus,i=Vp(n,e,"forward");if(!i)return;const s=n.createRange(e,i),o=Bp(n.schema,s,"backward");if(o)return n.createRange(e,o)}else{const e=t.focus,i=Vp(n,e,"backward");if(!i)return;const s=n.createRange(i,e),o=Bp(n.schema,s,"forward");if(o)return n.createRange(o,e)}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(r)return}(c.isCollapsed||function(e,t,i){const n=e.model,s=e.view.domConverter;if(i){const e=n.createSelection(t.start);n.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=n.createRange(e.focus,t.end))}const o=e.mapper.toViewRange(t),r=s.viewRangeToDom(o),a=ht.getDomRangeRects(r);let l;for(const e of a)if(void 0!==l){if(Math.round(e.top)>=l)return!1;l=Math.max(l,Math.round(e.bottom))}else l=Math.round(e.bottom);return!0}(e,c,l))&&(t.change(e=>{const i=l?c.end:c.start;if(r){const n=t.createSelection(a.anchor);n.setFocus(i),e.setSelection(n)}else e.setSelection(i)}),i.stop(),n.preventDefault(),n.stopPropagation())}}}function Vp(e,t,i){const n=e.schema,s=e.createRangeIn(t.root),o="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:r,type:a}of s.getWalker({startPosition:t,direction:i})){if(n.isLimit(r)&&!n.isInline(r))return e;if(a==o&&n.isBlock(r))return null}return null}function Bp(e,t,i){const n="backward"==i?t.end:t.start;if(e.checkChild(n,"$text"))return n;for(const{nextPosition:n}of t.getWalker({direction:i}))if(e.checkChild(n,"$text"))return n}class Mp extends Cc{_previouslySelected=new Set;static get pluginName(){return"Widget"}static get isOfficialPlugin(){return!0}static get requires(){return[Op,lf]}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.t;this.editor.editing.downcastDispatcher.on("selection",(t,i,n)=>{const s=n.writer,o=i.selection;if(o.isCollapsed)return;const r=o.getSelectedElement();if(!r)return;const a=e.editing.mapper.toViewElement(r);var l;pp(a)&&(n.consumable.consume(o,"selection")&&s.setSelection(s.createRangeOn(a),{fake:!0,label:(l=a,l.getCustomProperty("widgetLabel").reduce((e,t)=>"function"==typeof t?e?e+". "+t():t():e?e+". "+t:t,""))}))}),this.editor.editing.downcastDispatcher.on("selection",(e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,s=n.document.selection;let o=null;for(const e of s.getRanges())for(const t of e){const e=t.item;pp(e)&&!Fp(e,o)&&(n.addClass(fp,e),this._previouslySelected.add(e),o=e)}},{priority:"low"}),t.addObserver(cl),t.addObserver(ul),this.listenTo(i,"mousedown",(...e)=>this._onMousedown(...e)),this.listenTo(i,"pointerdown",(...e)=>this._onPointerdown(...e)),this.listenTo(i,"arrowKey",(...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)},{context:[pp,"$text"]}),this.listenTo(i,"arrowKey",(...e)=>{this._preventDefaultOnArrowKeyPress(...e)},{context:"$root"}),this.listenTo(i,"arrowKey",Rp(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",(e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())},{context:"$root"}),this.listenTo(i,"tab",(e,i)=>{this._selectNextEditable(i.shiftKey?"backward":"forward")&&(t.scrollToTheSelection(),i.preventDefault(),e.stop())},{context:e=>pp(e)||e.is("editableElement"),priority:"low"}),this.listenTo(i,"keydown",(e,t)=>{t.keystroke==Ut.esc&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())},{context:e=>e.is("editableElement"),priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:n("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:n("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:n("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:n("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:n("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:n("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=t.target;i&&t.domEvent.detail>=3&&this._selectBlockContent(i)&&t.preventDefault()}_onPointerdown(e,t){if(!t.domEvent.isPrimary)return;const i=this.editor,n=i.editing.view,s=n.document;let o=t.target;if(!o)return;if(!pp(o)){const e=function(e){let t=e;for(;t;){if(t.is("editableElement")||pp(t))return t;t=t.parent}return null}(o);if(!e)return;if(pp(e))o=e;else{const e=function(e,t){const i=rt(t.domEvent);let n=null;n=i?e.domConverter.domRangeToView(i):e.createRange(e.createPositionAt(t.target,0));if(!n)return null;const s=n.start;if(!s.parent)return null;let o=s.parent;s.parent.is("editableElement")&&(s.isAtEnd&&s.nodeBefore?o=s.nodeBefore:s.isAtStart&&s.nodeAfter&&(o=s.nodeAfter));if(o.is("$text"))return o.parent;return o}(n,t);if(!e||!pp(e))return;o=e}}(Q.isAndroid||Q.isiOS)&&t.preventDefault(),s.isFocused||n.focus();const r=i.editing.mapper.toModelElement(o);this._setSelectionOverElement(r)}_selectBlockContent(e){const t=this.editor,i=t.model,n=t.editing.mapper,s=i.schema,o=n.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),r=function(e,t){for(const i of e.getAncestors({includeSelf:!0,parentFirst:!0})){if(t.checkChild(i,"$text"))return i;if(t.isLimit(i)&&!t.isObject(i))break}return null}(n.toModelElement(o),i.schema);return!!r&&(i.change(e=>{const t=s.isLimit(r)?null:function(e,t){const i=new lo({startPosition:e});for(const{item:e}of i){if(t.isLimit(e)||!e.is("element"))return null;if(t.checkChild(e,"$text"))return e}return null}(e.createPositionAfter(r),s),i=e.createPositionAt(r,0),n=t?e.createPositionAt(t,0):e.createPositionAt(r,"end");e.setSelection(e.createRange(i,n))}),!0)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,s=n.schema,o=n.document.selection,r=o.getSelectedElement(),a=Yt(i,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(!t.shiftKey&&!o.isCollapsed){if(function(e,t){const i=e.getFirstPosition(),n=e.getLastPosition(),s=i.nodeAfter,o=n.nodeBefore;return!!s&&t.isObject(s)||!!o&&t.isObject(o)}(o,s)){const i=l?o.getLastPosition():o.getFirstPosition(),r=s.getNearestSelectionRange(i,l?"forward":"backward");r&&(n.change(e=>{e.setSelection(r)}),t.preventDefault(),e.stop())}return}const d=function(e,t){const i=e.document.selection,n=i.getSelectedElement(),s=xp(i);if(n&&"before"==s)return e.createSelection(n,"before");if(n&&"after"==s)return e.createSelection(n,"after");return e.createSelection(i.getRanges(),{backward:n&&e.schema.isObject(n)?!t:i.isBackward})}(n,l),u=n.createSelection(d);if(n.modifySelection(u,{direction:l?"forward":"backward"}),u.isEqual(d))return;u.focus.isTouching(d.focus)&&s.checkChild(u.focus.parent,"$text")&&(l?!u.focus.isAtEnd:!u.focus.isAtStart)&&n.modifySelection(u,{direction:l?"forward":"backward"});const h=l?d.focus.nodeBefore:d.focus.nodeAfter,m=u.focus.nodeBefore,g=u.focus.nodeAfter,f=l?m:g;if(t.shiftKey)(r&&s.isObject(r)||f&&s.isObject(f)||h&&s.isObject(h))&&(n.change(e=>{e.setSelection(u)}),t.preventDefault(),e.stop());else if(f&&s.isObject(f)){if(s.isInline(f)&&c)return;n.change(e=>{e.setSelection(f,"on")}),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,n=i.schema,s=i.document.selection.getSelectedElement();s&&n.isObject(s)&&(t.preventDefault(),e.stop())}_handleDelete(e){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t))return;if(!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);return i?(this.editor.model.change(e=>{let n=t.anchor.parent;for(;n.isEmpty;){const t=n;n=t.parent,e.remove(t)}this._setSelectionOverElement(i)}),!0):void 0}_setSelectionOverElement(e){this.editor.model.change(t=>{t.setSelection(t.createRangeOn(e))})}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,n=t.document.selection,s=t.createSelection(n);if(t.modifySelection(s,{direction:e?"forward":"backward"}),s.isEqual(n))return null;const o=e?s.focus.nodeBefore:s.focus.nodeAfter;return o&&i.isObject(o)?o:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(fp,t);this._previouslySelected.clear()}_selectNextEditable(e){const t=this.editor.editing,i=t.view,n=this.editor.model,s=i.document.selection,o=n.document.selection;let r;if(o.rangeCount>1){const i=o.isBackward?o.getFirstRange():o.getLastRange();r=t.mapper.toViewPosition("forward"==e?i.end:i.start)}else r="forward"==e?s.getFirstPosition():s.getLastPosition();const a=this._findNextFocusRange(r,e);return!!a&&(n.change(e=>{e.setSelection(a)}),!0)}_findNextFocusRange(e,t){const i=this.editor.editing,n=i.view,s=this.editor.model,o=n.document.selection,r=o.editableElement,a=r.getPath();let l=o.getSelectedElement();l&&!pp(l)&&(l=null);const c="forward"==t?n.createRange(e,n.createPositionAt(e.root,"end")):n.createRange(n.createPositionAt(e.root,0),e);for(const{nextPosition:e}of c.getWalker({direction:t})){const n=e.parent;if(pp(n)&&n!=l){const e=i.mapper.toModelElement(n);if(!s.schema.isBlock(e))continue;if("extension"!=qe(a,n.getPath()))return s.createRangeOn(e)}else if(n.is("editableElement")){if(n==r&&!l)continue;const o=i.mapper.toModelPosition(e),c=s.schema.getNearestSelectionRange(o,t);if(!c)continue;return n==r&&l?c:"extension"!=qe(a,n.getPath())?s.createRangeIn(s.schema.getLimitElement(c)):c}}return null}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,i=e.editing.view.document.selection.getFirstPosition().parent,n=(i.is("$text")?i.parent:i).findAncestor(pp);if(!n)return!1;const s=t.toModelElement(n);return!!s&&(e.model.change(e=>{e.setSelection(s,"on")}),!0)}}function Fp(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class Np extends Cc{_toolbarDefinitions=new Map;_balloon;static get requires(){return[vg]}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",t=>{(function(e){const t=e.getSelectedElement();return!(!t||!pp(t))})(e.editing.view.document.selection)&&t.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:n,balloonClassName:s="ck-toolbar-container",positions:o}){if(!i.length)return void pe("widget-toolbar-no-items",{toolbarId:e});const r=this.editor,a=r.t,l=new hm(r.locale);if(l.ariaLabel=t||a("Widget toolbar"),this._toolbarDefinitions.has(e))throw new fe("widget-toolbar-duplicated",this,{toolbarId:e});const c={view:l,getRelatedElement:n,balloonClassName:s,itemsConfig:i,positions:o,initialized:!1};r.ui.addToolbar(l,{isContextual:!0,beforeFocus:()=>{const e=n(r.editing.view.document.selection);e&&this._showToolbar(c,e)},afterBlur:()=>{this._hideToolbar(c)}}),this._toolbarDefinitions.set(e,c)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const n of this._toolbarDefinitions.values()){const s=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&s)if(this.editor.ui.focusTracker.isFocused){const o=s.getAncestors().length;o>e&&(e=o,t=s,i=n)}else this._isToolbarVisible(n)&&this._hideToolbar(n);else this._isToolbarInBalloon(n)&&this._hideToolbar(n)}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?Lp(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:Dp(this.editor,t,e.positions),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){const i=t.getRelatedElement(this.editor.editing.view.document.selection);Lp(this.editor,i,e.positions)}}))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function Lp(e,t,i){const n=e.plugins.get("ContextualBalloon"),s=Dp(e,t,i);n.updatePosition(s)}function Dp(e,t,i){const n=e.editing.view,s=Oh.defaultPositions;return{target:n.domConverter.mapViewToDom(t),positions:i||[s.northArrowSouth,s.northArrowSouthWest,s.northArrowSouthEast,s.southArrowNorth,s.southArrowNorthWest,s.southArrowNorthEast,s.viewportStickyNorth]}}class zp extends(Le()){_referenceCoordinates;_options;_originalWidth;_originalHeight;_originalWidthPercents;_aspectRatio;constructor(e){super(),this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(e,t,i){const n=new ht(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains(Hp(i)))return i}(e),this._referenceCoordinates=function(e,t){const i=new ht(e),n=t.split("-"),s={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return s.x+=e.ownerDocument.defaultView.scrollX,s.y+=e.ownerDocument.defaultView.scrollY,s}(t,function(e){const t=e.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[t[0]]}-${i[t[1]]}`}(this.activeHandlePosition)),this._originalWidth=n.width,this._originalHeight=n.height,this._aspectRatio=n.width/n.height;const s=i.style.width;s&&s.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(s):this._originalWidthPercents=function(e,t=new ht(e)){const i=Ap(e);return i?t.width/i*100:0}(i,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function Hp(e){return`ck-widget__resizer__handle-${e}`}class $p extends Uu{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",e=>e?`ck-orientation-${e}`:"")],style:{display:e.if("_isVisible","none",e=>!e)}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",(e,t)=>null!==e&&null!==t),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",(t,i,n)=>"px"===e.unit?`${t}×${i}`:`${n}%`),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",(e,t,i)=>t<50||i<50?"above-center":e)}_dismiss(){this.unbind(),this._isVisible=!1}}class Wp extends(Le()){_state;_sizeView;_options;_viewResizerWrapper=null;_initialViewWidth;constructor(e){super(),this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",(e,t)=>e&&t),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())},{priority:"high"})}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 n=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},function(t){const i=this.toDomElement(t);return e._appendHandles(i),e._appendSizeUI(i),i});i.insert(i.createPositionAt(t,"end"),n),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=n,this.isVisible||this.hide()}),this.on("change:isVisible",()=>{this.isVisible?(this.show(),this.redraw()):this.hide()})}begin(e){this._state=new zp(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change(e=>{const i=this._options.unit||"%",n=("%"===i?t.widthPercents:t.width)+i;e.setStyle("width",n,this._options.viewElement)});const i=this._getHandleHost(),n=new ht(i),s=Math.round(n.width),o=Math.round(n.height),r=new ht(i);t.width=Math.round(r.width),t.height=Math.round(r.height),this.redraw(n),this.state.update({...t,handleHostWidth:s,handleHostHeight:o})}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(!((i=t)&&i.ownerDocument&&i.ownerDocument.contains(i)))return;var i;const n=t.parentElement,s=this._getHandleHost(),o=this._viewResizerWrapper,r=[o.getStyle("width"),o.getStyle("height"),o.getStyle("left"),o.getStyle("top")];let a;if(n.isSameNode(s)){const t=e||new ht(s);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[s.offsetWidth+"px",s.offsetHeight+"px",s.offsetLeft+"px",s.offsetTop+"px"];"same"!==qe(r,a)&&this._options.editor.editing.view.change(e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},o)})}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change(e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){const t=this.state,i={x:(n=e).pageX,y:n.pageY};var n;const s=!this._options.isCentered||this._options.isCentered(this),o={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};s&&t.activeHandlePosition.endsWith("-right")&&(o.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),s&&(o.x*=2);let r=Math.abs(t.originalWidth+o.x),a=Math.abs(t.originalHeight+o.y);return"width"==(r/t.aspectRatio>a?"width":"height")?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 ku({tag:"div",attributes:{class:`ck-widget__resizer__handle ${jp(i)}`}}).render())}_appendSizeUI(e){this._sizeView=new $p,this._sizeView.render(),e.appendChild(this._sizeView.element)}}function jp(e){return`ck-widget__resizer__handle-${e}`}class Up extends Cc{_resizers=new Map;_observer;_redrawSelectedResizerThrottled;static get pluginName(){return"WidgetResize"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.editing,t=G.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(cl),this._observer=new(tt()),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=Ai(()=>this.redrawSelectedResizer(),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",()=>{for(const[e,t]of this._resizers)e.isAttached()||(this._resizers.delete(e),t.destroy())},{priority:"lowest"}),this._observer.listenTo(G.window,"resize",this._redrawSelectedResizerThrottled);const i=this.editor.editing.view.document.selection;i.on("change",()=>{const e=i.getSelectedElement(),t=this.getResizerByViewElement(e)||null;t?this.select(t):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 Wp(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const e=i.get("WidgetToolbarRepository");t.on("begin",()=>{e.forceDisabled("resize")},{priority:"lowest"}),t.on("cancel",()=>{e.clearForceDisabled("resize")},{priority:"highest"}),t.on("commit",()=>{e.clearForceDisabled("resize")},{priority:"highest"})}this._resizers.set(e.viewElement,t);const n=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(n)==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;Wp.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)}}class qp extends qs{domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];constructor(e){super(e);const t=this.document;function i(e){return(i,n)=>{n.preventDefault();const s=n.dropRange?[n.dropRange]:null,o=new de(t,e);t.fire(o,{dataTransfer:n.dataTransfer,method:i.name,targetRanges:s,target:n.target,domEvent:n.domEvent}),o.stop.called&&n.stopPropagation()}}this.listenTo(t,"paste",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",i("dragging"),{priority:"low"})}onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,i="drop"==e.type||"paste"==e.type,n={dataTransfer:new eo(t,{cacheFiles:i})};if("drop"==e.type||"dragover"==e.type){const t=rt(e);n.dropRange=t&&this.view.domConverter.domRangeToView(t)}this.fire(e.type,e,n)}}const Kp=["figcaption","li"],Gp=["ol","ul"];function Jp(e,t){if(t.is("$text")||t.is("$textProxy"))return t.data;if(t.is("element","img")&&t.hasAttribute("alt"))return t.getAttribute("alt");if(t.is("element","br"))return"\n";let i="",n=null;for(const s of t.getChildren())i+=Qp(s,n)+Jp(e,s),n=s;if(t.is("rawElement")){const n=document.implementation.createHTMLDocument("").createElement("div");t.render(n,e),i+=Yp(n)}return i}function Yp(e){let t="";if(e.nodeType===Node.TEXT_NODE)return e.textContent;if("BR"===e.tagName)return"\n";for(const i of e.childNodes)t+=Yp(i);return t}function Qp(e,t){return t?e.is("element","li")&&!e.isEmpty&&e.getChild(0).is("containerElement")||Gp.includes(e.name)&&Gp.includes(t.name)?"\n\n":e.is("containerElement")||t.is("containerElement")?Kp.includes(e.name)||Kp.includes(t.name)?"\n":e.is("element")&&e.getCustomProperty("dataPipeline:transparentRendering")||t.is("element")&&t.getCustomProperty("dataPipeline:transparentRendering")?"":"\n\n":"":""}class Xp extends Cc{_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=e=>e.model.getSelectedContent(e.model.document.selection)){return this.editor.model.change(n=>{const s=n.model.document.selection;n.setSelection(t);const o=this._insertFakeMarkersIntoSelection(n,n.model.document.selection,e),r=i(n),a=this._removeFakeMarkersInsideElement(n,r);for(const[e,t]of Object.entries(o)){a[e]||=n.createRangeIn(r);for(const e of t)n.remove(e)}r.markers.clear();for(const[e,t]of Object.entries(a))r.markers.set(e,t);return n.setSelection(s),r})}_pasteMarkersIntoTransformedElement(e,t){const i=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change(e=>{const n=this._insertFakeMarkersElements(e,i),s=t(e),o=this._removeFakeMarkersInsideElement(e,s);for(const t of Object.values(n).flat())e.remove(t);for(const[t,i]of Object.entries(o))e.model.markers.has(t)||e.addMarker(t,{usingOperation:!0,affectsData:!0,range:i});return s})}_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 n=this._markersToCopy.get(e);this._markersToCopy.set(e,i),t(),n?this._markersToCopy.set(e,n):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const i=this._getMarkerClipboardConfig(e);if(!i)return!1;if(!t)return!0;const{allowedActions:n}=i;return"all"===n||n.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 n=this._getCopyableMarkersFromSelection(e,t,i);return this._insertFakeMarkersElements(e,n)}_getCopyableMarkersFromSelection(e,t,i){const n=Array.from(t.getRanges()),s=new Set(n.flatMap(t=>Array.from(e.model.markers.getMarkersIntersectingRange(t))));return Array.from(s).filter(e=>{if(!this._isMarkerCopyable(e.name,i))return!1;const{copyPartiallySelected:t}=this._getMarkerClipboardConfig(e.name);if(!t){const t=e.getRange();return n.some(e=>e.containsRange(t,!0))}return!0}).map(e=>({name:"dragstart"===i?this._getUniqueMarkerName(e.name):e.name,range:e.getRange()}))}_getPasteMarkersFromRangeMap(e,t=null){const{model:i}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap(([e,n])=>{if(!this._hasMarkerConfiguration(e))return[{name:e,range:n}];if(this._isMarkerCopyable(e,t)){const t=this._getMarkerClipboardConfig(e),s=i.markers.has(e)&&"$graveyard"===i.markers.get(e).getRange().root.rootName;return(t.duplicateOnPaste||s)&&(e=this._getUniqueMarkerName(e)),[{name:e,range:n}]}return[]})}_insertFakeMarkersElements(e,t){const i={},n=t.flatMap(e=>{const{start:t,end:i}=e.range;return[{position:t,marker:e,type:"start"},{position:i,marker:e,type:"end"}]}).sort(({position:e},{position:t})=>e.isBefore(t)?1:-1);for(const{position:t,marker:s,type:o}of n){const n=e.createElement("$marker",{"data-name":s.name,"data-type":o});i[s.name]||(i[s.name]=[]),i[s.name].push(n),e.insert(n,t)}return i}_removeFakeMarkersInsideElement(e,t){return dp(this._getAllFakeMarkersFromElement(e,t).reduce((t,i)=>{const n=i.markerElement&&e.createPositionBefore(i.markerElement);let s=t[i.name],o=!1;if(s?.start&&s?.end){this._getMarkerClipboardConfig(i.name).duplicateOnPaste?t[this._getUniqueMarkerName(i.name)]=t[i.name]:o=!0,s=null}return o||(t[i.name]={...s,[i.type]:n}),i.markerElement&&e.remove(i.markerElement),t},{}),i=>new bo(i.start||e.createPositionFromPath(t,[0]),i.end||e.createPositionAt(t,"end")))}_getAllFakeMarkersFromElement(e,t){const i=Array.from(e.createRangeIn(t)).flatMap(({item:e})=>{if(!e.is("element","$marker"))return[];const t=e.getAttribute("data-name"),i=e.getAttribute("data-type");return[{markerElement:e,name:t,type:i}]}),n=[],s=[];for(const e of i){if("end"===e.type){i.some(t=>t.name===e.name&&"start"===t.type)||n.push({markerElement:null,name:e.name,type:"start"})}if("start"===e.type){i.some(t=>t.name===e.name&&"end"===t.type)||s.unshift({markerElement:null,name:e.name,type:"end"})}}return[...n,...i,...s]}_getUniqueMarkerName(e){const t=e.split(":"),i=he().substring(1,6);return 3===t.length?`${t.slice(0,2).join(":")}:${i}`:`${t.join(":")}:${i}`}}class Zp extends Cc{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[Xp]}init(){this.editor.editing.view.addObserver(qp),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const n=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:"cut"===i},()=>{const s=n._copySelectedFragmentWithMarkers(i,t);this.fire("outputTransformation",{dataTransfer:e,content:s,method:i})})}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,s=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(n,"clipboardInput",(t,i)=>{"paste"!=i.method||e.model.canEditAt(e.model.document.selection)||t.stop()},{priority:"highest"}),this.listenTo(n,"clipboardInput",(e,t)=>{const n=t.dataTransfer;let s;if(t.content)s=t.content;else{let e="";n.getData("text/html")?e=function(e){return e.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>1==t.length?" ":t).replace(/<!--[\s\S]*?-->/g,"")}(n.getData("text/html")):n.getData("text/plain")&&(((o=(o=n.getData("text/plain")).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br>").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("</p><p>")||o.includes("<br>"))&&(o=`<p>${o}</p>`),e=o),s=this.editor.data.htmlProcessor.toView(e)}var o;const r=new de(this,"inputTransformation"),a=n.getData("application/ckeditor5-editor-id")||null;this.fire(r,{content:s,dataTransfer:n,sourceEditorId:a,targetRanges:t.targetRanges,method:t.method}),r.stop.called&&e.stop(),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change(()=>{this.fire("contentInsertion",{content:n,method:i.method,sourceEditorId:i.sourceEditorId,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(e,t)=>{t.resultRange=s._pasteFragmentWithMarkers(t.content)},{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(e,i)=>{const n=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(n,t.selection,e.name)};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",(t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()},{priority:"low"}),this.listenTo(this,"outputTransformation",(t,n)=>{const s=e.data.toView(n.content,{isClipboardPipeline:!0});i.fire("clipboardOutput",{dataTransfer:n.dataTransfer,content:s,method:n.method})},{priority:"low"}),this.listenTo(i,"clipboardOutput",(i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",Jp(e.data.htmlProcessor.domConverter,n.content)),n.dataTransfer.setData("application/ckeditor5-editor-id",this.editor.id)),"cut"==n.method&&e.model.deleteContent(t.selection)},{priority:"low"})}}const eb=yt("px");class tb extends Uu{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",e=>!e)],style:{left:e.to("left",e=>eb(e)),top:e.to("top",e=>eb(e)),width:e.to("width",e=>eb(e))}}})}}class ib extends Cc{removeDropMarkerDelayed=hi(()=>this.removeDropMarker(),40);_updateDropMarkerThrottled=Ai(e=>this._updateDropMarker(e),40);_reconvertMarkerThrottled=Ai(()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")},0);_dropTargetLineView=new tb;_domEmitter=new(tt());_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,n,s,o){this.removeDropMarkerDelayed.cancel();const r=nb(this.editor,e,t,i,n,s,o);return r?o&&o.containsRange(r)||r&&!this.editor.model.canEditAt(r)?(this.removeDropMarker(),null):(this._updateDropMarkerThrottled(r),r):null}getFinalDropRange(e,t,i,n,s,o){const r=nb(this.editor,e,t,i,n,s,o);return this.removeDropMarker(),r}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change(e=>{e.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(t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})})}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},function(e){const t=this.toDomElement(e);return t.append("",e.createElement("span"),""),t})}_updateDropTargetLine(e){const t=this.editor.editing,i=e.start.nodeBefore,n=e.start.nodeAfter,s=e.start.parent,o=i?t.mapper.toViewElement(i):null,r=o?t.view.domConverter.mapViewToDom(o):null,a=n?t.mapper.toViewElement(n):null,l=a?t.view.domConverter.mapViewToDom(a):null,c=t.mapper.toViewElement(s);if(!c)return;const d=t.view.domConverter.mapViewToDom(c),u=this._getScrollableRect(c),{scrollX:h,scrollY:m}=G.window,g=r?new ht(r):null,f=l?new ht(l):null,p=new ht(d).excludeScrollbarsAndBorders(),b=g?g.bottom:p.top,w=f?f.top:p.bottom,_=G.window.getComputedStyle(d),v=b<=w?(b+w)/2:w;if(u.top<v&&v<u.bottom){const e=p.left+parseFloat(_.paddingLeft),t=p.right-parseFloat(_.paddingRight),i=Math.max(e+h,u.left),n=Math.min(t+h,u.right);this._dropTargetLineView.set({isVisible:!0,left:i,top:v+m,width:n-i})}else this._dropTargetLineView.isVisible=!1}_getScrollableRect(e){const t=e.root.rootName;let i;if(this._scrollables.has(t))i=this._scrollables.get(t).domElement;else{i=function(e){let t=e;do{t=t.parentElement;const e=G.window.getComputedStyle(t).overflowY;if("auto"==e||"scroll"==e)break}while("BODY"!=t.tagName);return t}(this.editor.editing.view.domConverter.mapViewToDom(e)),this._domEmitter.listenTo(i,"scroll",this._reconvertMarkerThrottled,{usePassive:!0});const n=new _t(i,this._reconvertMarkerThrottled);this._scrollables.set(t,{domElement:i,resizeObserver:n})}return new ht(i).excludeScrollbarsAndBorders()}}function nb(e,t,i,n,s,o,r){const a=e.model,l=e.editing.mapper;let c=ab(e,t);for(;c;){if(!o)if(a.schema.checkChild(c,"$text")){if(i){const t=i[0].start,o=l.toModelPosition(t);if(!r||Array.from(r.getItems({shallow:!0})).some(e=>a.schema.checkChild(o,e))){if(a.schema.checkChild(o,"$text"))return a.createRange(o);if(t)return ob(e,ab(e,t.parent),n,s)}}}else if(a.schema.isInline(c))return ob(e,c,n,s);if(a.schema.isBlock(c))return ob(e,c,n,s);if(a.schema.checkChild(c,"$block")){const t=Array.from(c.getChildren()).filter(t=>t.is("element")&&!sb(e,t));let i=0,o=t.length;if(0==o)return a.createRange(a.createPositionAt(c,"end"));for(;i<o-1;){const r=Math.floor((i+o)/2);"before"==rb(e,t[r],n,s)?o=r:i=r}return ob(e,t[i],n,s)}c=c.parent}return null}function sb(e,t){const i=e.editing.mapper,n=e.editing.view.domConverter,s=i.toViewElement(t);if(!s)return!0;const o=n.mapViewToDom(s);return"none"!=G.window.getComputedStyle(o).float}function ob(e,t,i,n){const s=e.model;return s.createRange(s.createPositionAt(t,rb(e,t,i,n)))}function rb(e,t,i,n){const s=e.editing.mapper,o=e.editing.view.domConverter,r=s.toViewElement(t),a=o.mapViewToDom(r),l=new ht(a);return e.model.schema.isInline(t)?i<(l.left+l.right)/2?"before":"after":n<(l.top+l.bottom)/2?"before":"after"}function ab(e,t){const i=e.editing.mapper,n=e.editing.view,s=i.toModelElement(t);if(s)return s;const o=n.createPositionBefore(t),r=i.findMappedViewAncestor(o);return i.toModelElement(r)}class lb extends Cc{_isBlockDragging=!1;_domEmitter=new(tt());static get pluginName(){return"DragDropBlockToolbar"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(this.listenTo(e,"change:isReadOnly",(e,t,i)=>{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")}),Q.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const t=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(t,"dragstart",(e,t)=>this._handleBlockDragStart(t)),this._domEmitter.listenTo(G.document,"dragover",(e,t)=>this._handleBlockDragging(t)),this._domEmitter.listenTo(G.document,"drop",(e,t)=>this._handleBlockDragging(t)),this._domEmitter.listenTo(G.document,"dragend",()=>this._handleBlockDragEnd(),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",(e,i,n)=>{t.setAttribute("draggable",n?"true":"false")})}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,n=this.editor.editing.view,s=Array.from(i.getSelectedBlocks()),o=t.createRange(t.createPositionBefore(s[0]),t.createPositionAfter(s[s.length-1]));t.change(e=>e.setSelection(o)),this._isBlockDragging=!0,n.focus(),n.getObserver(qp).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,n=document.elementFromPoint(t,i),s=this.editor.editing.view;n&&n.closest(".ck-editor__editable")&&s.getObserver(qp).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:n,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class cb extends Cc{_draggedRange;_draggingUid;_draggableElement;_clearDraggableAttributesDelayed=hi(()=>this._clearDraggableAttributes(),40);_blockMode=!1;_domEmitter=new(tt());_previewContainer;static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[Zp,Mp,ib,lb]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(qp),t.addObserver(ul),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",(e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(e,t,i)=>{i||this._finalizeDragging(!1)}),Q.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,n=i.document,s=e.plugins.get(ib);this.listenTo(n,"dragstart",(i,n)=>{if(n.target?.is("editableElement"))return void n.preventDefault();if(this._prepareDraggedRange(n.target),!this._draggedRange)return void n.preventDefault();this._draggingUid=he();const s=this.isEnabled&&e.model.canEditAt(this._draggedRange);n.dataTransfer.effectAllowed=s?"copyMove":"copy",n.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const o=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(n.dataTransfer,o,"dragstart");const{dataTransfer:r,domTarget:a,domEvent:l}=n,{clientX:c}=l;this._updatePreview({dataTransfer:r,domTarget:a,clientX:c}),n.stopPropagation(),s||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(n,"dragend",(e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)},{priority:"low"}),this._domEmitter.listenTo(G.document,"dragend",()=>{this._blockMode=!1},{useCapture:!0}),this.listenTo(n,"dragenter",()=>{this.isEnabled&&i.focus()}),this.listenTo(n,"dragleave",()=>{s.removeDropMarkerDelayed()}),this.listenTo(n,"dragging",(e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:i,clientY:n}=t.domEvent;s.updateDropMarker(t.target,t.targetRanges,i,n,this._blockMode,this._draggedRange)?(this._draggedRange||(t.dataTransfer.dropEffect="copy"),Q.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()):t.dataTransfer.dropEffect="none"},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(ib);this.listenTo(t,"clipboardInput",(t,n)=>{if("drop"!=n.method)return;const{clientX:s,clientY:o}=n.domEvent,r=i.getFinalDropRange(n.target,n.targetRanges,s,o,this._blockMode,this._draggedRange);if(!r)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==db(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(r,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(r)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Zp);e.on("contentInsertion",(e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map(e=>this.editor.editing.mapper.toModelRange(e));this.editor.model.change(e=>e.setSelection(i))},{priority:"high"}),e.on("contentInsertion",(e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==db(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"pointerdown",(n,s)=>{if(Q.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let o=ub(s.target);if(Q.isBlink&&!e.isReadOnly&&!o&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&pp(e)||(o=i.selection.editableElement)}o&&(t.change(e=>{e.setAttribute("draggable","true",o)}),this._draggableElement=e.editing.mapper.toModelElement(o))}),this.listenTo(i,"pointerup",()=>{Q.isAndroid||this._clearDraggableAttributesDelayed()})}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change(t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null})}_finalizeDragging(e){const t=this.editor,i=t.model;if(t.plugins.get(ib).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(e=>{const t=i.createSelection(this._draggedRange);i.deleteContent(t,{doNotAutoparagraph:!0});const n=t.getFirstPosition().parent;n.isEmpty&&!i.schema.checkChild(n,"$text")&&i.schema.checkChild(n,"paragraph")&&e.insertElement("paragraph",n,0)}),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,n=i.document.selection,s=e?ub(e):null;if(s){const e=t.editing.mapper.toModelElement(s);if(this._draggedRange=Vo.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(n.isCollapsed&&!n.getFirstPosition().parent.isEmpty)return;const o=Array.from(n.getSelectedBlocks()),r=n.getFirstRange();if(0==o.length)return void(this._draggedRange=Vo.fromRange(r));const a=hb(i,o);if(o.length>1)this._draggedRange=Vo.fromRange(a),this._blockMode=!0;else if(1==o.length){const e=r.start.isTouching(a.start)&&r.end.isTouching(a.end);this._draggedRange=Vo.fromRange(e?a:r),this._blockMode=e}i.change(e=>e.setSelection(this._draggedRange.toRange()))}_updatePreview({dataTransfer:e,domTarget:t,clientX:i}){const n=this.editor.editing.view,s=n.document.selection.editableElement,o=n.domConverter.mapViewToDom(s),r=G.window.getComputedStyle(o);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=Ge(G.document,"div",{style:"position: fixed; left: -999999px;"}),G.document.body.appendChild(this._previewContainer));const a=Ge(G.document,"div");a.className="ck ck-content ck-clipboard-preview";const l=new ht(o),c=parseFloat(r.paddingLeft),d=parseFloat(r.paddingRight),u=parseFloat(r.width)-c-d;if(o.contains(t)){if(!Q.isiOS)return;a.style.maxWidth=`${u}px`,a.style.padding="10px",a.style.minWidth="200px",a.style.minHeight="20px",a.style.boxSizing="border-box",a.style.backgroundColor="var(--ck-color-base-background)"}else if(Q.isiOS)a.style.width=`${u}px`,a.style.backgroundColor="var(--ck-color-base-background)";else{const e=l.left-i+c;a.style.width=`${u+e}px`,a.style.paddingLeft=`${e}px`}n.domConverter.setContentOf(a,e.getData("text/html")),e.setDragImage(a,0,0),this._previewContainer.appendChild(a)}}function db(e){return Q.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function ub(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(pp);if(pp(e))return e;const t=e.findAncestor(e=>pp(e)||e.is("editableElement"));return pp(t)?t:null}function hb(e,t){const i=t[0],n=t[t.length-1],s=i.getCommonAncestor(n),o=e.createPositionBefore(i),r=e.createPositionAfter(n);if(s&&s.is("element")&&!e.schema.isLimit(s)){const t=e.createRangeOn(s),i=o.isTouching(t.start),n=r.isTouching(t.end);if(i&&n)return hb(e,[s])}return e.createRange(o,r)}class mb extends Cc{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[Zp]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=t.document.selection;i.addObserver(qp),e.plugins.get(Zp).on("contentInsertion",(e,i)=>{(function(e,t){let i=t.createRangeIn(e);if(1==e.childCount){const n=e.getChild(0);n.is("element")&&t.schema.isBlock(n)&&!t.schema.isObject(n)&&!t.schema.isLimit(n)&&(i=t.createRangeIn(n))}for(const e of i.getItems()){if(!t.schema.isInline(e))return!1;if(Array.from(e.getAttributeKeys()).find(e=>t.schema.getAttributeProperties(e).isFormatting))return!1}return!0})(i.content,t)&&t.change(e=>{const s=Array.from(n.getAttributes()).filter(([e])=>t.schema.getAttributeProperties(e).isFormatting);n.isCollapsed||t.deleteContent(n,{doNotAutoparagraph:!0}),s.push(...n.getAttributes());const o=e.createRangeIn(i.content);for(const i of o.getItems())for(const n of s)t.schema.checkAttribute(i,n[0])&&e.setAttribute(n[0],n[1],i)})})}}class gb extends Cc{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Xp,Zp,cb,mb]}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"}]})}}function fb(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const e of i)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return i}function pb(e,t,i){const n={};for(const s of e)if("class"===t){n[s[t].split(" ").shift()]=s[i]}else n[s[t]]=s[i];return n}function bb(e){return e.data.match(/^(\s*)/)[0]}function wb(e){const t=e.document.selection,i=[];if(t.isCollapsed)return[t.anchor];const n=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of n){let n=t.is("$textProxy")?t.textNode:t;const s=n.parent;if(!s.is("element","codeBlock")||n.is("element","softBreak"))continue;for(;n.previousSibling&&!n.previousSibling.is("element","softBreak");)n=n.previousSibling;const o=n.is("$text")?n.startOffset+bb(n).length:n.startOffset,r=e.createPositionAt(s,o);i.every(e=>!e.isEqual(r))&&i.push(r)}return i}function _b(e){const t=si(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function vb(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}function yb(e,t,i,n){const s=pb(t,"language","label"),o=i.getAttribute("language");if(o in s){const t=s[o];return e("enter"===n?"Entering %0 code snippet":"Leaving %0 code snippet",t)}return e("enter"===n?"Entering code snippet":"Leaving code snippet")}function kb(e,t){for(e.textNode&&(e=t.createPositionBefore(e.textNode));e.nodeBefore&&!e.nodeBefore.is("element","softBreak");)e=t.createPositionBefore(e.nodeBefore);const i=e.nodeAfter;return i&&i.is("$text")?i:null}class Cb extends Tc{_lastLanguage;constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,s=fb(t)[0],o=Array.from(n.getSelectedBlocks()),r=null==e.forceValue?!this.value:e.forceValue,a=function(e,t,i){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return i}(e,this._lastLanguage,s.language);i.change(e=>{r?this._applyCodeBlock(e,o,a):this._removeCodeBlock(e,o)})}_getValue(){const e=si(this.editor.model.document.selection.getSelectedBlocks());return!!!!e?.is("element","codeBlock")&&e.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=si(e.getSelectedBlocks());return!!i&&vb(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,s=t.filter(e=>vb(n,e));for(const t of s)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),n.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter(e=>!n.checkChild(t,e)).forEach(t=>e.remove(t));s.reverse().forEach((t,i)=>{const n=s[i+1];t.previousSibling===n&&(e.appendElement("softBreak",n),e.merge(e.createPositionBefore(t)))})}_removeCodeBlock(e,t){const i=t.filter(e=>e.is("element","codeBlock"));for(const t of i){const i=e.createRangeOn(t);for(const t of Array.from(i.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:i}=e.split(e.createPositionBefore(t)),n=i.nodeAfter;e.rename(n,"paragraph"),e.removeAttribute("language",n),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class Ab extends Tc{_indentSequence;constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(t=>{const i=wb(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}})}_checkEnabled(){return!!this._indentSequence&&_b(this.editor.model.document.selection)}}class Tb extends Tc{_indentSequence;constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(()=>{const t=wb(e);for(const i of t){const t=Eb(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}})}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!_b(e.document.selection)&&wb(e).some(t=>Eb(e,t,this._indentSequence))}}function Eb(e,t,i){const n=kb(t,e);if(!n)return null;const s=bb(n),o=s.lastIndexOf(i);if(o+i.length!==s.length)return null;if(-1===o)return null;const{parent:r,startOffset:a}=n;return e.createRange(e.createPositionAt(r,a+o),e.createPositionAt(r,a+o+i.length))}function xb(e,t,i=!1){const n=pb(t,"language","class"),s=pb(t,"language","label");return(t,o,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(o.item,"insert"))return;const d=o.item.getAttribute("language"),u=l.toViewPosition(e.createPositionBefore(o.item)),h={};i&&(h["data-language"]=s[d],h.spellcheck="false");const m=n[d]?{class:n[d]}:void 0,g=a.createContainerElement("code",m),f=a.createContainerElement("pre",h,g);a.insert(u,f),l.bindElements(o.item,g)}}const Pb="paragraph";class Sb extends Cc{static get pluginName(){return"CodeBlockEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Jf]}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:"\t"})}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,s=fb(e);e.commands.add("codeBlock",new Cb(e)),e.commands.add("indentCodeBlock",new Ab(e)),e.commands.add("outdentCodeBlock",new Tb(e)),this.listenTo(n.document,"tab",(t,i)=>{const n=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",disallowChildren:"$inlineObject",allowAttributes:["language"],allowAttributesOf:"$listItem",isBlock:!0}),t.addAttributeCheck((e,i)=>{const n=e.getItem(e.length-2);if(t.getAttributeProperties(i).isFormatting&&n&&"codeBlock"==n.name)return!1}),e.editing.downcastDispatcher.on("insert:codeBlock",xb(i,s,!0)),e.data.downcastDispatcher.on("insert:codeBlock",xb(i,s)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:s,mapper:o,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const a=o.toViewPosition(e.createPositionBefore(i.item));s.insert(a,s.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=pb(t,"class","language"),n=t[0].language;return(e,t,s)=>{const o=t.viewItem,r=o.parent;if(!r||!r.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=s;if(!a.test(o,{name:!0}))return;const c=l.createElement("codeBlock"),d=[...o.getClassNames()];d.length||d.push("");for(const e of d){const t=i[e];if(t){a.consume(o,{classes:[e]}),l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",n,c),s.convertChildren(o,c),s.safeInsert(c,t.modelCursor)&&(a.consume(o,{name:!0}),s.updateConversionResult(c,t))}}(0,s)),e.data.upcastDispatcher.on("text",(e,t,{consumable:i,writer:n})=>{let s=t.modelCursor;if(!i.test(t.viewItem))return;if(!s.findAncestor("codeBlock"))return;i.consume(t.viewItem);const o=t.viewItem.data.split("\n").map(e=>n.createText(e)),r=o[o.length-1];for(const e of o)if(n.insert(e,s),s=s.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,s),s=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,s),t.modelCursor=s}),e.data.upcastDispatcher.on("element:pre",(e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const s=Array.from(n.getChildren()),o=s.find(e=>e.is("element","code"));if(o)for(const e of s)e!==o&&e.is("$text")&&i.consume(e,{name:!0})},{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",(t,n)=>{let s=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(s=e.editing.mapper.toModelRange(n.targetRanges[0])),!s.start.parent.is("element","codeBlock"))return;const o=n.dataTransfer.getData("text/plain"),r=new hl(e.editing.view.document);n.content=function(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),s=n.reduce((t,i,s)=>(t.push(i),s<n.length-1&&t.push(e.createElement("br")),t),[]);return e.appendChild(s,i),i}(r,o)}),e.plugins.has("ClipboardPipeline")&&e.plugins.get(Zp).on("contentInsertion",(i,n)=>{const s=e.model,o=s.document.selection;o.anchor.parent.is("element","codeBlock")&&s.change(e=>{const i=e.createRangeIn(n.content);for(const n of[...i.getItems()])n.is("node")&&!t.checkChild(o.anchor,n)&&e.remove(n)})}),this.listenTo(i,"getSelectedContent",(e,[n])=>{const s=n.anchor;!n.isCollapsed&&s.parent.is("element","codeBlock")&&s.hasSameParentAs(n.focus)&&i.change(i=>{const o=e.return;if(s.parent.is("element")&&(o.childCount>1||n.containsEntireContent(s.parent))){const t=i.createElement("codeBlock",s.parent.getAttributes());i.append(o,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const r=o.getChild(0);t.checkAttribute(r,"code")&&i.setAttribute("code",!0,r)})})}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),n&&n.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",(t,i)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const i=e.model,n=i.document,s=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeAfter;if(t||!n.selection.isCollapsed||!o.isAtStart)return!1;if(!Ob(r))return!1;return e.model.change(t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,Pb),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(r)}),s.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,s=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeBefore;let a;if(t||!n.selection.isCollapsed||!o.isAtEnd||!r||!r.previousSibling)return!1;if(Ob(r)&&Ob(r.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r));else if(Ib(r)&&Ob(r.previousSibling)&&Ob(r.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling),i.createPositionAfter(r));else{if(!(Ib(r)&&Ob(r.previousSibling)&&Ib(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&Ob(r.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling.previousSibling),i.createPositionAfter(r))}return e.model.change(t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,Pb),e.model.schema.removeDisallowedAttributes([i],t)}),s.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document;let n;const s=kb(i.selection.getLastPosition(),t);s&&s.is("$text")&&(n=bb(s));e.model.change(t=>{e.execute("shiftEnter"),n&&t.insertText(n,i.selection.anchor)})}(e),i.preventDefault(),t.stop())},{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor,n=fb(this.editor);let s=null;e.document.selection.on("change:range",()=>{const o=e.document.selection.focus.parent;t&&s!==o&&o.is("element")&&(s&&s.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(yb(i,n,s,"leave")),o.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(yb(i,n,o,"enter")),s=o)})}}function Ib(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function Ob(e){return e&&e.is("element","softBreak")}class Rb extends Cc{static get pluginName(){return"CodeBlockUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=fb(e),s=this._getLanguageListItemDefinitions(n),o=e.commands.get("codeBlock");i.add("codeBlock",i=>{const n=bm(i,pm),r=n.buttonView,a=t("Insert code block");return r.set({label:a,tooltip:!0,icon:sd,isToggleable:!0}),r.bind("isOn").to(o,"value",e=>!!e),r.on("execute",()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()}),n.on("execute",t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),n.class="ck-code-block-dropdown",n.bind("isEnabled").to(o),vm(n,s,{role:"menu",ariaLabel:a}),n}),i.add("menuBar:codeBlock",i=>{const n=new xg(i);n.buttonView.set({role:"menuitem",label:t("Code block"),icon:sd}),n.bind("isEnabled").to(o);const r=new Pg(i);r.set({ariaLabel:t("Insert code block")});for(const t of s){const s=new Km(i,n),a=new Eh(i);a.bind(...Object.keys(t.model)).to(t.model),a.set({isToggleable:!0,role:"menuitemcheckbox"}),a.delegate("execute").to(n),a.on("execute",()=>{e.execute("codeBlock",{language:t.model._codeBlockLanguage,forceValue:o.value!=t.model._codeBlockLanguage}),e.editing.view.focus()}),s.children.add(a),r.items.add(s)}return n.panelView.children.add(r),n})}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new ni;for(const n of e){const e={type:"button",model:new wg({_codeBlockLanguage:n.language,label:n.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",t=>t===e.model._codeBlockLanguage),i.add(e)}return i}}class Vb extends Tc{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)||!Bb(e.schema,i))do{if(i=i.parent,!i)return}while(!Bb(e.schema,i));e.change(e=>{e.setSelection(i,"in")})}}function Bb(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const Mb=Gt("Ctrl+A");class Fb extends Cc{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 Vb(e)),this.listenTo(i,"keydown",(t,i)=>{Kt(i)===Mb&&(e.execute("selectAll"),i.preventDefault())}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class Nb extends Cc{static get pluginName(){return"SelectAllUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",()=>{const e=this._createButton(rh);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:selectAll",()=>this._createButton(Eh))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("selectAll"),s=new e(t.locale),o=i.t;return s.set({label:o("Select all"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M.75 15.5a.75.75 0 0 1 .75.75V18l.008.09A.5.5 0 0 0 2 18.5h1.75a.75.75 0 1 1 0 1.5H1.5l-.144-.007a1.5 1.5 0 0 1-1.35-1.349L0 18.5v-2.25a.75.75 0 0 1 .75-.75m18.5 0a.75.75 0 0 1 .75.75v2.25l-.007.144a1.5 1.5 0 0 1-1.349 1.35L18.5 20h-2.25a.75.75 0 1 1 0-1.5H18a.5.5 0 0 0 .492-.41L18.5 18v-1.75a.75.75 0 0 1 .75-.75m-10.45 3c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2zm.45-5.5a.75.75 0 1 1 0 1.5h-8.5a.75.75 0 1 1 0-1.5zM1.3 11c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2zm-4.55-2a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5zM1.3 7c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2zm-4.55-2a.75.75 0 1 1 0 1.5h-2.5a.75.75 0 1 1 0-1.5zm-5 0a.75.75 0 1 1 0 1.5h-5.5a.75.75 0 0 1 0-1.5zm-6.5-5a.75.75 0 0 1 0 1.5H2a.5.5 0 0 0-.492.41L1.5 2v1.75a.75.75 0 0 1-1.5 0V1.5l.007-.144A1.5 1.5 0 0 1 1.356.006L1.5 0zM18.5 0l.144.007a1.5 1.5 0 0 1 1.35 1.349L20 1.5v2.25a.75.75 0 1 1-1.5 0V2l-.008-.09A.5.5 0 0 0 18 1.5h-1.75a.75.75 0 1 1 0-1.5zM8.8 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2z"/></svg>',keystroke:"Ctrl+A"}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("selectAll"),t.editing.view.focus()}),s}}class Lb extends Cc{static get requires(){return[Fb,Nb]}static get pluginName(){return"SelectAll"}static get isOfficialPlugin(){return!0}}class Db extends Tc{_stack=[];_createdBatches=new WeakSet;constructor(e){super(e),this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",(e,t)=>{t[1]={...t[1]};const i=t[1];i.batchType||(i.batchType={isUndoable:!1})},{priority:"high"}),this.listenTo(e.data,"set",(e,t)=>{t[1].batchType.isUndoable||this.clearStack()})}refresh(){this.isEnabled=this._stack.length>0}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 n=this.editor.model,s=n.document,o=[],r=e.map(e=>e.getTransformedByOperations(i)),a=r.flat();for(const e of r){const t=e.filter(e=>e.root!=s.graveyard).filter(e=>!Hb(e,a));t.length&&(zb(t),o.push(t[0]))}o.length&&n.change(e=>{e.setSelection(o,{backward:t})})}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const s=e.operations.slice().filter(e=>e.isDocumentOperation);s.reverse();for(const e of s){const s=e.baseVersion+1,o=Array.from(n.history.getOperations(s)),r=ua([e.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let s of r){const o=s.affectedSelectable;o&&!i.canEditAt(o)&&(s=new ta(s.baseVersion)),t.addOperation(s),i.applyOperation(s),n.history.setOperationAsUndone(e,s)}}}}function zb(e){e.sort((e,t)=>e.start.isBefore(t.start)?-1:1);for(let t=1;t<e.length;t++){const i=e[t-1].getJoined(e[t],!0);i&&(t--,e.splice(t,2,i))}}function Hb(e,t){return t.some(t=>t!==e&&t.containsRange(e,!0))}class $b extends Db{execute(e=null){const t=e?this._stack.findIndex(t=>t.batch==e):this._stack.length-1,i=this._stack.splice(t,1)[0],n=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(n,()=>{this._undo(i.batch,n);const e=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,e)}),this.fire("revert",i.batch,n),this.refresh()}}class Wb extends Db{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,n=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,n),this._undo(e.batch,t)}),this.fire("revert",e.batch,t),this.refresh()}}class jb extends Cc{_undoCommand;_redoCommand;_batchRegistry=new WeakSet;static get pluginName(){return"UndoEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;this._undoCommand=new $b(e),this._redoCommand=new Wb(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",(e,t)=>{const i=t[0];if(!i.isDocumentOperation)return;const n=i.batch,s=this._redoCommand.createdBatches.has(n),o=this._undoCommand.createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(s?this._undoCommand.addBatch(n):o||(this._undoCommand.addBatch(n),this._redoCommand.clearStack())))},{priority:"highest"}),this.listenTo(this._undoCommand,"revert",(e,t,i)=>{this._redoCommand.addBatch(i)}),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 Ub extends Cc{static get pluginName(){return"UndoUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Cd:vd,s="ltr"==t.uiLanguageDirection?vd:Cd;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",n),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",s)}_addButtonsToFactory(e,t,i,n){const s=this.editor;s.ui.componentFactory.add(e,()=>{const s=this._createButton(rh,e,t,i,n);return s.set({tooltip:!0}),s}),s.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(Eh,e,t,i,n))}_createButton(e,t,i,n,s){const o=this.editor,r=o.locale,a=o.commands.get(t),l=new e(r);return l.set({label:i,icon:s,keystroke:n}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",()=>{o.execute(t),o.editing.view.focus()}),l}}class qb extends Cc{static get requires(){return[jb,Ub]}static get pluginName(){return"Undo"}static get isOfficialPlugin(){return!0}}class Kb extends Tc{attributeKey;constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value,s=e.batch,o=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const s=t.schema.getValidRanges(i.getRanges(),this.attributeKey,{includeEmptyRanges:!0});for(const t of s){let i=t,s=this.attributeKey;t.isCollapsed&&(i=t.start.parent,s=Lo._getStoreAttributeKey(this.attributeKey)),n?e.setAttribute(s,n,i):e.removeAttribute(s,i)}}};s?t.enqueueChange(s,e=>{o(e)}):t.change(e=>{o(e)})}}const Gb="fontSize",Jb="fontFamily",Yb="fontColor",Qb="fontBackgroundColor";function Xb(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function Zb(e){return t=>t.getStyle(e).replace(/\s/g,"")}function ew(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class tw extends Kb{constructor(e){super(e,Jb)}}function iw(e){return e.map(sw).filter(e=>void 0!==e)}function nw(e){return e.replace(/["']/g,"").split(",").map(e=>e.trim())}function sw(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=nw(e),i=t[0],n=t.map(ow).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function ow(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class rw extends Cc{static get pluginName(){return"FontFamilyEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(Jb,{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:Jb}),e.model.schema.setAttributeProperties(Jb,{isFormatting:!0,copyOnEnter:!0});const t=iw(e.config.get("fontFamily.options")).filter(e=>e.model),i=Xb(Jb,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(Jb,new tw(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:Jb,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:Jb,value:e=>e.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:Jb,value:e=>e.getAttribute("face")}})}}class aw extends Cc{static get pluginName(){return"FontFamilyUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(Jb),s=t("Font Family"),o=function(e,t){const i=new ni;for(const n of e){const e={type:"button",model:new wg({commandName:Jb,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",e=>{if(e===n.model)return!0;if(!e||!n.model)return!1;return nw(e)[0].toLowerCase()===nw(n.model)[0].toLowerCase()}),n.view&&"string"!=typeof n.view&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n);e.ui.componentFactory.add(Jb,t=>{const i=bm(t);return vm(i,o,{role:"menu",ariaLabel:s}),i.buttonView.set({label:s,icon:ld,tooltip:!0}),i.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()}),i}),e.ui.componentFactory.add(`menuBar:${Jb}`,t=>{const i=new xg(t);i.buttonView.set({label:s,icon:ld}),i.bind("isEnabled").to(n);const r=new Pg(t);for(const n of o){const s=new Km(t,i),o=new Eh(t);o.set({role:"menuitemradio",isToggleable:!0}),o.bind(...Object.keys(n.model)).to(n.model),o.delegate("execute").to(i),o.on("execute",()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()}),s.children.add(o),r.items.add(s)}return i.panelView.children.add(r),i})}_getLocalizedOptions(){const e=this.editor,t=e.t;return iw(e.config.get(Jb).options).map(e=>("Default"===e.title&&(e.title=t("Default")),e))}}class lw extends Cc{static get requires(){return[rw,aw]}static get pluginName(){return"FontFamily"}static get isOfficialPlugin(){return!0}}class cw extends Kb{constructor(e){super(e,Gb)}}function dw(e){return e.map(e=>function(e){"number"==typeof e&&(e=String(e));if("object"==typeof e&&(t=e,t.title&&t.model&&t.view))return hw(e);var t;const i=function(e){return"string"==typeof e?uw[e]:uw[e.model]}(e);if(i)return hw(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new fe("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},hw(e)}(e)}(e)).filter(e=>void 0!==e)}const uw={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 hw(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const mw=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class gw extends Cc{static get pluginName(){return"FontSizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(Gb,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Gb}),e.model.schema.setAttributeProperties(Gb,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=dw(this.editor.config.get("fontSize.options")).filter(e=>e.model),n=Xb(Gb,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(Gb,new cw(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter(e=>!Al(String(e))&&!El(String(e)));if(i.length)throw new fe("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:Gb,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:Gb,value:e=>e.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:Gb,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const s=mw.length-1,o=Math.min(Math.max(n,0),s);return mw[o]}}})}}class fw extends Cc{static get pluginName(){return"FontSizeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(Gb),s=t("Font Size"),o=function(e,t){const i=new ni;for(const n of e){const e={type:"button",model:new wg({commandName:Gb,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&"string"!=typeof n.view&&(n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`)),e.model.bind("isOn").to(t,"value",e=>e===n.model),i.add(e)}return i}(i,n);e.ui.componentFactory.add(Gb,t=>{const i=bm(t);return vm(i,o,{role:"menu",ariaLabel:s}),i.buttonView.set({label:s,icon:cd,tooltip:!0}),i.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()}),i}),e.ui.componentFactory.add(`menuBar:${Gb}`,t=>{const i=new xg(t);i.buttonView.set({label:s,icon:cd}),i.bind("isEnabled").to(n);const r=new Pg(t);for(const n of o){const s=new Km(t,i),o=new Eh(t);o.set({role:"menuitemradio",isToggleable:!0}),o.bind(...Object.keys(n.model)).to(n.model),o.delegate("execute").to(i),o.on("execute",()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()}),s.children.add(o),r.items.add(s)}return i.panelView.children.add(r),i})}_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 dw(e.config.get(Gb).options).map(e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e})}}class pw extends Cc{static get requires(){return[gw,fw]}static get pluginName(){return"FontSize"}static get isOfficialPlugin(){return!0}normalizeSizeOptions(e){return dw(e)}}class bw extends Kb{constructor(e){super(e,Yb)}}class ww extends Cc{static get pluginName(){return"FontColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(Yb,{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:Yb,value:Zb("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:Yb,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:Yb,view:ew("color")}),e.commands.add(Yb,new bw(e)),e.model.schema.extend("$text",{allowAttributes:Yb}),e.model.schema.setAttributeProperties(Yb,{isFormatting:!0,copyOnEnter:!0})}}class _w extends Cc{commandName;componentName;icon;dropdownLabel;columns;constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:s}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=s,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),s=e.config.get(this.componentName),o=Wh(t,jh(s.colors)),r=s.documentColors,a=!1!==s.colorPicker;e.ui.componentFactory.add(this.componentName,t=>{const l=bm(t);let c=!1;const d=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:s,documentColorsLabel:o,documentColorsCount:r,colorPickerViewConfig:a}){const l=e.locale,c=new Nm(l,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:s,documentColorsLabel:o,documentColorsCount:r,colorPickerViewConfig:a});return e.colorSelectorView=c,e.panelView.children.add(c),c}({dropdownView:l,colors:o.map(e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!!a&&(s.colorPicker||{})});return d.bind("selectedColor").to(n,"value"),l.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),l.bind("isEnabled").to(n),d.on("execute",(t,i)=>{l.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(l.isOpen=!1)}),d.on("colorPicker:show",()=>{this._undoStepBatch=e.model.createBatch()}),d.on("colorPicker:cancel",()=>{this._undoStepBatch.operations.length&&(l.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()}),l.on("change:isOpen",(t,i,n)=>{c||(c=!0,l.colorSelectorView.appendUI()),n&&(0!==r&&d.updateDocumentColors(e.model,this.componentName),d.updateSelectedColors(),d.showColorGridsFragment())}),km(l,()=>l.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find(e=>e.isOn)),l}),e.ui.componentFactory.add(`menuBar:${this.componentName}`,t=>{const s=new xg(t);s.buttonView.set({label:this.dropdownLabel,icon:this.icon}),s.bind("isEnabled").to(n);let a=!1;const l=new Nm(t,{colors:o.map(e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!1});return l.bind("selectedColor").to(n,"value"),l.delegate("execute").to(s),l.on("execute",(t,i)=>{e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),e.editing.view.focus()}),s.on("change:isOpen",(t,i,n)=>{a||(a=!0,l.appendUI()),n&&(0!==r&&l.updateDocumentColors(e.model,this.componentName),l.updateSelectedColors(),l.showColorGridsFragment())}),s.panelView.children.add(l),s})}}class vw extends _w{constructor(e){const t=e.locale.t;super(e,{commandName:Yb,componentName:Yb,icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M12.4 10.3 10 4.5l-2.4 5.8zm.5 1.2H7.1L5.7 15H4.2l5-12h1.6l5 12h-1.5L13 11.5zm3.1 7H4a1 1 0 0 1 0-2h12a1 1 0 0 1 0 2"/></svg>',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class yw extends Cc{static get requires(){return[ww,vw]}static get pluginName(){return"FontColor"}static get isOfficialPlugin(){return!0}}class kw extends Kb{constructor(e){super(e,Qb)}}class Cw extends Cc{static get pluginName(){return"FontBackgroundColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(Qb,{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(ql),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:Qb,value:Zb("background-color")}}),e.conversion.for("downcast").attributeToElement({model:Qb,view:ew("background-color")}),e.commands.add(Qb,new kw(e)),e.model.schema.extend("$text",{allowAttributes:Qb}),e.model.schema.setAttributeProperties(Qb,{isFormatting:!0,copyOnEnter:!0})}}class Aw extends _w{constructor(e){const t=e.locale.t;super(e,{commandName:Qb,componentName:Qb,icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M4 2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m8.38 9.262H7.62L10 5.506zm.532 1.285L14.34 16h1.426L10.804 4H9.196L4.234 16H5.66l1.428-3.453z"/></svg>',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Tw extends Cc{static get requires(){return[Cw,Aw]}static get pluginName(){return"FontBackgroundColor"}static get isOfficialPlugin(){return!0}}class Ew extends Tc{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=si(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&xw(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change(e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&xw(n,t.schema)&&e.rename(n,"paragraph")})}}function xw(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class Pw extends Tc{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;return t.canEditAt(n)?t.change(e=>{if(n=this._findPositionToInsertParagraph(n,e),!n)return null;const s=e.createElement("paragraph");return i&&t.schema.setAllowedAttributes(s,i,e),t.insertContent(s,n),e.setSelection(s,"in"),e.createPositionAt(s,0)}):null}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const n=i.schema.findAllowedParent(e,"paragraph");if(!n)return null;const s=e.parent,o=i.schema.checkChild(s,"$text");return s.isEmpty||o&&e.isAtEnd?i.createPositionAfter(s):!s.isEmpty&&o&&e.isAtStart?i.createPositionBefore(s):t.split(e,n).position}}class Sw extends Cc{static get pluginName(){return"Paragraph"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new Ew(e)),e.commands.add("insertParagraph",new Pw(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>Sw.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}static paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"])}class Iw extends Tc{modelElements;constructor(e,t){super(e),this.modelElements=t}refresh(){const e=si(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>Ow(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change(e=>{const s=Array.from(i.selection.getSelectedBlocks()).filter(e=>Ow(e,n,t.schema));for(const t of s)t.is("element",n)||e.rename(t,n)})}}function Ow(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const Rw="paragraph";class Vw extends Cc{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[Sw]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new Iw(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(t,n)=>{const s=e.model.document.selection.getFirstPosition().parent;i.some(e=>s.is("element",e.model))&&!s.is("element",Rw)&&0===s.childCount&&n.writer.rename(s,Rw)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:me.low+1})}}function Bw(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map(e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e})}class Mw extends Cc{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=Bw(e),n=t("Choose heading"),s=t("Heading");e.ui.componentFactory.add("heading",t=>{const o={},r=new ni,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new wg({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",t=>t===e.model),t.model.set({commandName:"heading",commandValue:e.model})),r.add(t),o[e.model]=e.title}const d=bm(t);return vm(d,r,{ariaLabel:s,role:"menu"}),d.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(c,"isEnabled",(...e)=>e.some(e=>e)),d.buttonView.bind("label").to(a,"value",l,"value",(e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?n:o[i]?o[i]:n}),d.buttonView.bind("ariaLabel").to(a,"value",l,"value",(e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?s:o[i]?`${o[i]}, ${s}`:s}),this.listenTo(d,"execute",t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()}),d}),e.ui.componentFactory.add("menuBar:heading",n=>{const s=new xg(n),o=e.commands.get("heading"),r=e.commands.get("paragraph"),a=[o],l=new Pg(n);s.set({class:"ck-heading-dropdown"}),l.set({ariaLabel:t("Heading"),role:"menu"}),s.buttonView.set({label:t("Heading")}),s.panelView.children.add(l);for(const t of i){const i=new Km(n,s),c=new Eh(n);i.children.add(c),l.items.add(i),c.set({isToggleable:!0,label:t.title,role:"menuitemradio",class:t.class}),c.delegate("execute").to(s),c.on("execute",()=>{const i="paragraph"===t.model?"paragraph":"heading";e.execute(i,{value:t.model}),e.editing.view.focus()}),"paragraph"===t.model?(c.bind("isOn").to(r,"value"),a.push(r)):c.bind("isOn").to(o,"value",e=>e===t.model)}return s.bind("isEnabled").toMany(a,"isEnabled",(...e)=>e.some(e=>e)),s})}}new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class Fw extends Tc{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change(e=>{if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,s=t.getLastMatchingPosition(i,{direction:"backward"}),o=t.getLastMatchingPosition(i),r=e.createRange(s,o);n&&this.value!==n?(t.isEqual(o)||e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(t.isEqual(o)||e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else{const s=t.schema.getValidRanges(i.getRanges(),"highlight",{includeEmptyRanges:!0});for(const t of s){let i=t,s="highlight";t.isCollapsed&&(i=t.start.parent,s=Lo._getStoreAttributeKey("highlight")),n?e.setAttribute(s,n,i):e.removeAttribute(s,i)}}})}}class Nw extends Cc{static get pluginName(){return"HighlightEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-content-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-content-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-content-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-content-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-content-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-content-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new Fw(e))}}class Lw extends Cc{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e),this._addMenuBarButton(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),ad,null,e=>{e.bind("isEnabled").to(t,"isEnabled")})}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,Dw(e.type),e.model,function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",t=>t===e.model),i.iconView.fillColor=e.color,i.isToggleable=!0})}_addButton(e,t,i,n,s){const o=this.editor;o.ui.componentFactory.add(e,e=>{const r=new rh(e),a=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return r.set({label:a,icon:i,tooltip:!0}),r.on("execute",()=>{o.execute("highlight",{value:n}),o.editing.view.focus()}),s(r),r})}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,s=e[0],o=e.reduce((e,t)=>(e[t.model]=t,e),{});n.add("highlight",r=>{const a=t.commands.get("highlight"),l=bm(r,pm),c=l.buttonView;c.set({label:i("Highlight"),tooltip:!0,lastExecuted:s.model,commandValue:s.model,isToggleable:!0}),c.bind("icon").to(a,"value",e=>Dw(d(e,"type"))),c.bind("color").to(a,"value",e=>d(e,"color")),c.bind("commandValue").to(a,"value",e=>d(e,"model")),c.bind("isOn").to(a,"value",e=>!!e),c.delegate("execute").to(l);function d(e,t){const i=e&&e!==c.lastExecuted?e:c.lastExecuted;return o[i][t]}return l.bind("isEnabled").to(a,"isEnabled"),wm(l,()=>{const t=e.map(e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",()=>{l.buttonView.set({lastExecuted:e.model})}),t});return t.push(new lm),t.push(n.create("removeHighlight")),t},{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:i("Text highlight toolbar")}),function(e){const t=e.buttonView.actionView;t.iconView.bind("fillColor").to(e.buttonView,"color")}(l),c.on("execute",()=>{t.execute("highlight",{value:c.commandValue})}),this.listenTo(l,"execute",()=>{t.editing.view.focus()}),l})}_addMenuBarButton(e){const t=this.editor,i=t.t,n=t.commands.get("highlight");t.ui.componentFactory.add("menuBar:highlight",s=>{const o=new xg(s);o.buttonView.set({label:i("Highlight"),icon:Dw("marker")}),o.bind("isEnabled").to(n),o.buttonView.iconView.fillColor="transparent";const r=new Pg(s);for(const i of e){const e=new Km(s,o),a=new Eh(s);a.set({label:i.title,icon:Dw(i.type),role:"menuitemradio",isToggleable:!0}),a.iconView.fillColor=i.color,a.delegate("execute").to(o),a.bind("isOn").to(n,"value",e=>e===i.model),a.on("execute",()=>{t.execute("highlight",{value:i.model}),t.editing.view.focus()}),e.children.add(a),r.items.add(e)}r.items.add(new om(s));const a=new Km(s,o),l=new Eh(s);return l.set({label:i("Remove highlight"),icon:ad}),l.delegate("execute").to(o),l.on("execute",()=>{t.execute("highlight",{value:null}),t.editing.view.focus()}),a.children.add(l),r.items.add(a),o.panelView.children.add(r),o})}}function Dw(e){return"marker"===e?'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10.798 1.59 3.002 12.875l1.895 1.852 2.521 1.402 6.997-12.194z" class="ck-icon__fill"/><path d="m2.556 16.727.234-.348q-.445-.226-.498-.426-.054-.206.115-.837.14-.375.169-.595a4.5 4.5 0 0 0 0-.725q-.313-.931-.284-1.26.03-.327.475-.862l6.77-9.414q.808-1.365 3.199.18 2.39 1.549 1.784 2.686l-5.877 10.36q-.237.618-.526.782-.29.163-1.232.21-.543.196-.738.318t-.526.47q-.44.397-.632.397-.143 0-.524-.226l-.31.41zm-.279.415 1.575 1.103-.392.515H1.19zm8.1-13.656-4.953 6.9L8.75 12.57l4.247-7.574q.263-.375-1.092-1.192-1.354-.819-1.528-.32zM8.244 18.5 9.59 17h9.406v1.5z"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10.126 2.268 2.002 13.874l1.895 1.852 2.521 1.402L14.47 5.481l-1.543-2.568z" class="ck-icon__fill"/><path d="m4.5 18.088-2.645-1.852-.04-2.95-.006-.005.006-.008v-.025l.011.008L8.73 2.97q.249-.348.567-.557l-1.212.308L4.604 7.9l-.83-.558 3.694-5.495 2.708-.69 1.65 1.145.046.018.85-1.216 2.16 1.512-.856 1.222c.828.967 1.144 2.141.432 3.158L7.55 17.286l.006.005zm-.634.166-1.976.516-.026-1.918zM9.968 3.817l-.006-.004-6.123 9.184 3.277 2.294 6.108-9.162.005.003c.317-.452-.16-1.332-1.064-1.966-.891-.624-1.865-.776-2.197-.349M8.245 18.5 9.59 17h9.406v1.5z"/></svg>'}class zw extends Tc{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=kp(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,i);return t.checkChild(n,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change(t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})})}}class Hw extends Cc{static get pluginName(){return"HorizontalLineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),s=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",s),t.setCustomProperty("hr",!0,s),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),bp(e,t,{label:i})}(s,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new zw(e))}}class $w extends Cc{static get pluginName(){return"HorizontalLineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("horizontalLine",()=>{const e=this._createButton(rh);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:horizontalLine",()=>this._createButton(Eh))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("horizontalLine"),s=new e(t.locale),o=i.t;return s.set({label:o("Horizontal line"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 9h16v2H2z"/></svg>'}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("horizontalLine"),t.editing.view.focus()}),s}}const Ww=new Map([["Æ","Ae"],["Ð","D"],["Ø","O"],["Þ","Th"],["ß","ss"],["æ","ae"],["ð","d"],["ø","o"],["þ","th"],["Đ","D"],["đ","d"],["Ħ","H"],["ħ","h"],["ı","i"],["IJ","IJ"],["ij","ij"],["ĸ","k"],["Ŀ","L"],["ŀ","l"],["Ł","L"],["ł","l"],["ʼn","'n"],["Ŋ","N"],["ŋ","n"],["Œ","Oe"],["œ","oe"],["Ŧ","T"],["ŧ","t"],["ſ","s"]]);function jw(e){return function(e){e=e.normalize("NFD");let t="";for(let i=0;i<e.length;i++){const n=e[i];n>="̀"&&n<="ͯ"||n>="︠"&&n<="︣"||(t+=Ww.get(n)??n)}return t}(Bi(e))}const Uw=/\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;function qw(e){const t=function(e){return Array.from(e.match(Uw)??[])}(function(e){return"string"!=typeof e&&(e=Bi(e)),e.replace(/['\u2019]/g,"")}(jw(e)).trim());let i="";for(let e=0;e<t.length;e++){const n=t[e];i&&(i+=" "),n===n.toUpperCase()?i+=n:i+=n[0].toUpperCase()+n.slice(1).toLowerCase()}return i}function Kw(e,t,i,n){t&&function(e,t,i){if(t.attributes)for(const[n]of Object.entries(t.attributes))e.removeAttribute(n,i);if(t.styles)for(const n of Object.keys(t.styles))e.removeStyle(n,i);t.classes&&e.removeClass(t.classes,i)}(e,t,n),i&&Gw(e,i,n)}function Gw(e,t,i){if(t.attributes)for(const[n,s]of Object.entries(t.attributes))e.setAttribute(n,s,i);t.styles&&e.setStyle(t.styles,i),t.classes&&e.addClass(t.classes,i)}function Jw(e,t,i,n,s){const o=t.getAttribute(i),r={};for(const e of["attributes","styles","classes"]){if(e!=n){o&&o[e]&&(r[e]=o[e]);continue}if("classes"==n){const t=new Set(o&&o.classes||[]);s(t),t.size&&(r[e]=Array.from(t));continue}const t=new Map(Object.entries(o&&o[e]||{}));s(t),t.size&&(r[e]=Object.fromEntries(t))}Object.keys(r).length?t.is("documentSelection")?e.setSelectionAttribute(i,r):e.setAttribute(i,r,t):o&&(t.is("documentSelection")?e.removeSelectionAttribute(i):e.removeAttribute(i,t))}function Yw(e,t,i){for(const n of t.getItems({shallow:!0})){const t=n.getAttribute(e);t&&t.attributes&&Object.keys(t.attributes).length?Object.keys(t).length>1&&i.setAttribute(e,{attributes:t.attributes},n):i.removeAttribute(e,n)}}function Qw(e){return`html${t=e,qw(t).replace(/ /g,"")}Attributes`;var t}function Xw({model:e}){return(t,i)=>i.writer.createElement(e,{htmlContent:t.getCustomProperty("$rawContent")})}function Zw(e,{view:t,isInline:i}){const n=e.t;return(e,{writer:s})=>{const o=n("HTML object"),r=e_(t,e,s),a=e.getAttribute(Qw(t));s.addClass("html-object-embed__content",r),a&&Gw(s,a,r);return bp(s.createContainerElement(i?"span":"div",{class:"html-object-embed","data-html-object-embed-label":o},r),s,{label:o})}}function e_(e,t,i){return i.createRawElement(e,null,(e,i)=>{i.setContentOf(e,t.getAttribute("htmlContent"))})}function t_({view:e,model:t,allowEmpty:i},n){return t=>{t.on(`element:${e}`,(e,t,o)=>{let r=n.processViewAttributes(t.viewItem,o);if(r||o.consumable.test(t.viewItem,{name:!0})){if(r=r||{},o.consumable.consume(t.viewItem,{name:!0}),t.modelRange||(t=Object.assign(t,o.convertChildren(t.viewItem,t.modelCursor))),i&&t.modelRange.isCollapsed&&Object.keys(r).length){const e=o.writer.createElement("htmlEmptyElement");if(!o.safeInsert(e,t.modelCursor))return;const i=o.getSplitParts(e);return t.modelRange=o.writer.createRange(t.modelRange.start,o.writer.createPositionAfter(i[i.length-1])),o.updateConversionResult(e,t),void s(e,r,o)}for(const e of t.modelRange.getItems())s(e,r,o)}},{priority:"low"})};function s(e,i,n){if(n.schema.checkAttribute(e,t)){const s=function(e,t){const i=N(e);let n="attributes";for(n in t)i[n]="classes"==n?Array.from(new Set([...e[n]||[],...t[n]])):{...e[n],...t[n]};return i}(i,e.getAttribute(t)||{});n.writer.setAttribute(t,s,e)}}}function i_({model:e,view:t},i){return(n,{writer:s,consumable:o})=>{if(!n.hasAttribute(e))return null;const r=s.createContainerElement(t),a=n.getAttribute(e);return o.consume(n,`attribute:${e}`),Gw(s,a,r),r.getFillerOffset=()=>null,i?bp(r,s):r}}function n_({priority:e,view:t}){return(i,n)=>{if(!i)return;const{writer:s}=n,o=s.createAttributeElement(t,null,{priority:e});return Gw(s,i,o),o}}function s_({view:e},t){return i=>{i.on(`element:${e}`,(e,i,n)=>{if(!i.modelRange||i.modelRange.isCollapsed)return;const s=t.processViewAttributes(i.viewItem,n);s&&n.writer.setAttribute(Qw(i.viewItem.name),s,i.modelRange)},{priority:"low"})}}function o_({view:e,model:t}){return i=>{i.on(`attribute:${Qw(e)}:${t}`,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t;Kw(i.writer,n,s,i.mapper.toViewElement(t.item))})}}const r_=[{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","htmlTfoot"],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:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDiv"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",allowIn:"htmlDiv",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",allowIn:"htmlDiv",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlHr",view:"hr",isEmpty:!0,modelSchema:{inheritAllFrom:"$blockObject"}}],a_=[{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:"htmlTfootAttributes",view:"tfoot",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",attributeProperties:{isFormatting:!0}},{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 l_ extends Cc{_definitions=[];static get pluginName(){return"DataSchema"}static get isOfficialPlugin(){return!0}init(){for(const e of r_)this.registerBlockElement(e);for(const e of a_)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 n of this._getMatchingViewDefinitions(e)){if(t)for(const e of this._getReferences(n.model))i.add(e);i.add(n)}return i}getDefinitionsForModel(e){return this._definitions.filter(t=>t.model==e)}_getMatchingViewDefinitions(e){return this._definitions.filter(t=>t.view&&function(e,t){if("string"==typeof e)return e===t;if(e instanceof RegExp)return e.test(t);return!1}(e,t.view))}*_getReferences(e){const t=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter(t=>t.model==e);for(const{modelSchema:n}of i)if(n)for(const i of t)for(const t of ei(n[i]||[])){const i=this._definitions.filter(e=>e.model==t);for(const n of i)t!==e&&(yield*this._getReferences(n.model),yield n)}}_extendDefinition(e){const t=Array.from(this._definitions.entries()).filter(([,t])=>t.model==e.model);if(0!=t.length)for(const[i,n]of t)this._definitions[i]=j({},n,e,(e,t)=>Array.isArray(e)?e.concat(t):void 0);else this._definitions.push(e)}}class c_ extends Cc{_dataSchema;_allowedAttributes;_disallowedAttributes;_allowedElements;_disallowedElements;_dataInitialized;_coupledAttributes;constructor(e){super(e),this._dataSchema=e.plugins.get("DataSchema"),this._allowedAttributes=new bn,this._disallowedAttributes=new bn,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[l_,Mp]}loadAllowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=g_(t);this.allowElement(e),i.forEach(e=>this.allowAttributes(e))}}loadDisallowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=g_(t);0==i.length?this.disallowElement(e):i.forEach(e=>this.disallowAttributes(e))}}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 d_(e,this._disallowedAttributes,i),function(e,{attributes:t,classes:i,styles:n}){if(!t.length&&!i.length&&!n.length)return null;return{...t.length&&{attributes:u_(e,t)},...n.length&&{styles:h_(e,n)},...i.length&&{classes:i}}}(e,d_(e,this._allowedAttributes,i))}_addAllowedElement(e){if(!this._allowedElements.has(e)){if(this._allowedElements.add(e),"appliesToBlock"in e&&"string"==typeof e.appliesToBlock)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:me.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",()=>{this._dataInitialized=!0;for(const e of this._allowedElements)this._fireRegisterEvent(e)},{priority:me.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)throw new fe("data-filter-invalid-definition",null,t);this._registerInlineElement(t)}e.stop()},{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const e=this.editor.model,t=e.document.selection;e.document.registerPostFixer(t=>{const i=e.document.differ.getChanges();let n=!1;const s=this._getCoupledAttributesMap();for(const e of i){if("attribute"!=e.type||null!==e.attributeNewValue)continue;const i=s.get(e.attributeKey);if(i)for(const{item:s}of e.range.getWalker())for(const e of i)s.hasAttribute(e)&&(t.removeAttribute(e,s),n=!0)}return n}),this.listenTo(t,"change:attribute",(i,{attributeKeys:n})=>{const s=new Set,o=this._getCoupledAttributesMap();for(const e of n){if(t.hasAttribute(e))continue;const i=o.get(e);if(i)for(const e of i)t.hasAttribute(e)&&s.add(e)}0!=s.size&&e.change(e=>{for(const t of s)e.removeSelectionAttribute(t)})})}_registerAssociatedHtmlAttributesPostFixer(){const e=this.editor.model;e.document.registerPostFixer(t=>{const i=e.document.differ.getChanges();let n=!1;for(const s of i)if("insert"===s.type&&"$text"!==s.name)for(const i of s.attributes.keys())i.startsWith("html")&&i.endsWith("Attributes")&&(e.schema.checkAttribute(s.name,i)||(t.removeAttribute(i,s.position.nodeAfter),n=!0));return n})}_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,n=t.conversion,{view:s,model:o}=e;i.register(o,e.modelSchema),s&&(i.extend(e.model,{allowAttributes:[Qw(s),"htmlContent"]}),t.data.registerRawContentMatcher({name:s}),n.for("upcast").elementToElement({view:s,model:Xw(e),converterPriority:me.low+2}),n.for("upcast").add(s_(e,this)),n.for("editingDowncast").elementToStructure({model:{name:o,attributes:[Qw(s)]},view:Zw(t,e)}),n.for("dataDowncast").elementToElement({model:o,view:(e,{writer:t})=>e_(s,e,t)}),n.for("dataDowncast").add(o_(e)))}_registerBlockElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:s,model:o}=e;if(!i.isRegistered(e.model)){if(!e.modelSchema)return;if(i.register(e.model,e.modelSchema),!s)return;n.for("upcast").elementToElement({model:o,view:s,converterPriority:me.low+2}),n.for("downcast").elementToElement({model:o,view:(t,{writer:i})=>e.isEmpty?i.createEmptyElement(s):i.createContainerElement(s)})}s&&(i.extend(e.model,{allowAttributes:Qw(s)}),n.for("upcast").add(s_(e,this)),n.for("downcast").add(o_(e)))}_registerInlineElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,s=e.model;if(!e.appliesToBlock&&(i.extend("$text",{allowAttributes:s}),e.attributeProperties&&i.setAttributeProperties(s,e.attributeProperties),n.for("upcast").add(t_(e,this)),n.for("downcast").attributeToElement({model:s,view:n_(e)}),e.allowEmpty)){if(i.setAttributeProperties(s,{copyFromObject:!1}),!i.isRegistered("htmlEmptyElement")){i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"});const e=e=>Array.from(e.getAttributeKeys()).some(e=>e.startsWith("html"));t.model.document.registerPostFixer(i=>{const n=t.model.document.differ.getChanges(),s=new Set;for(const t of n)if("remove"!==t.type){if("attribute"===t.type&&null===t.attributeNewValue)for(const{item:i}of t.range)i.is("element","htmlEmptyElement")&&!e(i)&&s.add(i);if("insert"===t.type&&t.position.nodeAfter){const n=t.position.nodeAfter;for(const{item:t}of i.createRangeOn(n))t.is("element","htmlEmptyElement")&&!e(t)&&s.add(t)}}for(const e of s)i.remove(e);return s.size>0})}t.data.htmlProcessor.domConverter.registerInlineObjectMatcher(t=>t.name==e.view&&t.isEmpty&&Array.from(t.getAttributeKeys()).length?{name:!0}:null),n.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:i_(e,!0)}),n.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:i_(e)})}}}function d_(e,t,i){const n=t.matchAll(e)||[],s=e.document.stylesProcessor;return n.reduce((t,{match:n})=>{for(const[o,r]of n.attributes||[])if("style"==o){const n=r,o=s.getRelatedStyles(n).filter(e=>e.split("-").length>n.split("-").length).sort((e,t)=>t.split("-").length-e.split("-").length);for(const n of o)i.consume(e,{styles:[n]})&&t.styles.push(n);i.consume(e,{styles:[n]})&&t.styles.push(n)}else if("class"==o){const n=r;i.consume(e,{classes:[n]})&&t.classes.push(n)}else i.consume(e,{attributes:[o]})&&t.attributes.push(o);return t},{attributes:[],classes:[],styles:[]})}function u_(e,t){const i={};for(const n of t){const t=e.getAttribute(n);void 0!==t&&Tt(n)&&(i[n]=t)}return i}function h_(e,t){const i=new vn(e.document.stylesProcessor);for(const n of t){const t=e.getStyle(n);void 0!==t&&i.set(n,t)}return Object.fromEntries(i.getStylesEntries())}function m_(e,t){const{name:i}=e,n=e[t];return s(n)?Object.entries(n).map(([e,n])=>({name:i,[t]:{[e]:n}})):Array.isArray(n)?n.map(e=>({name:i,[t]:[e]})):[e]}function g_(e){const{name:t,attributes:i,classes:n,styles:s}=e,o=[];return i&&o.push(...m_({name:t,attributes:i},"attributes")),n&&o.push(...m_({name:t,classes:n},"classes")),s&&o.push(...m_({name:t,styles:s},"styles")),o}class f_ extends Cc{static get requires(){return[c_]}static get pluginName(){return"CodeBlockElementSupport"}static get isOfficialPlugin(){return!0}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const e=this.editor.plugins.get(c_);e.on("register:pre",(t,i)=>{if("codeBlock"!==i.model)return;const n=this.editor,s=n.model.schema,o=n.conversion;s.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),o.for("upcast").add(function(e){return t=>{t.on("element:code",(t,i,n)=>{const s=i.viewItem,o=s.parent;function r(t,s){const o=e.processViewAttributes(t,n);o&&n.writer.setAttribute(s,o,i.modelRange)}o&&o.is("element","pre")&&(r(o,"htmlPreAttributes"),r(s,"htmlContentAttributes"))},{priority:"low"})}}(e)),o.for("downcast").add(e=>{e.on("attribute:htmlPreAttributes:codeBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item).parent;Kw(i.writer,n,s,o)}),e.on("attribute:htmlContentAttributes:codeBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item);Kw(i.writer,n,s,o)})}),t.stop()})}}class p_ extends Cc{static get requires(){return[c_]}static get pluginName(){return"DualContentModelElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.plugins.get(c_).on("register",(e,t)=>{const i=t,n=this.editor,s=n.model.schema,o=n.conversion;if(!i.paragraphLikeModel)return;if(s.isRegistered(i.model)||s.isRegistered(i.paragraphLikeModel))return;const r={model:i.paragraphLikeModel,view:i.view};s.register(i.model,i.modelSchema),s.register(r.model,{inheritAllFrom:"$block"}),o.for("upcast").elementToElement({view:i.view,model:(e,{writer:t})=>this._hasBlockContent(e)?t.createElement(i.model):t.createElement(r.model),converterPriority:me.low+.5}),o.for("downcast").elementToElement({view:i.view,model:i.model}),this._addAttributeConversion(i),o.for("downcast").elementToElement({view:r.view,model:r.model}),this._addAttributeConversion(r),e.stop()})}_hasBlockContent(e){const t=this.editor.editing.view,i=t.domConverter.blockElements;for(const n of t.createRangeIn(e).getItems())if(n.is("element")&&i.includes(n.name))return!0;return!1}_addAttributeConversion(e){const t=this.editor,i=t.conversion,n=t.plugins.get(c_);t.model.schema.extend(e.model,{allowAttributes:Qw(e.view)}),i.for("upcast").add(s_(e,n)),i.for("downcast").add(o_(e))}}class b_ extends Cc{static get requires(){return[l_,Uf]}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(l_),n=[];for(const e of t)"model"in e&&"view"in e&&(i.registerBlockElement({view:e.view,model:e.model}),n.push(e.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:n}}),i.extendBlockElement({model:"htmlSummary",modelSchema:{allowChildren:n}})}}function w_(e,t,i){const n=e.createRangeOn(t);for(const{item:e}of n.getWalker())if(e.is("element",i))return e}class __ extends Cc{static get requires(){return[c_]}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,n=e.plugins.get(c_);n.on("register:figure",()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",(t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("image"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)},{priority:"low"})}}(n))}),n.on("register:img",(s,o)=>{"imageBlock"!==o.model&&"imageInline"!==o.model||(t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:img",(t,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlImgAttributes",o,i.modelRange)},{priority:"low"})}}(n)),i.for("downcast").add(e=>{function t(t){e.on(`attribute:${t}:imageInline`,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item);Kw(i.writer,n,s,o)},{priority:"low"})}function i(t,i){e.on(`attribute:${i}:imageBlock`,(e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const{attributeOldValue:s,attributeNewValue:o}=i,r=n.mapper.toViewElement(i.item),a=w_(n.writer,r,t);a&&(Kw(n.writer,s,o,a),n.consumable.consume(i.item,e.name))},{priority:"low"}),"a"===t&&e.on("attribute:linkHref:imageBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,"attribute:htmlLinkAttributes:imageBlock"))return;const n=i.mapper.toViewElement(t.item),s=w_(i.writer,n,"a");Gw(i.writer,t.item.getAttribute("htmlLinkAttributes"),s)},{priority:"low"})}t("htmlImgAttributes"),i("img","htmlImgAttributes"),i("figure","htmlFigureAttributes"),i("a","htmlLinkAttributes")}),e.plugins.has("LinkImage")&&i.for("upcast").add(function(e,t){const i=t.plugins.get("ImageUtils");return t=>{t.on("element:a",(t,n,s)=>{const o=n.viewItem;if(!i.findViewImgElement(o))return;const r=n.modelCursor.parent;if(!r.is("element","imageBlock"))return;const a=e.processViewAttributes(o,s);a&&s.writer.setAttribute("htmlLinkAttributes",a,r)},{priority:"low"})}}(n,e)),s.stop())})}}class v_ extends Cc{static get requires(){return[c_]}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,n=this.editor.plugins.get(c_),s=this.editor.plugins.get(l_),o=e.config.get("mediaEmbed.elementName");s.registerBlockElement({model:"media",view:o}),n.on("register:figure",()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",(t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("media"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)},{priority:"low"})}}(n))}),n.on(`register:${o}`,(e,s)=>{"media"===s.model&&(t.extend("media",{allowAttributes:[Qw(o),"htmlFigureAttributes"]}),i.for("upcast").add(function(e,t){const i=(i,n,s)=>{function o(t,i){const o=e.processViewAttributes(t,s);o&&s.writer.setAttribute(i,o,n.modelRange)}o(n.viewItem,Qw(t))};return e=>{e.on(`element:${t}`,i,{priority:"low"})}}(n,o)),i.for("dataDowncast").add(function(e){return t=>{function i(e,i){t.on(`attribute:${i}:media`,(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const{attributeOldValue:s,attributeNewValue:o}=i,r=n.mapper.toViewElement(i.item),a=w_(n.writer,r,e);Kw(n.writer,s,o,a)})}i(e,Qw(e)),i("figure","htmlFigureAttributes")}}(o)),e.stop())})}}class y_ extends Cc{static get requires(){return[c_]}static get pluginName(){return"ScriptElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(c_);e.on("register:script",(t,i)=>{const n=this.editor,s=n.model.schema,o=n.conversion;s.register("htmlScript",i.modelSchema),s.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"script"}),o.for("upcast").elementToElement({view:"script",model:Xw(i)}),o.for("upcast").add(s_(i,e)),o.for("downcast").elementToElement({model:"htmlScript",view:(e,{writer:t})=>e_("script",e,t)}),o.for("downcast").add(o_(i)),t.stop()})}}const k_=["width","max-width","min-width","height","min-height","max-height"];class C_ extends Cc{static get requires(){return[c_]}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,n=e.plugins.get(c_),s=e.plugins.get("TableUtils");n.on("register:figure",()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",(t,i,n)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("table"))return;const o=e.processViewAttributes(s,n);o&&n.writer.setAttribute("htmlFigureAttributes",o,i.modelRange)},{priority:"low"})}}(n))}),n.on("register:table",(o,r)=>{"table"===r.model&&(t.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes","htmlTfootAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:table",(t,i,n)=>{if(!i.modelRange)return;const s=i.viewItem;n.consumable.consume(s,{classes:"table"}),o(s,"htmlTableAttributes");for(const e of s.getChildren())e.is("element","thead")&&o(e,"htmlTheadAttributes"),e.is("element","tfoot")&&o(e,"htmlTfootAttributes"),e.is("element","tbody")&&o(e,"htmlTbodyAttributes");function o(t,s){const o=e.processViewAttributes(t,n);o&&n.writer.setAttribute(s,o,i.modelRange)}},{priority:"low"})}}(n)),i.for("downcast").add(e=>{function t(t,i){e.on(`attribute:${i}:table`,(e,n,s)=>{if(!s.consumable.test(n.item,e.name))return;const o=s.mapper.toViewElement(n.item),r=w_(s.writer,o,t);if(r)if(s.consumable.consume(n.item,e.name),"htmlTableAttributes"===i&&o!==r){const e=A_(n.attributeOldValue),t=A_(n.attributeNewValue);Kw(s.writer,e.tableAttributes,t.tableAttributes,r),Kw(s.writer,e.figureAttributes,t.figureAttributes,o)}else Kw(s.writer,n.attributeOldValue,n.attributeNewValue,r)})}t("table","htmlTableAttributes"),t("figure","htmlFigureAttributes"),t("thead","htmlTheadAttributes"),t("tbody","htmlTbodyAttributes"),t("tfoot","htmlTfootAttributes")}),e.model.document.registerPostFixer(function(e,t){return i=>{const n=e.document.differ.getChanges();let s=!1;for(const e of n){if("attribute"!=e.type||"headingRows"!=e.attributeKey&&"footerRows"!=e.attributeKey)continue;const n=e.range.start.nodeAfter,o=n.getAttribute("htmlTheadAttributes"),r=n.getAttribute("htmlTbodyAttributes"),a=n.getAttribute("htmlTfootAttributes");if(o&&"headingRows"===e.attributeKey&&!e.attributeNewValue&&(i.removeAttribute("htmlTheadAttributes",n),s=!0),a&&"footerRows"===e.attributeKey&&!e.attributeNewValue&&(i.removeAttribute("htmlTfootAttributes",n),s=!0),r){(n.getAttribute("headingRows")||0)+(n.getAttribute("footerRows")||0)==t.getRows(n)&&(i.removeAttribute("htmlTbodyAttributes",n),s=!0)}}return s}}(e.model,s)),o.stop())})}}function A_(e){const t={},i={...e};if(!e||!("styles"in e))return{figureAttributes:t,tableAttributes:i};i.styles={};for(const[n,s]of Object.entries(e.styles))k_.includes(n)?t.styles={...t.styles,[n]:s}:i.styles={...i.styles,[n]:s};return{figureAttributes:t,tableAttributes:i}}class T_ extends Cc{static get requires(){return[c_]}static get pluginName(){return"StyleElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(c_);e.on("register:style",(t,i)=>{const n=this.editor,s=n.model.schema,o=n.conversion;s.register("htmlStyle",i.modelSchema),s.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"style"}),o.for("upcast").elementToElement({view:"style",model:Xw(i)}),o.for("upcast").add(s_(i,e)),o.for("downcast").elementToElement({model:"htmlStyle",view:(e,{writer:t})=>e_("style",e,t)}),o.for("downcast").add(o_(i)),t.stop()})}}class E_ extends Cc{static get requires(){return[c_]}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,n=e.plugins.get(c_),s=e.plugins.get("ListEditing"),o=e.plugins.get("ListUtils"),r=["ul","ol","li"];s.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:Gw}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:Gw}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:Gw}),n.on("register",(e,s)=>{if(!r.includes(s.view))return;if(e.stop(),t.checkAttribute("$block","htmlLiAttributes"))return;const o=r.map(e=>Qw(e));t.extend("$listItem",{allowAttributes:o}),i.for("upcast").add(e=>{e.on("element:ul",x_("htmlUlAttributes",n),{priority:"low"}),e.on("element:ol",x_("htmlOlAttributes",n),{priority:"low"}),e.on("element:li",x_("htmlLiAttributes",n),{priority:"low"})})}),s.on("postFixer",(e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:s}of t)if(s){if(s.getAttribute("listType")==n.getAttribute("listType")){const t=P_(s.getAttribute("listType")),o=s.getAttribute(t);!Xi(n.getAttribute(t),o)&&i.model.schema.checkAttribute(n,t)&&(i.setAttribute(t,o,n),e.return=!0)}if(s.getAttribute("listItemId")==n.getAttribute("listItemId")){const t=s.getAttribute("htmlLiAttributes");!Xi(n.getAttribute("htmlLiAttributes"),t)&&i.model.schema.checkAttribute(n,"htmlLiAttributes")&&(i.setAttribute("htmlLiAttributes",t,n),e.return=!0)}}}),s.on("postFixer",(e,{listNodes:t,writer:i})=>{for(const{node:n}of t){const t=n.getAttribute("listType");!o.isNumberedListType(t)&&n.getAttribute("htmlOlAttributes")&&(i.removeAttribute("htmlOlAttributes",n),e.return=!0),o.isNumberedListType(t)&&n.getAttribute("htmlUlAttributes")&&(i.removeAttribute("htmlUlAttributes",n),e.return=!0)}})}afterInit(){const e=this.editor;if(!e.commands.get("indentList"))return;const t=e.commands.get("indentList");this.listenTo(t,"afterExecute",(t,i)=>{e.model.change(t=>{for(const n of i){const i=P_(n.getAttribute("listType"));e.model.schema.checkAttribute(n,i)&&t.setAttribute(i,{},n)}})})}}function x_(e,t){return(i,n,s)=>{const o=n.viewItem;n.modelRange||Object.assign(n,s.convertChildren(n.viewItem,n.modelCursor));const r=t.processViewAttributes(o,s);for(const t of n.modelRange.getItems({shallow:!0}))t.hasAttribute("listItemId")&&(t.hasAttribute("htmlUlAttributes")||t.hasAttribute("htmlOlAttributes")||s.writer.model.schema.checkAttribute(t,e)&&s.writer.setAttribute(e,r||{},t))}}function P_(e){return"numbered"===e||"customNumbered"==e?"htmlOlAttributes":"htmlUlAttributes"}class S_ extends Cc{static get requires(){return[c_]}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,n=e.plugins.get(c_);n.on("register:hr",(e,s)=>{"horizontalLine"===s.model&&(t.extend("horizontalLine",{allowAttributes:["htmlHrAttributes"]}),i.for("upcast").add(s_(s,n)),i.for("downcast").add(e=>{e.on("attribute:htmlHrAttributes:horizontalLine",(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:s}=t,o=i.mapper.toViewElement(t.item),r=w_(i.writer,o,"hr");r&&(Kw(i.writer,n,s,r),i.consumable.consume(t.item,e.name))},{priority:"low"})}),e.stop())})}}class I_ extends Cc{static get requires(){return[c_]}static get pluginName(){return"IframeElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.config.define("htmlSupport.htmlIframeSandbox",!0),this._setupSandboxConversion()}_setupSandboxConversion(){const{plugins:e,config:t,conversion:i}=this.editor,n=e.get(c_),s=t.get("htmlSupport.htmlIframeSandbox");if(!1===s)return;const o=Array.isArray(s)?Array.from(s):[];n.on("register:iframe",(e,t)=>{i.for("editingDowncast").add(e=>{e.on(`insert:${t.model}`,(e,t,i)=>{const{mapper:n,writer:s}=i,r=n.toViewElement(t.item);for(const{item:e}of s.createRangeOn(r))if(e.is("element","iframe"))if(e.hasAttribute("sandbox")){const t=new Set,i=e.getAttribute("sandbox");for(const e of i.trim().split(/\s+/))o.includes(e)&&t.add(e);s.setAttribute("sandbox",Array.from(t).join(" "),e)}else s.setAttribute("sandbox",o.join(" "),e)},{priority:"lowest"})})})}}class O_ extends Cc{static get requires(){return[c_,l_]}static get pluginName(){return"CustomElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(c_),t=this.editor.plugins.get(l_);e.on("register:$customElement",(i,n)=>{i.stop();const s=this.editor,o=s.model.schema,r=s.conversion,a=s.editing.view.domConverter.unsafeElements,l=s.data.htmlProcessor.domConverter.preElements;o.register(n.model,n.modelSchema),o.extend(n.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),s.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),r.for("upcast").elementToElement({view:/.*/,model:(i,o)=>{if("$comment"==i.name)return null;if(!function(e){try{document.createElement(e)}catch{return!1}return!0}(i.name))return null;if(t.getDefinitionsForView(i.name).size)return null;a.includes(i.name)||a.push(i.name),l.includes(i.name)||l.push(i.name);const r=o.writer.createElement(n.model,{htmlElementName:i.name}),c=e.processViewAttributes(i,o);let d;if(c&&o.writer.setAttribute("htmlCustomElementAttributes",c,r),i.is("element","template")&&i.getCustomProperty("$rawContent"))d=i.getCustomProperty("$rawContent");else{const e=new hl(i.document).createDocumentFragment(i),t=s.data.htmlProcessor.domConverter.viewToDom(e),n=t.firstChild;for(;n.firstChild;)t.appendChild(n.firstChild);n.remove(),d=s.data.htmlProcessor.htmlWriter.getHtml(t)}o.writer.setAttribute("htmlContent",d,r);for(const{item:e}of s.editing.view.createRangeIn(i))o.consumable.consume(e,{name:!0});return r},converterPriority:"low"}),r.for("editingDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=t.createRawElement(i);return e.hasAttribute("htmlCustomElementAttributes")&&Gw(t,e.getAttribute("htmlCustomElementAttributes"),n),n}}),r.for("dataDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=e.getAttribute("htmlContent"),s=t.createRawElement(i,null,(e,t)=>{t.setContentOf(e,n)});return e.hasAttribute("htmlCustomElementAttributes")&&Gw(t,e.getAttribute("htmlCustomElementAttributes"),s),s}})})}}function*R_(e,t,i){if(t)if(!(Symbol.iterator in t)&&t.is("documentSelection")&&t.isCollapsed)e.schema.checkAttributeInSelection(t,i)&&(yield t);else for(const n of function(e,t,i){return!(Symbol.iterator in t)&&(t.is("node")||t.is("$text")||t.is("$textProxy"))?e.schema.checkAttribute(t,i)?[e.createRangeOn(t)]:[]:e.schema.getValidRanges(e.createSelection(t).getRanges(),i)}(e,t,i))yield*n.getItems({shallow:!0})}class V_{_placeholderMap;_wrapper=null;_document;_annotationsUIsData=null;_paginationBodyCollection=null;_hasLeftCollapseButton=!1;_collapseLeftSidebarButton=null;_resizeObserver=null;_sidebarsWidths={left:0,right:0};_keepLeftSidebarHidden=!1;_forceShowLeftSidebar=!1;_sourceEditingCallback=(e,t,i)=>{this.getWrapper().querySelector(".ck-fullscreen__document-outline-header").style.display=i?"none":""};_hiddenElements=new Map;_savedAncestorsScrollPositions=new Map;_showRevisionViewerCallback=null;_closeRevisionViewerCallback=null;_aiTabsData=null;constructor(e){this._placeholderMap=new Map,e.plugins.has("RevisionHistory")&&(this._showRevisionViewerCallback=e.config.get("revisionHistory").showRevisionViewerCallback,this._closeRevisionViewerCallback=e.config.get("revisionHistory").closeRevisionViewerCallback),this._editor=e,this._document=this._editor.sourceElement?this._editor.sourceElement.ownerDocument:G.document,this._editor.config.define("fullscreen.container",this._document.body),e.on("destroy",()=>{this._wrapper&&this.destroy(),this._resizeObserver&&this._resizeObserver.destroy()})}moveToFullscreen(e,t){const i=Ge(this._document,"div");i.setAttribute("data-ck-fullscreen-placeholder",t),e.replaceWith(i),this.getWrapper().querySelector(`[data-ck-fullscreen="${t}"]`).append(e),this._placeholderMap.set(t,{placeholderElement:i,movedElement:e})}restoreMovedElementLocation(e){if(!this._placeholderMap.has(e))return;const{placeholderElement:t,movedElement:i}=this._placeholderMap.get(e);t.replaceWith(i),t.remove(),this._placeholderMap.delete(e),0===this._placeholderMap.size&&this._destroyContainer()}getWrapper(){return this._wrapper||(this._wrapper=Ge(this._document,"div",{class:"ck ck-fullscreen__main-wrapper"}),this._wrapper.innerHTML='\n\t\t\t\t<div class="ck ck-fullscreen__top-wrapper ck-reset_all">\n\t\t\t\t\t<div class="ck ck-fullscreen__menu-bar" data-ck-fullscreen="menu-bar"></div>\n\t\t\t\t\t<div class="ck ck-fullscreen__toolbar" data-ck-fullscreen="toolbar"></div>\n\t\t\t\t</div>\n\t\t\t\t<div class="ck ck-fullscreen__editable-wrapper">\n\t\t\t\t\t<div class="ck ck-fullscreen__sidebar ck-fullscreen__left-sidebar" data-ck-fullscreen="left-sidebar"></div>\n\t\t\t\t\t<div class="ck ck-fullscreen__editable" data-ck-fullscreen="editable">\n\t\t\t\t\t\t<div class="ck ck-fullscreen__pagination-view" data-ck-fullscreen="pagination-view"></div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="ck ck-fullscreen__sidebar ck-fullscreen__right-sidebar" data-ck-fullscreen="right-sidebar"></div>\n\t\t\t\t\t<div class="ck ck-fullscreen__right-edge" data-ck-fullscreen="right-edge"></div>\n\t\t\t\t</div>\n\t\t\t\t<div class="ck ck-fullscreen__bottom-wrapper">\n\t\t\t\t\t<div class="ck ck-fullscreen__body-wrapper" data-ck-fullscreen="body-wrapper"></div>\n\t\t\t\t</div>\n\t\t\t',this._editor.config.get("fullscreen.container").appendChild(this._wrapper)),this._wrapper}enable(){if(this._saveAncestorsScrollPositions(this._editor.ui.getEditableElement()),this.defaultOnEnter(),this._editor.config.get("fullscreen.container")===this._document.body&&(this._document.body.classList.add("ck-fullscreen"),this._document.body.parentElement.classList.add("ck-fullscreen")),this._editor.plugins.has("PresenceListUI")&&this._generatePresenceListContainer(),this._editor.plugins.has("DocumentOutlineUI")&&this._generateDocumentOutlineContainer(),this._hasLeftCollapseButton&&this._generateCollapseButton(),this._editor.plugins.has("Pagination")&&this._editor.plugins.get("Pagination").isEnabled){const e=this._editor.plugins.get("PaginationRenderer");e.setupScrollableAncestor(),this._paginationBodyCollection=new Ph(this._editor.locale),this._paginationBodyCollection.attachToDom(),e.linesRepository.setViewCollection(this._paginationBodyCollection),this._editor.once("destroy",()=>{this._paginationBodyCollection.detachFromDom()}),this.moveToFullscreen(this._paginationBodyCollection.bodyCollectionContainer,"body-wrapper")}this._editor.plugins.has("AnnotationsUIs")&&this._overrideAnnotationsUIs(),this._editor.plugins.has("RevisionHistory")&&(this._editor.plugins.get("RevisionHistory").isRevisionViewerOpen&&this._editor.config.get("revisionHistory.closeRevisionViewerCallback")(),this._overrideRevisionHistoryCallbacks()),this._editor.plugins.has("AITabs")&&this._handleAITabsTransfer(),this._editor.plugins.has("SourceEditing")&&this._editor.plugins.has("DocumentOutlineUI")&&this._editor.plugins.get("SourceEditing").on("change:isSourceEditingMode",this._sourceEditingCallback),this._editor.plugins.has("Dialog")&&this._registerFullscreenDialogPositionAdjustments();for(const e of this._editor.config.get("fullscreen.container").children)e===this._wrapper||e.classList.contains("ck-body-wrapper")||e.classList.contains("ckbox-wrapper")||"none"===e.style.display||(this._hiddenElements.set(e,e.style.display),e.style.display="none");this._sidebarsWidths={left:this._wrapper.querySelector(".ck-fullscreen__left-sidebar").scrollWidth,right:this._wrapper.querySelector(".ck-fullscreen__right-sidebar").scrollWidth},this._adjustVisibleElements(),this._setupResizeObserver(),this._editor.config.get("fullscreen.onEnterCallback")&&this._editor.config.get("fullscreen.onEnterCallback")(this.getWrapper())}disable(){this._editor.config.get("fullscreen.onLeaveCallback")&&this._editor.config.get("fullscreen.onLeaveCallback")(this.getWrapper()),this._document.body.classList.remove("ck-fullscreen"),this._document.body.parentElement.classList.remove("ck-fullscreen"),this._editor.plugins.has("DocumentOutlineUI")&&this._restoreDocumentOutlineDefaultContainer(),this._annotationsUIsData&&this._restoreAnnotationsUIs(),this._editor.plugins.has("RevisionHistory")&&this._restoreRevisionHistoryCallbacks(),this._editor.plugins.has("AITabs")&&this._restoreAITabs(),this._editor.plugins.has("SourceEditing")&&this._editor.plugins.has("DocumentOutlineUI")&&this._editor.plugins.get("SourceEditing").off("change:isSourceEditingMode",this._sourceEditingCallback);for(const e of this._placeholderMap.keys())this.restoreMovedElementLocation(e);this._destroyContainer(),this._editor.ui.view.toolbar&&this._editor.ui.view.toolbar.switchBehavior(!0===this._editor.config.get("toolbar.shouldNotGroupWhenFull")?"static":"dynamic");for(const[e,t]of this._savedAncestorsScrollPositions)e.scrollTo({left:t.scrollLeft,top:t.scrollTop,behavior:"instant"});if(this._savedAncestorsScrollPositions.clear(),this._editor.plugins.has("Pagination")&&this._editor.plugins.get("Pagination").isEnabled){const e=this._editor.plugins.get("PaginationRenderer");e.setupScrollableAncestor(),e.linesRepository.setViewCollection(this._editor.ui.view.body),this._paginationBodyCollection.detachFromDom(),this._paginationBodyCollection?.destroy()}this._editor.plugins.has("Dialog")&&this._unregisterFullscreenDialogPositionAdjustments(),this._keepLeftSidebarHidden=!1,this._resizeObserver?.destroy()}destroy(){for(const{placeholderElement:e,movedElement:t}of this._placeholderMap.values())e.remove(),t.remove();this._destroyContainer(),this._document.body.classList.remove("ck-fullscreen"),this._document.body.parentElement.classList.remove("ck-fullscreen")}defaultOnEnter(){return this.getWrapper()}_destroyContainer(){if(this._wrapper){this._wrapper.remove(),this._wrapper=null;for(const[e,t]of this._hiddenElements)e.style.display=t;this._hiddenElements.clear()}}_generatePresenceListContainer(){const e=this._editor.t,t=Ge(document,"div",{class:"ck ck-fullscreen__left-sidebar-item"});t.innerHTML='\n\t\t\t<div class="ck ck-fullscreen__left-sidebar-header"></div>\n\t\t\t<div class="ck ck-fullscreen__presence-list" data-ck-fullscreen="presence-list"></div>\n\t\t',t.firstElementChild.innerText=e("Connected users"),document.querySelector('[data-ck-fullscreen="left-sidebar-sticky"]')||document.querySelector('[data-ck-fullscreen="left-sidebar"]').appendChild(Ge(document,"div",{class:"ck ck-fullscreen__left-sidebar-sticky","data-ck-fullscreen":"left-sidebar-sticky"})),document.querySelector('[data-ck-fullscreen="left-sidebar-sticky"]').appendChild(t);const i=this._editor.plugins.get("PresenceListUI");this.moveToFullscreen(i.view.element,"presence-list"),this._hasLeftCollapseButton=!0}_generateDocumentOutlineContainer(){const e=this._editor.t,t=Ge(document,"div",{class:"ck-fullscreen__left-sidebar-item ck-fullscreen__left-sidebar-item--no-margin"});t.innerHTML='\n\t\t\t<div class="ck ck-fullscreen__left-sidebar-header ck-fullscreen__document-outline-header"></div>\n\t\t',t.firstElementChild.innerText=e("Document outline");const i=Ge(document,"div",{class:"ck ck-fullscreen__left-sidebar-item ck-fullscreen__document-outline-wrapper"});i.innerHTML='\n\t\t\t<div class="ck ck-fullscreen__document-outline" data-ck-fullscreen="document-outline"></div>\n\t\t',document.querySelector('[data-ck-fullscreen="left-sidebar-sticky"]')||document.querySelector('[data-ck-fullscreen="left-sidebar"]').appendChild(Ge(document,"div",{class:"ck ck-fullscreen__left-sidebar-sticky","data-ck-fullscreen":"left-sidebar-sticky"})),document.querySelector('[data-ck-fullscreen="left-sidebar"]').appendChild(i),document.querySelector('[data-ck-fullscreen="left-sidebar-sticky"]').appendChild(t);const n=this._editor.plugins.get("DocumentOutlineUI");n.view.documentOutlineContainer=document.querySelector('[data-ck-fullscreen="left-sidebar"]'),this.moveToFullscreen(n.view.element,"document-outline"),this._hasLeftCollapseButton=!0}_restoreDocumentOutlineDefaultContainer(){const e=this._editor.plugins.get("DocumentOutlineUI");e.view.documentOutlineContainer=e.view.element}_generateCollapseButton(){const e=new rh(this._editor.locale),t=document.querySelector(".ck-fullscreen__left-sidebar"),i=this._editor.t;e.set({label:i("Toggle sidebar"),class:"ck-fullscreen__left-sidebar-toggle-button",tooltip:i("Hide left sidebar"),tooltipPosition:"se",icon:_d}),e.on("execute",()=>{t.classList.contains("ck-fullscreen__left-sidebar--collapsed")?(this._forceShowLeftSidebar=!0,this._keepLeftSidebarHidden=!1,this._showLeftSidebar()):(this._keepLeftSidebarHidden=!0,this._hideLeftSidebar()),this._editor.editing.view.focus()}),e.render(),this._collapseLeftSidebarButton=e,t.prepend(e.element)}_overrideAnnotationsUIs(){const e=this._editor.plugins.get("AnnotationsUIs");this._annotationsUIsData=new Map(e.uisData),e.deactivateAll();const t=this._editor.plugins.get("Sidebar");t.container?(this._switchAnnotationsUI("wideSidebar"),this.moveToFullscreen(t.container.firstElementChild,"right-sidebar"),t.setContainer(this.getWrapper().querySelector('[data-ck-fullscreen="right-sidebar"]'))):(t.setContainer(this.getWrapper().querySelector('[data-ck-fullscreen="right-sidebar"]')),this._switchAnnotationsUI("wideSidebar"),this.moveToFullscreen(t.container.firstElementChild,"right-sidebar"))}_restoreAnnotationsUIs(){const e=this._editor.plugins.get("Sidebar"),t=e.context.config.get("sidebar.container");t&&e.setContainer(t);const i=this._editor.plugins.get("AnnotationsUIs");i.deactivateAll();for(const[e,t]of[...this._annotationsUIsData])i.activate(e,t.filter);this._annotationsUIsData=null}_overrideRevisionHistoryCallbacks(){this._editor.config.set("revisionHistory.showRevisionViewerCallback",async()=>{const e=await this._showRevisionViewerCallback();return this._editor.plugins.has("DocumentOutlineUI")&&(this.getWrapper().querySelector(".ck-fullscreen__document-outline-header").style.display="none"),this.restoreMovedElementLocation("editable"),this.restoreMovedElementLocation("toolbar"),this.restoreMovedElementLocation("right-sidebar"),this._annotationsUIsData&&this._restoreAnnotationsUIs(),this._editor.ui.view.menuBarView&&this._editor.ui.view.menuBarView.disable(),this.moveToFullscreen(e.ui.getEditableElement(),"editable"),this.moveToFullscreen(e.ui.view.toolbar.element,"toolbar"),this.moveToFullscreen(this._editor.config.get("revisionHistory.viewerSidebarContainer"),"right-sidebar"),e}),this._editor.config.set("revisionHistory.closeRevisionViewerCallback",async()=>{this.restoreMovedElementLocation("toolbar"),this.restoreMovedElementLocation("editable"),this.restoreMovedElementLocation("right-sidebar"),this._editor.plugins.has("DocumentOutlineUI")&&(this.getWrapper().querySelector(".ck-fullscreen__document-outline-header").style.display=""),this.moveToFullscreen(this._editor.ui.getEditableElement(),"editable"),this.moveToFullscreen(this._editor.ui.view.toolbar.element,"toolbar"),await this._closeRevisionViewerCallback(),this._editor.plugins.has("AnnotationsUIs")&&this._overrideAnnotationsUIs(),this._editor.ui.view.menuBarView&&this._editor.ui.view.menuBarView.enable()})}_restoreRevisionHistoryCallbacks(){this._editor.config.set("revisionHistory.showRevisionViewerCallback",async()=>this._showRevisionViewerCallback()),this._editor.config.set("revisionHistory.closeRevisionViewerCallback",async()=>this._closeRevisionViewerCallback())}_registerFullscreenDialogPositionAdjustments(){const e=this._editor.plugins.get("Dialog");this._setNewDialogPosition(),e.on("change:isOpen",this.updateDialogPositionCallback,{priority:"highest"})}_unregisterFullscreenDialogPositionAdjustments(){const e=this._editor.plugins.get("Dialog"),t=e.view;t&&null===t.position&&(t.position=ph),t&&t.updatePosition(),e.off("change:isOpen",this.updateDialogPositionCallback)}updateDialogPositionCallback=this._updateDialogPosition.bind(this);_updateDialogPosition(e,t,i){i&&this._setNewDialogPosition()}_setNewDialogPosition(){const e=this._editor.plugins.get("Dialog").view;if(!e||e.position!==ph)return;const t=new ht(this._wrapper.querySelector(".ck-fullscreen__right-edge")).getVisible(),i=t?this._wrapper.querySelector(".ck-fullscreen__right-edge"):this._wrapper,n=new ht(i).getVisible(),s=new ht(document.querySelector(".ck-fullscreen__editable")).getVisible(),o=new ht(e.element.querySelector(".ck-dialog")).getVisible(),r=new ht(document.querySelector(".ck-fullscreen__editable-wrapper")).excludeScrollbarsAndBorders().getVisible().width-new ht(document.querySelector(".ck-fullscreen__editable-wrapper")).getVisible().width;if(n&&s&&o){e.position=null;const i=t?n.left-o.width-28:n.left+n.width-o.width-28+r;e.moveTo(i,s.top)}}_saveAncestorsScrollPositions(e){let t=e.parentElement;if(t)for(;t;){const e=t.style.overflowY||G.window.getComputedStyle(t).overflowY,i=t.style.overflowX||G.window.getComputedStyle(t).overflowX;("auto"===e||"scroll"===e||"auto"===i||"scroll"===i||"HTML"===t.tagName)&&this._savedAncestorsScrollPositions.set(t,{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}),t=t.parentElement}}_handleAITabsTransfer(){const e=this._editor.plugins.get("AITabs");this._aiTabsData={side:e.side,type:e.type},this.moveToFullscreen(e.view.element,"right-edge"),e.side="right",e.type="sidebar",e.view.element.addEventListener("transitionend",e=>this._handleAISidebarTransitions(e))}_handleAISidebarTransitions(e){const t=this._editor.plugins.get("AITabs");e.target===t.view.element&&e.propertyName.includes("width")&&this._adjustVisibleElements()}_restoreAITabs(){const e=this._editor.plugins.get("AITabs");e.side=this._aiTabsData?.side,e.type=this._aiTabsData?.type,this._aiTabsData=null,e.view.element.removeEventListener("transitionend",this._handleAISidebarTransitions)}_adjustVisibleElements(){const e=this._wrapper.querySelector(".ck-fullscreen__editable-wrapper");if(this._forceShowLeftSidebar)this._forceShowLeftSidebar=!1;else if(e.scrollWidth>e.clientWidth)this._hideLeftSidebar(),e.scrollWidth>e.clientWidth&&this._hideRightSidebar();else{let t=[...e.children].reduce((e,t)=>e+t.scrollWidth,0);t+this._sidebarsWidths.right<e.clientWidth&&(this._showRightSidebar(),t=[...e.children].reduce((e,t)=>e+t.scrollWidth,0)),t+this._sidebarsWidths.left<e.clientWidth&&!this._keepLeftSidebarHidden&&this._showLeftSidebar()}}_switchAnnotationsUI(e){const t=this._editor.plugins.get("AnnotationsUIs");t.deactivateAll();const i=new Map;for(const[e,n]of[...this._annotationsUIsData])n.filter!==t.defaultFilter&&i.set(e,n.filter);i.has(e)?t.activate(e,i.get(e)):i.size?t.activate(e,e=>[...i.values()].some(t=>t(e))):t.switchTo(e)}_setupResizeObserver(){const e=this._wrapper.querySelector(".ck-fullscreen__editable-wrapper");this._resizeObserver&&this._resizeObserver.destroy(),this._resizeObserver=new _t(e,()=>{this._adjustVisibleElements()})}_hideLeftSidebar(){const e=this._editor.t;if(this._collapseLeftSidebarButton){this._wrapper.querySelector(".ck-fullscreen__left-sidebar").classList.add("ck-fullscreen__left-sidebar--collapsed"),this._collapseLeftSidebarButton.icon='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M5 9.5a.5.5 0 0 0 .5-.5v-.5A.5.5 0 0 0 5 8H3.5a.5.5 0 0 0-.5.5V9a.5.5 0 0 0 .5.5zm.5 2.5a.5.5 0 0 1-.5.5H3.5A.5.5 0 0 1 3 12v-.5a.5.5 0 0 1 .5-.5H5a.5.5 0 0 1 .5.5zM5 6.5a.5.5 0 0 0 .5-.5v-.5A.5.5 0 0 0 5 5H3.5a.5.5 0 0 0-.5.5V6a.5.5 0 0 0 .5.5z"/><path d="M2 19a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2zm6-1.5h10a.5.5 0 0 0 .5-.5V3a.5.5 0 0 0-.5-.5H8zm-1.5-15H2a.5.5 0 0 0-.5.5v14a.5.5 0 0 0 .5.5h4.5z" clip-rule="evenodd"/></svg>',this._collapseLeftSidebarButton.tooltip=e("Show left sidebar")}}_showLeftSidebar(){const e=this._editor.t;if(this._collapseLeftSidebarButton){this._wrapper.querySelector(".ck-fullscreen__left-sidebar").classList.remove("ck-fullscreen__left-sidebar--collapsed"),this._collapseLeftSidebarButton.icon=_d,this._collapseLeftSidebarButton.tooltip=e("Hide left sidebar")}}_hideRightSidebar(){this._wrapper.querySelector(".ck-fullscreen__right-sidebar").firstChild&&(this._switchAnnotationsUI("narrowSidebar"),this._wrapper.querySelector(".ck-fullscreen__right-sidebar").classList.add("ck-fullscreen__right-sidebar--collapsed"))}_showRightSidebar(){this._wrapper.querySelector(".ck-fullscreen__right-sidebar").firstChild&&(this._switchAnnotationsUI("wideSidebar"),this._wrapper.querySelector(".ck-fullscreen__right-sidebar").classList.remove("ck-fullscreen__right-sidebar--collapsed"))}}class B_ extends V_{_editor;constructor(e){super(e),this._editor=e}defaultOnEnter(){const e=this._editor.ui,t=e.view;return this._editor.plugins.has("Pagination")&&this._editor.plugins.get("Pagination").isEnabled&&this.moveToFullscreen(e.getEditableElement().parentElement.querySelector(".ck-pagination-view"),"pagination-view"),this.moveToFullscreen(e.getEditableElement(),"editable"),this.moveToFullscreen(t.toolbar.element,"toolbar"),t.toolbar.switchBehavior(!0===this._editor.config.get("fullscreen.toolbar.shouldNotGroupWhenFull")?"static":"dynamic"),this.getWrapper().setAttribute("dir",t.element.getAttribute("dir")),this.getWrapper().classList.add("ck-rounded-corners"),this._editor.config.get("fullscreen.menuBar.isVisible")&&(t.menuBarView||(t.menuBarView=new Rg(this._editor.locale),t.menuBarView.render(),e.initMenuBar(t.menuBarView)),this.moveToFullscreen(t.menuBarView.element,"menu-bar")),this.getWrapper()}}class M_ extends V_{_editor;constructor(e){super(e),this._editor=e}defaultOnEnter(){return this._editor.plugins.has("Pagination")&&this._editor.plugins.get("Pagination").isEnabled&&this.moveToFullscreen(this._editor.ui.getEditableElement().parentElement.querySelector(".ck-pagination-view"),"pagination-view"),this.moveToFullscreen(this._editor.ui.getEditableElement(),"editable"),this.moveToFullscreen(this._editor.ui.view.toolbar.element,"toolbar"),this._editor.ui.view.toolbar.switchBehavior(!0===this._editor.config.get("fullscreen.toolbar.shouldNotGroupWhenFull")?"static":"dynamic"),this._editor.config.get("fullscreen.menuBar.isVisible")&&this.moveToFullscreen(this._editor.ui.view.menuBarView.element,"menu-bar"),this.getWrapper()}}class F_ extends Tc{fullscreenHandler;constructor(e){super(e),this.affectsData=!1,this.isEnabled=!0,this.value=!1,!function(e){return"ClassicEditor"===e.constructor.editorName}(e)?!function(e){return"DecoupledEditor"===e.constructor.editorName}(e)?this.fullscreenHandler=new V_(e):this.fullscreenHandler=new M_(e):this.fullscreenHandler=new B_(e)}execute(){this.value?this._disableFullscreenMode():this._enableFullscreenMode()}_enableFullscreenMode(){this.fullscreenHandler.enable(),this.value=!0}_disableFullscreenMode(){this.fullscreenHandler.disable(),this.value=!1}}class N_ extends Cc{static get pluginName(){return"FullscreenEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("fullscreen.menuBar.isVisible",!0),e.config.define("fullscreen.toolbar.shouldNotGroupWhenFull",!0===e.config.get("toolbar.shouldNotGroupWhenFull"))}init(){this.editor.commands.add("toggleFullscreen",new F_(this.editor));const e=this.editor.locale.t;this.editor.keystrokes.set("Ctrl+Shift+F",(e,t)=>{this.editor.execute("toggleFullscreen"),Q.isBlink||(this.editor.editing.view.document.isFocused=!1,this.editor.ui.view.toolbar.focusTracker.focusedElement=null),this.editor.editing.view.scrollToTheSelection(),this.editor.editing.view.focus(),t()}),this.editor.accessibility.addKeystrokeInfos({keystrokes:[{label:e("Toggle fullscreen mode"),keystroke:"CTRL+SHIFT+F"}],categoryId:"navigation"})}}const L_="toggleFullscreen";class D_ extends Cc{static get requires(){return[N_]}static get pluginName(){return"FullscreenUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("fullscreen",()=>this._createButton(rh)),e.ui.componentFactory.add("menuBar:fullscreen",()=>this._createButton(Eh))}_createButton(e){const t=this.editor,i=t.t,n=t.commands.get(L_),s=new e(t.locale);return s.set({isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value"),s instanceof Eh?s.set({role:"menuitemcheckbox",label:i("Fullscreen mode")}):(s.bind("icon").to(n,"value",e=>e?'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M15.53 5.53a.75.75 0 0 0-1.06-1.06l-2.72 2.72V5.5a.75.75 0 0 0-1.5 0V9a.75.75 0 0 0 .75.75h3.5a.75.75 0 0 0 0-1.5h-1.69zM5.5 10.25a.75.75 0 0 0 0 1.5h1.69l-2.72 2.72a.75.75 0 1 0 1.06 1.06l2.72-2.72v1.69a.75.75 0 0 0 1.5 0V11a.75.75 0 0 0-.75-.75z"/><path d="M0 2a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zm18.5 0a.5.5 0 0 0-.5-.5H2a.5.5 0 0 0-.5.5v16a.5.5 0 0 0 .5.5h16a.5.5 0 0 0 .5-.5z"/></svg>':'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M11.5 5.75a.75.75 0 0 1 0-1.5H15a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0V6.81l-2.72 2.72a.75.75 0 0 1-1.06-1.06l2.72-2.72zm-1.97 4.72a.75.75 0 0 1 0 1.06l-2.72 2.72H8.5a.75.75 0 0 1 0 1.5H5a.75.75 0 0 1-.75-.75v-3.5a.75.75 0 0 1 1.5 0v1.69l2.72-2.72a.75.75 0 0 1 1.06 0"/><path d="M2 0h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2m16 1.5H2a.5.5 0 0 0-.5.5v16a.5.5 0 0 0 .5.5h16a.5.5 0 0 0 .5-.5V2a.5.5 0 0 0-.5-.5"/></svg>'),s.bind("label").to(n,"value",e=>i(e?"Leave fullscreen mode":"Enter fullscreen mode")),s.set({tooltip:!0})),this.listenTo(s,"execute",()=>{t.execute(L_),Q.isBlink||(this.editor.ui.view.toolbar.focusTracker.focusedElement=null),t.editing.view.scrollToTheSelection(),t.editing.view.focus()}),s}}class z_ extends(Le()){total;_reader;_data;constructor(){super();const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.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,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)})}abort(){this._reader.abort()}}class H_ extends Cc{loaders=new ni;_loadersMap=new Map;_pendingAction=null;static get pluginName(){return"FileRepository"}static get isOfficialPlugin(){return!0}static get requires(){return[Gc]}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 pe("filerepository-no-upload-adapter"),null;const t=new $_(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then(e=>{this._loadersMap.set(e,t)}).catch(()=>{}),t.on("change:uploaded",()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e}),t.on("change:uploadTotal",()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e}),t}destroyLoader(e){const t=e instanceof $_?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach((e,i)=>{e===t&&this._loadersMap.delete(i)})}_updatePendingAction(){const e=this.editor.plugins.get(Gc);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}class $_ extends(Le()){id;_filePromiseWrapper;_adapter;_reader;constructor(e,t){super(),this.id=he(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new z_,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(e,t)=>t?e/t*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("idle"!=this.status)throw new fe("filerepository-read-wrong-status",this);return this.status="reading",this.file.then(e=>this._reader.read(e)).then(e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e}).catch(e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e})}upload(){if("idle"!=this.status)throw new fe("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=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e})}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&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,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then(e=>{t.isFulfilled=!0,i(e)}).catch(e=>{t.isFulfilled=!0,n(e)})}),t}}function W_(e){return e}function j_(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function U_(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>{if(!i.isInlineImageView(e))return null;if(!n)return s(e);return("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:s(e)};function s(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function q_(e,t){const i=si(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}function K_(e){return e&&e.endsWith("px")?parseInt(e):null}function G_(e){const t=K_(e.getStyle("width")),i=K_(e.getStyle("height"));return!(!t||!i)}const J_=/^(image|image-inline)$/;class Y_ extends Cc{_domEmitter=new(tt());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,n={}){const s=this.editor,o=s.model,r=o.document.selection,a=Q_(s,t||r,i);e={...Object.fromEntries(r.getAttributes()),...e};for(const t in e)o.schema.checkAttribute(a,t)||delete e[t];return o.change(i=>{const{setImageSizes:s=!0}=n,r=i.createElement(a,e);return o.insertObject(r,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==a?void 0:"auto"}),r.parent?(s&&this.setImageNaturalSizeAttributes(r),r):null})}setImageNaturalSizeAttributes(e){const t=e.getAttribute("src");t&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change(i=>{const n=new G.window.Image;this._domEmitter.listenTo(n,"load",()=>{e.getAttribute("width")||e.getAttribute("height")||this.editor.model.enqueueChange(i.batch,t=>{t.setAttribute("width",n.naturalWidth,e),t.setAttribute("height",n.naturalHeight,e)}),this._domEmitter.stopListening(n,"load")}),n.src=t}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:J_})}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){const i=Q_(e,t,null);if("imageBlock"==i){const i=function(e,t){const i=kp(e,t),n=i.start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every(e=>!e.is("element","imageBlock"))}(e)}toImageWidget(e,t,i){t.setCustomProperty("image",!0,e);return bp(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&pp(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 Q_(e,t,i){const n=e.model.schema,s=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===s?"imageInline":"auto"!==s?"imageBlock":t.is("selection")?q_(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class X_ extends Tc{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"),n=t.model,s=i.getClosestSelectedImageElement(n.document.selection);n.change(t=>{t.setAttribute("alt",e.newValue,s)})}}class Z_ extends Cc{static get requires(){return[Y_]}static get pluginName(){return"ImageTextAlternativeEditing"}static get isOfficialPlugin(){return!0}init(){this.editor.commands.add("imageTextAlternative",new X_(this.editor))}}class ev extends Uu{focusTracker;keystrokes;labeledInput;backButtonView;saveButtonView;children;_focusables;_focusCycler;constructor(e){super(e),this.focusTracker=new oi,this.keystrokes=new ci,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new pg(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new yu,this.keystrokes.set("Esc",(e,t)=>{this.fire("cancel"),t()}),this._focusCycler=new ch({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(),Zu({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 rh(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:_d,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new rh(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 lh(this.locale,{label:e("Text Alternative")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new Yh(this.locale,Tm);return t.label=e("Text alternative"),t.class="ck-labeled-field-view_full-width",t}}function tv(e){const t=e.editing.view,i=Oh.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class iv extends Cc{_balloon;_form;static get requires(){return[vg]}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 n=e.commands.get("imageTextAlternative"),s=new rh(i);return s.set({label:t("Change image text alternative"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M3.035 1C2.446 1 2 1.54 2 2.098V10.5h1.5v-8h13v8H18V2.098C18 1.539 17.48 1 16.9 1zm10.453 2.61a1.89 1.89 0 0 0-1.442.736 1.89 1.89 0 0 0 1.011 2.976 1.9 1.9 0 0 0 2.253-1.114 1.887 1.887 0 0 0-1.822-2.598M7.463 8.163a.6.6 0 0 0-.432.154L5.071 10.5h5.119L7.88 8.348a.63.63 0 0 0-.417-.185m6.236 1.059a.62.62 0 0 0-.42.164L12.07 10.5h2.969l-.92-1.113a.62.62 0 0 0-.42-.165M.91 11.5a.91.91 0 0 0-.91.912v6.877c0 .505.405.91.91.91h18.178a.91.91 0 0 0 .912-.91v-6.877a.91.91 0 0 0-.912-.912zM3.668 13h1.947l2.135 5.7H5.898l-.28-.946H3.601l-.278.945H1.516zm4.947 0h1.801v4.3h2.7v1.4h-4.5zm4.5 0h5.4v1.4h-1.798v4.3h-1.701v-4.3h-1.9zm-8.517 1.457-.614 2.059h1.262z"/></svg>',tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>!!e),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(Qu(ev))(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&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=tv(e);t.updatePosition(i)}}(e):this._hideForm(!0)}),Yu({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:tv(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 nv extends Cc{static get requires(){return[Z_,iv]}static get pluginName(){return"ImageTextAlternative"}static get isOfficialPlugin(){return!0}}function sv(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);null===i.attributeNewValue?(s.removeAttribute("srcset",r),s.removeAttribute("sizes",r)):i.attributeNewValue&&(s.setAttribute("srcset",i.attributeNewValue,r),s.setAttribute("sizes","100vw",r))};return e=>{e.on(`attribute:srcset:${t}`,i)}}function ov(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const s=n.writer,o=n.mapper.toViewElement(i.item),r=e.findViewImgElement(o);s.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on(`attribute:${i}:${t}`,n)}}class rv extends js{observe(e){this.listenTo(e,"load",(e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)},{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class av extends Tc{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&pe("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&pe("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=ei(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((t,o)=>{const r=i.getSelectedElement();if("string"==typeof t&&(t={src:t}),o&&r&&n.isImage(r)){const i=this.editor.model.createPositionAfter(r);n.insertImage({...t,...s},i,e.imageType)}else e.breakBlock?n.insertImage({...t,...s},i.getFirstPosition(),e.imageType):n.insertImage({...t,...s},null,e.imageType)})}}class lv extends Tc{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(n=>{n.setAttribute("src",e.source,t),this.cleanupImage(n,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 cv extends Cc{static get requires(){return[Y_]}static get pluginName(){return"ImageEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(rv),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new av(e),n=new lv(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class dv extends Cc{static get requires(){return[Y_]}static get pluginName(){return"ImageSizeAttributes"}static get isOfficialPlugin(){return!0}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n="imageBlock"===e?"figure":"img";function s(t,n,s,o,r=!1){t.on(`attribute:${n}:${e}`,(t,n,a)=>{if(!a.consumable.consume(n.item,t.name))return;const l=a.writer,c=a.mapper.toViewElement(n.item),d=i.findViewImgElement(c);null!==n.attributeNewValue?l.setAttribute(s,n.attributeNewValue,d):l.removeAttribute(s,d);const u=n.item.getAttribute("width"),h=n.item.getAttribute("height"),m=u&&h;if(m&&r&&l.setAttribute("loading","lazy",d),n.item.hasAttribute("sources"))return;const g=n.item.hasAttribute("resizedWidth");("imageInline"!==e||g||o)&&m&&l.setStyle("aspect-ratio",`${u}/${h}`,d)})}t.conversion.for("upcast").attributeToAttribute({view:{name:n,styles:{width:/.+/}},model:{key:"width",value:e=>G_(e)?K_(e.getStyle("width")):null}}).attributeToAttribute({view:{name:n,key:"width"},model:"width"}).attributeToAttribute({view:{name:n,styles:{height:/.+/}},model:{key:"height",value:e=>G_(e)?K_(e.getStyle("height")):null}}).attributeToAttribute({view:{name:n,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add(e=>{s(e,"width","width",!0,!0),s(e,"height","height",!0,!0)}),t.conversion.for("dataDowncast").add(e=>{s(e,"width","width",!1),s(e,"height","height",!1)}),t.conversion.for("upcast").add(e=>{e.on("element:img",(e,t,i)=>{const n=t.viewItem.getAttribute("width"),s=t.viewItem.getAttribute("height");n&&s&&i.consumable.consume(t.viewItem,{styles:["aspect-ratio"]})})})}}class uv extends Tc{_modelElementName;constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(e={}){const t=this.editor,i=this.editor.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection),o=Object.fromEntries(s.getAttributes());return o.src||o.uploadId?i.change(t=>{const{setImageSizes:r=!0}=e,a=Array.from(i.markers).filter(e=>e.getRange().containsItem(s)),l=n.insertImage(o,i.createSelection(s,"on"),this._modelElementName,{setImageSizes:r});if(!l)return null;const c=t.createRangeOn(l);for(const e of a){const i=e.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(c,!0):c;t.updateMarker(e,{range:n})}return{oldElement:s,newElement:l}}):null}}class hv extends Cc{static get requires(){return[Y_]}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(e=>{e.on("attribute:placeholder",(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;if(!t.item.is("element","imageBlock")&&!t.item.is("element","imageInline"))return;n.consumable.consume(t.item,e.name);const s=n.writer,o=n.mapper.toViewElement(t.item),r=i.findViewImgElement(o);t.attributeNewValue?(s.addClass("image_placeholder",r),s.setStyle("background-image",`url(${t.attributeNewValue})`,r),s.setCustomProperty("editingPipeline:doNotReuseOnce",!0,r)):(s.removeClass("image_placeholder",r),s.removeStyle("background-image",r))})})}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,n=i.view,s=e.plugins.get("ImageUtils");n.addObserver(rv),this.listenTo(n.document,"imageLoaded",(e,o)=>{const r=n.domConverter.mapDomToView(o.target);if(!r)return;const a=s.getImageWidgetFromImageView(r);if(!a)return;const l=i.mapper.toModelElement(a);l&&l.hasAttribute("placeholder")&&t.enqueueChange({isUndoable:!1},e=>{e.removeAttribute("placeholder",l)})})}}class mv extends Cc{static get requires(){return[cv,dv,Y_,hv,Zp]}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 uv(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>j_(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(j_(i),i,t("image widget"))}),i.for("downcast").add(ov(n,"imageBlock","src")).add(ov(n,"imageBlock","alt")).add(sv(n,"imageBlock")),i.for("upcast").elementToElement({view:U_(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(function(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const s=e.findViewImgElement(i.viewItem);if(!s||!n.consumable.test(s,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const o=si(n.convertItem(s,i.modelCursor).modelRange.getItems());o?(n.convertChildren(i.viewItem,o),n.updateConversionResult(o,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isInlineImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===q_(t.schema,l)){const e=new hl(i.document),t=r.map(t=>e.createElement("figure",{class:"image"},t));o.content=e.createDocumentFragment(t)}}),this.listenTo(s,"contentInsertion",(e,i)=>{"paste"===i.method&&t.change(e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageBlock")&&n.setImageNaturalSizeAttributes(e)})})}}class gv extends Uu{focusTracker;keystrokes;_focusables;_focusCycler;children;constructor(e,t=[]){super(e),this.focusTracker=new oi,this.keystrokes=new ci,this._focusables=new yu,this.children=this.createCollection(),this._focusCycler=new ch({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const e of t)this.children.add(e),this._focusables.add(e),e instanceof $h&&this._focusables.addMany(e.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),Zu({view:this});for(const e of this._focusables)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element);const e=e=>e.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 fv extends Cc{static get pluginName(){return"ImageInsertUI"}static get isOfficialPlugin(){return!0}static get requires(){return[Y_]}dropdownView;_integrations=new Map;constructor(e){super(e),e.config.define("image.insert.integrations",["upload","assetManager","url"])}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 n=e=>this._createToolbarComponent(e);e.ui.componentFactory.add("insertImage",n),e.ui.componentFactory.add("imageInsert",n),e.ui.componentFactory.add("menuBar:insertImage",e=>this._createMenuBarComponent(e))}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:n,menuBarButtonViewCreator:s,requiresForm:o=!1,override:r=!1}){this._integrations.has(e)&&!r&&pe("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,menuBarButtonViewCreator:s,formViewCreator:n,requiresForm:o})}_createToolbarComponent(e){const t=this.editor,i=e.t,n=this._prepareIntegrations();if(!n.length)return null;let s;const o=n[0];if(1==n.length){if(!o.requiresForm)return o.buttonViewCreator(!0);s=o.buttonViewCreator(!0)}else{const t=o.buttonViewCreator(!1);s=new pm(e,t),s.tooltip=!0,s.bind("label").to(this,"isImageSelected",e=>i(e?"Replace image":"Insert image"))}const r=this.dropdownView=bm(e,s),a=n.map(({observable:e})=>"function"==typeof e?e():e);return r.bind("isEnabled").toMany(a,"isEnabled",(...e)=>e.some(e=>e)),r.once("change:isOpen",()=>{const e=n.flatMap(({formViewCreator:e})=>e(1==n.length)),i=new gv(t.locale,e);r.panelView.children.add(i)}),r}_createMenuBarComponent(e){const t=e.t,i=this._prepareIntegrations();if(!i.length)return null;const n=i.flatMap(({menuBarButtonViewCreator:e})=>e(1==i.length)),s=new xg(e),o=new Pg(e);s.panelView.children.add(o),s.buttonView.set({icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M6.66 9.118a.693.693 0 0 1 .956.032l3.65 3.411 2.422-2.238a.695.695 0 0 1 .945 0L17.5 13.6V2.5h-15v11.1zM17.8 1c.652 0 1.2.47 1.2 1.1v14.362c0 .64-.532 1.038-1.184 1.038H2.184C1.532 17.5 1 17.103 1 16.462V2.1C1 1.47 1.537 1 2.2 1zm-5.655 6a2.13 2.13 0 0 1 .157-2.364A2.133 2.133 0 1 1 12.145 7"/></svg>',label:t("Image")});for(const t of n){const i=new Km(e,s);i.children.add(t),o.items.add(i),t.delegate("execute").to(s)}return s}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return pe("image-insert-integrations-not-specified"),t;for(const i of e)this._integrations.has(i)?t.push(this._integrations.get(i)):["upload","assetManager","url"].includes(i)||pe("image-insert-unknown-integration",{item:i});return t.length||pe("image-insert-integrations-not-registered"),t}}class pv extends Cc{static get requires(){return[mv,Mp,nv,fv]}static get pluginName(){return"ImageBlock"}static get isOfficialPlugin(){return!0}}class bv extends Cc{static get requires(){return[cv,dv,Y_,hv,Zp]}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 uv(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(i),i,t("image widget"))}),i.for("downcast").add(ov(n,"imageInline","src")).add(ov(n,"imageInline","alt")).add(sv(n,"imageInline")),i.for("upcast").elementToElement({view:U_(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(s,o)=>{const r=Array.from(o.content.getChildren());let a;if(!r.every(n.isBlockImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===q_(t.schema,l)){const e=new hl(i.document),t=r.map(t=>1===t.childCount?(Array.from(t.getAttributes()).forEach(i=>e.setAttribute(...i,n.findViewImgElement(t))),t.getChild(0)):t);o.content=e.createDocumentFragment(t)}}),this.listenTo(s,"contentInsertion",(e,i)=>{"paste"===i.method&&t.change(e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageInline")&&n.setImageNaturalSizeAttributes(e)})})}}class wv extends Cc{static get requires(){return[bv,Mp,nv,fv]}static get pluginName(){return"ImageInline"}static get isOfficialPlugin(){return!0}}class _v extends Cc{static get pluginName(){return"ImageCaptionUtils"}static get isOfficialPlugin(){return!0}static get requires(){return[Y_]}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"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class vv extends Tc{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(mv))return this.isEnabled=!1,void(this.value=!1);const n=e.model.document.selection,s=n.getSelectedElement();if(!s){const e=t.getCaptionFromModelSelection(n);return this.isEnabled=!!e,void(this.value=!!e)}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(e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)})}_showImageCaption(e,t){const i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageCaptionEditing"),s=this.editor.plugins.get("ImageUtils");let o=i.getSelectedElement();const r=n._getSavedCaption(o);s.isInlineImage(o)&&(this.editor.execute("imageTypeBlock"),o=i.getSelectedElement());const a=r||e.createElement("caption");e.append(a,o),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),s=t.plugins.get("ImageCaptionUtils");let o,r=i.getSelectedElement();r?o=s.getCaptionFromImageModelElement(r):(o=s.getCaptionFromModelSelection(i),r=o.parent),n._saveCaption(r,o),e.setSelection(r,"on"),e.remove(o)}}class yv extends Cc{static get requires(){return[Y_,_v]}static get pluginName(){return"ImageCaptionEditing"}static get isOfficialPlugin(){return!0}_savedCaptionsMap;constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new vv(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),s=e.t;e.conversion.for("upcast").elementToElement({view:e=>n.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>i.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:n})=>{if(!i.isBlockImage(e.parent))return null;const o=n.createEditableElement("figcaption");n.setCustomProperty("imageCaption",!0,o),o.placeholder=s("Enter image caption"),sn({view:t,element:o,keepOnFocus:!0});const r=e.parent.getAttribute("alt");return yp(o,n,{label:r?s("Caption for image: %0",[r]):s("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),s=e.commands.get("imageTypeBlock"),o=e=>{if(!e.return)return;const{oldElement:n,newElement:s}=e.return;if(!n)return;if(t.isBlockImage(n)){const e=i.getCaptionFromImageModelElement(n);if(e)return void this._saveCaption(s,e)}const o=this._getSavedCaption(n);o&&this._saveCaption(s,o)};n&&this.listenTo(n,"execute",o,{priority:"low"}),s&&this.listenTo(s,"execute",o,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?$o.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"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",()=>{const s=t.document.differ.getChanges();for(const t of s){if("alt"!==t.attributeKey)continue;const s=t.range.start.nodeAfter;if(i.isBlockImage(s)){const t=n.getCaptionFromImageModelElement(s);if(!t)return;e.editing.reconvertItem(t)}}})}}class kv extends Cc{static get requires(){return[_v]}static get pluginName(){return"ImageCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),n=e.t;e.ui.componentFactory.add("toggleImageCaption",s=>{const o=e.commands.get("toggleImageCaption"),r=new rh(s);return r.set({icon:id,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.bind("label").to(o,"value",e=>n(e?"Toggle caption off":"Toggle caption on")),this.listenTo(r,"execute",()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const n=i.getCaptionFromModelSelection(e.model.document.selection);if(n){const i=e.editing.mapper.toViewElement(n);t.scrollToTheSelection(),t.change(e=>{e.addClass("image__caption_highlighted",i)})}e.editing.view.focus()}),r})}}function Cv(e){const t=e.map(e=>e.replace("+","\\+"));return new RegExp(`^image\\/(${t.join("|")})$`)}function Av(e){return new Promise((t,i)=>{const n=e.getAttribute("src");fetch(n).then(e=>e.blob()).then(e=>{const i=Tv(e,n),s=i.replace("image/",""),o=new File([e],`image.${s}`,{type:i});t(o)}).catch(e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise((t,i)=>{const n=G.document.createElement("img");n.addEventListener("load",()=>{const e=G.document.createElement("canvas");e.width=n.width,e.height=n.height;e.getContext("2d").drawImage(n,0,0),e.toBlob(e=>e?t(e):i())}),n.addEventListener("error",()=>i()),n.src=e})}(e).then(t=>{const i=Tv(t,e),n=i.replace("image/","");return new File([t],`image.${n}`,{type:i})})}(n).then(t).catch(i):i(e))})}function Tv(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class Ev extends Cc{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:e=>this._createMenuBarButton(e?"insertOnly":"insertNested")})}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("uploadImage"),s=t.config.get("image.upload.types"),o=Cv(s),r=new e(t.locale),a=i.t;return r.set({acceptedType:s.map(e=>`image/${e}`).join(","),allowMultipleFiles:!0,label:a("Upload from computer"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M1.201 1C.538 1 0 1.47 0 2.1v14.363c0 .64.534 1.037 1.186 1.037h9.494a3 3 0 0 1-.414-.287 3 3 0 0 1-1.055-2.03 3 3 0 0 1 .693-2.185l.383-.455-.02.018-3.65-3.41a.695.695 0 0 0-.957-.034L1.5 13.6V2.5h15v5.535a2.97 2.97 0 0 1 1.412.932l.088.105V2.1c0-.63-.547-1.1-1.2-1.1zm11.713 2.803a2.146 2.146 0 0 0-2.049 1.992 2.14 2.14 0 0 0 1.28 2.096 2.13 2.13 0 0 0 2.644-3.11 2.13 2.13 0 0 0-1.875-.978"/><path d="M15.522 19.1a.79.79 0 0 0 .79-.79v-5.373l2.059 2.455a.79.79 0 1 0 1.211-1.015l-3.352-3.995a.79.79 0 0 0-.995-.179.8.8 0 0 0-.299.221l-3.35 3.99a.79.79 0 1 0 1.21 1.017l1.936-2.306v5.185c0 .436.353.79.79.79"/><path d="M15.522 19.1a.79.79 0 0 0 .79-.79v-5.373l2.059 2.455a.79.79 0 1 0 1.211-1.015l-3.352-3.995a.79.79 0 0 0-.995-.179.8.8 0 0 0-.299.221l-3.35 3.99a.79.79 0 1 0 1.21 1.017l1.936-2.306v5.185c0 .436.353.79.79.79"/></svg>'}),r.bind("isEnabled").to(n),r.on("done",(e,i)=>{const n=Array.from(i).filter(e=>o.test(e.type));n.length&&(t.execute("uploadImage",{file:n}),t.editing.view.focus())}),r}_createToolbarButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this.editor.commands.get("uploadImage"),n=this._createButton(Lh);return n.tooltip=!0,n.bind("label").to(t,"isImageSelected",i,"isAccessAllowed",(t,i)=>e(i?t?"Replace image from computer":"Upload image from computer":"You have no image upload permissions.")),n}_createDropdownButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this._createButton(Lh);return i.withText=!0,i.bind("label").to(t,"isImageSelected",t=>e(t?"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(Ig);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")}return i}}class xv extends Cc{static get pluginName(){return"ImageUploadProgress"}static get isOfficialPlugin(){return!0}placeholder;constructor(e){super(e),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}uploadStatusChange=(e,t,i)=>{const n=this.editor,s=t.item,o=s.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(H_),l=o?t.attributeNewValue:null,c=this.placeholder,d=n.editing.mapper.toViewElement(s),u=i.writer;if("reading"==l)return Pv(d,u),void Sv(r,c,d,u);if("uploading"==l){const e=a.loaders.get(o);return Pv(d,u),void(e?(Iv(d,u),function(e,t,i,n){const s=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),s),i.on("change:uploadedPercent",(e,t,i)=>{n.change(e=>{e.setStyle("width",i+"%",s)})})}(d,u,e,n.editing.view),function(e,t,i,n){if(n.data){const s=e.findViewImgElement(t);i.setAttribute("src",n.data,s)}}(r,d,u,e)):Sv(r,c,d,u))}"complete"==l&&a.loaders.get(o)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout(()=>{i.change(e=>e.remove(e.createRangeOn(n)))},3e3)}(d,u,n.editing.view),function(e,t){Rv(e,t,"progressBar")}(d,u),Iv(d,u),function(e,t){t.removeClass("ck-appear",e)}(d,u)}}function Pv(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function Sv(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const s=e.findViewImgElement(i);s.getAttribute("src")!==t&&n.setAttribute("src",t,s),Ov(i,"placeholder")||n.insert(n.createPositionAfter(s),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function Iv(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),Rv(e,t,"placeholder")}function Ov(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function Rv(e,t,i){const n=Ov(e,i);n&&t.remove(t.createRangeOn(n))}class Vv extends Tc{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=ei(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((e,t)=>{const o=i.getSelectedElement();if(t&&o&&n.isImage(o)){const t=this.editor.model.createPositionAfter(o);this._uploadImage(e,s,t)}else this._uploadImage(e,s)})}_uploadImage(e,t,i){const n=this.editor,s=n.plugins.get(H_).createLoader(e),o=n.plugins.get("ImageUtils");s&&o.insertImage({...t,uploadId:s.id},i)}}class Bv extends Cc{static get requires(){return[H_,bg,Zp,Y_]}static get pluginName(){return"ImageUploadEditing"}static get isOfficialPlugin(){return!0}_uploadImageElements;_uploadedImages=new Map;constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(H_),s=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline"),r=Cv(e.config.get("image.upload.types")),a=new Vv(e);e.commands.add("uploadImage",a),e.commands.add("imageUpload",a),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}).add(e=>e.on("element:img",(e,t,i)=>{if(!i.consumable.test(t.viewItem,{attributes:["data-ck-upload-id"]}))return;const s=t.viewItem.getAttribute("data-ck-upload-id");if(!s)return;const[o]=Array.from(t.modelRange.getItems({shallow:!0})),r=n.loaders.get(s);o&&(i.writer.setAttribute("uploadId",s,o),i.consumable.consume(t.viewItem,{attributes:["data-ck-upload-id"]}),r&&r.data&&i.writer.setAttribute("uploadStatus",r.status,o))},{priority:"low"})),this.listenTo(e.editing.view.document,"clipboardInput",(t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const s=Array.from(i.dataTransfer.files).filter(e=>!!e&&r.test(e.type));if(!s.length)return;t.stop(),e.model.change(t=>{i.targetRanges&&t.setSelection(i.targetRanges.map(t=>e.editing.mapper.toModelRange(t))),e.execute("uploadImage",{file:s})});if(!e.commands.get("uploadImage").isAccessAllowed){const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("You have no image upload permissions."),{namespace:"image"})}}),this.listenTo(o,"inputTransformation",(t,i)=>{const o=Array.from(e.editing.view.createRangeIn(i.content)).map(e=>e.item).filter(e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src")||!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)&&!t.getAttribute("src").match(/^blob:/g))}(s,e)&&!e.getAttribute("uploadProcessed")).map(e=>({promise:Av(e),imageElement:e}));if(!o.length)return;const r=new hl(e.editing.view.document);for(const e of o){r.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(r.setAttribute("src","",e.imageElement),r.setAttribute("uploadId",t.id,e.imageElement))}}),e.editing.view.document.on("dragover",(e,t)=>{t.preventDefault()}),t.on("change",()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),s=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,o="$graveyard"==t.position.root.rootName;for(const t of Mv(e,i)){const i=t.getAttribute("uploadId"),r=t.getAttribute("uploadStatus");if(!i||"complete"==r)continue;const a=n.loaders.get(i);if(a)if(o){if(!s.has(i)){Array.from(this._uploadImageElements.get(i)).every(e=>"$graveyard"==e.root.rootName)&&a.abort()}}else s.add(i),this._uploadImageElements.has(i)?this._uploadImageElements.get(i).add(t):this._uploadImageElements.set(i,new Set([t])),"idle"==a.status&&this._readAndUpload(a);else!o&&this._uploadedImages.has(i)&&e.model.enqueueChange({isUndoable:!1},e=>{e.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:this._uploadedImages.get(i),imageElement:t})})}}}),this.on("uploadComplete",(e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change(e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e),s.setImageNaturalSizeAttributes(t)})},{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,n=t.locale.t,s=t.plugins.get(H_),o=t.plugins.get(bg),r=t.plugins.get("ImageUtils"),a=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},t=>{const i=a.get(e.id);for(const e of i)t.setAttribute("uploadStatus","reading",e)}),e.read().then(()=>{const s=e.upload();t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Uploading image"));for(const n of a.get(e.id)){if(Q.isSafari){const e=t.editing.mapper.toViewElement(n),i=r.findViewImgElement(e);t.editing.view.once("render",()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n})}i.enqueueChange({isUndoable:!1},e=>{e.setAttribute("uploadStatus","uploading",n)})}return s}).then(s=>{i.enqueueChange({isUndoable:!1},i=>{for(const t of a.get(e.id))i.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:s,imageElement:t});t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Image upload complete")),this._uploadedImages.set(e.id,s)}),l()}).catch(s=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Error during image upload")),"error"!==e.status&&"aborted"!==e.status)throw s;"error"==e.status&&s&&o.showWarning(s,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},t=>{for(const i of a.get(e.id))"$graveyard"!==i.root.rootName&&t.remove(i)}),l()});function l(){i.enqueueChange({isUndoable:!1},t=>{for(const i of a.get(e.id))t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i);a.delete(e.id)}),s.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const s=Object.keys(e).filter(e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0}).map(t=>`${e[t]} ${t}w`).join(", ");if(""!=s){const e={srcset:s};t.hasAttribute("width")||t.hasAttribute("height")||(e.width=n),i.setAttributes(e,t)}}_registerConverters(e){const{conversion:t,plugins:i}=this.editor,n=i.get(H_),s=i.get(Y_);t.for("dataDowncast").add(t=>{t.on(`attribute:uploadId:${e}`,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const o=n.loaders.get(t.attributeNewValue);if(!o||!o.data)return null;const r=i.mapper.toViewElement(t.item),a=s.findViewImgElement(r);a&&(i.consumable.consume(t.item,e.name),i.writer.setAttribute("data-ck-upload-id",o.id,a))})})}}function Mv(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter(e=>i.isImage(e.item)).map(e=>e.item)}class Fv extends Cc{static get pluginName(){return"ImageUpload"}static get isOfficialPlugin(){return!0}static get requires(){return[Bv,Ev,xv]}}class Nv extends Tc{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,t&&t.hasAttribute("resizedWidth")?this.value={width:t.getAttribute("resizedWidth"),height:null}:this.value=null}execute(e){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils"),s=n.getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},s&&i.change(t=>{t.setAttribute("resizedWidth",e.width,s),t.removeAttribute("resizedHeight",s),n.setImageNaturalSizeAttributes(s)})}}class Lv extends Cc{static get requires(){return[Y_]}static get pluginName(){return"ImageResizeEditing"}static get licenseFeatureCode(){return"IR"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){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 Nv(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),e.setAttributeProperties("resizedWidth",{isFormatting:!0}),e.setAttributeProperties("resizedHeight",{isFormatting:!0})),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]}),e.setAttributeProperties("resizedWidth",{isFormatting:!0}),e.setAttributeProperties("resizedHeight",{isFormatting:!0}))}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add(t=>t.on(`attribute:resizedWidth:${e}`,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,s=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,s),n.addClass("image_resized",s)):(n.removeStyle("width",s),n.removeClass("image_resized",s))})),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:e=>({key:"style",value:{height:e}})}),t.conversion.for("editingDowncast").add(t=>t.on(`attribute:resizedHeight:${e}`,(t,n,s)=>{if(!s.consumable.consume(n.item,t.name))return;const o=s.writer,r=s.mapper.toViewElement(n.item),a="imageInline"===e?i.findViewImgElement(r):r;null!==n.attributeNewValue?o.setStyle("height",n.attributeNewValue,a):o.removeStyle("height",a)})),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:e=>G_(e)?null:e.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:e=>G_(e)?null:e.getStyle("height")}}),t.conversion.for("upcast").add(t=>{t.on("element:"+("imageBlock"===e?"figure":"img"),(e,t,i)=>{i.consumable.consume(t.viewItem,{classes:["image_resized"]})})})}}const Dv=(()=>({small:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 16.5v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zM1 15v1H0v-1zm19 0v1h-1v-1zM1 13v1H0v-1zm19 0v1h-1v-1zM1 11v1H0v-1zm19 0v1h-1v-1zM1 9v1H0V9zm19 0v1h-1V9zM1 7v1H0V7zm19 0v1h-1V7zM1 5v1H0V5zm19 0v1h-1V5zm0-2v1h-1V3zM1 3v1H0V3zm13.5-1.5v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm-8 0v1h-1v-1zm-2 0v1h-1v-1zm-2 0v1h-1v-1zm-2 0v1h-1v-1zm8 0v1h-1v-1zm-10 0v1h-1v-1z"/><path d="M7 9.5H2a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h5a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2M7 11a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-4A.5.5 0 0 1 2 11z"/></svg>',medium:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 16.5v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zM1 15v1H0v-1zm19 0v1h-1v-1zM1 13v1H0v-1zm19 0v1h-1v-1zM1 11v1H0v-1zm19 0v1h-1v-1zM1 9v1H0V9zm19 0v1h-1V9zM1 7v1H0V7zm19 0v1h-1V7zM1 5v1H0V5zm19 0v1h-1V5zm0-2v1h-1V3zM1 3v1H0V3zm13.5-1.5v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm-8 0v1h-1v-1zm-2 0v1h-1v-1zm-2 0v1h-1v-1zm-2 0v1h-1v-1zm8 0v1h-1v-1zm-10 0v1h-1v-1z"/><path d="M10 7.5H2a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-6a2 2 0 0 0-2-2M10 9a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-6A.5.5 0 0 1 2 9z"/></svg>',large:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 16.5v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zM1 15v1H0v-1zm19 0v1h-1v-1zM1 13v1H0v-1zm19 0v1h-1v-1zM1 11v1H0v-1zm19 0v1h-1v-1zM1 9v1H0V9zm19 0v1h-1V9zM1 7v1H0V7zm19 0v1h-1V7zM1 5v1H0V5zm19 0v1h-1V5zm0-2v1h-1V3zM1 3v1H0V3zm13.5-1.5v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm-8 0v1h-1v-1zm-2 0v1h-1v-1zm-2 0v1h-1v-1zm-2 0v1h-1v-1zm8 0v1h-1v-1zm-10 0v1h-1v-1z"/><path d="M13 5.5H2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-8a2 2 0 0 0-2-2M13 7a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5H2a.5.5 0 0 1-.5-.5v-8A.5.5 0 0 1 2 7z"/></svg>',custom:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M.95 1.43a.95.95 0 0 0-.95.95v3.1a.95.95 0 0 0 .95.95h.75v6.3H.95a.95.95 0 0 0-.95.95v3.1a.95.95 0 0 0 .95.95h3.1a.95.95 0 0 0 .95-.95v-.65h1.932l1.539-1.5H5v-.95a.95.95 0 0 0-.95-.95H3.2v-6.3h.85A.95.95 0 0 0 5 5.48v-.55h10v.55a.95.95 0 0 0 .95.95h3.1a.95.95 0 0 0 .95-.95v-3.1a.95.95 0 0 0-.95-.95h-3.1a.95.95 0 0 0-.95.95v1.05H5V2.38a.95.95 0 0 0-.95-.95zm.55 3.5v-2h2v2zm0 9.3v2h2v-2zm15-11.3v2h2v-2zM8.139 20.004v-2.388l7.045-7.048 2.391 2.391-7.046 7.046zm11.421-9.101a.6.6 0 0 1-.138.206l-1.165 1.168-2.391-2.391 1.167-1.163a.6.6 0 0 1 .206-.138.6.6 0 0 1 .243-.049.63.63 0 0 1 .449.187l1.491 1.488c.059.059.108.129.138.206s.049.16.049.243a.6.6 0 0 1-.049.243"/></svg>',original:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zm2 0v1h-1v-1zM1 15.5v1H0v-1zm19 0v1h-1v-1zm-19-2v1H0v-1zm19 0v1h-1v-1zm-19-2v1H0v-1zm19 0v1h-1v-1zm-19-2v1H0v-1zm19 0v1h-1v-1zm-19-2v1H0v-1zm19 0v1h-1v-1zm-19-2v1H0v-1zm19 0v1h-1v-1zm0-2v1h-1v-1zm-19 0v1H0v-1zM14.5 2v1h-1V2zm2 0v1h-1V2zm2 0v1h-1V2zm-8 0v1h-1V2zm-2 0v1h-1V2zm-2 0v1h-1V2zm-2 0v1h-1V2zm8 0v1h-1V2zm-10 0v1h-1V2z"/><path d="M18.095 2H1.905C.853 2 0 2.895 0 4v12c0 1.105.853 2 1.905 2h16.19C19.147 18 20 17.105 20 16V4c0-1.105-.853-2-1.905-2m0 1.5c.263 0 .476.224.476.5v12c0 .276-.213.5-.476.5H1.905a.49.49 0 0 1-.476-.5V4c0-.276.213-.5.476-.5z"/></svg>'}))();class zv extends Cc{static get requires(){return[Lv]}static get pluginName(){return"ImageResizeButtons"}static get isOfficialPlugin(){return!0}_resizeUnit;constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:s}=e;t.ui.componentFactory.add(i,i=>{const o=new rh(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!Dv[s])throw new fe("imageresizebuttons-missing-icon",t,e);if(o.set({label:a,icon:Dv[s],tooltip:a,isToggleable:!0}),o.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&Hv(e)){const e=t.plugins.get("ImageCustomResizeUI");this.listenTo(o,"execute",()=>{e._showForm(this._resizeUnit)})}else{const e=n?n+this._resizeUnit:null;o.bind("isOn").to(r,"value",r,"isEnabled",$v(e)),this.listenTo(o,"execute",()=>{t.execute("resizeImage",{width:e})})}return o})}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find(e=>!e.value),s=s=>{const o=t.commands.get("resizeImage"),r=bm(s,nm),a=r.buttonView,l=i("Resize image");return a.set({tooltip:l,commandValue:n.value,icon:Dv.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(o,"value",e=>e&&e.width?e.width:this._getOptionLabelValue(n)),r.bind("isEnabled").to(this),vm(r,()=>this._getResizeDropdownListItemDefinitions(e,o),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(r,"execute",e=>{"onClick"in e.source?e.source.onClick():(t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus())}),r};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?Hv(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):Hv(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,n=new ni,s=e.map(e=>Hv(e)?{...e,valueWithUnits:"custom"}:e.value?{...e,valueWithUnits:`${e.value}${this._resizeUnit}`}:{...e,valueWithUnits:null});for(const e of s){let o=null;if(i.plugins.has("ImageCustomResizeUI")&&Hv(e)){const n=i.plugins.get("ImageCustomResizeUI");o={type:"button",model:new wg({label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{n._showForm(this._resizeUnit)}})};const r=Object.values(s).map(e=>e.valueWithUnits);o.model.bind("isOn").to(t,"value",t,"isEnabled",Wv(r))}else o={type:"button",model:new wg({commandName:"resizeImage",commandValue:e.valueWithUnits,label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null})},o.model.bind("isOn").to(t,"value",t,"isEnabled",$v(e.valueWithUnits));o.model.bind("isEnabled").to(t,"isEnabled"),n.add(o)}return n}}function Hv(e){return"custom"===e.value}function $v(e){return(t,i)=>!(void 0===t||!i)&&(null===e&&t===e||null!==t&&t.width===e)}function Wv(e){return(t,i)=>!e.some(e=>$v(e)(t,i))}const jv="image_resized";class Uv extends Cc{static get requires(){return[Up,Y_]}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(rv),this.listenTo(t.document,"imageLoaded",(n,s)=>{if(!s.target.matches("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"))return;const o=e.editing.view.domConverter,r=o.domToView(s.target),a=i.getImageWidgetFromImageView(r);let l=this.editor.plugins.get(Up).getResizerByViewElement(a);if(l)return void l.redraw();const c=e.editing.mapper,d=c.toModelElement(a);l=e.plugins.get(Up).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:d,viewElement:a,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>o.mapViewToDom(c.toViewElement(d)),isCentered:()=>"alignCenter"==d.getAttribute("imageStyle"),onCommit(i){t.change(e=>{e.removeClass(jv,a)}),e.execute("resizeImage",{width:i})}}),l.on("updateSize",()=>{a.hasClass(jv)||t.change(e=>{e.addClass(jv,a)});const e="imageInline"===d.name?r:a;e.getStyle("height")&&t.change(t=>{t.removeStyle("height",e)})}),l.bind("isEnabled").to(this)})}}function qv(e){if(!e)return null;const[,t,i]=e.trim().match(/([.,\d]+)(%|px)$/)||[],n=Number.parseFloat(t);return Number.isNaN(n)?null:{value:n,unit:i}}function Kv(e,t,i){return"px"===i?{value:t.value,unit:"px"}:{value:t.value/e*100,unit:"%"}}function Gv(e){const{editing:t}=e,i=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);if(!i)return null;const n=t.mapper.toViewElement(i);return{model:i,view:n,dom:t.view.domConverter.mapViewToDom(n)}}class Jv extends Uu{focusTracker;keystrokes;unit;backButtonView;saveButtonView;labeledInput;children;_focusables;_focusCycler;_validators;constructor(e,t,i){super(e),this.focusTracker=new oi,this.keystrokes=new ci,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 pg(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new yu,this._validators=i,this.keystrokes.set("Esc",(e,t)=>{this.fire("cancel"),t()}),this._focusCycler=new ch({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(),Zu({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 rh(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:_d,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new rh(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 lh(this.locale,{label:e("Image Resize")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new Yh(this.locale,Em);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(null===e)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return null===e?null:`${e}${t}`}}class Yv extends Cc{_balloon;_form;static get requires(){return[vg]}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(Qu(Jv))(t.locale,e,function(e){const t=e.t;return[e=>""===e.rawSize.trim()?t("The value must not be empty."):null===e.parsedSize?t("The value should be a plain number."):void 0]}(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)}),Yu({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:tv(t)});const n=function(e,t){const i=Gv(e);if(!i)return null;const n=qv(i.model.getAttribute("resizedWidth")||null);return n?n.unit===t?n:Kv(Ap(i.dom),{value:new ht(i.dom).width},t):null}(t,e),s=n?n.value.toFixed(1):"",o=function(e,t){const i=Gv(e);if(!i)return null;const n=Ap(i.dom),s=qv(window.getComputedStyle(i.dom).minWidth)||{value:1};return{unit:t,lower:Math.max(.1,Kv(n,s,t).value),upper:"px"===t?n:100}}(t,e);i.fieldView.value=i.fieldView.element.value=s,o&&Object.assign(i.fieldView,{min:o.lower.toFixed(1),max:Math.ceil(o.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)}}class Qv extends Tc{_defaultStyles;_styles;constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map(e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]}))}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,n=t.plugins.get("ImageUtils");i.change(t=>{const s=e.value,{setImageSizes:o=!0}=e;let r=n.getClosestSelectedImageElement(i.document.selection);s&&this.shouldConvertImageType(s,r)&&(this.editor.execute(n.isBlockImage(r)?"imageTypeInline":"imageTypeBlock",{setImageSizes:o}),r=n.getClosestSelectedImageElement(i.document.selection)),!s||this._styles.get(s).isDefault?t.removeAttribute("imageStyle",r):t.setAttribute("imageStyle",s,r),o&&n.setImageNaturalSizeAttributes(r)})}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const Xv={get inline(){return{name:"inline",title:"In line",icon:fd,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:md,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:pd,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:hd,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:gd,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:bd,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:hd,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:gd,modelElements:["imageBlock"],className:"image-style-side"}}},Zv=(()=>({full:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2 3h16v1.5H2zm0 12h16v1.5H2z" opacity=".5"/><path d="M18 7v5.5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1m-1.505.5H3.504V12h12.991z"/></svg>',left:pd,right:bd,center:hd,inlineLeft:md,inlineRight:gd,inline:fd}))(),ey=[{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 ty(e){pe("image-style-configuration-definition-invalid",e)}const iy={normalizeStyles:function(e){const t=(e.configuredStyles.options||[]).map(e=>function(e){e="string"==typeof e?Xv[e]?{...Xv[e]}:{name:e}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(Xv[e.name],e);"string"==typeof e.icon&&(e.icon=Zv[e.icon]||e.icon);return e}(e)).filter(t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:s}=e;if(!(n&&n.length&&s))return ty({style:e}),!1;{const s=[t?"imageBlock":null,i?"imageInline":null];if(!n.some(e=>s.includes(e)))return pe("image-style-missing-dependency",{style:e,missingPlugins:n.map(e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing")}),!1}return!0}(t,e));return t},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...ey]:[]},warnInvalidStyle:ty};function ny(e){const t={imageInline:e.filter(e=>!e.isDefault&&e.modelElements.includes("imageInline")),imageBlock:e.filter(e=>!e.isDefault&&e.modelElements.includes("imageBlock"))};return(i,n,s)=>{if(!n.modelRange)return;const o=n.viewItem,r=si(n.modelRange.getItems());if(r&&s.schema.checkAttribute(r,"imageStyle")){for(const e of t[r.name])s.consumable.consume(o,{classes:e.className})&&s.writer.setAttribute("imageStyle",e.name,r);!function(e,t,i,n){if(!e.consumable.test(t,{styles:["float"]}))return;let s=null;switch(t.getStyle("float")){case"left":s="alignLeft";break;case"right":s="alignRight"}if(!s)return;const o=sy(s,n);if(!o)return;const r=Xv[o.name];if(!Xi(o,r))return;e.writer.setAttribute("imageStyle",s,i),e.consumable.consume(t,{styles:["float"]})}(s,o,r,e)}}}function sy(e,t){for(const i of t)if(i.name===e)return i}class oy extends Cc{static get pluginName(){return"ImageStyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Y_]}normalizedStyles;init(){const e=this.editor,t=e.plugins.has("ImageBlockEditing"),i=e.plugins.has("ImageInlineEditing");e.config.define("image.styles",iy.getDefaultStylesConfiguration(t,i)),this.normalizedStyles=iy.normalizeStyles({configuredStyles:e.config.get("image.styles"),isBlockPluginLoaded:t,isInlinePluginLoaded:i}),this._setupConversion(t,i),this._setupPostFixer(),e.commands.add("imageStyle",new Qv(e,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,s=(o=this.normalizedStyles,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=sy(t.attributeNewValue,o),s=sy(t.attributeOldValue,o),r=i.mapper.toViewElement(t.item),a=i.writer;s&&a.removeClass(s.className,r),n&&a.addClass(n.className,r)});var o;const r=ny(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",s),i.data.downcastDispatcher.on("attribute:imageStyle",s),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),n.setAttributeProperties("imageStyle",{isFormatting:!0}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),n.setAttributeProperties("imageStyle",{isFormatting:!0}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(Y_),n=new Map(this.normalizedStyles.map(e=>[e.name,e]));t.registerPostFixer(e=>{let s=!1;for(const o of t.differ.getChanges())if("insert"==o.type||"attribute"==o.type&&"imageStyle"==o.attributeKey){let t="insert"==o.type?o.position.nodeAfter:o.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),s=!0)}return s})}}class ry extends Cc{static get requires(){return[oy]}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")||[],n=ay(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of n)this._createButton(e);const s=ay([...t.filter(i),...iy.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of s)this._createDropdown(e,n)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,n=>{let s;const{defaultItem:o,items:r,title:a}=e,l=r.filter(e=>t.find(({name:t})=>ly(t)===e)).map(e=>{const t=i.create(e);return e===o&&(s=t),t});r.length!==l.length&&iy.warnInvalidStyle({dropdown:e});const c=bm(n,pm),d=c.buttonView,u=d.arrowView;return wm(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:cy(a,s.label),class:null,tooltip:!0}),u.unbind("label"),u.set({label:a}),d.bind("icon").toMany(l,"isOn",(...e)=>{const t=e.findIndex(W_);return t<0?s.icon:l[t].icon}),d.bind("label").toMany(l,"isOn",(...e)=>{const t=e.findIndex(W_);return cy(a,t<0?s.label:l[t].label)}),d.bind("isOn").toMany(l,"isOn",(...e)=>e.some(W_)),d.bind("class").toMany(l,"isOn",(...e)=>e.some(W_)?"ck-splitbutton_flatten":void 0),d.on("execute",()=>{l.some(({isOn:e})=>e)?c.isOpen=!c.isOpen:s.fire("execute")}),c.bind("isEnabled").toMany(l,"isEnabled",(...e)=>e.some(W_)),this.listenTo(c,"execute",()=>{this.editor.editing.view.focus()}),c})}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(ly(t),i=>{const n=this.editor.commands.get("imageStyle"),s=new rh(i);return s.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>e===t),s.on("execute",this._executeCommand.bind(this,t)),s})}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function ay(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function ly(e){return`imageStyle:${e}`}function cy(e,t){return(e?e+": ":"")+t}class dy{_startElement;_referenceIndent;_isForward;_includeSelf;_sameAttributes;_sameIndent;_lowerIndent;_higherIndent;constructor(e,t){this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=ei(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){return si(new this(e,t)[Symbol.iterator]())}*[Symbol.iterator](){const e=[];for(const{node:t}of new uy(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(i<this._referenceIndent){if(!this._lowerIndent)break;this._referenceIndent=i}else if(i>this._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(e=>t.getAttribute(e)!==this._startElement.getAttribute(e)))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 uy{_node;_isForward;_previousNodesByIndent=[];_previous=null;_previousNodeIndent=null;constructor(e,t="forward"){this._node=e,this._isForward="forward"===t}[Symbol.iterator](){return this}next(){if(!gy(this._node))return{done:!0,value:void 0};const e=this._node.getAttribute("listIndent");let t=null;if(this._previous){const i=this._previousNodeIndent;e>i?this._previousNodesByIndent[i]=this._previous:e<i?(t=this._previousNodesByIndent[e]||null,this._previousNodesByIndent.length=e):t=this._previous}const i={node:this._node,previous:this._previous,previousNodeInList:t};return this._previous=this._node,this._previousNodeIndent=e,this._node=this._isForward?this._node.nextSibling:this._node.previousSibling,{value:i,done:!1}}}class hy{_listHead;constructor(e){this._listHead=e}[Symbol.iterator](){return new uy(this._listHead)}}class my{static next(){return he()}}function gy(e){return!!e&&e.is("element")&&e.hasAttribute("listItemId")}function fy(e,t={}){return[...py(e,{...t,direction:"backward"}),...py(e,{...t,direction:"forward"})]}function py(e,t={}){const i="forward"==t.direction,n=Array.from(new dy(e,{...t,includeSelf:i,sameIndent:!0,sameAttributes:"listItemId"}));return i?n:n.reverse()}function by(e,t){const i=new dy(e,{sameIndent:!0,sameAttributes:"listType",...t}),n=new dy(e,{sameIndent:!0,sameAttributes:"listType",includeSelf:!0,direction:"forward",...t});return[...Array.from(i).reverse(),...n]}function wy(e){return!dy.first(e,{sameIndent:!0,sameAttributes:"listItemId"})}function _y(e){return!dy.first(e,{direction:"forward",sameIndent:!0,sameAttributes:"listItemId"})}function vy(e,t={}){e=ei(e);const i=!1!==t.withNested,n=new Set;for(const t of e)for(const e of fy(t,{higherIndent:i}))n.add(e);return xy(n)}function yy(e){e=ei(e);const t=new Set;for(const i of e)for(const e of by(i))t.add(e);return xy(t)}function ky(e,t){const i=py(e,{direction:"forward"}),n=my.next();for(const e of i)t.setAttribute("listItemId",n,e);return i}function Cy(e,t,i){const n={};for(const[e,i]of t.getAttributes())e.startsWith("list")&&(n[e]=i);const s=py(e,{direction:"forward"});for(const e of s)i.setAttributes(n,e);return s}function Ay(e,t,{expand:i,indentBy:n=1,attributeNames:s}){e=ei(e);const o=i?vy(e):e;for(const e of o){const i=e.getAttribute("listIndent")+n;i<0?Ty(e,t,s):t.setAttribute("listIndent",i,e)}return o}function Ty(e,t,i){e=ei(e);for(const i of e)i.is("element","listItem")&&t.rename(i,"paragraph");for(const n of e)for(const e of n.getAttributeKeys())i.includes(e)&&t.removeAttribute(e,n);return e}function Ey(e){if(!e.length)return!1;const t=e[0].getAttribute("listItemId");return!!t&&!e.some(e=>e.getAttribute("listItemId")!=t)}function xy(e){return Array.from(e).filter(e=>"$graveyard"!==e.root.rootName).sort((e,t)=>e.index-t.index)}function Py(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function Sy(e,t){return t.checkChild(e.parent,"listItem")&&t.checkChild(e,"$text")&&!t.isObject(e)}function Iy(e){return"numbered"==e||"customNumbered"==e}function Oy(e,t,i){return py(t,{direction:"forward"}).pop().index>e.index?Cy(e,t,i):[]}class Ry extends Tc{_direction;constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor,t=e.model,i=Vy(t.document.selection),n=e.plugins.get("ListEditing").getListAttributeNames();t.change(e=>{const t=[];Ey(i)&&!wy(i[0])?("forward"==this._direction&&t.push(...Ay(i,e,{attributeNames:n})),t.push(...ky(i[0],e))):"forward"==this._direction?t.push(...Ay(i,e,{expand:!0,attributeNames:n})):t.push(...function(e,t,{attributeNames:i}){const n=vy(e=ei(e)),s=new Set,o=Math.min(...n.map(e=>e.getAttribute("listIndent"))),r=new Map;for(const e of n)r.set(e,dy.first(e,{lowerIndent:!0}));for(const e of n){if(s.has(e))continue;s.add(e);const n=e.getAttribute("listIndent")-1;if(n<0)Ty(e,t,i);else{if(e.getAttribute("listIndent")==o){const i=Oy(e,r.get(e),t);for(const e of i)s.add(e);if(i.length)continue}t.setAttribute("listIndent",n,e)}}return xy(s)}(i,e,{attributeNames:n}));for(const i of t){if(!i.hasAttribute("listType"))continue;const t=dy.first(i,{sameIndent:!0});t&&e.setAttribute("listType",t.getAttribute("listType"),i)}this._fireAfterExecute(t)})}_fireAfterExecute(e){this.fire("afterExecute",xy(new Set(e)))}_checkEnabled(){let e=Vy(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(Ey(e)&&!wy(e[0]))return!0;e=vy(e),t=e[0];const i=dy.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}}function Vy(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex(e=>!gy(e));return-1!=i&&(t.length=i),t}class By extends Tc{type;_listWalkerOptions;constructor(e,t,i={}){super(e),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,n=Py(t),s=Array.from(i.selection.getSelectedBlocks()).filter(e=>t.schema.checkAttribute(e,"listType")||Sy(e,t.schema)),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change(r=>{if(o){const e=s[s.length-1],t=this.editor.plugins.get("ListEditing").getListAttributeNames(),i=py(e,{direction:"forward"}),n=[];i.length>1&&n.push(...ky(i[1],r)),n.push(...Ty(s,r,t)),n.push(...function(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:s}of new uy(e.nextSibling)){const e=s.getAttribute("listIndent");if(0==e)break;e<n&&(n=e);const o=e-n;t.setAttribute("listIndent",o,s),i.push(s)}return i}(e,r)),this._fireAfterExecute(n)}else if((n||i.selection.isCollapsed)&&gy(s[0])){const t=by(n||s[0],this._listWalkerOptions);for(const i of t)r.setAttributes({...e.additionalAttributes,listType:this.type},i);this._fireAfterExecute(t)}else{const i=[];for(const n of s)if(n.hasAttribute("listType"))for(const t of vy(n,{withNested:!1}))t.getAttribute("listType")!=this.type&&(r.setAttributes({...e.additionalAttributes,listType:this.type},t),i.push(t));else!n.is("element","listItem")&&Sy(n,t.schema)&&r.rename(n,"listItem"),r.setAttributes({...e.additionalAttributes,listIndent:0,listItemId:my.next(),listType:this.type},n),i.push(n);this._fireAfterExecute(i)}})}_fireAfterExecute(e){this.fire("afterExecute",xy(new Set(e)))}_getValue(){const e=this.editor.model.document.selection,t=Array.from(e.getSelectedBlocks());if(!t.length)return!1;for(const e of t)if(e.getAttribute("listType")!=this.type)return!1;return!0}_checkEnabled(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=Array.from(i.getSelectedBlocks());if(!n.length)return!1;if(this.value)return!0;for(const e of n)if(t.checkAttribute(e,"listType")||Sy(e,t))return!0;return!1}}class My extends Tc{_direction;constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute({shouldMergeOnBlocksContentLevel:e=!1}={}){const t=this.editor,i=t.model,n=i.document.selection,s=[],o=t.plugins.get("ListEditing").getListAttributeNames();i.change(t=>{const{firstElement:r,lastElement:a}=this._getMergeSubjectElements(n,e),l=r.getAttribute("listIndent")||0,c=a.getAttribute("listIndent"),d=a.getAttribute("listItemId");if(l!=c){const e=(u=a,Array.from(new dy(u,{direction:"forward",higherIndent:!0})));s.push(...Ay([a,...e],t,{indentBy:l-c,expand:l<c,attributeNames:o}))}var u;if(e){let e=n;n.isCollapsed&&(e=t.createSelection(t.createRange(t.createPositionAt(r,"end"),t.createPositionAt(a,0)))),i.deleteContent(e,{doNotResetEntireContent:n.isCollapsed});const o=e.getLastPosition().parent,l=o.nextSibling;s.push(o),l&&l!==a&&l.getAttribute("listItemId")==d&&s.push(...Cy(l,o,t))}else s.push(...Cy(a,r,t));this._fireAfterExecute(s)})}_fireAfterExecute(e){this.fire("afterExecute",xy(new Set(e)))}_checkEnabled(){const e=this.editor.model,t=e.document.selection,i=Py(e);if(t.isCollapsed||i){const e=i||t.getFirstPosition().parent;if(!gy(e))return!1;const n="backward"==this._direction?e.previousSibling:e.nextSibling;if(!n)return!1;if(Ey([e,n]))return!1}else{const e=t.getLastPosition(),i=t.getFirstPosition();if(e.parent===i.parent)return!1;if(!gy(e.parent))return!1}return!0}_getMergeSubjectElements(e,t){const i=Py(this.editor.model);let n,s;if(e.isCollapsed||i){const o=i||e.getFirstPosition().parent,r=wy(o);"backward"==this._direction?(s=o,n=r&&!t?dy.first(o,{sameIndent:!0,lowerIndent:!0}):o.previousSibling):(n=o,s=o.nextSibling)}else n=e.getFirstPosition().parent,s=e.getLastPosition().parent;return{firstElement:n,lastElement:s}}}class Fy extends Tc{_direction;constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){this.editor.model.change(e=>{const t=ky(this._getStartBlock(),e);this._fireAfterExecute(t)})}_fireAfterExecute(e){this.fire("afterExecute",xy(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&gy(t)&&!wy(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}}class Ny extends Cc{static get pluginName(){return"ListItemBoldIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[lk]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(lk);e.plugins.has("BoldEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("bold","listItemBold"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemBold",setAttributeOnDowncast(e,t,i,n){t&&(e.addClass("ck-list-marker-bold",i),!Q.isSafari||n&&n.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-bold","0",i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("BoldEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemBold"}),t.schema.setAttributeProperties("listItemBold",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemBold"),e.conversion.for("upcast").attributeToAttribute({model:"listItemBold",view:{name:"li",classes:"ck-list-marker-bold"}}))}}class Ly extends Cc{static get pluginName(){return"ListItemItalicIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[lk]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(lk);e.plugins.has("ItalicEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("italic","listItemItalic"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemItalic",setAttributeOnDowncast(e,t,i,n){t&&(e.addClass("ck-list-marker-italic",i),!Q.isSafari||n&&n.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-italic","0",i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("ItalicEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemItalic"}),t.schema.setAttributeProperties("listItemItalic",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemItalic"),e.conversion.for("upcast").attributeToAttribute({model:"listItemItalic",view:{name:"li",classes:"ck-list-marker-italic"}}))}}class Dy extends Cc{static get pluginName(){return"ListItemFontSizeIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[lk]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(lk);if(!e.plugins.has("FontSizeEditing")||!this.editor.config.get("list.enableListItemMarkerFormatting"))return;const n=dw(e.config.get("fontSize.options"));t.registerFormatAttribute("fontSize","listItemFontSize"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontSize",setAttributeOnDowncast(e,t,i,s){if(t){const o=n.find(e=>e.model==t);o&&o.view&&"string"!=typeof o.view?o.view.styles?(e.addClass("ck-list-marker-font-size",i),e.setStyle("--ck-content-list-marker-font-size",o.view.styles["font-size"],i)):o.view.classes&&(e.addClass(`ck-list-marker-font-size-${t}`,i),!Q.isSafari||s&&s.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-font-size","0",i)):(e.addClass("ck-list-marker-font-size",i),e.setStyle("--ck-content-list-marker-font-size",t,i))}}})}afterInit(){const e=this.editor,t=e.model;if(!e.plugins.has("FontSizeEditing")||!this.editor.config.get("list.enableListItemMarkerFormatting"))return;t.schema.extend("$listItem",{allowAttributes:"listItemFontSize"}),t.schema.setAttributeProperties("listItemFontSize",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemFontSize"),e.conversion.for("upcast").elementToAttribute({model:{key:"listItemFontSize",value:e=>e.getStyle("--ck-content-list-marker-font-size")},view:{name:"li",classes:"ck-list-marker-font-size",styles:{"--ck-content-list-marker-font-size":/.*/}}});const i=dw(e.config.get("fontSize.options"));for(const t of i)t.model&&t.view&&e.conversion.for("upcast").elementToAttribute({model:{key:"listItemFontSize",value:t.model},view:{name:"li",classes:`ck-list-marker-font-size-${t.model}`}})}}class zy extends Cc{static get pluginName(){return"ListItemFontColorIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[lk]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(lk);e.plugins.has("FontColorEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("fontColor","listItemFontColor"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontColor",setAttributeOnDowncast(e,t,i){t&&(e.addClass("ck-list-marker-color",i),e.setStyle("--ck-content-list-marker-color",t,i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("FontColorEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemFontColor"}),t.schema.setAttributeProperties("listItemFontColor",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemFontColor"),e.conversion.for("upcast").attributeToAttribute({model:{key:"listItemFontColor",value:e=>e.getStyle("--ck-content-list-marker-color")},view:{name:"li",classes:"ck-list-marker-color",styles:{"--ck-content-list-marker-color":/.*/}}}))}}class Hy extends Cc{static get pluginName(){return"ListItemFontFamilyIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[lk]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(lk);e.plugins.has("FontFamilyEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("fontFamily","listItemFontFamily"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontFamily",setAttributeOnDowncast(e,t,i){t&&(e.addClass("ck-list-marker-font-family",i),e.setStyle("--ck-content-list-marker-font-family",t,i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("FontFamilyEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemFontFamily"}),t.schema.setAttributeProperties("listItemFontFamily",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"listItemFontFamily"),e.conversion.for("upcast").attributeToAttribute({model:{key:"listItemFontFamily",value:e=>e.getStyle("--ck-content-list-marker-font-family")},view:{name:"li",classes:"ck-list-marker-font-family",styles:{"--ck-content-list-marker-font-family":/.*/}}}))}}class $y extends Cc{_loadedFormatting={};static get pluginName(){return"ListFormatting"}static get isOfficialPlugin(){return!0}static get requires(){return[Ny,Ly,Dy,zy,Hy]}constructor(e){super(e),e.config.define("list.enableListItemMarkerFormatting",!0)}afterInit(){this.editor.config.get("list.enableListItemMarkerFormatting")&&this._registerPostfixerForListItemFormatting()}_registerPostfixerForListItemFormatting(){const e=this.editor.model;e.document.registerPostFixer(t=>{const i=e.document.differ.getChanges(),n=new Set;let s=!1;for(const e of i)if("attribute"===e.type)("listItemId"==e.attributeKey||"listType"==e.attributeKey||this._isInlineOrSelectionFormatting(e.attributeKey)||Object.values(this._loadedFormatting).includes(e.attributeKey))&&(gy(e.range.start.nodeAfter)?n.add(e.range.start.nodeAfter):gy(e.range.start.parent)&&n.add(e.range.start.parent));else if(gy(e.position.nodeAfter)&&n.add(e.position.nodeAfter),gy(e.position.nodeBefore)&&n.add(e.position.nodeBefore),gy(e.position.parent)&&n.add(e.position.parent),"insert"==e.type&&"$text"!=e.name){const i=t.createRangeIn(e.position.nodeAfter);for(const e of i.getItems())gy(e)&&n.add(e)}for(const i of n){const n=Wy(e,i,Object.keys(this._loadedFormatting));for(const[e,o]of Object.entries(n)){const n=this._loadedFormatting[e];(o&&Uy(t,i,n,o)||!o&&qy(t,i,n))&&(s=!0)}}return s})}registerFormatAttribute(e,t){this._loadedFormatting[e]=t}_isInlineOrSelectionFormatting(e){return e.replace(/^selection:/,"")in this._loadedFormatting}}function Wy(e,t,i){if(wy(t))return jy(e,t,i);return jy(e,fy(t)[0],i)}function jy(e,t,i){if(!function(e){return["numbered","bulleted","customNumbered","customBulleted"].includes(e.getAttribute("listType"))}(t)||e.schema.isLimit(t))return Object.fromEntries(i.map(e=>[e]));if(t.isEmpty)return Object.fromEntries(i.map(e=>[e,t.getAttribute(`selection:${e}`)]));const n=new Set(i),s={},o=e.createRangeIn(t).getWalker({ignoreElementEnd:!0});for(const{item:t}of o){for(const i of n)if(e.schema.checkAttribute(t,i)){const e=t.getAttribute(i);void 0===e?(n.delete(i),s[i]=void 0):void 0===s[i]?s[i]=e:s[i]!==e&&(n.delete(i),s[i]=void 0)}else i in s||(s[i]=void 0);if(!n.size)break;e.schema.isLimit(t)&&o.jumpTo(e.createPositionAfter(t))}return s}function Uy(e,t,i,n){const s=fy(t);let o=!1;for(const t of s)t.hasAttribute(i)&&t.getAttribute(i)===n||(e.setAttribute(i,n,t),o=!0);return o}function qy(e,t,i){const n=fy(t);let s=!1;for(const t of n)t.hasAttribute(i)&&(e.removeAttribute(i,t),s=!0);return s}class Ky extends Cc{static get pluginName(){return"ListUtils"}static get isOfficialPlugin(){return!0}expandListBlocksToCompleteList(e){return yy(e)}isFirstBlockOfListItem(e){return wy(e)}isListItemBlock(e){return gy(e)}expandListBlocksToCompleteItems(e,t={}){return vy(e,t)}isNumberedListType(e){return Iy(e)}isFirstListItemInList(e){return function(e){return!dy.first(e,{sameIndent:!0,sameAttributes:"listType"})}(e)}}function Gy(e){return e.is("element","ol")||e.is("element","ul")}function Jy(e){return e.is("element","li")}function Yy(e,t,i,n=Zy(i,t)){return e.createAttributeElement(Xy(i),null,{priority:2*t/100-100,id:n})}function Qy(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function Xy(e){return"numbered"==e||"customNumbered"==e?"ol":"ul"}function Zy(e,t){return`list-${e}-${t}`}function ek(e,t,i){const n=e.nodeBefore;if(gy(n)){let e=n;for(const{node:s}of new uy(e,"backward")){if(e=s,i.has(e))return;if(i.add(e),t.has(n))return}t.add(e)}else{const i=e.nodeAfter;gy(i)&&t.add(i)}}function tk(){return(e,t,i)=>{const{writer:n,schema:s}=i;if(!t.modelRange)return;const o=Array.from(t.modelRange.getItems({shallow:!0})).filter(e=>s.checkAttribute(e,"listItemId"));if(!o.length)return;const r=t.viewItem.getAttribute("data-list-item-id")||my.next();i.consumable.consume(t.viewItem,{attributes:"data-list-item-id"});const a=function(e){let t=0,i=e.parent;for(;i;){if(Jy(i))t++;else{const e=i.previousSibling;e&&Jy(e)&&t++}i=i.parent}return t}(t.viewItem);let l=t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=o[0].getAttribute("listType");c&&(l=c);const d={listItemId:r,listIndent:a,listType:l};for(const e of o)e.hasAttribute("listItemId")||n.setAttributes(d,e);o.length>1&&o[1].getAttribute("listItemId")!=d.listItemId&&i.keepEmptyElement(o[0])}}function ik(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Set,l=new Set,c=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)ek(e.position,a,c),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):ek(e.position.getShiftedBy(e.length),a,c);else if("remove"==e.type&&e.attributes.has("listItemId"))ek(e.position,a,c);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(ek(e.range.start,a,c),null===e.attributeNewValue?(ek(e.range.start.getShiftedBy(1),a,c),o(t)&&r.push(t)):l.add(t)):gy(t)&&o(t)&&r.push(t)}for(const e of a.values())r.push(...s(e,l));for(const e of new Set(r))t.reconvertItem(e)};function s(e,t){const n=[],s=new Set,a=[];for(const{node:l,previous:c}of new uy(e)){if(s.has(l))continue;const e=l.getAttribute("listIndent");c&&e<c.getAttribute("listIndent")&&(a.length=e+1),a[e]={modelAttributes:Object.fromEntries(Array.from(l.getAttributes()).filter(([e])=>i.includes(e))),modelElement:l};const d=py(l,{direction:"forward"});for(const e of d)s.add(e),(o(e,d)||r(e,a,t))&&n.push(e)}return n}function o(e,s){const o=t.mapper.toViewElement(e);if(!o)return!1;if(function(e){e=e.parent;for(;e.is("attributeElement")&&["ol","ul","li"].includes(e.name);)e=e.parent;if(e.getCustomProperty("$structureSlotParent")&&!t.mapper.toModelElement(e))return!0;return!1}(o))return!0;if(n.fire("checkElement",{modelElement:e,viewElement:o}))return!0;if(!e.is("element","paragraph")&&!e.is("element","listItem"))return!1;const r=rk(e,i,s);return!(!r||!o.is("element","p"))||!(r||!o.is("element","span"))}function r(e,i,s){if(s.has(e))return!1;const o=t.mapper.toViewElement(e);let r=i.length-1;for(let e=o.parent;!e.is("editableElement");e=e.parent){const t=Jy(e),s=Gy(e);if(!s&&!t)continue;const o="checkAttributes:"+(t?"item":"list");if(n.fire(o,{viewElement:e,modelAttributes:i[r].modelAttributes,modelReferenceElement:i[r].modelElement}))break;if(s&&(r--,r<0))return!1}return!0}}function nk(e,t,i,{dataPipeline:n}={}){const s=function(e,t){const i=t.filter(e=>!1===e.consume).map(e=>e.attributeName);return(t,n)=>{const s=[];for(const n of e)t.hasAttribute(n)&&!i.includes(n)&&s.push(`attribute:${n}`);return!!s.every(e=>!1!==n.test(t,e))&&(s.forEach(e=>n.consume(t,e)),!0)}}(e,t);return(o,r,a)=>{const{writer:l,mapper:c,consumable:d}=a,u=r.item;if(!e.includes(r.attributeKey))return;if(!s(u,d))return;const h={...a.options,dataPipeline:n},m=function(e,t,i,n){const s=i.createRangeOn(e),o=t.toViewRange(s).getTrimmed(),r=o.getWalker();for(const{item:e}of r)if(e.is("element")&&e.getCustomProperty("listItemMarker"))r.jumpTo(n.createPositionAfter(e));else if(e.is("element")&&!e.getCustomProperty("listItemWrapper"))return e}(u,c,i,l);ok(m,l,c),function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(m,l);const g=function(e,t,i,n,{dataPipeline:s}){let o=n.createRangeOn(t);if(!wy(e))return o;for(const r of i){if("itemMarker"!=r.scope)continue;const i=r.createElement(n,e,{dataPipeline:s});if(!i)continue;if(n.setCustomProperty("listItemMarker",!0,i),r.canInjectMarkerIntoElement&&r.canInjectMarkerIntoElement(e)?n.insert(n.createPositionAt(t,0),i):(n.insert(o.start,i),o=n.createRange(n.createPositionBefore(i),n.createPositionAfter(t))),!r.createWrapperElement||!r.canWrapElement)continue;const a=r.createWrapperElement(n,e,{dataPipeline:s});n.setCustomProperty("listItemWrapper",!0,a),r.canWrapElement(e)?o=n.wrap(o,a):(o=n.wrap(n.createRangeOn(i),a),o=n.createRange(o.start,n.createPositionAfter(t)))}return o}(u,m,t,l,h);!function(e,t,i,n,s){if(!e.hasAttribute("listIndent"))return;const o=e.getAttribute("listIndent");let r=e;for(let e=o;e>=0;e--){const o=Qy(n,e,r.getAttribute("listItemId")),a=Yy(n,e,r.getAttribute("listType"));for(const e of i)"list"!=e.scope&&"item"!=e.scope||!r.hasAttribute(e.attributeName)||e.setAttributeOnDowncast(n,r.getAttribute(e.attributeName),"list"==e.scope?a:o,s,r);if(t=n.wrap(t,o),t=n.wrap(t,a),0==e)break;if(r=dy.first(r,{lowerIndent:!0}),!r)break}}(u,g,t,l,h)}}function sk(e,{dataPipeline:t}={}){return(i,{writer:n})=>{if(!rk(i,e))return null;if(!t)return n.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const s=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,s),s}}function ok(e,t,i){for(;e.parent.is("attributeElement")&&e.parent.getCustomProperty("listItemWrapper");)t.unwrap(t.createRangeOn(e),e.parent);const n=[];s(t.createPositionBefore(e).getWalker({direction:"backward"})),s(t.createRangeIn(e).getWalker());for(const e of n)t.remove(e);function s(e){for(const{item:t}of e){if(t.is("element")&&i.toModelElement(t))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&n.push(t)}}}function rk(e,t,i=fy(e)){if(!gy(e))return!1;for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&"htmlEmptyBlock"!=i&&!t.includes(i))return!1;return i.length<2}const ak=["listType","listIndent","listItemId"];class lk extends Cc{_downcastStrategies=[];static get pluginName(){return"ListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Uf,lf,Ky,Zp,$y]}constructor(e){super(e),e.config.define("list.multiBlock",!0)}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new fe("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:ak}),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 e of ak)t.schema.setAttributeProperties(e,{copyOnReplace:!0});e.commands.add("numberedList",new By(e,"numbered")),e.commands.add("bulletedList",new By(e,"bulleted")),e.commands.add("customNumberedList",new By(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new By(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new Ry(e,"forward")),e.commands.add("outdentList",new Ry(e,"backward")),e.commands.add("splitListItemBefore",new Fy(e,"before")),e.commands.add("splitListItemAfter",new Fy(e,"after")),i&&(e.commands.add("mergeListItemBackward",new My(e,"backward")),e.commands.add("mergeListItemForward",new My(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration(),this._setupListItemIdConversionStrategy()}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[...ak,...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",(n,s)=>{const o=e.model.document.selection;Py(e.model)||e.model.change(()=>{const r=o.getFirstPosition();if(o.isCollapsed&&"backward"==s.direction){if(!r.isAtStart)return;const i=r.parent;if(!gy(i))return;if(dy.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:ck(e.model,"backward")})}else _y(i)||e.execute("splitListItemAfter"),e.execute("outdentList");s.preventDefault(),n.stop()}else{if(o.isCollapsed&&!o.getLastPosition().isAtEnd)return;if(!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:ck(e.model,"forward")}),s.preventDefault(),n.stop()}})},{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",(i,n)=>{const s=t.document,o=s.selection.getFirstPosition().parent;if(s.selection.isCollapsed&&gy(o)&&o.isEmpty&&!n.isSoft){const t=wy(o),s=_y(o);t&&s?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!s?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):s&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}},{context:"li"}),this.listenTo(n,"afterExecute",()=>{const t=i.get("splitListItemBefore");if(t.refresh(),!t.isEnabled)return;2===fy(e.model.document.selection.getLastPosition().parent).length&&t.execute()})}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",(t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),n=e.config.get("list.multiBlock"),s=n?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(e,{writer:t})=>t.createElement(s,{listType:""})}).elementToElement({view:"p",model:(e,{writer:t})=>e.parent&&e.parent.is("element","li")?t.createElement(s,{listType:""}):null,converterPriority:"high"}).add(e=>{e.on("element:li",tk())}),n||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:s,view:sk(i),converterPriority:"high"}).add(e=>{var n;e.on("attribute",nk(i,this._downcastStrategies,t)),e.on("remove",(n=t.schema,(e,t,i)=>{const{writer:s,mapper:o}=i,r=e.name.split(":")[1];if(!n.checkAttribute(r,"listItemId"))return;const a=o.toViewPosition(t.position),l=t.position.getShiftedBy(t.length),c=o.toViewPosition(l,{isPhantom:!0}),d=s.createRange(a,c).getTrimmed().end.nodeBefore;d&&ok(d,s,o)}))}),e.conversion.for("dataDowncast").elementToElement({model:s,view:sk(i,{dataPipeline:!0}),converterPriority:"high"}).add(e=>{e.on("attribute",nk(i,this._downcastStrategies,t,{dataPipeline:!0}))});const o=(r=this._downcastStrategies,a=e.editing.view,(e,t)=>{if(t.modelPosition.offset>0)return;const i=t.modelPosition.parent;if(!gy(i))return;if(!r.some(e=>"itemMarker"==e.scope&&e.canInjectMarkerIntoElement&&e.canInjectMarkerIntoElement(i)))return;const n=t.mapper.toViewElement(i),s=a.createRangeIn(n),o=s.getWalker();let l=s.start;for(const{item:e}of o){if(e.is("element")&&t.mapper.toModelElement(e)||e.is("$textProxy"))break;e.is("element")&&e.getCustomProperty("listItemMarker")&&(l=a.createPositionAfter(e),o.skip(({previousPosition:e})=>!e.isEqual(l)))}t.viewPosition=l});var r,a;e.editing.mapper.on("modelToViewPosition",o),e.data.mapper.on("modelToViewPosition",o),this.listenTo(t.document,"change:data",ik(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",(e,{viewElement:t,modelAttributes:i})=>{t.id!=i.listItemId&&(e.return=!0,e.stop())}),this.on("checkAttributes:list",(e,{viewElement:t,modelAttributes:i})=>{t.name==Xy(i.listType)&&t.id==Zy(i.listType,i.listIndent)||(e.return=!0,e.stop())})}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer(i=>function(e,t,i,n){const s=e.document.differ.getChanges(),o=new Set,r=new Set,a=n.editor.config.get("list.multiBlock");let l=!1;for(const n of s){if("insert"==n.type&&"$text"!=n.name){const s=n.position.nodeAfter;if(!e.schema.checkAttribute(s,"listItemId"))for(const e of Array.from(s.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,s),l=!0);ek(n.position,r,o),n.attributes.has("listItemId")||ek(n.position.getShiftedBy(n.length),r,o);for(const{item:t,previousPosition:i}of e.createRangeIn(s))gy(t)&&ek(i,r,o)}else"remove"==n.type?ek(n.position,r,o):"attribute"==n.type&&i.includes(n.attributeKey)&&(ek(n.range.start,r,o),null===n.attributeNewValue&&ek(n.range.start.getShiftedBy(1),r,o));if(!a&&"attribute"==n.type&&ak.includes(n.attributeKey)){const e=n.range.start.nodeAfter;null===n.attributeNewValue&&e&&e.is("element","listItem")?(t.rename(e,"paragraph"),l=!0):null===n.attributeOldValue&&e&&e.is("element")&&"listItem"!=e.name&&(t.rename(e,"listItem"),l=!0)}}const c=new Set;for(const e of r.values())l=n.fire("postFixer",{listNodes:new hy(e),listHead:e,writer:t,seenIds:c})||l;return l}(e,i,t,this)),this.on("postFixer",(e,{listNodes:t,writer:i})=>{e.return=function(e,t){let i=0,n=-1,s=null,o=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===s?(s=e-i,a=i):(s>e&&(s=e),a=e-s),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),o=!0,n=a}else s=null,i=e+1,n=e}return o}(t,i)||e.return},{priority:"high"}),this.on("postFixer",(e,{listNodes:t,writer:i,seenIds:n})=>{e.return=function(e,t,i){const n=new Set;let s=!1;for(const{node:o}of e){if(n.has(o))continue;let e=o.getAttribute("listType"),r=o.getAttribute("listItemId");if(t.has(r)&&(r=my.next()),t.add(r),o.is("element","listItem"))o.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,o),s=!0);else for(const t of py(o,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=my.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),s=!0)}return s}(t,n,i)||e.return},{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",function(e){return(t,[i,n])=>{const s=i.is("documentFragment")?Array.from(i.getChildren()):[i];if(!s.length)return;const o=(n?e.createSelection(n):e.document.selection).getFirstPosition();let r;if(gy(o.parent))r=o.parent;else{if(!gy(o.nodeBefore)||!gy(o.nodeAfter))return;r=o.nodeBefore}e.change(e=>{const t=r.getAttribute("listType"),i=r.getAttribute("listIndent"),n=s[0].getAttribute("listIndent")||0,o=Math.max(i-n,0);for(const i of s){const n=gy(i);r.is("element","listItem")&&i.is("element","paragraph")&&e.rename(i,"listItem"),e.setAttributes({listIndent:(n?i.getAttribute("listIndent"):0)+o,listItemId:n?i.getAttribute("listItemId"):my.next(),listType:t},i)}})}}(e),{priority:"high"}),this.listenTo(t,"outputTransformation",(t,i)=>{e.change(e=>{const t=Array.from(i.content.getChildren()),n=t[t.length-1];if(t.length>1&&n.is("element")&&n.isEmpty){t.slice(0,-1).every(gy)&&e.remove(n)}if("copy"==i.method||"cut"==i.method){const t=Array.from(i.content.getChildren());Ey(t)&&Ty(t,e,this.getListAttributeNames())}})})}_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"}]})}_setupListItemIdConversionStrategy(){this.registerDowncastStrategy({scope:"item",attributeName:"listItemId",setAttributeOnDowncast(e,t,i,n){n&&(n.skipListItemIds||n.isClipboardPipeline)||e.setAttribute("data-list-item-id",t,i)}})}}function ck(e,t){const i=e.document.selection;if(!i.isCollapsed)return!Py(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,s=n.previousSibling;return!e.schema.isObject(s)&&(!!s.isEmpty||Ey([n,s]))}function dk(e,t,i,n){e.ui.componentFactory.add(t,()=>{const s=uk(rh,e,t,i,n);return s.set({tooltip:!0,isToggleable:!0}),s}),e.ui.componentFactory.add(`menuBar:${t}`,()=>{const s=uk(Eh,e,t,i,n);return s.set({role:"menuitemcheckbox",isToggleable:!0}),s})}function uk(e,t,i,n,s){const o=t.commands.get(i),r=new e(t.locale);return r.set({label:n,icon:s}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.on("execute",()=>{t.execute(i),t.editing.view.focus()}),r}class hk extends Cc{static get pluginName(){return"ListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||dk(this.editor,"numberedList",e("Numbered List"),'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75M3.5 3v5H2V3.7H1v-1h2.5zM.343 17.857l2.59-3.257H2.92a.6.6 0 1 0-1.04 0H.302a2 2 0 1 1 3.995 0h-.001q-.073.607-.333.988-.263.381-1.244 1.312H4.3v1h-4zM7 14.75a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75"/></svg>'),this.editor.ui.componentFactory.has("bulletedList")||dk(this.editor,"bulletedList",e("Bulleted List"),'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75m-6 0C1 4.784 1.777 4 2.75 4c.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75C1.784 7.5 1 6.723 1 5.75m6 9c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75m-6 0c0-.966.777-1.75 1.75-1.75.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75-.966 0-1.75-.777-1.75-1.75"/></svg>')}}const mk={},gk={},fk={},pk=[{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"},{listStyle:"arabic-indic",typeAttribute:null,listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:i}of pk)mk[e]=i,gk[e]=t,t&&(fk[t]=e);class bk extends Cc{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("indent",new xc(e)),e.commands.add("outdent",new xc(e))}}class wk extends Cc{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?dd:wd,s="ltr"==t.uiLanguageDirection?wd:dd;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),s)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,()=>{const n=this._createButton(rh,e,t,i);return n.set({tooltip:!0}),n}),n.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(Eh,e,t,i))}_createButton(e,t,i,n){const s=this.editor,o=s.commands.get(t),r=new e(s.locale);return r.set({label:i,icon:n}),r.bind("isEnabled").to(o,"isEnabled"),this.listenTo(r,"execute",()=>{s.execute(t),s.editing.view.focus()}),r}}class _k extends Tc{_indentBehavior;constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=si(this.editor.model.document.selection.getSelectedBlocks());e&&this._isIndentationChangeAllowed(e)?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=this._getBlocksToChange();e.change(e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}})}_getBlocksToChange(){const e=this.editor.model.document.selection;return Array.from(e.getSelectedBlocks()).filter(e=>this._isIndentationChangeAllowed(e))}_isIndentationChangeAllowed(e){const t=this.editor;if(!t.model.schema.checkAttribute(e,"blockIndent"))return!1;if(!t.plugins.has("ListUtils"))return!0;if(!this._indentBehavior.isForward)return!0;return!t.plugins.get("ListUtils").isListItemBlock(e)}}class vk{isForward;offset;unit;constructor(e){this.isForward="forward"===e.direction,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"),i=!e||e.endsWith(this.unit);if(t<0)return;if(!i)return this.isForward?this.offset+this.unit:void 0;const n=t+(this.isForward?this.offset:-this.offset);return n>0?n+this.unit:void 0}}class yk{isForward;classes;constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t<this.classes.length-1:t>=0}getNextIndent(e){const t=this.classes.indexOf(e)+(this.isForward?1:-1),i=Math.min(t,this.classes.length-1);return this.classes[i]}}class kk extends Tc{_indentBehavior;constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=this._getFirstListItemIfSelectionIsAtListStart(this.editor.model.document.selection);this.isEnabled=!!e&&this._indentBehavior.checkEnabled(e.getAttribute("blockIndentList"))}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,s=t.plugins.get("ListUtils");i.change(t=>{const o=this._getFirstListItemIfSelectionIsAtListStart(n),r=[];if(e.firstListOnly)r.push(o);else{const e=Array.from(n.getSelectedBlocks());for(const t of e)gy(t)&&0===t.getAttribute("listIndent")&&i.schema.checkAttribute(t,"blockIndentList")&&r.push(t)}const a=s.expandListBlocksToCompleteList(r);for(const e of a){const i=e.getAttribute("blockIndentList"),n=this._indentBehavior.getNextIndent(i);n?t.setAttribute("blockIndentList",n,e):t.removeAttribute("blockIndentList",e)}})}_getFirstListItemIfSelectionIsAtListStart(e){const t=e.getFirstPosition(),i=this.editor.plugins.get("ListUtils"),n=t.parent,s=this.editor.model.schema;return t.isAtStart&&gy(n)&&0==n.getAttribute("listIndent")&&s.checkAttribute(n,"blockIndentList")&&i.isFirstListItemInList(n)?n:null}}class Ck extends Tc{_indentBehavior;constructor(e,t){super(e),this._indentBehavior=t}refresh(){this.isEnabled=this._getAffectedListItems().length>0}execute(){this.editor.model.change(e=>{for(const t of this._getAffectedListItems())e.removeAttribute("blockIndentListItem",t)})}_getAffectedListItems(){const e=this.editor.model.document.selection,t=this.editor.plugins.get("ListUtils"),i=Array.from(e.getSelectedBlocks());return t.expandListBlocksToCompleteItems(i).filter(e=>this._isIndentationChangeAllowed(e))}_isIndentationChangeAllowed(e){return!!e.hasAttribute("blockIndentListItem")&&this._indentBehavior.checkEnabled(e.getAttribute("blockIndentListItem"))}}class Ak extends vk{checkEnabled(e){const t=parseFloat(e);return this.isForward&&t<0||!this.isForward&&t>0}}class Tk extends yk{checkEnabled(e){return!this.isForward&&!!e}}class Ek extends Cc{static get pluginName(){return"IndentBlockListIntegration"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!this.editor.plugins.has("ListEditing"))return;const t=e.config.get("indentBlock");t.classes&&t.classes.length?(this._setupConversionUsingClasses(t.classes,"ol","blockIndentList","list"),this._setupConversionUsingClasses(t.classes,"ul","blockIndentList","list"),this._setupConversionUsingClasses(t.classes,"li","blockIndentListItem","item"),e.commands.add("indentBlockList",new kk(e,new yk({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlockList",new kk(e,new yk({direction:"backward",classes:t.classes}))),e.commands.add("indentBlockListItem",new Ck(e,new Tk({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlockListItem",new Ck(e,new Tk({direction:"backward",classes:t.classes})))):(e.data.addStyleProcessorRules(lc),this._setupConversionUsingOffset("ol","blockIndentList","list"),this._setupConversionUsingOffset("ul","blockIndentList","list"),this._setupConversionUsingOffset("li","blockIndentListItem","item"),e.commands.add("indentBlockList",new kk(e,new vk({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlockList",new kk(e,new vk({direction:"backward",offset:t.offset,unit:t.unit}))),e.commands.add("indentBlockListItem",new Ck(e,new Ak({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlockListItem",new Ck(e,new Ak({direction:"backward",offset:t.offset,unit:t.unit}))));e.plugins.get("ListEditing").on("postFixer",(e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:s}of t)s&&s.getAttribute("listType")==n.getAttribute("listType")&&(Pk("blockIndentList",n,s,i)&&(e.return=!0),s.getAttribute("listItemId")==n.getAttribute("listItemId")&&Pk("blockIndentListItem",n,s,i)&&(e.return=!0))}),this.listenTo(e.editing.view.document,"tab",(t,i)=>{const n=i.shiftKey?"outdentBlockList":"indentBlockList";this.editor.commands.get(n).isEnabled&&(e.execute(n,{firstListOnly:!0}),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"li",priority:"high"})}afterInit(){const e=this.editor,t=e.model,i=t.schema;if(!e.plugins.has("ListEditing"))return;i.extend("$listItem",{allowAttributes:["blockIndentList","blockIndentListItem"]}),i.setAttributeProperties("blockIndentList",{isFormatting:!0}),i.setAttributeProperties("blockIndentListItem",{isFormatting:!0}),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"blockIndentList"),t.schema.addAttributeCheck(e=>{if(!e.last.getAttribute("listItemId"))return!1},"blockIndentListItem");const n=(t,i)=>{e.model.change(e=>{for(const t of i)t.hasAttribute("listItemId")&&(t.hasAttribute("blockIndentList")&&e.removeAttribute("blockIndentList",t),t.hasAttribute("blockIndentListItem")&&e.removeAttribute("blockIndentListItem",t))})},s=e.commands.get("indentList"),o=e.commands.get("outdentList");s&&this.listenTo(s,"afterExecute",n),o&&this.listenTo(o,"afterExecute",n);const r=e.commands.get("indent"),a=e.commands.get("outdent");r.registerChildCommand(e.commands.get("indentBlockList")),a.registerChildCommand(e.commands.get("outdentBlockList")),r.registerChildCommand(e.commands.get("indentBlockListItem")),a.registerChildCommand(e.commands.get("outdentBlockListItem"))}_setupConversionUsingOffset(e,t,i){const n=this.editor,s=n.locale,o=n.conversion,r="rtl"===s.contentLanguageDirection?"margin-right":"margin-left",a=n.plugins.get("ListEditing");o.for("upcast").add(i=>{i.on(`element:${e}`,xk(t,e=>e.getStyle(r),(e,t)=>e.consume(t,{styles:r})),{priority:"low"})}),a.registerDowncastStrategy({scope:i,attributeName:t,setAttributeOnDowncast(e,t,i){t&&e.setStyle(r,t,i)}})}_setupConversionUsingClasses(e,t,i,n){const s=this.editor,o=s.conversion,r=s.plugins.get("ListEditing");o.for("upcast").add(n=>{n.on(`element:${t}`,xk(i,t=>e.find(e=>t.hasClass(e)),(e,t,i)=>e.consume(t,{classes:i})),{priority:"low"})}),r.registerDowncastStrategy({scope:n,attributeName:i,setAttributeOnDowncast(e,t,i){t&&e.addClass(t,i)}})}}function xk(e,t,i){return(n,s,o)=>{const{writer:r,consumable:a}=o;s.modelRange||Object.assign(s,o.convertChildren(s.viewItem,s.modelCursor));const l=t(s.viewItem);if(void 0===l)return;let c,d=!1;for(const t of s.modelRange.getItems({shallow:!0}))void 0===c&&(c=t.getAttribute("listIndent")),t.hasAttribute(e)||t.getAttribute("listIndent")===c&&(r.setAttribute(e,l,t),d=!0);d&&i(a,s.viewItem,l)}}function Pk(e,t,i,n){const s=i.getAttribute(e);return t.getAttribute(e)!==s&&(s?n.setAttribute(e,s,t):n.removeAttribute(e,t),!0)}const Sk=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];function Ik(e){return function(e){return e.substring(0,1).toUpperCase()+e.substring(1)}(Bi(e))}class Ok{_definitions=new Set;_conflictChecker;get length(){return this._definitions.size}setConflictChecker(e){this._conflictChecker=e}add(e){Array.isArray(e)?e.forEach(e=>this._definitions.add(e)):this._definitions.add(e)}getDispatcher(){return e=>{const t=(e,t)=>{const i=t.createAttributeElement("a",e.attributes,{priority:5});e.classes&&t.addClass(e.classes,i);for(const n in e.styles)t.setStyle(n,e.styles[n],i);return t.setCustomProperty("link",!0,i),i},i=e=>(i,n,s)=>{if(n.attributeKey.startsWith("link")&&("linkHref"!=n.attributeKey||s.consumable.test(n.item,"attribute:linkHref"))&&(n.item.is("selection")||s.schema.isInline(n.item)))for(const i of this._definitions)i.callback(n.item.getAttribute("linkHref"))&&!this._conflictChecker?.(i,n.item)&&e?n.item.is("selection")?s.writer.wrap(s.writer.document.selection.getFirstRange(),t(i,s.writer)):s.writer.wrap(s.mapper.toViewRange(n.range),t(i,s.writer)):s.writer.unwrap(s.mapper.toViewRange(n.range),t(i,s.writer))};e.on("attribute",i(!1),{priority:me.high-1}),e.on("attribute",i(!0),{priority:me.high-2})}}getDispatcherForLinkedImage(){return e=>{const t=e=>(t,i,{writer:n,mapper:s})=>{if(!i.item.is("element","imageBlock")||!i.attributeKey.startsWith("link"))return;const o=s.toViewElement(i.item),r=Array.from(o.getChildren()).find(e=>e.is("element","a"));if(r)for(const t of this._definitions){const s=di(t.attributes);if(t.callback(i.item.getAttribute("linkHref"))&&!this._conflictChecker?.(t,i.item)&&e){for(const[e,t]of s)"class"===e?n.addClass(t,r):n.setAttribute(e,t,!1,r);t.classes&&n.addClass(t.classes,r);for(const e in t.styles)n.setStyle(e,t.styles[e],r)}else{for(const[e,t]of s)"class"===e?n.removeClass(t,r):n.removeAttribute(e,t,r);t.classes&&n.removeClass(t.classes,r);for(const e in t.styles)n.removeStyle(e,r)}}};e.on("attribute",t(!1),{priority:me.high-1}),e.on("attribute",t(!0),{priority:me.high-2})}}}const Rk=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Vk=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,Bk=/^((\w+:(\/{2,})?)|(\W))/i,Mk=["https?","ftps?","mailto"],Fk="Ctrl+K";function Nk(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function Lk(e,t=Mk){const i=String(e),n=t.join("|");return function(e,t){const i=e.replace(Rk,"");return!!i.match(t)}(i,new RegExp(`${"^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("<protocols>",n)}`,"i"))?i:"#"}function Dk(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function zk(e,t){const i=(n=e,Vk.test(n)?"mailto:":t);var n;const s=!!i&&!Hk(e);return e&&s?i+e:e}function Hk(e){return Bk.test(e)}function $k(e){let t="";for(const i of e.getItems()){if(!i.is("$text")&&!i.is("$textProxy"))return;t+=i.data}return t}function Wk(e,t){if(e.attributes&&t.attributes){if(Object.keys(e.attributes).some(e=>!function(e){return"class"===e||"style"===e||"rel"===e}(e)&&e in t.attributes))return!0}if(e.styles&&t.styles){if(Object.keys(e.styles).some(e=>e in t.styles))return!0}return!1}function jk(e,t){const i=t.find(t=>t.id===e);return i?t.filter(t=>t.id!==e&&Wk(i,t)).map(e=>e.id):[]}class Uk extends Tc{manualDecorators=new ni;automaticDecorators=new Ok;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()||si(t.getSelectedBlocks());Dk(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 e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={},i){const n=this.editor.model,s=n.document.selection,o=function({decoratorStates:e,allDecorators:t}){const i={...e};for(const s in e)if(e[s]&&n(s)){const e=jk(s,t);for(const t of e)i[t]=!1}function n(e){return t.some(t=>t.id===e&&!t.value)}return i}({allDecorators:Array.from(this.manualDecorators),decoratorStates:t}),r=[],a=[];for(const e in o)o[e]?r.push(e):a.push(e);n.change(t=>{const o=i=>{t.setAttribute("linkHref",e,i),r.forEach(e=>t.setAttribute(e,!0,i)),a.forEach(e=>t.removeAttribute(e,i))},l=(s,r)=>{const a=$k(s);if(!a)return s;let l=i;if(l||(l=r&&r==a?e:a),l!=a){const e=t.createDocumentFragment();for(const i of s.getItems()){const n=i;t.append(t.createText(n.data,n.getAttributes()),e)}const i=t.createRangeIn(e),r=function(e,t){const i=ce(e,t),n={equal:0,insert:0,delete:0},s=[];let o="",r="";for(const a of[...i,null])"insert"==a?r+=t[n.equal+n.insert]:"delete"==a?o+=e[n.equal+n.delete]:(o.length||r.length)&&(s.push({offset:n.equal,actual:o,expected:r}),o="",r=""),a&&n[a]++;return s}(a,l);let c=0;for(const{offset:e,actual:s,expected:a}of r){const r=e+c,l=t.createRange(i.start.getShiftedBy(r),i.start.getShiftedBy(r+s.length)),d=qk(l,i).getAttributes(),u=Array.from(d).filter(([e])=>n.schema.getAttributeProperties(e).isFormatting),h=t.createText(a,u);o(h),t.remove(l),t.insert(h,l.start),c+=a.length}return n.insertContent(e,s),t.createRange(s.start,s.start.getShiftedBy(l.length))}},c=e=>{const{plugins:i}=this.editor;if(t.setSelection(e.end),i.has("TwoStepCaretMovement"))i.get("TwoStepCaretMovement")._handleForwardMovement();else for(const e of["linkHref",...r,...a])t.removeSelectionAttribute(e)};if(s.isCollapsed){const a=s.getFirstPosition();if(s.hasAttribute("linkHref")){const e=s.getAttribute("linkHref"),t=vf(a,"linkHref",e,n),i=l(t,e);o(i||t),i&&c(i)}else if(""!==e){const o=di(s.getAttributes());o.set("linkHref",e),r.forEach(e=>{o.set(e,!0)});c(n.insertContent(t.createText(i||e,o),a))}}else{const e=Array.from(s.getRanges()),i=n.schema.getValidRanges(e,"linkHref"),r=[];for(const e of s.getSelectedBlocks())n.schema.checkAttribute(e,"linkHref")&&r.push(t.createRangeOn(e));const a=r.slice();for(const e of i)this._isRangeToUpdate(e,r)&&a.push(e);const c=e.map(e=>({start:_a.fromPosition(e.start,"toPrevious"),end:_a.fromPosition(e.end,"toNext")}));for(let e of a){e=l(e,(e.start.textNode||e.start.nodeAfter).getAttribute("linkHref"))||e,o(e)}t.setSelection(c.map(e=>{const t=e.start.toPosition(),i=e.end.toPosition();return e.start.detach(),e.end.detach(),n.createRange(t,i)}))}}),this.restoreManualDecoratorStates()}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return Dk(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}function qk(e,t){if(!e.isCollapsed)return si(e.getItems());const i=e.start;return i.textNode?i.textNode:!i.nodeBefore||i.isEqual(t.start)?i.nodeAfter:i.nodeBefore}class Kk extends Tc{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();Dk(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,n=e.commands.get("link");t.change(e=>{const s=i.isCollapsed?[vf(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of s)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)})}}class Gk extends(Le()){id;defaultValue;label;attributes;classes;styles;constructor({id:e,label:t,attributes:i,classes:n,styles:s,defaultValue:o}){super(),this.id=e,this.set("value",void 0),this.defaultValue=o,this.label=t,this.attributes=i,this.classes=n,this.styles=s}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const Jk="automatic",Yk=/^(https?:)?\/\//;class Qk extends Cc{_linkOpeners=[];static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[hf,Yg,Zp]}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1,toolbar:["linkPreview","|","editLink","linkProperties","unlink"]})}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:Nk}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,i)=>Nk(Lk(e,t),i)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new Uk(e)),e.commands.add("unlink",new Kk(e));const i=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach(e=>("label"in e&&i[e.label]&&(e.label=i[e.label]),e)),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:`link${Ik(i)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter(e=>e.mode===Jk)),this._enableManualDecorators(i.filter(e=>"manual"===e.mode));e.plugins.get(hf).registerAttribute("linkHref"),function(e,t,i,n){const s=e.editing.view,o=new Set;s.document.registerPostFixer(s=>{const r=e.model.document.selection;let a=!1;if(r.hasAttribute(t)){const l=vf(r.getFirstPosition(),t,r.getAttribute(t),e.model),c=e.editing.mapper.toViewRange(l);for(const e of c.getItems())e.is("element",i)&&!e.hasClass(n)&&(s.addClass(n,e),o.add(e),a=!0)}return a}),e.conversion.for("editingDowncast").add(e=>{function t(){s.change(e=>{for(const t of o.values())e.removeClass(n,t),o.delete(t)})}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})})}(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration(),this._enableDecoratorConflictPostfixer()}_registerLinkOpener(e){this._linkOpeners.push(e)}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link"),n=i.automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:Jk,callback:e=>!!e&&Yk.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(e),n.setConflictChecker((e,t)=>{for(const n of i.manualDecorators)if(t.hasAttribute(n.id)&&Wk(e,n))return!0}),n.length&&t.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach(e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const n=new Gk(e);i.add(n),t.conversion.for("downcast").add(e=>{const t=e=>{const t=e.createAttributeElement("a",n.attributes,{priority:5});n.classes&&e.addClass(n.classes,t);for(const i in n.styles)e.setStyle(i,n.styles[i],t);return e.setCustomProperty("link",!0,t),t},i=e=>(i,n,s)=>{if(n.item.is("selection")||s.schema.isInline(n.item)){if(!e&&n.attributeOldValue){if(!s.consumable.test(n.item,i.name))return;s.writer.unwrap(s.mapper.toViewRange(n.range),t(s.writer))}if(e&&n.attributeNewValue){if(!s.consumable.consume(n.item,i.name))return;n.item.is("selection")?s.writer.wrap(s.writer.document.selection.getFirstRange(),t(s.writer)):s.writer.wrap(s.mapper.toViewRange(n.range),t(s.writer))}}};e.on(`attribute:${n.id}`,i(!1),{priority:me.high-1}),e.on(`attribute:${n.id}`,i(!0),{priority:me.high-2})}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...n._createPattern()},model:{key:n.id}})})}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document,i=e=>{var t;this._linkOpeners.some(t=>t(e))||(t=e,window.open(t,"_blank","noopener"))};this.listenTo(t,"click",(e,t)=>{if(!(Q.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let n=t.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const s=n.getAttribute("href");s&&(e.stop(),t.preventDefault(),i(s))},{context:"$capture"}),this.listenTo(t,"keydown",(t,n)=>{const s=e.commands.get("link").value;!!s&&n.keyCode===Ut.enter&&n.altKey&&(t.stop(),i(s))})}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",(i,{attributeKeys:n})=>{n.includes("linkHref")&&!t.hasAttribute("linkHref")&&e.change(t=>{var i;!function(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}(t,(i=e.schema,i.getDefinition("$text").allowAttributes.filter(e=>e.startsWith("link"))))})})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",(e,n)=>{t.change(e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=zk(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}})})}_enableDecoratorConflictPostfixer(){const e=this.editor,t=e.model,i=e.commands.get("link");t.document.registerPostFixer(e=>{let n=!1;const s=t.document.differ.getChanges(),o=new Set,r=new Set(i.manualDecorators.map(e=>e.id));for(const e of s){if("attribute"===e.type){if("linkHref"!==e.attributeKey&&!r.has(e.attributeKey))continue;for(const t of e.range.getItems())t.hasAttribute("linkHref")&&o.add(t)}"insert"===e.type&&e.attributes.has("linkHref")&&e.position.nodeAfter&&o.add(e.position.nodeAfter)}for(const t of o){const s=[];for(const o of i.manualDecorators)if(t.hasAttribute(o.id)){for(let i=s.length-1;i>=0;i--){const r=s[i];Wk(r,o)&&(e.removeAttribute(r.id,t),s.splice(i,1),n=!0)}s.push(o)}}return n})}}class Xk extends rh{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(e=>{if(this.href){const t=()=>e.preventDefault();this.fire("navigate",this.href,t)}})}}),this.template.tag="a"}}class Zk extends Uu{focusTracker=new oi;keystrokes=new ci;backButtonView;saveButtonView;displayedTextInputView;urlInputView;children;providersListChildren;_validators;_focusables=new yu;_focusCycler;constructor(e,t){super(e),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 ch({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(),Zu({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 rh(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:_d,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new rh(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 lh(this.locale,{label:e("Link")});return t.children.add(this.backButtonView,0),t}_createProvidersListView(){const e=new am(this.locale);return e.extendTemplate({attributes:{class:["ck-link-form__providers-list"]}}),e.items.bindTo(this.providersListChildren).using(e=>{const t=new sm(this.locale);return t.children.add(e),t}),e}_createDisplayedTextInput(){const e=this.locale.t,t=new Yh(this.locale,Tm);return t.label=e("Displayed text"),t.class="ck-labeled-field-view_full-width",t}_createUrlInput(){const e=this.locale.t,t=new Yh(this.locale,Tm);return t.fieldView.inputMode="url",t.label=e("Link URL"),t.class="ck-labeled-field-view_full-width",t}_createFormChildren(){this.children.add(new pg(this.locale,{children:[this.displayedTextInputView],class:["ck-form__row_large-top-padding"]})),this.children.add(new pg(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 eC extends Uu{focusTracker=new oi;keystrokes=new ci;backButtonView;listView;listChildren;emptyListInformation;children;_focusables=new yu;_focusCycler;constructor(e){super(e),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",(e,t,i)=>{i?(this.children.remove(this.emptyListInformation),this.children.add(this.listView)):(this.children.remove(this.listView),this.children.add(this.emptyListInformation))}),this.keystrokes.set("Esc",(e,t)=>{this.fire("cancel"),t()}),this._focusCycler=new ch({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 am(this.locale);return e.extendTemplate({attributes:{class:["ck-link-providers__list"]}}),e.items.bindTo(this.listChildren).using(e=>{const t=new sm(this.locale);return t.children.add(e),t}),e}_createBackButton(){const e=this.locale.t,t=new rh(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:_d,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=new lh(this.locale);return e.bind("label").to(this,"title"),e.children.add(this.backButtonView,0),e}_createEmptyLinksListItemView(){const e=new Uu(this.locale);return e.setTemplate({tag:"p",attributes:{class:["ck","ck-link__empty-list-info"]},children:[{text:this.bindTemplate.to("emptyListPlaceholder")}]}),e}}class tC extends Uu{focusTracker=new oi;keystrokes=new ci;backButtonView;children;listChildren;_focusables=new yu;_focusCycler;constructor(e){super(e),this.backButtonView=this._createBackButton(),this.listChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView(),this._createListView()]),this._focusCycler=new ch({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",(e,t)=>{this.fire("back"),t()})}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 rh(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:_d,tooltip:!0}),t.delegate("execute").to(this,"back"),t}_createHeaderView(){const e=this.locale.t,t=new lh(this.locale,{label:e("Link properties")});return t.children.add(this.backButtonView,0),t}_createListView(){const e=new am(this.locale);return e.extendTemplate({attributes:{class:["ck-link__list"]}}),e.items.bindTo(this.listChildren).using(e=>{const t=new sm(this.locale);return t.children.add(e),t}),e}}class iC extends rh{arrowView;constructor(e){super(e),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 sh;return e.content=ud,e}}const nC="link-ui";class sC extends Cc{toolbarView=null;formView=null;linkProviderItemsView=null;propertiesView=null;_balloon;_linksProviders=new ni;static get requires(){return[vg,Qk]}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(ll),this._balloon=e.plugins.get(vg),this._registerComponents(),this._registerEditingOpeners(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:nC,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:nC,view:(e,{writer:t})=>{if(!e.markerRange.isCollapsed)return null;const i=t.createUIElement("span");return t.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],i),i}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:Fk},{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(t=>(t.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 hm(e.locale),i=e.commands.get("link");t.class="ck-link-toolbar";let n=e.config.get("link.toolbar");return i.manualDecorators.length||(n=n.filter(e=>"linkProperties"!==e)),t.fillFromConfig(n,e.ui.componentFactory),t.keystrokes.set("Esc",(e,t)=>{this._hideUI(),t()}),t.keystrokes.set(Fk,(e,t)=>{this._addFormView(),t()}),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"),n=e.config.get("link.defaultProtocol"),s=new(Qu(Zk))(e.locale,function(e){const t=e.t,i=e.config.get("link.allowCreatingEmptyLinks");return[e=>{if(!i&&!e.url.length)return t("Link URL must not be empty.")}]}(e));return s.displayedTextInputView.bind("isEnabled").to(this,"selectedLinkableText",e=>void 0!==e),s.urlInputView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("label").to(i,"value",e=>t(e?"Update":"Insert")),this.listenTo(s,"submit",()=>{if(s.isValid()){const t=zk(s.urlInputView.fieldView.element.value,n),i=s.displayedTextInputView.fieldView.element.value;e.execute("link",t,this._getDecoratorSwitchesState(),i!==this.selectedLinkableText?i:void 0),this._closeFormView()}}),this.listenTo(s.urlInputView,"change:errorText",()=>{e.ui.update()}),this.listenTo(s,"cancel",()=>{this._closeFormView()}),s.keystrokes.set("Esc",(e,t)=>{this._closeFormView(),t()}),s.providersListChildren.bindTo(this._linksProviders).using(e=>this._createLinksListProviderButton(e)),s}_createLinkProviderListView(e){return e.getListItems().map(({href:e,label:t,icon:i})=>{const n=new rh;return n.set({label:t,icon:i,tooltip:!1,withText:!0}),n.on("execute",()=>{this.formView.resetFormStatus(),this.formView.urlInputView.fieldView.value=e,this.editor.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),n})}_createLinkProviderItemsView(e){const t=this.editor,i=t.locale.t,n=new eC(t.locale),{emptyListPlaceholder:s,label:o}=e;return n.emptyListPlaceholder=s||i("No links available"),n.title=o,this.listenTo(n,"cancel",()=>{t.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),n}_createPropertiesView(){const e=this.editor,t=this.editor.commands.get("link"),i=new(Qu(tC))(e.locale);return this.listenTo(i,"back",()=>{e.editing.view.focus(),this._removePropertiesView()}),i.listChildren.bindTo(t.manualDecorators).using(i=>{const n=new Nh(e.locale);return n.set({label:i.label,withText:!0}),n.bind("isOn").toMany([i,t],"value",(e,t)=>void 0===t&&void 0===e?!!i.defaultValue:!!e),n.on("execute",()=>{e.execute("link",t.value,{...this._getDecoratorSwitchesState(),[i.id]:!n.isOn})}),n}),i}_getDecoratorSwitchesState(){const e=this.editor.commands.get("link");return Array.from(e.manualDecorators).reduce((t,i)=>{const n=void 0===e.value&&void 0===i.value?i.defaultValue:i.value;return{...t,[i.id]:!!n}},{})}_registerEditingOpeners(){this.editor.plugins.get(Qk)._registerLinkOpener(e=>{const t=this._getLinkProviderLinkByHref(e);if(!t)return!1;const{item:i,provider:n}=t;return!!n.navigate&&n.navigate(i)})}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("link",()=>{const e=this._createButton(rh);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add("menuBar:link",()=>{const e=this._createButton(Eh);return e.set({role:"menuitemcheckbox"}),e}),e.ui.componentFactory.add("linkPreview",t=>{const i=new Xk(t),n=e.config.get("link.allowedProtocols"),s=e.commands.get("link"),o=t.t;i.bind("isEnabled").to(s,"value",e=>!!e),i.bind("href").to(s,"value",e=>e&&Lk(e,n));const r=e=>{if(!e)return i.label=void 0,i.icon=void 0,void(i.tooltip=o("Open link in new tab"));const t=this._getLinkProviderLinkByHref(e);if(t){const{label:e,tooltip:n,icon:s}=t.item;i.label=e,i.tooltip=n||!1,i.icon=s}else i.label=e,i.icon=void 0,i.tooltip=o("Open link in new tab")};return r(s.value),this.listenTo(s,"change:value",(e,t,i)=>{r(i)}),this.listenTo(i,"navigate",(e,t,i)=>{const n=this._getLinkProviderLinkByHref(t);if(!n)return;const{provider:s,item:o}=n,{navigate:r}=s;r&&r(o)&&(e.stop(),i())}),i}),e.ui.componentFactory.add("unlink",t=>{const i=e.commands.get("unlink"),n=new rh(t),s=t.t;return n.set({label:s("Unlink"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.8.8 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.7.7 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294zm5.494-5.335a.8.8 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.8.8 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955m-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184m4.919 10.562-1.414 1.414a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.061-1.06l1.414 1.414 1.414-1.415a.75.75 0 0 1 1.061 1.061l-1.414 1.414 1.414 1.415a.75.75 0 0 1-1.06 1.06z"/></svg>',tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",()=>{e.execute("unlink"),this._hideUI()}),n}),e.ui.componentFactory.add("editLink",t=>{const i=e.commands.get("link"),n=new rh(t),s=t.t;return n.set({label:s("Edit link"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m7.3 17.37-.061.088a1.52 1.52 0 0 1-.934.535l-4.178.663-.806-4.153a1.5 1.5 0 0 1 .187-1.058l.056-.086L8.77 2.639c.958-1.351 2.803-1.076 4.296-.03 1.497 1.047 2.387 2.693 1.433 4.055zM9.14 4.728l-5.545 8.346 3.277 2.294 5.544-8.346zM6.07 16.512l-3.276-2.295.53 2.73zM9.994 3.506 13.271 5.8c.316-.452-.16-1.333-1.065-1.966-.905-.634-1.895-.78-2.212-.328M8 18.5 9.375 17H19v1.5z"/></svg>',tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",()=>{this._addFormView()}),n}),e.ui.componentFactory.add("linkProperties",t=>{const i=e.commands.get("link"),n=new rh(t),s=t.t;return n.set({label:s("Link properties"),icon:'<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.734 6.375H1.75a.75.75 0 0 1 0-1.5h1.984a2.626 2.626 0 0 1 5.032 0h9.48a.75.75 0 0 1 0 1.5h-9.48a2.626 2.626 0 0 1-5.032 0Zm1.141-.75a1.375 1.375 0 1 1 2.75 0 1.375 1.375 0 0 1-2.75 0ZM16.263 14.625h1.983a.75.75 0 0 1 0 1.5h-1.983a2.626 2.626 0 0 1-5.033 0H1.75a.75.75 0 0 1 0-1.5h9.48a2.626 2.626 0 0 1 5.033 0Zm-1.142.75a1.375 1.375 0 1 1-2.75 0 1.375 1.375 0 0 1 2.75 0Z"/></svg>\n',tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled",i,"value",i,"manualDecorators",(e,t,i)=>e&&!!t&&i.length>0),this.listenTo(n,"execute",()=>{this._addPropertiesView()}),n})}_createLinksListProviderButton(e){const t=this.editor.locale,i=new iC(t);return i.set({label:e.label}),this.listenTo(i,"execute",()=>{this._showLinksProviderView(e)}),i}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),s=new e(t.locale),o=i.t;return s.set({label:o("Link"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.8.8 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.7.7 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294zm5.494-5.335a.8.8 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.8.8 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955m-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184"/></svg>',keystroke:Fk,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>!!e),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(Fk,(t,i)=>{i(),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())}),Yu({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,void 0!==e.value?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(),n=o();const s=()=>{const e=this._getSelectedLinkElement(),t=o();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function o(){return t.selection.focus.getAncestors().reverse().find(e=>e.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(nC)){const t=this.editor.editing.mapper.markerNameToElements(nC);if(t){const i=Array.from(t),n=e.createRange(e.createPositionBefore(i[0]),e.createPositionAfter(i[i.length-1]));return{target:e.domConverter.viewRangeToDom(n)}}}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&&pp(i))return oC(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=oC(i.start),s=oC(i.end);return n&&n==s&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_getSelectedLinkableText(){const e=this.editor.model,t=this.editor.editing,i=this._getSelectedLinkElement();if(!i)return $k(e.document.selection.getFirstRange());const n=t.view.createRangeOn(i);return $k(t.mapper.toModelRange(n))}_getLinkProviderLinkByHref(e){if(!e)return null;for(const t of this._linksProviders){const i=t.getItem?t.getItem(e):t.getListItems().find(t=>t.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(nC))t.updateMarker(nC,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition(({item:t})=>!e.schema.isContent(t),{boundaries:i});t.addMarker(nC,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(nC,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(nC)&&e.change(e=>{e.removeMarker(nC)})}}function oC(e){return e.getAncestors().find(e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t})||null}const rC=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");class aC extends Cc{static get requires(){return[lf,Qk]}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")?vf(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,n=i.document.selection,s=n.getFirstPosition(),o=n.getLastPosition();let r=t.getJoined(this._expandLinkRange(i,s)||t);r&&(r=r.getJoined(this._expandLinkRange(i,o)||t)),r&&(r.start.isBefore(s)||r.end.isAfter(o))&&e.setSelection(r)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),s=e.commands.get("link");n.on("inputTransformation",(e,n)=>{if(!this.isEnabled||!s.isEnabled||i.isCollapsed||"paste"!==n.method)return;if(i.rangeCount>1)return;const o=i.getFirstRange(),r=n.dataTransfer.getData("text/plain");if(!r)return;const a=r.match(rC);a&&a[2]===r&&(t.change(e=>{this._selectEntireLinks(e,o),s.execute(r)}),e.stop())},{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new uf(e.model,e=>{let t=e;if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(t))return;t=t.slice(0,-1),"!.:,;?".includes(t[t.length-1])&&(t=t.slice(0,-1));const i=lC(t);return i?{url:i,removedTrailingCharacters:e.length-t.length}:void 0});t.on("matched:data",(t,i)=>{const{batch:n,range:s,url:o,removedTrailingCharacters:r}=i;if(!n.isTyping)return;const a=s.end.getShiftedBy(-r),l=a.getShiftedBy(-o.length),c=e.model.createRange(l,a);this._applyAutoLink(o,c)}),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",()=>{const e=t.document.selection.getFirstPosition();let i;i=e.parent.previousSibling?.is("element")?t.createRangeIn(e.parent.previousSibling):t.createRange(t.createPositionAt(e.parent,0),e),this._checkAndApplyAutoLinkOnRange(i)})}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)})}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=df(e,t),s=lC(i);if(s){const e=t.createRange(n.end.getShiftedBy(-s.length),n.end);this._applyAutoLink(s,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=zk(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&Hk(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange(s=>{s.setAttribute("linkHref",e,t),i.enqueueChange(()=>{n.requestUndoOnBackspace()})})}}function lC(e){const t=rC.exec(e);return t?t[2]:null}const cC={"(":")","[":"]","{":"}"};class dC extends Tc{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,n="string"==typeof e.mention?{id:e.mention}:e.mention,s=n.id,o=e.range||i.getFirstRange();if(!t.canEditAt(o))return;const r=e.text||s,a=hC({_text:r,id:s},n);if(!s.startsWith(e.marker))throw new fe("mentioncommand-incorrect-id",this);t.change(e=>{const n=di(i.getAttributes()),s=new Map(n.entries());s.set("mention",a);const l=t.insertContent(e.createText(r,s),o),c=l.start.nodeBefore,d=l.end.nodeAfter,u=d&&d.is("$text")&&d.data.startsWith(" ");let h=!1;if(c&&d&&c.is("$text")&&d.is("$text")){const e=c.data.slice(-1),t=e in cC,i=t&&d.data.startsWith(cC[e]);h=t&&i}h||u||t.insertContent(e.createText(" ",n),o.start.getShiftedBy(r.length))})}}class uC extends Cc{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:e=>mC(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:fC}),e.conversion.for("downcast").add(gC),i.registerPostFixer(e=>function(e,t,i){const n=t.differ.getChanges();let s=!1;for(const t of n){if("attribute"==t.type)continue;const n=t.position;if("$text"==t.name){const t=n.textNode&&n.textNode.nextSibling;s=bC(n.textNode,e)||s,s=bC(t,e)||s,s=bC(n.nodeBefore,e)||s,s=bC(n.nodeAfter,e)||s}if("$text"!=t.name&&"insert"==t.type){const t=n.nodeAfter;for(const i of e.createRangeIn(t).getItems())s=bC(i,e)||s}if("insert"==t.type&&i.isInline(t.name)){const t=n.nodeAfter&&n.nodeAfter.nextSibling;s=bC(n.nodeBefore,e)||s,s=bC(t,e)||s}}return s}(e,i,t.schema)),i.registerPostFixer(e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const t of i)if("attribute"===t.type&&"mention"!=t.attributeKey){const i=t.range.start.nodeBefore,s=t.range.end.nodeAfter;for(const o of[i,s])pC(o)&&o.getAttribute(t.attributeKey)!=t.attributeNewValue&&(e.setAttribute(t.attributeKey,t.attributeNewValue,o),n=!0)}return n}(e,i)),i.registerPostFixer(e=>function(e,t){const i=t.selection,n=i.focus;if(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart;return e.nodeBefore&&e.nodeBefore.is("$text")||t}(n))return e.removeSelectionAttribute("mention"),!0;return!1}(e,i)),e.commands.add("mention",new dC(e))}}function hC(e,t){return Object.assign({uid:he().slice(0,8)},e,t||{})}function mC(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(!n)return;const s=e.getAttribute("data-mention-uid");return hC({id:i,_text:n.data},s?{uid:s,...t}:t)}function gC(e){e.on("attribute:mention",(e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const s=t.range.start;(s.textNode||s.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)},{priority:"highest"})}function fC(e,{writer:t,options:i}){if(e)return t.createAttributeElement("span",{class:"mention","data-mention":e.id,...!i.isClipboardPipeline&&{"data-mention-uid":e.uid}},{id:e.uid,priority:20})}function pC(e){if(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))return!1;return e.data!=e.getAttribute("mention")._text}function bC(e,t){return!!pC(e)&&(t.removeAttribute("mention",e),!0)}class wC extends am{selected;position;constructor(e){super(e),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<this.items.length?t=e:e<0&&(t=this.items.length-1);const i=this.items.get(t);this.selected!==i&&(this.selected&&this.selected.removeHighlight(),i.highlight(),this.selected=i,this._isItemVisibleInScrolledArea(i)||(this.element.scrollTop=i.element.offsetTop))}executeSelected(){this.selected.fire("execute")}_isItemVisibleInScrolledArea(e){return new ht(this.element).contains(new ht(e.element))}}class _C extends Uu{domElement;constructor(e,t){super(e),this.template=void 0,this.domElement=t,this.domElement.classList.add("ck-button"),this.set("isOn",!1),this.on("change:isOn",(e,t,i)=>{i?(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 vC extends sm{item;marker;highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const yC=[Ut.arrowup,Ut.arrowdown,Ut.esc],kC=[Ut.enter,Ut.tab];class CC extends Cc{_mentionsView;_mentionsConfigurations;_balloon;_items=new ni;_lastRequested;_requestFeedDebounced;static get pluginName(){return"MentionUI"}static get isOfficialPlugin(){return!0}static get requires(){return[vg]}constructor(e){super(e),this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=Ci(this._requestFeed,100),e.config.define("mention",{feeds:[]})}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||kC,i=yC.concat(t);this._balloon=e.plugins.get(vg),e.editing.view.document.on("keydown",(e,n)=>{var s;s=n.keyCode,i.includes(s)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==Ut.arrowdown&&this._mentionsView.selectNext(),n.keyCode==Ut.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==Ut.esc&&this._hideUIAndRemoveMarker())},{priority:"highest"}),Yu({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const e of n){const{feed:t,marker:i,dropdownLimit:n}=e;if(!PC(i))throw new fe("mentionconfig-incorrect-marker",null,{marker:i});const s={marker:i,feedCallback:"function"==typeof t?t.bind(this.editor):xC(t),itemRenderer:e.itemRenderer,dropdownLimit:n};this._mentionsConfigurations.set(i,s)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",()=>{this._hideUIAndRemoveMarker()}),this.on("requestFeed:response",(e,t)=>this._handleFeedResponse(t)),this.on("requestFeed:error",()=>this._hideUIAndRemoveMarker())}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new wC(e);return t.items.bindTo(this._items).using(i=>{const{item:n,marker:s}=i,{dropdownLimit:o}=this._mentionsConfigurations.get(s),r=o||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new vC(e),l=this._renderItem(n,s);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=s,a.on("execute",()=>{t.fire("execute",{item:n,marker:s})}),a}),t.on("execute",(e,t)=>{const i=this.editor,n=i.model,s=t.item,o=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:s,text:s.text,marker:o,range:c}),i.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),n=i(t);n instanceof Promise?n.then(i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})}).catch(t=>{this.fire("requestFeed:error",{error:t}),pe("mention-feed-callback-error",{marker:e})}):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map(e=>({...e,pattern:EC(e.marker,e.minimumCharacters||0)})),n=new uf(t.model,function(e){const t=t=>{const i=TC(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const s=t.substring(n);return i.pattern.test(s)};return t}(i));n.on("matched",(e,n)=>{const s=TC(i,n.text),o=t.model.document.selection.focus,r=t.model.createPositionAt(o.parent,s.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(o)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=EC(e.marker,0),s=t.substring(i);return s.match(n)[2]}(s,n.text),l=s.marker.length+a.length,c=o.getShiftedBy(-l),d=o.getShiftedBy(-a.length),u=t.model.createRange(c,d);if(SC(t)){const e=t.model.markers.get("mention");t.model.change(t=>{t.updateMarker(e,{range:u})})}else t.model.change(e=>{e.addMarker("mention",{range:u,usingOperation:!1,affectsData:!1})});this._requestFeedDebounced(s.marker,a)}),n.on("unmatched",()=>{this._hideUIAndRemoveMarker()});const s=t.commands.get("mention");return n.bind("isEnabled").to(s),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!SC(this.editor))return;this._items.clear();for(const e of t){const t="object"!=typeof e?{id:e,text:e}:e;this._items.add({item:t,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):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),SC(this.editor)&&this.editor.model.change(e=>e.removeMarker("mention")),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,s=e.id;const o=this._getItemRenderer(t);if(o){const t=o(e);"string"!=typeof t?n=new _C(i.locale,t):s=t}if(!n){const e=new rh(i.locale);e.label=s,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,s=n.view.domConverter,o=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=o.toViewRange(t);return ht.getDomRangeRects(s.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:AC(t,i.locale.uiLanguageDirection)}}}function AC(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function TC(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function EC(e,t){const i=0==t?"*":`{${t},}`,n=Q.features.isRegExpUnicodePropertySupported?"\\p{Ps}\\p{Pi}\"'":"\\(\\[{\"'";e=e.replace(/[.*+?^${}()\-|[\]\\]/g,"\\$&");return new RegExp(`(?:^|[ ${n}])(${e})(.${i})$`,"u")}function xC(e){return t=>e.filter(e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase()))}function PC(e){return!!e}function SC(e){return e.model.markers.has("mention")}function IC(e){const t=parseFloat(e);return e.endsWith("pt")?OC(96*t/72):e.endsWith("pc")?OC(12*t*96/72):e.endsWith("in")?OC(96*t):e.endsWith("cm")?OC(96*t/2.54):e.endsWith("mm")?OC(t/10*96/2.54):e}function OC(e){return Math.round(e)+"px"}function RC(e,t,i){if(!e.childCount)return;const n=new hl(e.document),s=function(e,t){const i=t.createRangeIn(e),n=[],s=new Set;for(const e of i.getItems()){if(!e.is("element")||!e.name.match(/^(p|h\d+|li|div)$/))continue;let t=WC(e);if(void 0===t||0!=parseFloat(t)||Array.from(e.getClassNames()).find(e=>e.startsWith("MsoList"))||(t=void 0),e.hasStyle("mso-list")&&"none"!==e.getStyle("mso-list")||void 0!==t&&s.has(t)){const i=HC(e);n.push({element:e,id:i.id,order:i.order,indent:i.indent,marginLeft:t}),void 0!==t&&s.add(t)}else s.clear()}return n}(e,n);if(!s.length)return;const o={},r=[];let a=BC();for(const e of s)if(void 0!==e.indent){FC(e)||(MC(n,r,a),a=BC(),r.length=0);const s=`${e.id}:${e.indent}`,l=Math.min(e.indent-1,r.length);if(l<r.length&&r[l].id!==e.id&&(r.length=l),l<r.length-1)r.length=l+1;else{const a=LC(e,t);if(l>r.length-1||r[l].listElement.name!=a.type){0==l&&"ol"==a.type&&void 0!==e.id&&o[s]&&(a.startIndex=o[s]);const t=zC(a,n,i);if(0==r.length){const i=e.element.parent,s=i.getChildIndex(e.element)+1;n.insertChild(s,t,i)}else{const e=r[l-1].listItemElements;n.appendChild(t,e[e.length-1])}r[l]={...e,listElement:t,listItemElements:[]},0==l&&void 0!==e.id&&(o[s]=a.startIndex||1)}}const c="li"==e.element.name?e.element:n.createElement("li");VC(n,r,a,e,c,l),n.appendChild(c,r[l].listElement),r[l].listItemElements.push(c),0==l&&void 0!==e.id&&o[s]++,e.element!=c&&n.appendChild(e.element,c),$C(e.element,n),n.removeStyle("text-indent",e.element),n.removeStyle("margin-left",e.element)}else{const t=r.find(t=>t.marginLeft==e.marginLeft);if(t){const i=t.listItemElements;n.appendChild(e.element,i[i.length-1]),n.removeStyle("margin-left",e.element)}else r.length=0}MC(n,r,a)}function VC(e,t,i,n,s,o){if(void 0===n.marginLeft)return void(0==o&&(i.canApplyMarginOnList=!1));const r=parseFloat(n.marginLeft);let a=0;if(t.length>1){const e=t[t.length-2].listItemElements;if(e.length>0){const t=e[e.length-1].getStyle("margin-left");void 0!==t&&(a+=parseFloat(t))}}a+=40*t.length;const l=r-a,c=0!==l?OC(l):void 0;c&&(e.setStyle("margin-left",c,s),0==o&&i.canApplyMarginOnList&&(void 0===i.marginLeft&&(i.marginLeft=c),c!==i.marginLeft&&(i.canApplyMarginOnList=!1),i.topLevelListItemElements.push(s)))}function BC(){return{marginLeft:void 0,canApplyMarginOnList:!0,topLevelListItemElements:[]}}function MC(e,t,i){if(i.canApplyMarginOnList&&i.marginLeft&&i.topLevelListItemElements.length>0){e.setStyle("margin-left",i.marginLeft,t[0].listElement);for(const t of i.topLevelListItemElements)e.removeStyle("margin-left",t)}}function FC(e){const t=e.element.previousSibling;if(!t){const t=e.element.parent;return NC(t)&&(!t.previousSibling||NC(t.previousSibling))}return NC(t)}function NC(e){return e.is("element","ol")||e.is("element","ul")}function LC(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,s=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=new RegExp(`@list\\s+l${e.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),r=new RegExp(`@list l${e.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=o.exec(t),l=r.exec(t),c=a&&!l,d=i.exec(t);let u="decimal",h="ol",m=null;if(d&&d[1]){const t=n.exec(d[1]);if(t&&t[1]&&(u=t[1].trim(),h="bullet"!==u&&"image"!==u?"ol":"ul"),"bullet"===u){const t=function(e){if("li"==e.name&&"ul"==e.parent.name&&e.parent.hasAttribute("type"))return e.parent.getAttribute("type");const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const i=t._data;if("o"===i)return"circle";if("·"===i)return"disc";if("§"===i)return"square";return null}(e.element);t&&(u=t)}else{const e=s.exec(d[1]);e&&e[1]&&(m=parseInt(e[1]))}c&&(h="ol")}return{type:h,startIndex:m,style:DC(u),isLegalStyleList:c}}function DC(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){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 e;default:return null}}function zC(e,t,i){const n=t.createElement(e.type);return e.style&&t.setStyle("list-style-type",e.style,n),e.startIndex&&e.startIndex>1&&t.setAttribute("start",e.startIndex,n),e.isLegalStyleList&&i&&t.addClass("legal-list",n),n}function HC(e){const t=e.getStyle("mso-list");if(void 0===t)return{};const i=t.match(/(^|\s{1,100})l(\d+)/i),n=t.match(/\s{0,100}lfo(\d+)/i),s=t.match(/\s{0,100}level(\d+)/i);return i&&n&&s?{id:i[2],order:n[1],indent:parseInt(s[1])}:{indent:1}}function $C(e,t){const i=new bn({name:"span",styles:{"mso-list":"Ignore"}}),n=t.createRangeIn(e);for(const e of n)"elementStart"===e.type&&i.match(e.item)&&t.remove(e.item)}function WC(e){const t=e.getStyle("margin-left");return void 0===t||t.endsWith("px")?t:IC(t)}function jC(e,t){if(!e.childCount)return;const i=new hl(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new bn({name:/v:(.+)/}),s=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,o=i&&i.is("element")?i.name:null,r=["Chart"],a=n.match(t),l=t.getAttribute("o:gfxdata"),c="v:shapetype"===o,d=l&&r.some(e=>t.getAttribute("id").includes(e));a&&l&&!c&&!d&&s.push(e.item.getAttribute("id"))}return s}(e,i);!function(e,t,i){const n=i.createRangeIn(t),s=new bn({name:"img"}),o=[];for(const t of n)if(t.item.is("element")&&s.match(t.item)){const i=t.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every(t=>e.indexOf(t)>-1)?o.push(i):i.getAttribute("src")||o.push(i)}for(const e of o)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),s=[];for(const t of n)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;o(t.item.parent.getChildren(),i)||s.push(t.item)}for(const e of s){const t={src:r(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function o(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(o(i.getChildren(),t))return!0}return!1}function r(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new bn({name:/v:(.+)/}),s=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&s.push(e.item);for(const e of s)t.remove(e)}(e,i);const s=function(e,t){const i=t.createRangeIn(e),n=new bn({name:"img"}),s=[];let o=0;for(const e of i)e.item.is("element")&&n.match(e.item)&&(e.item.getAttribute("src").startsWith("file://")&&s.push({element:e.item,imageIndex:o}),o++);return s}(e,i);s.length&&function(e,t,i){for(let n=0;n<e.length;n++){const{element:s,imageIndex:o}=e[n],r=t[o];if(r){const e=`data:${r.type};base64,${UC(r.hex)}`;i.setAttribute("src",e,s)}}}(s,function(e){if(!e)return[];const t=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+t.source+"))([\\da-fA-F\\s]+)\\}","g"),n=e.match(i),s=[];if(n)for(const e of n){let i=!1;e.includes("\\pngblip")?i="image/png":e.includes("\\jpegblip")&&(i="image/jpeg"),i&&s.push({hex:e.replace(t,"").replace(/[^\da-fA-F]/g,""),type:i})}return s}(t),i)}function UC(e){return btoa(e.match(/\w{2}/g).map(e=>String.fromCharCode(parseInt(e,16))).join(""))}function qC(e,t){for(const i of t.createRangeIn(e).getItems())i.is("element","table")&&("0px"===i.getStyle("width")&&t.removeStyle("width",i),"0"===i.getAttribute("width")&&t.removeAttribute("width",i))}function KC(e,t){const i=[],n=[];for(const{item:s}of e.createRangeIn(t))if(s.is("element")&&s.getStyle("mso-footnote-id")){i.unshift(s);const{nextSibling:e}=s;e?.is("$text")&&e.data.startsWith(" ")&&n.unshift(e)}for(const t of i)e.remove(t);for(const t of n){const i=t.data.substring(1);if(i.length>0){const n=t.parent,s=n.getChildIndex(t),o=e.createText(i);e.remove(t),e.insertChild(s,o,n)}else e.remove(t)}return t}function GC(e,t){const i=e.createElement("sup",{class:"footnote"}),n=e.createElement("a",{id:`ref-${t}`,href:`#${t}`});return e.appendChild(n,i),i}function JC(e,t){const i=e.createElement("li",{id:t,class:"footnote-definition"}),n=e.createElement("a",{href:`#ref-${t}`,class:"footnote-backlink"}),s=e.createElement("div",{class:"footnote-content"});return e.appendChild(e.createText("^"),n),e.appendChild(n,i),e.appendChild(s,i),{listItem:i,content:s}}const YC=/<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i,QC=/xmlns:o="urn:schemas-microsoft-com/i;class XC{document;hasMultiLevelListPlugin;hasTablePropertiesPlugin;constructor(e,t=!1,i=!1){this.document=e,this.hasMultiLevelListPlugin=t,this.hasTablePropertiesPlugin=i}isActive(e){return YC.test(e)||QC.test(e)}execute(e){const t=new hl(this.document),{body:i,stylesString:n}=e._parsedData;!function(e,t){const i=[];for(const n of t.createRangeIn(e)){const e=n.item;e.is("element","a")&&!e.hasAttribute("href")&&(e.hasAttribute("id")||e.hasAttribute("name"))&&i.push(e)}for(const e of i){const i=e.parent.getChildIndex(e)+1,n=e.getChildren();t.insertChild(i,n,e.parent)}}(i,t),RC(i,n,this.hasMultiLevelListPlugin),jC(i,e.dataTransfer.getData("text/rtf")),function(e,t,i=!1){for(const n of t.createRangeIn(e).getItems()){if(!n.is("element","table")&&!n.is("element","td")&&!n.is("element","th"))continue;if(i&&n.is("element","table")){const e=n.parent?.is("element","div")?n.parent:null,i=n.parent?.parent?.is("element","div")?n.parent.parent:null,s=e??i;s&&"center"===s.getAttribute("align")&&!n.getAttribute("align")?(t.setStyle("margin-left","auto",n),t.setStyle("margin-right","auto",n)):s&&"right"===s.getAttribute("align")&&!n.getAttribute("align")?(t.setStyle("margin-left","auto",n),t.setStyle("margin-right","0",n)):s||n.getAttribute("align")||(t.setStyle("margin-left","0",n),t.setStyle("margin-right","auto",n))}const e=["left","top","right","bottom"];if(e.every(e=>!n.hasStyle(`border-${e}-style`)))t.setStyle("border-style","none",n);else for(const i of e)n.hasStyle(`border-${i}-style`)||t.setStyle(`border-${i}-style`,"none",n);const s=["width","height",...e.map(e=>`border-${e}-width`),...e.map(e=>`padding-${e}`)];for(const e of s)n.hasStyle(e)&&t.setStyle(e,IC(n.getStyle(e)),n)}}(i,t,this.hasTablePropertiesPlugin),qC(i,t),function(e,t){const i=new Map,n=new Map;let s=null;for(const{item:o}of t.createRangeIn(e))if(o.is("element"))if("footnote-list"!==o.getStyle("mso-element")){if(o.hasStyle("mso-footnote-id")){const e=o.findAncestor("element",e=>"footnote"===e.getStyle("mso-element"));if(e){const t=e.getAttribute("id");n.set(t,e)}else{const e=o.getStyle("mso-footnote-id");i.set(e,o)}continue}}else s=o;if(!i.size||!s)return;const o=function(e){return e.createElement("ol",{class:"footnotes"})}(t);t.replace(s,o);for(const[e,s]of i){const i=n.get(e);if(!i)continue;t.replace(s,GC(t,e));const r=JC(t,e);KC(t,i);for(const e of i.getChildren()){let i=e;e.is("element")&&(i=t.clone(e,!0)),t.appendChild(i,r.content)}t.appendChild(r.listItem,o)}}(i,t),function(e){const t=[],i=new hl(e.document);for(const{item:n}of i.createRangeIn(e))if(n.is("element")){for(const e of n.getClassNames())/\bmso/gi.exec(e)&&i.removeClass(e,n);for(const e of n.getStyleNames())/\bmso/gi.exec(e)&&i.removeStyle(e,n);(n.is("element","w:sdt")||n.is("element","w:sdtpr")&&n.isEmpty||n.is("element","o:p")&&n.isEmpty)&&t.push(n)}for(const e of t){const t=e.parent,n=t.getChildIndex(e);i.insertChild(n,e.getChildren(),t),i.remove(e)}}(i),e.content=i}}function ZC(e,t,i,{blockElements:n,inlineObjectElements:s}){let o=i.createPositionAt(e,"forward"==t?"after":"before");return o=o.getLastMatchingPosition(({item:e})=>e.is("element")&&!n.includes(e.name)&&!s.includes(e.name),{direction:t}),"forward"==t?o.nodeAfter:o.nodeBefore}function eA(e,t){return!!e&&e.is("element")&&t.includes(e.name)}function tA(e){let t=e;for(;t;){if(t.is("element")){const e=t.getStyle?.("white-space");if("pre-wrap"===e)return!0}t=t.parent}return!1}function iA(e,t,i){const{parent:n,data:s}=e,o=s.replaceAll("\t"," ".repeat(i)),r=n.getChildIndex(e);t.remove(e),t.insertChild(r,t.createText(o),n)}const nA=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class sA{document;constructor(e){this.document=e}isActive(e){return nA.test(e)}execute(e){const t=new hl(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}(i,t),function(e,t){const i=new Yn(t.document.stylesProcessor),n=new Fs(i,{renderingMode:"data"}),s=n.blockElements,o=n.inlineObjectElements,r=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=ZC(e,"forward",t,{blockElements:s,inlineObjectElements:o}),n=ZC(e,"backward",t,{blockElements:s,inlineObjectElements:o}),a=eA(i,s);(eA(n,s)||a)&&r.push(e)}}for(const e of r)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),function(e,t,i){const n=new Set;for(const i of t.createRangeIn(e).getItems())i.is("view:$textProxy")&&i.data.includes("\t")&&tA(i.parent)&&n.add(i.textNode);for(const e of n)iA(e,t,i)}(i,t,8),e.content=i}}const oA=/<google-sheets-html-origin/i;class rA{document;constructor(e){this.document=e}isActive(e){return oA.test(e)}execute(e){const t=new hl(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","google-sheets-html-origin")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of e.getChildren())i.is("element","table")&&i.hasAttribute("xmlns")&&t.removeAttribute("xmlns",i)}(i,t),qC(i,t),function(e,t){for(const i of Array.from(e.getChildren()))i.is("element","style")&&t.remove(i)}(i,t),e.content=i}}function aA(e){return e.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>1===t.length?" ":Array(t.length+1).join(" ").substr(0,t.length))}function lA(e,t){const i=new DOMParser,n=function(e){return aA(aA(e)).replace(/(<span\s+style=['"]mso-spacerun:yes['"]>[^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g,"").replace(/(<span\s+style=['"]letter-spacing:[^'"]+?['"]>)[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," </").replace(/ <o:p><\/o:p>/g," <o:p></o:p>").replace(/<o:p>( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)</g,"><")}(function(e){const t="</body>",i="</html>",n=e.indexOf(t);if(n<0)return e;const s=e.indexOf(i,n+t.length);return e.substring(0,n+t.length)+(s>=0?e.substring(s):"")}(e=(e=e.replace(/<!--\[if gte vml 1]>/g,"")).replace(/<o:SmartTagType(?:\s+[^\s>=]+(?:="[^"]*")?)*\s*\/?>/gi,""))),s=i.parseFromString(n,"text/html");!function(e){e.querySelectorAll("span[style*=spacerun]").forEach(e=>{const t=e,i=t.innerText.length||0;t.innerText=Array(i+1).join(" ").substr(0,i)})}(s);const o=s.body.innerHTML,r=function(e,t){const i=new Yn(t),n=new Fs(i,{renderingMode:"data"}),s=e.createDocumentFragment(),o=e.body.childNodes;for(;o.length>0;)s.appendChild(o[0]);return n.domToView(s,{skipComments:!0})}(s,t),a=function(e){const t=[],i=[],n=Array.from(e.getElementsByTagName("style"));for(const e of n)e.sheet&&e.sheet.cssRules&&e.sheet.cssRules.length&&(t.push(e.sheet),i.push(e.innerHTML));return{styles:t,stylesString:i.join(" ")}}(s);return{body:r,bodyString:o,styles:a.styles,stylesString:a.stylesString}}function cA(e,t){const{modelAttribute:i,styleName:n,attributeName:s,attributeType:o,viewElement:r,defaultValue:a,shouldUpcast:l=()=>!0,reduceBoxSides:c=!1}=t;e.for("upcast").attributeToAttribute({view:{name:r,styles:{[n]:/[\s\S]+/}},model:{key:i,value:(e,t,i)=>{if(!l(e))return;const s=mA(a,"",i),o=e.getNormalizedStyle(n),r=c?gA(o):o;if(s!==r)return r;t.consumable.consume(e,{styles:n})}}}),s&&e.for("upcast").attributeToAttribute({view:{name:r,attributes:{[s]:/.+/}},model:{key:i,value:(e,t,i)=>{if("figure"==e.name||e.hasStyle(n)||"table"==e.name&&"figure"==e.parent.name&&e.parent.hasStyle(n))return;const r=mA(a,"",i);let l=e.getAttribute(s);if(l&&"length"==o){const e=parseFloat(l);l=isNaN(e)?r:e+(l.includes("%")?"%":"px")}if(r!==l)return l;t.consumable.consume(e,{attributes:s})}}})}function dA(e,t,i,n){const{conversion:s}=e;s.for("upcast").add(e=>{e.on(`element:${t}`,(e,t,s)=>{const{modelRange:o,viewItem:r}=t;if(!o)return;const a=["border-top-width","border-top-color","border-top-style","border-bottom-width","border-bottom-color","border-bottom-style","border-right-width","border-right-color","border-right-style","border-left-width","border-left-color","border-left-style"].filter(e=>r.hasStyle(e)),l=r.is("element","table")?r:r.findAncestor("table"),c=l.hasAttribute("border");if(!a.length&&!c)return;const d={styles:a};if(!s.consumable.test(r,d))return;const u=si(o.getItems({shallow:!0})),h=u.findAncestor("table",{includeSelf:!0});let m=n;h&&"layout"==h.getAttribute("tableType")&&(m={style:"none",color:"",width:""}),s.consumable.consume(r,d);const g={style:r.getNormalizedStyle("border-style"),color:r.getNormalizedStyle("border-color"),width:r.getNormalizedStyle("border-width")};if(c&&s.consumable.test(l,{attributes:"border"})){const e=parseFloat(l.getAttribute("border")||"1"),t=Number.isNaN(e)||!Number.isFinite(e)||e<0||"table"!=r.name&&e>1?"1px":`${e}px`;g.width={top:t,bottom:t,right:t,left:t,...g.width||{}},r.is("element","table")&&s.consumable.consume(l,{attributes:"border"})}const f={style:gA(g.style),color:gA(g.color),width:gA(g.width)};f.style!==m.style&&s.writer.setAttribute(i.style,f.style,u),f.color!==m.color&&s.writer.setAttribute(i.color,f.color,u),f.width!==m.width&&s.writer.setAttribute(i.width,f.width,u)})})}function uA(e,t){const{modelElement:i,modelAttribute:n,styleName:s}=t;e.for("downcast").attributeToAttribute({model:{name:i,key:n},view:e=>({key:"style",value:{[s]:e}})})}function hA(e,t){const{modelAttribute:i,styleName:n}=t;e.for("downcast").add(e=>{e.on(`attribute:${i}:table`,(e,t,i)=>{const{item:s,attributeNewValue:o}=t,{mapper:r,writer:a}=i;if(!i.consumable.consume(t.item,e.name))return;const l=Array.from(r.toViewElement(s).getChildren()).find(e=>e.is("element","table"));o?a.setStyle(n,o,l):a.removeStyle(n,l)})})}function mA(e,t,i){const n=i.modelRange&&si(i.modelRange.getItems({shallow:!0})),s=n&&n.is("element")&&n.findAncestor("table",{includeSelf:!0});return s&&"layout"===s.getAttribute("tableType")?t:e}function gA(e){if(!e)return;const t=["top","right","bottom","left"];if(!t.every(t=>e[t]))return e;const i=e.top;return t.every(t=>e[t]===i)?i:e}function fA(e,t,i){const{conversion:n}=e;n.for("upcast").add(e=>{e.on(`element:${t}`,(e,t,n)=>{const{modelRange:s,viewItem:o}=t;if(!s)return;if(o.is("element","table"))return void n.consumable.consume(o,{attributes:"cellpadding"});const r=o.findAncestor("table");if(!r.hasAttribute("cellpadding")||!n.consumable.test(r,{attributes:"cellpadding"}))return;const a=s?.start?.nodeAfter,l=parseFloat(r.getAttribute("cellpadding")||"1"),c=Number.isNaN(l)||!Number.isFinite(l)||l<0?"0px":`${l}px`,d=a.getAttribute("tableCellPadding");if(d){if("object"==typeof d){const e={...i!==c&&{top:c},...i!==c&&{right:c},...i!==c&&{bottom:c},...i!==c&&{left:c},...d};n.writer.setAttribute("tableCellPadding",e,a)}}else i!==c&&n.writer.setAttribute("tableCellPadding",c,a)},{priority:"low"})})}const pA={className:"table-style-align-left"},bA={className:"table-style-align-center"},wA={className:"table-style-align-right"},_A={className:"table-style-block-align-left"},vA={className:"table-style-block-align-right"},yA=[{view:{name:/^(table|figure)$/,styles:{float:/^(left|none|right)$/}},getAlign:e=>{let t=e.getStyle("float");return"none"===t&&(t="center"),t},getConsumables(e){const t=e.getStyle("float"),i=["float"];return"left"===t&&e.hasStyle("margin-right")?i.push("margin-right"):"right"===t&&e.hasStyle("margin-left")&&i.push("margin-left"),{styles:i}}},{view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},getAlign:()=>"center",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:/^(table|figure)$/,key:"class",value:"table-style-align-left"},getAlign:()=>"left",getConsumables:()=>({classes:pA.className})},{view:{name:/^(table|figure)$/,key:"class",value:wA.className},getAlign:()=>"right",getConsumables:()=>({classes:wA.className})},{view:{name:/^(table|figure)$/,key:"class",value:bA.className},getAlign:()=>"center",getConsumables:()=>({classes:bA.className})},{view:{name:/^(table|figure)$/,key:"class",value:_A.className},getAlign:()=>"blockLeft",getConsumables:()=>({classes:_A.className})},{view:{name:/^(table|figure)$/,key:"class",value:vA.className},getAlign:()=>"blockRight",getConsumables:()=>({classes:vA.className})},{view:{name:/^(table|figure)$/,styles:{"margin-left":"0","margin-right":"auto"}},getAlign:()=>"blockLeft",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"0"}},getAlign:()=>"blockRight",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:"table",attributes:{align:/^(left|center|right)$/}},getAlign:e=>e.getAttribute("align"),getConsumables:()=>({attributes:"align"})}],kA={center:{align:"center",style:"margin-left: auto; margin-right: auto;",className:"table-style-align-center"},left:{align:"left",style:"float: left;",className:"table-style-align-left"},right:{align:"right",style:"float: right;",className:"table-style-align-right"},blockLeft:{align:void 0,style:"margin-left: 0; margin-right: auto;",className:_A.className},blockRight:{align:void 0,style:"margin-left: auto; margin-right: 0;",className:vA.className}};class CA{_table;_startRow;_endRow;_startColumn;_endColumn;_includeAllSlots;_skipRows;_row;_rowIndex;_column;_cellIndex;_spannedCells;_nextCellAtColumn;_jumpedToStartRow=!1;constructor(e,t={}){this._table=e,this._startRow=void 0!==t.row?t.row:t.startRow||0,this._endRow=void 0!==t.row?t.row:t.endRow,this._startColumn=void 0!==t.column?t.column:t.startColumn||0,this._endColumn=void 0!==t.column?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){this._canJumpToStartRow()&&this._jumpToNonSpannedRowClosestToStartRow();const e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0,value:void 0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const i=this._getSpanned();if(i)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(i.cell,i.row,i.column));else{const i=e.getChild(this._cellIndex);if(!i)return this._advanceToNextRow();const n=parseInt(i.getAttribute("colspan")||"1"),s=parseInt(i.getAttribute("rowspan")||"1");(n>1||s>1)&&this._recordSpans(i,s,n),this._shouldSkipSlot()||(t=this._formatOutValue(i)),this._nextCellAtColumn=this._column+n}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,i=this._column){return{done:!1,value:new AA(this,e,t,i)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,i=this._column<this._startColumn,n=void 0!==this._endColumn&&this._column>this._endColumn;return e||t||i||n}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,i){const n={cell:e,row:this._row,column:this._column};for(let e=this._row;e<this._row+t;e++)for(let t=this._column;t<this._column+i;t++)e==this._row&&t==this._column||this._markSpannedCell(e,t,n)}_markSpannedCell(e,t,i){this._spannedCells.has(e)||this._spannedCells.set(e,new Map);this._spannedCells.get(e).set(t,i)}_canJumpToStartRow(){return!!this._startRow&&this._startRow>0&&!this._jumpedToStartRow}_jumpToNonSpannedRowClosestToStartRow(){const e=this._getRowLength(0);for(let t=this._startRow;!this._jumpedToStartRow;t--)e===this._getRowLength(t)&&(this._row=t,this._rowIndex=t,this._jumpedToStartRow=!0)}_getRowLength(e){return[...this._table.getChild(e).getChildren()].reduce((e,t)=>e+parseInt(t.getAttribute("colspan")||"1"),0)}}class AA{cell;row;column;cellAnchorRow;cellAnchorColumn;_cellIndex;_rowIndex;_table;constructor(e,t,i,n){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=i,this.cellAnchorColumn=n,this._cellIndex=e._cellIndex,this._rowIndex=e._rowIndex,this._table=e._table}get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||"1")}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||"1")}get rowIndex(){return this._rowIndex}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}}function TA(e){return"header"===e||"header-row"===e||"header-column"===e}function EA(e,t,i,n,s=1){null!=t&&null!=s&&t>s?n.setAttribute(e,t,i):n.removeAttribute(e,i)}function xA(e,t,i={}){const n=e.createElement("tableCell",i);return e.insertElement("paragraph",n),e.insert(n,t),n}function PA(e,t){const i=t.parent.parent,n=parseInt(i.getAttribute("headingColumns")||"0"),{column:s}=e.getCellLocation(t);return!!n&&s<n}function SA(e,t,i){const{modelAttribute:n}=i;e.extend("tableCell",{allowAttributes:[n]}),e.setAttributeProperties(n,{isFormatting:!0}),cA(t,{viewElement:/^(td|th)$/,...i}),uA(t,{modelElement:"tableCell",...i})}function IA(e){const t=e.getSelectedElement();return t&&t.is("element","table")?t:e.getFirstPosition().findAncestor("table")}function OA({table:e,row:t,column:i}){const n=new CA(e,{row:t,column:i});for(const{cell:e}of n){if(!TA(e.getAttribute("tableCellType")))return!1}return!0}function RA(e){return e.model.schema.checkAttribute("tableCell","tableCellType")}function VA(e,t,i){const{startRow:n,startColumn:s,endRow:o,endColumn:r}=t,a=i.createElement("table"),l=e.getAttribute("tableType");l&&i.setAttribute("tableType",l,a);const c=o-n+1;for(let e=0;e<c;e++)i.insertElement("tableRow",a,"end");const d=[...new CA(e,{startRow:n,endRow:o,startColumn:s,endColumn:r,includeAllSlots:!0})];for(const{row:e,column:t,cell:l,isAnchor:c,cellAnchorRow:u,cellAnchorColumn:h}of d){const d=e-n,m=a.getChild(d);if(c){const n=i.cloneElement(l);i.append(n,m),LA(n,e,t,o,r,i)}else(u<n||h<s)&&xA(i,i.createPositionAt(m,"end"))}return function(e,t,i,n,s){const o=parseInt(t.getAttribute("headingRows")||"0");if(o>0){EA("headingRows",o-i,e,s,0)}const r=parseInt(t.getAttribute("headingColumns")||"0");if(r>0){EA("headingColumns",r-n,e,s,0)}}(a,e,n,s,i),function(e,t,i,n,s){const o=Array.from(t.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0),r=parseInt(t.getAttribute("footerRows")||"0"),a=o-r;if(r<1)return;let l=0;n>=a&&(l=n-Math.max(a,i)+1);EA("footerRows",l,e,s,0)}(a,e,n,o,i),a}function BA(e,t,i=0){const n=[],s=new CA(e,{startRow:i,endRow:t-1});for(const e of s){const{row:i,cellHeight:s}=e;i<t&&t<=i+s-1&&n.push(e)}return n}function MA(e,t,i){const n=e.parent,s=n.parent,o=n.index,r=t-o,a={},l=parseInt(e.getAttribute("rowspan"))-r;l>1&&(a.rowspan=l);const c=parseInt(e.getAttribute("colspan")||"1");c>1&&(a.colspan=c);const d=o+r,u=[...new CA(s,{startRow:o,endRow:d,includeAllSlots:!0})];let h,m=null;for(const t of u){const{row:n,column:s,cell:o}=t;o===e&&void 0===h&&(h=s),void 0!==h&&h===s&&n===d&&(m=xA(i,t.getPositionBefore(),a))}return EA("rowspan",r,e,i),m}function FA(e,t){const i=[],n=new CA(e);for(const e of n){const{column:n,cellWidth:s}=e;n<t&&t<=n+s-1&&i.push(e)}return i}function NA(e,t,i,n){const s=i-t,o={},r=parseInt(e.getAttribute("colspan"))-s;r>1&&(o.colspan=r);const a=parseInt(e.getAttribute("rowspan")||"1");a>1&&(o.rowspan=a);const l=xA(n,n.createPositionAfter(e),o);return EA("colspan",s,e,n),l}function LA(e,t,i,n,s,o){const r=parseInt(e.getAttribute("colspan")||"1"),a=parseInt(e.getAttribute("rowspan")||"1");if(i+r-1>s){EA("colspan",s-i+1,e,o,1)}if(t+a-1>n){EA("rowspan",n-t+1,e,o,1)}}function DA(e,t){const i=t.getColumns(e),n=new Array(i).fill(0);for(const{column:t}of new CA(e))n[t]++;const s=n.reduce((e,t,i)=>t?e:[...e,i],[]);if(s.length>0){const i=s[s.length-1];return t.removeColumns(e,{at:i}),!0}return!1}function zA(e,t){const i=[],n=t.getRows(e);for(let t=0;t<n;t++){e.getChild(t).isEmpty&&i.push(t)}if(i.length>0){const n=i[i.length-1];return t.removeRows(e,{at:n}),!0}return!1}function HA(e,t){DA(e,t)||zA(e,t)}function $A(e,t){const i=Array.from(new CA(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(i.every(({cellHeight:e})=>1===e))return t.lastRow;const n=i[0].cellHeight-1;return t.lastRow+n}function WA(e,t){const i=Array.from(new CA(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(i.every(({cellWidth:e})=>1===e))return t.lastColumn;const n=i[0].cellWidth-1;return t.lastColumn+n}function jA(e){for(const t of e.getChildren())if(t.is("element","table"))return t}function UA(e){return t=>{t.on("element:table",(t,i,n)=>{const s=i.viewItem;if(!n.consumable.test(s,{name:!0}))return;const{rows:o,headingRows:r,headingColumns:a,footerRows:l}=function(e){let t,i=!0;const n=[],s=[],o=[];let r=null,a=null;const l=Array.from(e.getChildren());for(let e=0;e<l.length;e++){const t=l[e];if("tbody"!==t.name&&"thead"!==t.name&&"tfoot"!==t.name)continue;"thead"!==t.name||r||(i=!0,r=t);const c=Array.from(t.getChildren()).filter(e=>e.is("element","tr"));let d=null,u=null;for(const h of c){const m=Array.from(h.getChildren()).filter(e=>e.is("element","td")||e.is("element","th"));if("tfoot"===t.name){a||={element:t,rows:c},i=!1;const n=a.element===t;if(!n&&null===u)for(let t=e;t<l.length&&(u="tfoot"===l[t].name,u);t++);if(n){o.push(h);continue}if(!1!==u){o.splice(o.length-a.rows.length,0,h);continue}}r&&t===r||"tbody"===t.name&&m.length>0&&(null===d||m.length===d)&&m.every(e=>e.is("element","th"))&&i?(n.push(h),i=!0):(s.push(h),i=!1),d=Math.max(d||0,m.length)}}const c=function(e){let t=new Map,i=0;const n=e.map(e=>{const n=[],s=Array.from(e.getChildren()).filter(e=>"th"===e.name||"td"===e.name),o=new Map;for(;s.length||n.length<i;){const e=t.get(n.length);if(e&&e.remaining>0)n.push(e.cell);else{const e=s.shift();if(!e){n.push(null);continue}{const t=parseInt(e.getAttribute("colspan")||"1"),i=parseInt(e.getAttribute("rowspan")||"1");for(let s=0;s<t;s++)i>1&&o.set(n.length,{cell:e,remaining:i-1}),n.push(e)}}}for(const[e,i]of t.entries())i.remaining-=1,i.remaining>0&&!o.has(e)&&o.set(e,i);return t=o,i=Math.max(i,n.length),n});for(const e of n)for(;e.length<i;)e.push(null);return n}(s);for(const e of c){let i=0;for(;i<e.length&&"th"===e[i]?.name;)i+=1;(void 0===t||i<t)&&(t=i)}return{headingRows:n.length,headingColumns:t||0,footerRows:o.length,rows:[...n,...s,...o]}}(s),c={};a&&(c.headingColumns=a),r&&(c.headingRows=r),e.enableFooters&&l&&(c.footerRows=l);const d=n.writer.createElement("table",c);if(n.safeInsert(d,i.modelCursor)){if(n.consumable.consume(s,{name:!0}),o.forEach(e=>n.convertItem(e,n.writer.createPositionAt(d,"end"))),n.convertChildren(s,n.writer.createPositionAt(d,"end")),d.isEmpty){const e=n.writer.createElement("tableRow");n.writer.insert(e,n.writer.createPositionAt(d,"end")),xA(n.writer,n.writer.createPositionAt(e,"end"))}n.updateConversionResult(d,i)}})}}function qA(e){return t=>{t.on(`element:${e}`,(e,t,{writer:i})=>{if(!t.modelRange)return;const n=t.modelRange.start.nodeAfter,s=i.createPositionAt(n,0);if(t.viewItem.isEmpty)return void i.insertElement("paragraph",s);const o=Array.from(n.getChildren());if(o.every(e=>e.is("element","$marker"))){const e=i.createElement("paragraph");i.insert(e,i.createPositionAt(n,0));for(const t of o)i.move(i.createRangeOn(t),i.createPositionAt(e,"end"))}},{priority:"low"})}}function KA(e,t){return 4e3/GA(e,t)}function GA(e,t){const i=JA(e,"tbody",t)||JA(e,"thead",t)||JA(e,"tfoot",t);return YA(t.editing.view.domConverter.mapViewToDom(i))}function JA(e,t,i){return[...[...i.editing.mapper.toViewElement(e).getChildren()].find(e=>e.is("element","table")).getChildren()].find(e=>e.is("element",t))}function YA(e){const t=G.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseFloat(t.width)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth):parseFloat(t.width)}function QA(e){const t=Math.pow(10,2),i="number"==typeof e?e:parseFloat(e);return Math.round(i*t)/t}function XA(e,t){return Array(e).fill(t)}function ZA(e){return e.map(e=>"number"==typeof e?e:parseFloat(e)).filter(e=>!Number.isNaN(e)).reduce((e,t)=>e+t,0)}function eT(e){let t=function(e){const t=e.filter(e=>"auto"===e).length;if(0===t)return e.map(e=>QA(e));const i=ZA(e),n=Math.max((100-i)/t,5);return e.map(e=>"auto"===e?n:e).map(e=>QA(e))}(e.map(e=>"auto"===e||void 0===e?"auto":parseFloat(e.replace("%",""))));const i=ZA(t);return 100!==i&&(t=t.map(e=>QA(100*e/i)).map((e,t,i)=>{if(!(t===i.length-1))return e;return QA(e+100-ZA(i))})),t.map(e=>e+"%")}function tT(e){const t=G.window.getComputedStyle(e);return"border-box"===t.boxSizing?parseInt(t.width):parseFloat(t.width)+parseFloat(t.paddingLeft)+parseFloat(t.paddingRight)+parseFloat(t.borderWidth)}function iT(e,t,i,n){for(let s=0;s<Math.max(i.length,e.length);s++){const o=e[s],r=i[s];r?o?n.setAttribute("columnWidth",r,o):n.appendElement("tableColumn",{columnWidth:r},t):n.remove(o)}}function nT(e){if(e.is("element","tableColumnGroup"))return e;const t=e.getChildren();return Array.from(t).find(e=>e.is("element","tableColumnGroup"))}function sT(e){const t=nT(e);return t?Array.from(t.getChildren()):[]}class oT extends Cc{static get pluginName(){return"TableUtils"}static get isOfficialPlugin(){return!0}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,i=t.parent,n=i.getChildIndex(t),s=new CA(i,{row:n});for(const{cell:t,row:i,column:n}of s)if(t===e)return{row:i,column:n}}createTable(e,t){const i=e.createElement("table");return rT(e,i,0,t.rows||2,t.columns||2),t.footerRows&&this.setFooterRowsCount(e,i,t.footerRows),t.headingRows&&this.setHeadingRowsCount(e,i,t.headingRows),t.headingColumns&&this.setHeadingColumnsCount(e,i,t.headingColumns),i}insertRows(e,t={}){const i=this.editor.model,n=t.at||0,s=t.rows||1,o=void 0!==t.copyStructureFromAbove,r=t.copyStructureFromAbove?n-1:n,a=RA(this.editor),l=!!this.editor.config.get("table.tableCellProperties.scopedHeaders"),c=this.getRows(e),d=this.getColumns(e);if(n>c)throw new fe("tableutils-insertrows-insert-out-of-range",this,{options:t});i.change(t=>{let i=e.getAttribute("headingRows")||0,u=e.getAttribute("footerRows")||0;if(i>n&&(i+=s),u&&n>c-u&&(u+=s),o||0!==n&&n!==c){const i=o?Math.max(n,r):n,c=new CA(e,{endRow:i}),u=new Array(d).fill(1);for(const{row:e,column:i,cellHeight:a,cellWidth:l,cell:d}of c){const c=e+a-1,h=e<=r&&r<=c;e<n&&n<=c?(t.setAttribute("rowspan",a+s,d),u[i]=-l):o&&h&&(u[i]=l)}for(let i=0;i<s;i++){const s=t.createElement("tableRow");t.insert(s,e,n);for(let o=0;o<u.length;o++){const r=u[o],c=t.createPositionAt(s,"end");if(r>0){const s=xA(t,c,r>1?{colspan:r}:void 0);a&&dT({table:e,writer:t,cell:s,row:n+i,column:o,scopedHeaders:l})}o+=Math.abs(r)-1}}}else{const i=rT(t,e,n,s,d);if(a)for(let s=0;s<i.length;s++){const o=i[s];for(let i=0;i<d;i++)dT({table:e,writer:t,cell:o[i],row:n+s,column:i,scopedHeaders:l})}}this.setFooterRowsCount(t,e,u),this.setHeadingRowsCount(t,e,i,{updateCellType:!1})})}insertColumns(e,t={}){const i=this.editor.model,n=t.at||0,s=t.columns||1,o=RA(this.editor),r=!!this.editor.config.get("table.tableCellProperties.scopedHeaders");i.change(t=>{let i=e.getAttribute("headingColumns");n<i&&(i+=s);const a=this.getColumns(e);if(0===n||a===n){let i=0;for(const a of e.getChildren()){if(!a.is("element","tableRow"))continue;const l=aT(s,t,t.createPositionAt(a,n?"end":0));if(o)for(let s=0;s<l.length;s++)dT({table:e,writer:t,cell:l[s],row:i,column:n+s,scopedHeaders:r});i++}}else{const i=new CA(e,{column:n,includeAllSlots:!0});for(const a of i){const{row:l,cell:c,cellAnchorColumn:d,cellAnchorRow:u,cellWidth:h,cellHeight:m}=a;if(d<n){t.setAttribute("colspan",h+s,c);const e=u+m-1;for(let t=l;t<=e;t++)i.skipRow(t)}else{const i=aT(s,t,a.getPositionBefore());if(o)for(let s=0;s<i.length;s++)dT({table:e,writer:t,cell:i[s],row:l,column:n+s,scopedHeaders:r})}}}this.setHeadingColumnsCount(t,e,i,{updateCellType:!1})})}removeRows(e,t){const i=this.editor.model,n=t.rows||1,s=this.getRows(e),o=t.at,r=o+n-1;if(r>s-1)throw new fe("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});i.change(t=>{const i={first:o,last:r},{cellsToMove:n,cellsToTrim:a}=function(e,{first:t,last:i}){const n=new Map,s=[];for(const{row:o,column:r,cellHeight:a,cell:l}of new CA(e,{endRow:i})){const e=o+a-1;if(o>=t&&o<=i&&e>i){const e=a-(i-o+1);n.set(r,{cell:l,rowspan:e})}if(o<t&&e>=t){let n;n=e>=i?i-t+1:e-t+1,s.push({cell:l,rowspan:a-n})}}return{cellsToMove:n,cellsToTrim:s}}(e,i);if(n.size){!function(e,t,i,n){const s=new CA(e,{includeAllSlots:!0,row:t}),o=[...s],r=e.getChild(t);let a;for(const{column:e,cell:t,isAnchor:s}of o)if(i.has(e)){const{cell:t,rowspan:s}=i.get(e),o=a?n.createPositionAfter(a):n.createPositionAt(r,0);n.move(n.createRangeOn(t),o),EA("rowspan",s,t,n),a=t}else s&&(a=t)}(e,r+1,n,t)}for(let i=r;i>=o;i--)t.remove(e.getChild(i));for(const{rowspan:e,cell:i}of a)EA("rowspan",e,i,t);if(function(e,{first:t,last:i},n){const s=e.getAttribute("headingRows")||0;if(t<s){EA("headingRows",i<s?s-(i-t+1):t,e,n,0)}}(e,i,t),function(e,t,{first:i,last:n},s){if(!e.hasAttribute("footerRows"))return;const o=e.getAttribute("footerRows"),r=t-o;if(n>=r){EA("footerRows",i>=r?o-(n-i+1):t-1-n,e,s,0)}}(e,s,i,t),DA(e,this)||zA(e,this),RA(this.editor)){let i=e.getAttribute("headingRows")||0;const n=this.getRows(e);for(;i<n&&OA({table:e,row:i});)i++;this.setHeadingRowsCount(t,e,i,{updateCellType:!1})}})}removeColumns(e,t){const i=this.editor.model,n=t.at,s=t.columns||1,o=t.at+s-1;i.change(t=>{!function(e,t,i){const n=e.getAttribute("headingColumns")||0;if(n&&t.first<n){const s=Math.min(n-1,t.last)-t.first+1;i.setAttribute("headingColumns",n-s,e)}}(e,{first:n,last:o},t);const i=sT(e);for(let s=o;s>=n;s--){for(const{cell:i,column:n,cellWidth:o}of[...new CA(e)])n<=s&&o>1&&n+o>s?EA("colspan",o-1,i,t):n===s&&t.remove(i);if(i[s]){const e=0===s?i[1]:i[s-1],n=parseFloat(i[s].getAttribute("columnWidth")),o=parseFloat(e.getAttribute("columnWidth"));t.remove(i[s]),t.setAttribute("columnWidth",n+o+"%",e)}}if(zA(e,this)||DA(e,this),RA(this.editor)){let i=e.getAttribute("headingColumns")||0;const n=this.getColumns(e);for(;i<n&&OA({table:e,column:i});)i++;this.setHeadingColumnsCount(t,e,i,{updateCellType:!1})}})}splitCellVertically(e,t=2){const i=this.editor.model,n=e.parent.parent,s=parseInt(e.getAttribute("rowspan")||"1"),o=parseInt(e.getAttribute("colspan")||"1");i.change(i=>{if(o>1){const{newCellsSpan:n,updatedSpan:r}=lT(o,t);EA("colspan",r,e,i);const a={};n>1&&(a.colspan=n),s>1&&(a.rowspan=s);aT(o>t?t-1:o-1,i,i.createPositionAfter(e),a)}if(o<t){const r=t-o,a=[...new CA(n)],{column:l}=a.find(({cell:t})=>t===e),c=a.filter(({cell:t,cellWidth:i,column:n})=>t!==e&&n===l||n<l&&n+i>l);for(const{cell:e,cellWidth:t}of c)i.setAttribute("colspan",t+r,e);const d={};s>1&&(d.rowspan=s),aT(r,i,i.createPositionAfter(e),d);const u=n.getAttribute("headingColumns")||0;u>l&&EA("headingColumns",u+r,n,i)}})}splitCellHorizontally(e,t=2){const i=this.editor.model,n=e.parent,s=n.parent,o=s.getChildIndex(n),r=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");i.change(i=>{if(r>1){const n=[...new CA(s,{startRow:o,endRow:o+r-1,includeAllSlots:!0})],{newCellsSpan:l,updatedSpan:c}=lT(r,t);EA("rowspan",c,e,i);const{column:d}=n.find(({cell:t})=>t===e),u={};l>1&&(u.rowspan=l),a>1&&(u.colspan=a);let h=0;for(const e of n){const{column:t,row:n}=e,s=t===d;h>=l&&s&&(h=0),n>=o+c&&s&&(h||aT(1,i,e.getPositionBefore(),u),h++)}}if(r<t){const n=t-r,l=this.getRows(s),c=[...new CA(s,{startRow:0,endRow:o})];for(const{cell:t,cellHeight:s,row:r}of c)if(t!==e&&r+s>o){const e=s+n;i.setAttribute("rowspan",e,t)}const d={};a>1&&(d.colspan=a),rT(i,s,o+1,n,1,d);const u=s.getAttribute("headingRows")||0;u>o&&EA("headingRows",u+n,s,i);const h=s.getAttribute("footerRows")||0;l-h<=o&&EA("footerRows",h+n,s,i)}})}getColumns(e){return[...e.getChild(0).getChildren()].filter(e=>e.is("element","tableCell")).reduce((e,t)=>e+parseInt(t.getAttribute("colspan")||"1"),0)}getRows(e){return Array.from(e.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0)}createTableWalker(e,t={}){return new CA(e,t)}getSelectedTableCells(e){const t=[];for(const i of this.sortRanges(e.getRanges())){const e=i.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}setFooterRowsCount(e,t,i){if(!this.editor.config.get("table.enableFooters"))return;const n=t.getAttribute("headingRows")||0,s=this.getRows(t),o=Math.min(i,s);if(EA("footerRows",o,t,e,0),n+o>s){const i=s-o;this.setHeadingRowsCount(e,t,i)}}setHeadingRowsCount(e,t,i,n={}){const{updateCellType:s=!0,resetFormerHeadingCells:o=!0,autoExpand:r=!0}=n,a=this.getRows(t),l=!!this.editor.config.get("table.tableCellProperties.scopedHeaders"),c=t.getAttribute("headingRows")||0;let d=Math.min(i,a);if(d===c)return;EA("headingRows",d,t,e,0);if(d+(t.getAttribute("footerRows")||0)>a){const i=a-d;this.setFooterRowsCount(e,t,i)}if(RA(this.editor)){if(s){for(const{cell:i,row:n,column:s}of new CA(t,{endRow:d-1}))dT({table:t,writer:e,cell:i,row:n,column:s,scopedHeaders:l});if(o&&d<c)for(let i=d;i<c&&OA({table:t,row:i});i++)for(const{cell:n,row:s,column:o}of new CA(t,{row:i}))dT({table:t,writer:e,cell:n,row:s,column:o,scopedHeaders:l})}if(r&&d>c){for(;d<a&&OA({table:t,row:d});)d++;EA("headingRows",d,t,e,0)}}}setHeadingColumnsCount(e,t,i,n={}){const{updateCellType:s=!0,resetFormerHeadingCells:o=!0,autoExpand:r=!0}=n,a=this.getColumns(t),l=t.getAttribute("headingColumns")||0,c=!!this.editor.config.get("table.tableCellProperties.scopedHeaders");let d=Math.min(i,a);if(d!==l&&(EA("headingColumns",d,t,e,0),RA(this.editor))){if(s){for(const{cell:i,row:n,column:s}of new CA(t,{endColumn:d-1}))dT({table:t,writer:e,cell:i,row:n,column:s,scopedHeaders:c});if(o&&d<l)for(let i=d;i<l&&OA({table:t,column:i});i++)for(const{cell:n,row:s,column:o}of new CA(t,{column:i}))dT({table:t,writer:e,cell:n,row:s,column:o,scopedHeaders:c})}if(r&&d>l){for(;d<a&&OA({table:t,column:d});)d++;EA("headingColumns",d,t,e,0)}}}getTableCellsContainingSelection(e){const t=[];for(const i of e.getRanges()){const e=i.start.findAncestor("tableCell");e&&t.push(e)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map(e=>e.parent.index);return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),i=[...new CA(t)].filter(t=>e.includes(t.cell)).map(e=>e.column);return this._getFirstLastIndexesObject(i)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,i=new Set;let n=0;for(const s of e){const{row:e,column:o}=this.getCellLocation(s),r=parseInt(s.getAttribute("rowspan"))||1,a=parseInt(s.getAttribute("colspan"))||1;t.add(e),i.add(o),r>1&&t.add(e+r-1),a>1&&i.add(o+a-1),n+=r*a}const s=function(e,t){const i=Array.from(e.values()),n=Array.from(t.values()),s=Math.max(...i),o=Math.min(...i),r=Math.max(...n),a=Math.min(...n);return(s-o+1)*(r-a+1)}(t,i);return s==n}sortRanges(e){return Array.from(e).sort(cT)}_getFirstLastIndexesObject(e){const t=e.sort((e,t)=>e-t);return{first:t[0],last:t[t.length-1]}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),i=this.getRows(t),n=this.getRowIndexes(e),s=parseInt(t.getAttribute("headingRows"))||0,o=parseInt(t.getAttribute("footerRows"))||0;if(!this._areIndexesInSameHeadingSection(n,s)||!this._areIndexesInSameFooterSection(n,i,o))return!1;const r=this.getColumnIndexes(e),a=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameHeadingSection(r,a)}_areIndexesInSameHeadingSection({first:e,last:t},i){return e<i===t<i}_areIndexesInSameFooterSection({first:e,last:t},i,n){const s=i-n;return e>=s===t>=s}}function rT(e,t,i,n,s,o={}){const r=[];for(let a=0;a<n;a++){const n=e.createElement("tableRow");e.insert(n,t,i),r.push(aT(s,e,e.createPositionAt(n,"end"),o))}return r}function aT(e,t,i,n={}){const s=[];let o=i;for(let i=0;i<e;i++){const e=xA(t,o,n);s.push(e),o=t.createPositionAfter(e)}return s}function lT(e,t){if(e<t)return{newCellsSpan:1,updatedSpan:1};const i=Math.floor(e/t);return{newCellsSpan:i,updatedSpan:e-i*t+i}}function cT(e,t){const i=e.start,n=t.start;return i.isBefore(n)?-1:1}function dT({writer:e,table:t,row:i,column:n,cell:s,scopedHeaders:o}){const r=t.getAttribute("headingRows")||0,a=t.getAttribute("headingColumns")||0;if(i>=r&&n>=a)return void e.removeAttribute("tableCellType",s);let l="header";o&&(l=i<r?"header-column":"header-row"),e.setAttribute("tableCellType",l,s)}function uT(e){if(!e||!i(e))return e;const{top:t,right:n,bottom:s,left:o}=e;return t==n&&n==s&&s==o?t:void 0}function hT(e,t){const i=parseFloat(e);return Number.isNaN(i)||String(i)!==String(e)?e:`${i}${t}`}function mT(e,t={}){const i={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...e};return t.includeAlignmentProperty&&!i.alignment&&(i.alignment="center"),t.includePaddingProperty&&!i.padding&&(i.padding=""),t.includeVerticalAlignmentProperty&&!i.verticalAlignment&&(i.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!i.horizontalAlignment&&(i.horizontalAlignment=t.isRightToLeftContent?"right":"left"),i}function gT(e,t){return mT({borderStyle:"double",borderColor:"hsl(0, 0%, 70%)",borderWidth:"1px",...e},t)}function fT(e,t){return mT({borderStyle:"solid",borderColor:"hsl(0, 0%, 75%)",borderWidth:"1px",...e},t)}function pT(e,t){return(i,{writer:n})=>{const s=i.getAttribute("headingRows")||0,o=i.getAttribute("footerRows")||0,r=n.createContainerElement("table",null,[]),a=n.createContainerElement("figure",{class:"table"},r),l=e.getRows(i);s>0&&n.insert(n.createPositionAt(r,"end"),n.createContainerElement("thead",null,n.createSlot(e=>e.is("element","tableRow")&&e.index<s))),s+o<l&&n.insert(n.createPositionAt(r,"end"),n.createContainerElement("tbody",null,n.createSlot(e=>e.is("element","tableRow")&&e.index>=s&&e.index<l-o))),o>0&&n.insert(n.createPositionAt(r,"end"),n.createContainerElement("tfoot",null,n.createSlot(e=>e.is("element","tableRow")&&e.index>=l-o)));for(const{positionOffset:e,filter:i}of t.additionalSlots)n.insert(n.createPositionAt(r,e),n.createSlot(i));return n.insert(n.createPositionAt(r,"after"),n.createSlot(e=>!e.is("element","tableRow")&&!t.additionalSlots.some(({filter:t})=>t(e)))),t.asWidget?function(e,t){return t.setCustomProperty("table",!0,e),bp(e,t,{hasSelectionHandle:!0})}(a,n):a}}function bT(e){return(i,{writer:n})=>{if(e.cellTypeEnabled?.()){return t(n,TA(i.getAttribute("tableCellType"))?"th":"td")}const s=i.parent,o=s.parent,r=o.getChildIndex(s),a=new CA(o,{row:r}),l=o.getAttribute("headingRows")||0,c=o.getAttribute("headingColumns")||0;let d=null;for(const e of a)if(e.cell==i){d=t(n,e.row<l||e.column<c?"th":"td");break}return d};function t(t,i){return e.asWidget?yp(t.createEditableElement(i),t,{withAriaRole:!1}):t.createContainerElement(i)}}function wT(e={}){return(t,{writer:i})=>{if(!t.parent.is("element","tableCell"))return null;if(!_T(t))return null;if(e.asWidget)return i.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const e=i.createContainerElement("p");return i.setCustomProperty("dataPipeline:transparentRendering",!0,e),e}}}function _T(e){return 1==e.parent.childCount&&!function(e){for(const t of e.getAttributeKeys())if(!t.startsWith("selection:")&&"htmlEmptyBlock"!=t)return!0;return!1}(e)}function vT(e){return(t,i)=>{const n=e.plugins.has("PlainTableOutput"),s=i.options.isClipboardPipeline,o=kT(e,t);return n||o||s?function(e,t,i){const n=i.plugins.get(oT),s=t.writer,o=n.getRows(e),r=e.getAttribute("headingRows")||0,a=e.getAttribute("footerRows")||0,l=o-a,c=s.createSlot(e=>e.is("element","tableRow")&&e.index<r),d=s.createSlot(e=>e.is("element","tableRow")&&e.index>=r&&e.index<l),u=s.createSlot(e=>e.is("element","tableRow")&&e.index>=l),h=s.createSlot(e=>!e.is("element","tableRow")),m=s.createContainerElement("thead",null,c),g=s.createContainerElement("tbody",null,d),f=s.createContainerElement("tfoot",null,u),p=[];r&&p.push(m);r+a<o&&p.push(g);a&&p.push(f);const b={class:"table"};if(i.plugins.has("TablePropertiesEditing")&&t.options.isClipboardPipeline){const t=gT(i.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),n=e.getAttribute("tableAlignment");let s=t.alignment;"layout"===e.getAttribute("tableType")&&(s="");const o=n||s;o&&(b.class+=" "+kA[o].className,b.style=kA[o].style,void 0!==kA[o].align&&(b.align=kA[o].align))}return s.createContainerElement("table",b,[h,...p])}(t,i,e):null}}function yT(e){return(t,{writer:i,options:n})=>{const s=e.plugins.has("PlainTableOutput"),o=n.isClipboardPipeline,r=kT(e,t);return(s||r||o)&&"table"===t.parent.name?i.createContainerElement("caption"):null}}function kT(e,t){const i=e.plugins.has("TableLayoutEditing"),n=e.config.get("table.tableLayout.stripFigureFromContentTable")??!1,s=t.findAncestor("table",{includeSelf:!0}),o=s?.getAttribute("tableType");return i&&(n||"layout"===o)}class CT extends Tc{refresh(){const e=this.editor.model,t=e.document.selection,i=e.schema;this.isEnabled=function(e,t){const i=e.getFirstPosition().parent,n=i===i.root?i:i.parent;return t.checkChild(n,"table")}(t,i)}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("TableUtils"),s=!!t.config.get("table.enableFooters"),o=t.config.get("table.defaultHeadings.rows"),r=t.config.get("table.defaultHeadings.columns"),a=t.config.get("table.defaultFooters");void 0===e.headingRows&&o&&(e.headingRows=o),void 0===e.headingColumns&&r&&(e.headingColumns=r),s&&void 0===e.footerRows&&a&&(e.footerRows=a),!s&&"footerRows"in e&&delete e.footerRows,i.change(t=>{const s=n.createTable(t,e);i.insertObject(s,null,null,{findOptimalPosition:"auto"}),t.setSelection(t.createPositionAt(s.getNodeByPath([0,0,0]),0))})}}class AT extends Tc{order;constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("TableUtils"),n="above"===this.order,s=i.getSelectionAffectedTableCells(t),o=i.getRowIndexes(s),r=n?o.first:o.last,a=s[0].findAncestor("table");i.insertRows(a,{at:n?r:r+1,copyStructureFromAbove:!n})}}class TT extends Tc{order;constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("TableUtils"),n="left"===this.order,s=i.getSelectionAffectedTableCells(t),o=i.getColumnIndexes(s),r=n?o.first:o.last,a=s[0].findAncestor("table");i.insertColumns(a,{columns:1,at:n?r:r+1})}}class ET extends Tc{direction;constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];"horizontally"===this.direction?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}class xT extends Tc{direction;isHorizontal;constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,i=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],n=this.value,s=this.direction;e.change(e=>{const t="right"==s||"down"==s,o=t?i:n,r=t?n:i,a=r.parent;!function(e,t,i){PT(e)||(PT(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end")));i.remove(e)}(r,o,e);const l=this.isHorizontal?"colspan":"rowspan",c=parseInt(i.getAttribute(l)||"1"),d=parseInt(n.getAttribute(l)||"1");e.setAttribute(l,c+d,o),e.setSelection(e.createRangeIn(o));const u=this.editor.plugins.get("TableUtils");HA(a.findAncestor("table"),u)})}_getMergeableCell(){const e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),i=t.getTableCellsContainingSelection(e.selection)[0];if(!i)return;const n=this.isHorizontal?function(e,t,i){const n=e.parent,s=n.parent,o="right"==t?e.nextSibling:e.previousSibling,r=(s.getAttribute("headingColumns")||0)>0;if(!o)return;const a="right"==t?e:o,l="right"==t?o:e,{column:c}=i.getCellLocation(a),{column:d}=i.getCellLocation(l),u=parseInt(a.getAttribute("colspan")||"1"),h=PA(i,a),m=PA(i,l);if(r&&h!=m)return;return c+u===d?o:void 0}(i,this.direction,t):function(e,t,i){const n=e.parent,s=n.parent,o=s.getChildIndex(n),r=i.getRows(s);if("down"==t&&o===r-1||"up"==t&&0===o)return null;const a=parseInt(e.getAttribute("rowspan")||"1"),l=s.getAttribute("headingRows")||0,c=s.getAttribute("footerRows")||0,d=r-c,u="up"==t&&o===d,h="up"==t&&o===l,m="down"==t&&o+a===l,g="down"==t&&o+a===d;if(l&&(m||h))return null;if(c&&(u||g))return null;const f=parseInt(e.getAttribute("rowspan")||"1"),p="down"==t?o+f:o,b=[...new CA(s,{endRow:p})],w=b.find(t=>t.cell===e),_=w.column,v=b.find(({row:e,cellHeight:i,column:n})=>n===_&&("down"==t?e===p:p===e+i));return v&&v.cell?v.cell:null}(i,this.direction,t);if(!n)return;const s=this.isHorizontal?"rowspan":"colspan",o=parseInt(i.getAttribute(s)||"1");return parseInt(n.getAttribute(s)||"1")===o?n:void 0}}function PT(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}class ST extends Tc{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const n=i.findAncestor("table"),s=e.getRows(n)-1,o=e.getRowIndexes(t),r=0===o.first&&o.last===s;this.isEnabled=!r}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(i),s=i[0],o=s.findAncestor("table"),r=t.getCellLocation(s).column;e.change(e=>{const i=n.last-n.first+1;t.removeRows(o,{at:n.first,rows:i});const s=function(e,t,i,n){const s=e.getChild(Math.min(t,n-1));let o=s.getChild(0),r=0;for(const e of s.getChildren()){if(r>i)return o;o=e,r+=parseInt(e.getAttribute("colspan")||"1")}return o}(o,n.first,r,t.getRows(o));e.setSelection(e.createPositionAt(s,0))})}}class IT extends Tc{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const n=i.findAncestor("table"),s=e.getColumns(n),{first:o,last:r}=e.getColumnIndexes(t);this.isEnabled=r-o<s-1}else this.isEnabled=!1}execute(){const e=this.editor.plugins.get("TableUtils"),[t,i]=function(e,t){const i=t.getSelectionAffectedTableCells(e),n=i[0],s=i.pop(),o=[n,s];return n.isBefore(s)?o:o.reverse()}(this.editor.model.document.selection,e),n=t.parent.parent,s=[...new CA(n)],o={first:s.find(e=>e.cell===t).column,last:s.find(e=>e.cell===i).column},r=function(e,t,i,n){const s=parseInt(i.getAttribute("colspan")||"1");return s>1?i:t.previousSibling||i.nextSibling?i.nextSibling||t.previousSibling:n.first?e.reverse().find(({column:e})=>e<n.first).cell:e.reverse().find(({column:e})=>e>n.last).cell}(s,t,i,o);this.editor.model.change(t=>{const i=o.last-o.first+1;e.removeColumns(n,{at:o.first,columns:i}),t.setSelection(t.createPositionAt(r,0))})}}class OT extends Tc{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection);if(0===i.length)return this.isEnabled=!1,void(this.value=!1);const n=i[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(n,"headingRows"),this.value=i.every(e=>this._isInHeading(e,e.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,n=t.getSelectionAffectedTableCells(i.document.selection),s=n[0].findAncestor("table"),{first:o,last:r}=t.getRowIndexes(n),a=this.value?o:r+1,l=s.getAttribute("headingRows")||0;i.change(e=>{if(a){const t=BA(s,a,a>l?l:0);for(const{cell:i}of t)MA(i,a,e)}t.setHeadingRowsCount(e,s,a)})}_isInHeading(e,t){const i=parseInt(t.getAttribute("headingRows")||"0");return!!i&&e.parent.index<i}}class RT extends Tc{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection);if(0===i.length)return this.isEnabled=!1,void(this.value=!1);const n=i[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(n,"footerRows"),this.value=i.every(e=>this._isInFooter(e,n))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,n=t.getSelectionAffectedTableCells(i.document.selection),s=n[0].findAncestor("table"),{first:o,last:r}=t.getRowIndexes(n),a=t.getRows(s),l=this.value?a-(r+1):a-o,c=s.getAttribute("footerRows")||0;i.change(e=>{if(l){const t=a-l,i=a-c,n=BA(s,t,t>i?i:0);for(const{cell:i}of n)MA(i,t,e)}t.setFooterRowsCount(e,s,l)})}_isInFooter(e,t){const i=parseInt(t.getAttribute("footerRows")||"0"),n=this.editor.plugins.get("TableUtils").getRows(t),s=e.parent.index;return!!i&&s>=n-i}}class VT extends Tc{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection);if(0===i.length)return this.isEnabled=!1,void(this.value=!1);const n=i[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(n,"headingColumns"),this.value=i.every(t=>PA(e,t))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,n=t.getSelectionAffectedTableCells(i.document.selection),s=n[0].findAncestor("table"),{first:o,last:r}=t.getColumnIndexes(n),a=this.value?o:r+1;i.change(e=>{if(a){const t=FA(s,a);for(const{cell:i,column:n}of t)NA(i,n,a,e)}t.setHeadingColumnsCount(e,s,a)})}}class BT extends Tc{refresh(){const e=this.editor.plugins.get(oT),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(oT);e.change(i=>{const n=t.getSelectedTableCells(e.document.selection),s=n.shift(),{mergeWidth:o,mergeHeight:r}=function(e,t,i){let n=0,s=0;for(const e of t){const{row:t,column:o}=i.getCellLocation(e);n=NT(e,o,n,"colspan"),s=NT(e,t,s,"rowspan")}const{row:o,column:r}=i.getCellLocation(e),a=n-r,l=s-o;return{mergeWidth:a,mergeHeight:l}}(s,n,t);EA("colspan",o,s,i),EA("rowspan",r,s,i);for(const e of n)MT(e,s,i);HA(s.findAncestor("table"),t),i.setSelection(s,"in")})}}function MT(e,t,i){FT(e)||(FT(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end"))),i.remove(e)}function FT(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function NT(e,t,i,n){const s=parseInt(e.getAttribute(n)||"1");return Math.max(i,t+s)}class LT extends Tc{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(i),s=i[0].findAncestor("table"),o=[];for(let t=n.first;t<=n.last;t++)for(const i of s.getChild(t).getChildren())o.push(e.createRangeOn(i));e.change(e=>{e.setSelection(o)})}}class DT extends Tc{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection),n=i[0],s=i.pop(),o=n.findAncestor("table"),r=e.getCellLocation(n),a=e.getCellLocation(s),l=Math.min(r.column,a.column),c=Math.max(r.column,a.column),d=[];for(const e of new CA(o,{startColumn:l,endColumn:c}))d.push(t.createRangeOn(e.cell));t.change(e=>{e.setSelection(d)})}}function zT(e){e.document.registerPostFixer(t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;const s=new Set;for(const t of i){let i=null;"insert"==t.type&&"table"==t.name&&(i=t.position.nodeAfter),"insert"!=t.type&&"remove"!=t.type||"tableRow"!=t.name&&"tableCell"!=t.name||(i=t.position.findAncestor("table")),WT(t)&&(i=t.range.start.findAncestor("table")),i&&!s.has(i)&&(n=HT(i,e)||n,n=$T(i,e)||n,s.add(i))}return n}(t,e))}function HT(e,t){let i=!1;const n=function(e){const t=parseInt(e.getAttribute("headingRows")||"0"),i=parseInt(e.getAttribute("footerRows")||"0"),n=Array.from(e.getChildren()).reduce((e,t)=>t.is("element","tableRow")?e+1:e,0),s=n-i,o=[];for(const{row:i,cell:r,cellHeight:a}of new CA(e)){if(a<2)continue;let e;if(e=i<t?t:i>=s?n:s,i+a>e){const t=e-i;o.push({cell:r,rowspan:t})}}return o}(e);if(n.length){i=!0;for(const e of n)EA("rowspan",e.rowspan,e.cell,t,1)}return i}function $T(e,t){let i=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:i}of new CA(e,{includeAllSlots:!0}))t[i]++;return t}(e),s=[];for(const[t,i]of n.entries())!i&&e.getChild(t).is("element","tableRow")&&s.push(t);if(s.length){i=!0;for(const i of s.reverse())t.remove(e.getChild(i)),n.splice(i,1)}const o=n.filter((t,i)=>e.getChild(i).is("element","tableRow")),r=o[0];if(!o.every(e=>e===r)){const n=o.reduce((e,t)=>t>e?t:e,0);for(const[s,r]of o.entries()){const o=n-r;if(o){for(let i=0;i<o;i++)xA(t,t.createPositionAt(e.getChild(s),"end"));i=!0}}}return i}function WT(e){if("attribute"!==e.type)return!1;const t=e.attributeKey;return"headingRows"===t||"colspan"===t||"rowspan"===t}function jT(e){e.document.registerPostFixer(t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;for(const t of i)"insert"==t.type&&"table"==t.name&&(n=UT(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=qT(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=KT(t.position.nodeAfter,e)||n),"remove"!=t.type&&"insert"!=t.type||!GT(t)||(n=KT(t.position.parent,e)||n);return n}(t,e))}function UT(e,t){let i=!1;for(const n of e.getChildren())n.is("element","tableRow")&&(i=qT(n,t)||i);return i}function qT(e,t){let i=!1;for(const n of e.getChildren())i=KT(n,t)||i;return i}function KT(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const i=Array.from(e.getChildren()).filter(e=>e.is("$text"));for(const e of i)t.wrap(t.createRangeOn(e),"paragraph");return!!i.length}function GT(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function JT(e,t,i){const n=i.getAttribute("headingRows")||0,s=i.getAttribute("footerRows")||0,o=e.getRows(i);if(n+s>o){return EA("footerRows",Math.max(0,o-n),i,t,0),!0}return!1}function YT(e,t){if(!e.is("element","paragraph"))return!1;const i=t.toViewElement(e);return!!i&&_T(e)!==i.is("element","span")}class QT extends Cc{_additionalSlots;static get pluginName(){return"TableEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[oT]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,i=t.schema,n=e.conversion,s=e.plugins.get(oT);e.config.define("table.enableFooters",!1);const o=!!e.config.get("table.enableFooters");i.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns",...o?["footerRows"]:[]]}),i.register("tableRow",{allowIn:"table",isLimit:!0}),i.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),n.for("upcast").add(e=>{e.on("element:figure",(e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const n=jA(t.viewItem);if(!n||!i.consumable.test(n,{name:!0}))return;i.consumable.consume(t.viewItem,{name:!0,classes:"table"});const s=i.convertItem(n,t.modelCursor),o=si(s.modelRange.getItems());if(!o||!o.is("element","table"))return i.consumable.revert(t.viewItem,{name:!0,classes:"table"}),void(s.modelRange&&!s.modelRange.isCollapsed&&(t.modelRange=s.modelRange,t.modelCursor=s.modelCursor));i.convertChildren(t.viewItem,i.writer.createPositionAt(o,"end")),i.updateConversionResult(o,t)})}),n.for("upcast").add(UA({enableFooters:o})),n.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows",...o?["footerRows"]:[]]},view:pT(s,{asWidget:!0,additionalSlots:this._additionalSlots})}),n.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows",...o?["footerRows"]:[]]},view:pT(s,{additionalSlots:this._additionalSlots})}),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add(e=>{e.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()},{priority:"high"})}),n.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(qA("td")),n.for("upcast").add(qA("th")),n.for("editingDowncast").elementToElement({model:"tableCell",view:bT({asWidget:!0,cellTypeEnabled:()=>RA(this.editor)})}),n.for("dataDowncast").elementToElement({model:"tableCell",view:bT({cellTypeEnabled:()=>RA(this.editor)})}),n.for("editingDowncast").elementToElement({model:"paragraph",view:wT({asWidget:!0}),converterPriority:"high"}),n.for("dataDowncast").elementToElement({model:"paragraph",view:wT(),converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:XT("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:XT("rowspan")},view:"rowspan"}),this._addPlainTableOutputConverters(),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.config.define("table.defaultFooters",0),e.config.define("table.showHiddenBorders",!0),e.config.get("table.showHiddenBorders")&&e.editing.view.change(t=>{for(const i of e.editing.view.document.roots)t.addClass("ck-table-show-hidden-borders",i)}),e.commands.add("insertTable",new CT(e)),e.commands.add("insertTableRowAbove",new AT(e,{order:"above"})),e.commands.add("insertTableRowBelow",new AT(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new TT(e,{order:"left"})),e.commands.add("insertTableColumnRight",new TT(e,{order:"right"})),e.commands.add("removeTableRow",new ST(e)),e.commands.add("removeTableColumn",new IT(e)),e.commands.add("splitTableCellVertically",new ET(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new ET(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new BT(e)),e.commands.add("mergeTableCellRight",new xT(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new xT(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new xT(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new xT(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new VT(e)),e.commands.add("setTableRowHeader",new OT(e)),o&&e.commands.add("setTableFooterRow",new RT(e)),e.commands.add("selectTableRow",new LT(e)),e.commands.add("selectTableColumn",new DT(e)),zT(t),jT(t),o&&function(e){const{model:t}=e,i=e.plugins.get(oT);t.document.registerPostFixer(e=>{let n=!1;const s=t.document.differ.getChanges(),o=new Set;for(const e of s){let t=null;"attribute"!=e.type||"headingRows"!=e.attributeKey&&"footerRows"!=e.attributeKey?("insert"==e.type&&"tableRow"==e.name||"remove"==e.type&&"tableRow"==e.name)&&(t=e.position.parent):t=e.range.start.nodeAfter,t&&t.is("element","table")&&o.add(t)}for(const t of o)JT(i,e,t)&&(n=!0);return n})}(e),this.listenTo(t.document,"change:data",()=>{RA(e)||function(e,t){const i=e.document.differ,n=new Set,s=new Set,o=new Set;for(const e of i.getChanges()){let i;if("attribute"==e.type){const t=e.range.start.nodeAfter;if(!t||!t.is("element","table"))continue;if("headingRows"!=e.attributeKey&&"headingColumns"!=e.attributeKey&&"footerRows"!=e.attributeKey)continue;i=t}else"tableRow"!=e.name&&"tableCell"!=e.name||(i=e.position.findAncestor("table"));if(!i)continue;"insert"==e.type&&"tableRow"==e.name&&t.mapper.toViewElement(e.position.nodeAfter)&&n.add(e.position.nodeAfter);const r=i.getAttribute("headingRows")||0,a=i.getAttribute("headingColumns")||0,l=new CA(i);for(const e of l){const i=t.mapper.toViewElement(e.cell);if(!i||!i.is("element"))continue;const l=e.row<r||e.column<a?"th":"td";i.name!=l&&(o.add(e.cell),n.has(e.cell.parent)&&s.add(e.cell.parent))}}for(const e of s)t.reconvertItem(e);for(const e of o)t.reconvertItem(e)}(t,e.editing),function(e,t){const i=e.document.differ,n=new Set;for(const e of i.getChanges()){const t="attribute"==e.type?e.range.start.parent:e.position.parent;t.is("element","tableCell")&&n.add(t)}for(const e of n.values()){const i=Array.from(e.getChildren()).filter(e=>YT(e,t.mapper));for(const e of i)t.reconvertItem(e)}}(t,e.editing)})}registerAdditionalSlot(e){this._additionalSlots.push(e)}_addPlainTableOutputConverters(){const e=this.editor;e.conversion.for("dataDowncast").elementToStructure({model:"table",view:vT(e),converterPriority:"high"}),e.plugins.has("TableCaptionEditing")&&e.conversion.for("dataDowncast").elementToElement({model:"caption",view:yT(e),converterPriority:"high"}),e.plugins.has("TablePropertiesEditing")&&function(e){const t={"border-width":"tableBorderWidth","border-color":"tableBorderColor","border-style":"tableBorderStyle","background-color":"tableBackgroundColor"};for(const[i,n]of Object.entries(t))e.conversion.for("dataDowncast").add(t=>t.on(`attribute:${n}:table`,(t,n,s)=>{const{item:o,attributeNewValue:r}=n,{mapper:a,writer:l}=s,c=e.plugins.has("PlainTableOutput"),d=s.options.isClipboardPipeline,u=kT(e,o);if(!(c||u||d))return;if(!s.consumable.consume(o,t.name))return;const h=a.toViewElement(o);r?l.setStyle(i,r,h):l.removeStyle(i,h)},{priority:"high"}))}(e)}}function XT(e){return t=>{const i=parseInt(t.getAttribute(e));return Number.isNaN(i)||i<=0?null:i}}class ZT extends Uu{items;keystrokes;focusTracker;constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new ci,this.focusTracker=new oi,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(e,t)=>`${t} × ${e}`),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to(e=>{e.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(e,t)=>{const{row:i,column:n}=t.target.dataset;this.items.get(10*(parseInt(i,10)-1)+(parseInt(n,10)-1)).focus()}),this.focusTracker.on("change:focusedElement",(e,t,i)=>{if(!i)return;const{row:n,column:s}=i.dataset;this.set({rows:parseInt(n),columns:parseInt(s)})}),this.on("change:columns",()=>this._highlightGridBoxes()),this.on("change:rows",()=>this._highlightGridBoxes())}render(){super.render(),eh({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}reset(){this.set({rows:1,columns:1})}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map((i,n)=>{const s=Math.floor(n/10)<e&&n%10<t;i.set("isOn",s)})}_createGridButton(e,t,i,n){const s=new rh(e);return s.set({label:n,class:"ck-insert-table-dropdown-grid-box"}),s.extendTemplate({attributes:{"data-row":t,"data-column":i}}),s}_createGridCollection(){const e=[];for(let t=0;t<100;t++){const i=Math.floor(t/10),n=t%10,s=`${i+1} × ${n+1}`;e.push(this._createGridButton(this.locale,i+1,n+1,s))}return this.createCollection(e)}}class eE extends Cc{static get pluginName(){return"TableUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t,i="ltr"===e.locale.contentLanguageDirection,n=!!e.config.get("table.enableFooters");e.ui.componentFactory.add("insertTable",i=>{const n=e.commands.get("insertTable"),s=bm(i);let o;return s.bind("isEnabled").to(n),s.buttonView.set({icon:yd,label:t("Insert table"),tooltip:!0}),s.on("change:isOpen",()=>{o||(o=new ZT(i),s.panelView.children.add(o),o.delegate("execute").to(s),s.on("execute",()=>{e.execute("insertTable",{rows:o.rows,columns:o.columns}),e.editing.view.focus()}))}),s}),e.ui.componentFactory.add("menuBar:insertTable",i=>{const n=e.commands.get("insertTable"),s=new xg(i),o=new ZT(i);return o.delegate("execute").to(s),s.on("change:isOpen",(e,t,i)=>{i||o.reset()}),o.on("execute",()=>{e.execute("insertTable",{rows:o.rows,columns:o.columns}),e.editing.view.focus()}),s.buttonView.set({label:t("Table"),icon:yd}),s.panelView.children.add(o),s.bind("isEnabled").to(n),s}),e.ui.componentFactory.add("tableColumn",e=>{const n=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:i?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:i?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1M2 2v16h16V2z" opacity=".6"/><path d="M18 7v1H2V7zm0 5v1H2v-1z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1m-2 1H8v4h4zm0 6H8v4h4zm0 6H8v4h4z"/></svg>',n,e)}),e.ui.componentFactory.add("tableRow",e=>{const i=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},n&&{type:"switchbutton",model:{commandName:"setTableFooterRow",label:t("Footer row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}].filter(Boolean);return this._prepareDropdown(t("Row"),'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1M2 2v16h16V2z" opacity=".6"/><path d="M7 2h1v16H7zm5 0h1v16h-1z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1m1 2v4h4V8zm6 0v4h4V8zm6 0v4h4V8z"/></svg>',i,e)}),e.ui.componentFactory.add("mergeTableCells",e=>{const n=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:i?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:i?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1M2 2v16h16V2z" opacity=".6"/><path d="M7 2h1v16H7zm5 0h1v7h-1zm6 5v1H2V7zM8 12v1H2v-1z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1m1 2v9h10V9z"/></svg>',n,e)})}_prepareDropdown(e,t,i,n){const s=this.editor,o=bm(n),r=this._fillDropdownWithListOptions(o,i);return o.buttonView.set({label:e,icon:t,tooltip:!0}),o.bind("isEnabled").toMany(r,"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(o,"execute",e=>{s.execute(e.source.commandName),e.source instanceof Nh||s.editing.view.focus()}),o}_prepareMergeSplitButtonDropdown(e,t,i,n){const s=this.editor,o=bm(n,pm),r="mergeTableCells",a=s.commands.get(r),l=this._fillDropdownWithListOptions(o,i);return o.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),o.bind("isEnabled").toMany([a,...l],"isEnabled",(...e)=>e.some(e=>e)),this.listenTo(o.buttonView,"execute",()=>{s.execute(r),s.editing.view.focus()}),this.listenTo(o,"execute",e=>{s.execute(e.source.commandName),s.editing.view.focus()}),o}_fillDropdownWithListOptions(e,t){const i=this.editor,n=[],s=new ni;for(const e of t)tE(e,i,n,s);return vm(e,s),n}}function tE(e,t,i,n){if("button"===e.type||"switchbutton"===e.type){const n=e.model=new wg(e.model),{commandName:s,bindIsOn:o}=e.model,r=t.commands.get(s);i.push(r),n.set({commandName:s}),n.bind("isEnabled").to(r),o&&n.bind("isOn").to(r,"value"),n.set({withText:!0})}n.add(e)}class iE extends Cc{static get pluginName(){return"TableSelection"}static get isOfficialPlugin(){return!0}static get requires(){return[oT,oT]}init(){const e=this.editor,t=e.model,i=e.editing.view;this.listenTo(t,"deleteContent",(e,t)=>this._handleDeleteContent(e,t),{priority:"high"}),this.listenTo(i.document,"insertText",(e,t)=>this._handleInsertTextEvent(e,t),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(oT),t=this.editor.model.document.selection,i=e.getSelectedTableCells(t);return 0==i.length?null:i}getSelectionAsFragment(){const e=this.editor.plugins.get(oT),t=this.getSelectedTableCells();return t?this.editor.model.change(i=>{const n=i.createDocumentFragment(),{first:s,last:o}=e.getColumnIndexes(t),{first:r,last:a}=e.getRowIndexes(t),l=t[0].findAncestor("table");let c=a,d=o;if(e.isSelectionRectangular(t)){const e={firstColumn:s,lastColumn:o,firstRow:r,lastRow:a};c=$A(l,e),d=WA(l,e)}const u=VA(l,{startRow:r,startColumn:s,endRow:c,endColumn:d},i);return i.insert(u,n,0),n}):null}setCellSelection(e,t){const i=this._getCellsToSelect(e,t);this.editor.model.change(e=>{e.setSelection(i.cells.map(t=>e.createRangeOn(t)),{backward:i.backward})})}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=si(this.editor.model.document.selection.getRanges()).getContainedElement();return e&&e.is("element","tableCell")?e:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(e=>e.on("selection",(e,i,n)=>{const s=n.writer;!function(e){for(const i of t)e.removeClass("ck-editor__editable_selected",i);t.clear()}(s);const o=this.getSelectedTableCells();if(!o)return;for(const e of o){const i=n.mapper.toViewElement(e);s.addClass("ck-editor__editable_selected",i),t.add(i)}const r=n.mapper.toViewElement(o[o.length-1]);s.setSelection(r,0)},{priority:"lowest"}))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change(i=>{const n=i.createPositionAt(t[0],0),s=e.model.schema.getNearestSelectionRange(n);i.setSelection(s)})}})}_handleDeleteContent(e,t){const i=this.editor.plugins.get(oT),n=t[0],s=t[1],o=this.editor.model,r=!s||"backward"==s.direction,a=i.getSelectedTableCells(n);a.length&&(e.stop(),o.change(e=>{const t=a[r?a.length-1:0];o.change(e=>{for(const t of a)o.deleteContent(e.createSelection(t,"in"))});const i=o.schema.getNearestSelectionRange(e.createPositionAt(t,0));n.is("documentSelection")?e.setSelection(i):n.setTo(i)}))}_handleInsertTextEvent(e,t){const i=this.editor,n=this.getSelectedTableCells();if(!n)return;const s=i.editing.view,o=i.editing.mapper,r=n.map(e=>s.createRangeOn(o.toViewElement(e)));t.selection=s.createSelection(r),t.preventDefault()}_getCellsToSelect(e,t){const i=this.editor.plugins.get("TableUtils"),n=i.getCellLocation(e),s=i.getCellLocation(t),o=Math.min(n.row,s.row),r=Math.max(n.row,s.row),a=Math.min(n.column,s.column),l=parseInt(t.getAttribute("colspan")||"1")-1,c=Math.max(n.column,s.column+l),d=new Array(r-o+1).fill(null).map(()=>[]),u={startRow:o,endRow:r,startColumn:a,endColumn:c};for(const{row:t,cell:i}of new CA(e.findAncestor("table"),u))d[t-o].push(i);const h=s.row<n.row,m=s.column<n.column;return h&&d.reverse(),m&&d.forEach(e=>e.reverse()),{cells:d.flat(),backward:h||m}}}class nE extends Cc{static get pluginName(){return"TableClipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Xp,Zp,iE,oT]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"copy",(e,t)=>this._onCopyCut(e,t)),this.listenTo(e,"cut",(e,t)=>this._onCopyCut(e,t)),this._listenToContentInsertion(),this.decorate("_replaceTableSlotCell")}_listenToContentInsertion(){const{editor:e}=this,t=e.plugins.get(Zp),i=e.plugins.get(iE);let n=!1;t.on("contentInsertion",(e,t)=>{n="paste"===t.method}),this.listenTo(e.model,"insertContent",(e,[t,s])=>{(n||null!==i.getSelectedTableCells())&&this._onInsertContent(e,t,s)},{priority:"high"}),t.on("contentInsertion",()=>{n=!1},{priority:"lowest"})}_onCopyCut(e,t){const i=this.editor.editing.view,n=this.editor.plugins.get(iE),s=this.editor.plugins.get(Xp);n.getSelectedTableCells()&&("cut"!=e.name||this.editor.model.canEditAt(this.editor.model.document.selection))&&(t.preventDefault(),e.stop(),this.editor.model.enqueueChange({isUndoable:"cut"===e.name},()=>{const o=s._copySelectedFragmentWithMarkers(e.name,this.editor.model.document.selection,()=>n.getSelectionAsFragment());i.document.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:this.editor.data.toView(o),method:e.name})}))}_onInsertContent(e,t,i){if(i&&!i.is("documentSelection"))return;const n=this.editor.model,s=this.editor.plugins.get(oT),o=this.editor.plugins.get(Xp),r=this.getTableIfOnlyTableInContent(t,n);if(!r)return;const a=s.getSelectionAffectedTableCells(n.document.selection);a.length?(e.stop(),t.is("documentFragment")?o._pasteMarkersIntoTransformedElement(t.markers,e=>this._replaceSelectedCells(r,a,e)):this.editor.model.change(e=>{this._replaceSelectedCells(r,a,e)})):HA(r,s)}_replaceSelectedCells(e,t,i){const n=this.editor.plugins.get(oT),s={width:n.getColumns(e),height:n.getRows(e)},o=function(e,t,i,n){const s=e[0].findAncestor("table"),o=n.getColumnIndexes(e),r=n.getRowIndexes(e),a={firstColumn:o.first,lastColumn:o.last,firstRow:r.first,lastRow:r.last},l=1===e.length;l&&(a.lastRow+=t.height-1,a.lastColumn+=t.width-1,function(e,t,i,n){const s=n.getColumns(e),o=n.getRows(e);i>s&&n.insertColumns(e,{at:s,columns:i-s});t>o&&n.insertRows(e,{at:o,rows:t-o})}(s,a.lastRow+1,a.lastColumn+1,n));l||!n.isSelectionRectangular(e)?function(e,t,i){const{firstRow:n,lastRow:s,firstColumn:o,lastColumn:r}=t,a={first:n,last:s},l={first:o,last:r};oE(e,o,a,i),oE(e,r+1,a,i),sE(e,n,l,i),sE(e,s+1,l,i,n)}(s,a,i):(a.lastRow=$A(s,a),a.lastColumn=WA(s,a));return a}(t,s,i,n),r=o.lastRow-o.firstRow+1,a=o.lastColumn-o.firstColumn+1;e=VA(e,{startRow:0,startColumn:0,endRow:Math.min(r,s.height)-1,endColumn:Math.min(a,s.width)-1},i);const l=t[0].findAncestor("table"),c=this._replaceSelectedCellsWithPasted(e,s,l,o,i,n);if(this.editor.plugins.get("TableSelection").isEnabled){const e=n.sortRanges(c.map(e=>i.createRangeOn(e)));i.setSelection(e)}else i.setSelection(c[0],0);return l}_replaceSelectedCellsWithPasted(e,t,i,n,s,o){const{width:r,height:a}=t,l=function(e,t,i){const n=new Array(i).fill(null).map(()=>new Array(t).fill(null));for(const{column:t,row:i,cell:s}of new CA(e))n[i][t]=s;return n}(e,r,a),c=[...new CA(i,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],d=[];let u;for(const e of c){const{row:t,column:i}=e;i===n.firstColumn&&(u=e.getPositionBefore());const o=t-n.firstRow,c=i-n.firstColumn,h=l[o%a][c%r],m=h?s.cloneElement(h):null,g=this._replaceTableSlotCell(e,m,u,s);g&&(LA(g,t,i,n.lastRow,n.lastColumn,s),d.push(g),u=s.createPositionAfter(g))}const h=parseInt(i.getAttribute("headingRows")||"0"),m=parseInt(i.getAttribute("headingColumns")||"0"),g=parseInt(i.getAttribute("footerRows")||"0"),f=o.getRows(i)-g,p=n.firstRow<h&&h<=n.lastRow,b=n.firstColumn<m&&m<=n.lastColumn,w=n.firstRow<f&&f<=n.lastRow;if(p){const e=sE(i,h,{first:n.firstColumn,last:n.lastColumn},s,n.firstRow);d.push(...e)}if(b){const e=oE(i,m,{first:n.firstRow,last:n.lastRow},s);d.push(...e)}if(w){const e=sE(i,f,{first:n.firstColumn,last:n.lastColumn},s,n.firstRow);d.push(...e)}return d}_replaceTableSlotCell(e,t,i,n){const{cell:s,isAnchor:o}=e;return o&&n.remove(s),t?(n.insert(t,i),t):null}getTableIfOnlyTableInContent(e,t){if(!e.is("documentFragment")&&!e.is("element"))return null;if(e.is("element","table"))return e;if(1==e.childCount&&e.getChild(0).is("element","table"))return e.getChild(0);const i=t.createRangeIn(e);for(const e of i.getItems())if(e.is("element","table")){const n=t.createRange(i.start,t.createPositionBefore(e));if(t.hasContent(n,{ignoreWhitespaces:!0}))return null;const s=t.createRange(t.createPositionAfter(e),i.end);return t.hasContent(s,{ignoreWhitespaces:!0})?null:e}return null}}function sE(e,t,i,n,s=0){if(t<1)return;return BA(e,t,s).filter(({column:e,cellWidth:t})=>rE(e,t,i)).map(({cell:e})=>MA(e,t,n))}function oE(e,t,i,n){if(t<1)return;return FA(e,t).filter(({row:e,cellHeight:t})=>rE(e,t,i)).map(({cell:e,column:i})=>NA(e,i,t,n))}function rE(e,t,i){const n=e+t-1,{first:s,last:o}=i;return e>=s&&e<=o||e<s&&n>=s}class aE extends Cc{static get pluginName(){return"TableKeyboard"}static get isOfficialPlugin(){return!0}static get requires(){return[iE,oT]}init(){const e=this.editor,t=e.editing.view.document,i=e.t;this.listenTo(t,"arrowKey",(...e)=>this._onArrowKey(...e),{context:"table"}),this.listenTo(t,"tab",(...e)=>this._handleTabOnSelectedTable(...e),{context:"figure"}),this.listenTo(t,"tab",(...e)=>this._handleTab(...e),{context:["th","td"]}),e.accessibility.addKeystrokeInfoGroup({id:"table",label:i("Keystrokes that can be used in a table cell"),keystrokes:[{label:i("Move the selection to the next cell"),keystroke:"Tab"},{label:i("Move the selection to the previous cell"),keystroke:"Shift+Tab"},{label:i("Insert a new table row (when in the last cell of a table)"),keystroke:"Tab"},{label:i("Navigate through the table"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]}]})}_handleTabOnSelectedTable(e,t){const i=this.editor.model.document.selection.getSelectedElement();i&&i.is("element","table")&&t.stopPropagation()}_handleTab(e,t){const i=this.editor,n=this.editor.plugins.get(oT),s=this.editor.plugins.get("TableSelection"),o=i.model.document.selection,r=!t.shiftKey;let a=n.getTableCellsContainingSelection(o)[0];if(a||(a=s.getFocusCell()),!a)return;t.stopPropagation();const l=a.parent,c=l.parent,d=c.getChildIndex(l),u=l.getChildIndex(a)===l.childCount-1,h=d===n.getRows(c)-1;r&&h&&u&&i.execute("insertTableRowBelow")}_onArrowKey(e,t){const i=this.editor,n=Yt(t.keyCode,i.locale.contentLanguageDirection);this._handleArrowKeys(n,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const i=this.editor.plugins.get(oT),n=this.editor.plugins.get("TableSelection"),s=this.editor.model,o=s.document.selection,r=["right","down"].includes(e),a=i.getSelectedTableCells(o);if(a.length){let i;return i=t?n.getFocusCell():r?a[a.length-1]:a[0],this._navigateFromCellInDirection(i,e,t),!0}const l=o.focus.findAncestor("tableCell");if(!l)return!1;if(!o.isCollapsed)if(t){if(o.isBackward==r&&!o.containsEntireContent(l))return!1}else{const e=o.getSelectedElement();if(!e||!s.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(o,l,r)&&(this._navigateFromCellInDirection(l,e,t),!0)}_isSelectionAtCellEdge(e,t,i){const n=this.editor.model,s=this.editor.model.schema,o=i?e.getLastPosition():e.getFirstPosition();if(!s.getLimitElement(o).is("element","tableCell")){return n.createPositionAt(t,i?"end":0).isTouching(o)}const r=n.createSelection(o);return n.modifySelection(r,{direction:i?"forward":"backward"}),o.isEqual(r.focus)}_navigateFromCellInDirection(e,t,i=!1){const n=this.editor.model,s=e.findAncestor("table"),o=[...new CA(s,{includeAllSlots:!0})],{row:r,column:a}=o[o.length-1],l=o.find(({cell:t})=>t==e);let{row:c,column:d}=l;switch(t){case"left":d--;break;case"up":c--;break;case"right":d+=l.cellWidth;break;case"down":c+=l.cellHeight}if(c<0||c>r||d<0&&c<=0||d>a&&c>=r)return void n.change(e=>{e.setSelection(e.createRangeOn(s))});d<0?(d=i?0:a,c--):d>a&&(d=i?a:0,c++);const u=o.find(e=>e.row==c&&e.column==d).cell,h=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(i&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,u)}else{const e=n.createPositionAt(u,h?0:"end");n.change(t=>{t.setSelection(e)})}}}class lE extends qs{domEventType=["mousemove","mouseleave"];onDomEvent(e){this.fire(e.type,e)}}class cE extends Cc{static get pluginName(){return"TableMouse"}static get isOfficialPlugin(){return!0}static get requires(){return[iE,oT]}init(){this.editor.editing.view.addObserver(lE),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(oT);let i=!1;const n=e.plugins.get(iE);this.listenTo(e.editing.view.document,"mousedown",(s,o)=>{const r=e.model.document.selection;if(!this.isEnabled||!n.isEnabled)return;if(!o.domEvent.shiftKey)return;const a=n.getAnchorCell()||t.getTableCellsContainingSelection(r)[0];if(!a)return;const l=this._getModelTableCellFromDomEvent(o);l&&dE(a,l)&&(i=!0,n.setCellSelection(a,l),o.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{i=!1}),this.listenTo(e.editing.view.document,"selectionChange",e=>{i&&e.stop()},{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,i,n=!1,s=!1;const o=e.plugins.get(iE);this.listenTo(e.editing.view.document,"mousedown",(e,i)=>{this.isEnabled&&o.isEnabled&&(i.domEvent.shiftKey||i.domEvent.ctrlKey||i.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(i)))}),this.listenTo(e.editing.view.document,"mousemove",(e,r)=>{if(!r.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(r);a&&dE(t,a)&&(i=a,n||i==t||(n=!0)),n&&(s=!0,o.setCellSelection(t,i),r.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{n=!1,s=!1,t=null,i=null}),this.listenTo(e.editing.view.document,"selectionChange",e=>{s&&e.stop()},{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,i=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(i).parent.findAncestor("tableCell",{includeSelf:!0})}}function dE(e,t){return e.parent.parent==t.parent.parent}class uE extends Cc{static get requires(){return[QT,eE,iE,cE,aE,nE,Mp]}static get pluginName(){return"Table"}static get isOfficialPlugin(){return!0}}function hE(e){const t=mE(e);return t||gE(e)}function mE(e){const t=e.getSelectedElement();return t&&fE(t)?t:null}function gE(e){const t=e.getFirstPosition();if(!t)return null;let i=t.parent;for(;i;){if(i.is("element")&&fE(i))return i;i=i.parent}return null}function fE(e){return e.is("element")&&!!e.getCustomProperty("table")&&pp(e)}class pE extends Uu{options;focusTracker;focusCycler;_focusables;dropdownView;inputView;keystrokes;_stillTyping;constructor(e,t){super(e),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new oi,this._focusables=new yu,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new ci,this._stillTyping=!1,this.focusCycler=new ch({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",(e,t,i)=>this._setInputValue(i))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach(e=>{this.focusTracker.add(e.element),this._focusables.add(e)}),this.keystrokes.listenTo(this.element)}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const e=this.locale,t=e.t,i=this.bindTemplate,n=this._createColorSelector(e),s=bm(e),o=new Uu;return o.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:i.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",i.if("value","ck-hidden",e=>""!=e)]}}]}),s.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),s.buttonView.children.add(o),s.buttonView.label=t("Color picker"),s.buttonView.tooltip=!0,s.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",s.panelView.children.add(n),s.bind("isEnabled").to(this,"isReadOnly",e=>!e),s.on("change:isOpen",(e,t,i)=>{i&&(n.updateSelectedColors(),n.showColorGridsFragment())}),s}_createInputTextView(){const e=this.locale,t=new Zh(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",()=>{const e=t.element.value,i=this.options.colorDefinitions.find(t=>e===t.label);this._stillTyping=!0,this.value=i&&i.color||e}),t.on("blur",()=>{this._stillTyping=!1,this._setInputValue(t.element.value)}),t.delegate("input").to(this),t}_createColorSelector(e){const t=e.t,i=this.options.defaultColorValue||"",n=t(i?"Restore default":"Remove color"),s=new Nm(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:n,colorPickerLabel:t("Color picker"),colorPickerViewConfig:!1!==this.options.colorPickerConfig&&{...this.options.colorPickerConfig,hideInput:!0}});s.appendUI(),s.on("execute",(e,t)=>{"colorPickerSaveButton"!==t.source?(this.value=t.value||i,this.fire("input"),"colorPicker"!==t.source&&(this.dropdownView.isOpen=!1)):this.dropdownView.isOpen=!1});let o=this.value;return s.on("colorPicker:cancel",()=>{this.value=o,this.fire("input"),this.dropdownView.isOpen=!1}),s.colorGridsFragmentView.colorPickerButtonView.on("execute",()=>{o=this.value}),s.bind("selectedColor").to(this,"value"),s}_setInputValue(e){if(!this._stillTyping){const t=bE(e),i=this.options.colorDefinitions.find(e=>t===bE(e.color));this.inputView.value=i?i.label:e||""}}}function bE(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const wE=e=>""===e;function _E(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function vE(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function yE(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function kE(e){return e=e.trim().toLowerCase(),wE(e)||vl(e)}function CE(e){return e=e.trim(),wE(e)||SE(e)||Al(e)||El(e)}function AE(e){return e=e.trim(),wE(e)||SE(e)||Al(e)}function TE(e,t){const i=new ni,n=_E(e.t);for(const s in n){const o={type:"button",model:new wg({_borderStyleValue:s,label:n[s],role:"menuitemradio",withText:!0})};"none"===s?o.model.bind("isOn").to(e,"borderStyle",e=>"none"===t?!e:e===s):o.model.bind("isOn").to(e,"borderStyle",e=>e===s),i.add(o)}return i}function EE(e){const{view:t,icons:i,toolbar:n,labels:s,propertyName:o,nameToValue:r,defaultValue:a}=e;for(const e in s){const l=new rh(t.locale);l.set({role:"radio",isToggleable:!0,label:s[e],icon:i[e],tooltip:s[e]});const c=r?r(e):e;l.bind("isOn").to(t,o,e=>{let t=e;return""===e&&a&&(t=a),c===t}),l.on("execute",()=>{!a&&c&&t[o]===c?t[o]=void 0:t[o]=c}),n.items.add(l)}}const xE=[{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"}];function PE(e){return(t,i,n)=>{const s=new pE(t.locale,{colorDefinitions:(o=e.colorConfig,o.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}}))),columns:e.columns,defaultColorValue:e.defaultColorValue,colorPickerConfig:e.colorPickerConfig});var o;return s.inputView.set({id:i,ariaDescribedById:n}),s.bind("isReadOnly").to(t,"isEnabled",e=>!e),s.bind("hasError").to(t,"errorText",e=>!!e),s.on("input",()=>{t.errorText=null}),t.bind("isEmpty","isFocused").to(s),s}}function SE(e){const t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}class IE extends Uu{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;cellTypeDropdown;paddingInput;widthInput;heightInput;horizontalAlignmentToolbar;verticalAlignmentToolbar;saveButtonView;cancelButtonView;backButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:"",cellType:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:n,borderColorInput:s,borderRowLabel:o}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:a}=this._createBackgroundFields(),{cellTypeRowLabel:l,cellTypeDropdown:c}=this._createCellTypeField(),{widthInput:d,operatorLabel:u,heightInput:h,dimensionsLabel:m}=this._createDimensionFields(),{horizontalAlignmentToolbar:g,verticalAlignmentToolbar:f,alignmentLabel:p}=this._createAlignmentFields();this.focusTracker=new oi,this.keystrokes=new ci,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=n,this.borderColorInput=s,this.backgroundInput=a,this.cellTypeDropdown=c,this.paddingInput=this._createPaddingField(),this.widthInput=d,this.heightInput=h,this.horizontalAlignmentToolbar=g,this.verticalAlignmentToolbar=f;const{saveButtonView:b,cancelButtonView:w}=this._createActionButtons();this.saveButtonView=b,this.cancelButtonView=w,this.backButtonView=this._createBackButton(),this._focusables=new yu,this._focusCycler=new ch({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const _=new lh(e,{label:this.t("Cell properties")});_.children.add(this.backButtonView,0),this.children.add(_),this.children.add(new pg(e,{labelView:o,children:[o,i,n,s],class:"ck-table-form__border-row"})),this.children.add(new pg(e,{children:[new pg(e,{labelView:l,children:[l,c],class:"ck-table-form__cell-type-row"}),new pg(e,{labelView:r,children:[r,a],class:"ck-table-form__background-row"})]})),this.children.add(new pg(e,{children:[new pg(e,{labelView:m,children:[m,d,u,h],class:"ck-table-form__dimensions-row"}),new pg(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new pg(e,{labelView:p,children:[p,g,f],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new pg(e,{children:[this.cancelButtonView,this.saveButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Zu({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.cellTypeDropdown,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.cancelButtonView,this.saveButtonView,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()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},i=PE({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,s=this.t,o=s("Style"),r=new th(n);r.text=s("Border");const a=_E(s),l=new Yh(n,xm);l.set({label:o,class:"ck-table-form__border-style"}),l.fieldView.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),l.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>a[e||"none"]),l.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),l.bind("isEmpty").to(this,"borderStyle",e=>!e),vm(l.fieldView,TE(this,t.style),{role:"menu",ariaLabel:o});const c=new Yh(n,Tm);c.set({label:s("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",OE),c.fieldView.on("input",()=>{this.borderWidth=c.fieldView.element.value});const d=new Yh(n,i);return d.set({label:s("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",OE),d.fieldView.on("input",()=>{this.borderColor=d.fieldView.value}),this.on("change:borderStyle",(e,i,n,s)=>{OE(n)||(this.borderColor="",this.borderWidth=""),OE(s)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:l,borderColorInput:d,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new th(e);i.text=t("Background");const n=PE({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),s=new Yh(e,n);return s.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),s.fieldView.bind("value").to(this,"backgroundColor"),s.fieldView.on("input",()=>{this.backgroundColor=s.fieldView.value}),{backgroundRowLabel:i,backgroundInput:s}}_createCellTypeField(){const e=this.locale,t=this.t,i=new th(e);i.text=t("Cell type");const n=this._cellTypeLabels,s=new Yh(e,xm);return s.set({label:t("Cell type"),class:"ck-table-cell-properties-form__cell-type"}),s.fieldView.buttonView.set({ariaLabel:t("Cell type"),ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:t("Cell type")}),s.fieldView.buttonView.bind("label").to(this,"cellType",e=>n[e||"data"]),s.fieldView.on("execute",e=>{this.cellType=e.source._cellTypeValue}),s.bind("isEmpty").to(this,"cellType",e=>!e),vm(s.fieldView,this._getCellTypeDefinitions(),{role:"menu",ariaLabel:t("Cell type")}),{cellTypeRowLabel:i,cellTypeDropdown:s}}_createDimensionFields(){const e=this.locale,t=this.t,i=new th(e);i.text=t("Dimensions");const n=new Yh(e,Tm);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const s=new Uu(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const o=new Yh(e,Tm);return o.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),o.fieldView.bind("value").to(this,"height"),o.fieldView.on("input",()=>{this.height=o.fieldView.element.value}),{dimensionsLabel:i,widthInput:n,operatorLabel:s,heightInput:o}}_createPaddingField(){const e=this.locale,t=this.t,i=new Yh(e,Tm);return i.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),i.fieldView.bind("value").to(this,"padding"),i.fieldView.on("input",()=>{this.padding=i.fieldView.element.value}),i}_createAlignmentFields(){const e=this.locale,t=this.t,i=new th(e),n={left:Xc,center:Yc,right:Zc,justify:Qc,top:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m10.261 7.062 2.88 1.663a.75.75 0 0 1-.75 1.3L10.5 8.933v7.317a.75.75 0 1 1-1.5 0V8.932l-1.89 1.093a.75.75 0 0 1-.75-1.3l2.879-1.663a.75.75 0 0 1 .511-.187.75.75 0 0 1 .511.187M15.25 4a.75.75 0 1 1 0 1.5H4.75a.75.75 0 0 1 0-1.5z"/></svg>',middle:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.75 11.875a.75.75 0 0 1 .508.184l2.883 1.666a.75.75 0 0 1-.659 1.344l-.091-.044-1.892-1.093.001 4.318a.75.75 0 1 1-1.5 0v-4.317l-1.89 1.092a.75.75 0 0 1-.75-1.3l2.879-1.663a.75.75 0 0 1 .51-.187zM15.25 9a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5zM9.75.375a.75.75 0 0 1 .75.75v4.318l1.89-1.093.092-.045a.75.75 0 0 1 .659 1.344l-2.883 1.667a.75.75 0 0 1-.508.184.75.75 0 0 1-.511-.187L6.359 5.65a.75.75 0 0 1 .75-1.299L9 5.442V1.125a.75.75 0 0 1 .75-.75"/></svg>',bottom:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m9.239 13.938-2.88-1.663a.75.75 0 0 1 .75-1.3L9 12.067V4.75a.75.75 0 1 1 1.5 0v7.318l1.89-1.093a.75.75 0 0 1 .75 1.3l-2.879 1.663a.75.75 0 0 1-.511.187.75.75 0 0 1-.511-.187M4.25 17a.75.75 0 1 1 0-1.5h10.5a.75.75 0 0 1 0 1.5z"/></svg>'};i.text=t("Table cell text alignment");const s=new hm(e),o="rtl"===e.contentLanguageDirection;s.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Horizontal text alignment toolbar"),class:"ck-table-cell-properties-form__horizontal-alignment-toolbar"}),EE({view:this,icons:n,toolbar:s,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(o){if("left"===e)return"right";if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new hm(e);return r.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Vertical text alignment toolbar"),class:"ck-table-cell-properties-form__vertical-alignment-toolbar"}),EE({view:this,icons:n,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:s,verticalAlignmentToolbar:r,alignmentLabel:i}}_createActionButtons(){const e=this.locale,t=this.t,i=new rh(e),n=new rh(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return i.set({label:t("Save"),class:"ck-button-action",type:"submit",withText:!0}),i.bind("isEnabled").toMany(s,"errorText",(...e)=>e.every(e=>!e)),n.set({label:t("Cancel"),withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:n}}_createBackButton(){const e=this.locale.t,t=new rh(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:_d,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_getCellTypeDefinitions(){const e=new ni,t=this._cellTypeLabels,i=["data","header"];this.options.showScopedHeaderOptions&&i.push("header-column","header-row");for(const n of i){const i={type:"button",model:new wg({_cellTypeValue:n,label:t[n],role:"menuitemradio",withText:!0})};i.model.bind("isOn").to(this,"cellType",e=>e===n),e.add(i)}return e}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,i=t("Align cell text to the left"),n=t("Align cell text to the center"),s=t("Align cell text to the right"),o=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:s,center:n,left:i,justify:o}:{left:i,center:n,right:s,justify:o}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}get _cellTypeLabels(){const e=this.t;return{data:e("Data cell"),header:e("Header cell"),"header-column":e("Column header"),"header-row":e("Row header")}}}function OE(e){return"none"!==e}const RE=(()=>[Oh.defaultPositions.northArrowSouth,Oh.defaultPositions.northArrowSouthWest,Oh.defaultPositions.northArrowSouthEast,Oh.defaultPositions.southArrowNorth,Oh.defaultPositions.southArrowNorthWest,Oh.defaultPositions.southArrowNorthEast,Oh.defaultPositions.viewportStickyNorth])();function VE(e,t){const i=e.plugins.get("ContextualBalloon"),n=e.editing.view.document.selection;let s;"cell"===t?gE(n)&&(s=ME(e)):hE(n)&&(s=BE(e)),s&&i.updatePosition(s)}function BE(e){const t=IA(e.model.document.selection),i=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.mapViewToDom(i),positions:RE}}function ME(e){const t=e.editing.mapper,i=e.editing.view.domConverter,n=e.model.document.selection;if(n.rangeCount>1)return{target:()=>function(e,t){const i=t.editing.mapper,n=t.editing.view.domConverter,s=Array.from(e).map(e=>{const t=FE(e.start),s=i.toViewElement(t);return new ht(n.mapViewToDom(s))});return ht.getBoundingRect(s)}(n.getRanges(),e),positions:RE};const s=FE(n.getFirstPosition()),o=t.toViewElement(s);return{target:i.mapViewToDom(o),positions:RE}}function FE(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")}const NE={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment",cellType:"tableCellType"};class LE extends Cc{_defaultContentTableCellProperties;_defaultLayoutTableCellProperties;_balloon;view;_viewWithContentTableDefaults;_viewWithLayoutTableDefaults;_undoStepBatch;_isReady;static get requires(){return[vg]}static get pluginName(){return"TableCellPropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:xE,backgroundColors:xE})}init(){const e=this.editor,t=e.t;this._defaultContentTableCellProperties=fT(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._defaultLayoutTableCellProperties=mT(void 0,{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(vg),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",i=>{const n=new rh(i);n.set({label:t("Cell properties"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m11.105 18-.17 1H2.5A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1h15A1.5 1.5 0 0 1 19 2.5v9.975l-.85-.124-.15-.302V8h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5zM2 12h5V8H2zm10-4H8v4h4zM2 2v5h5V2zm0 16h5v-5H2zM13 7h5V2h-5zM8 2v5h4V2z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43zM13 6a1 1 0 0 1 1 1v3.172a2 2 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.98 1.98 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm-1 2H8v4h4z"/></svg>',tooltip:!0}),this.listenTo(n,"execute",()=>this._showView());const s=Object.values(NE).map(t=>e.commands.get(t)).filter(e=>!!e);return n.bind("isEnabled").toMany(s,"isEnabled",(...e)=>e.some(e=>e)),n})}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,i=t.config.get("table.tableCellProperties"),n=!!t.config.get("table.tableCellProperties.scopedHeaders"),s=jh(i.borderColors),o=Wh(t.locale,s),r=jh(i.backgroundColors),a=Wh(t.locale,r),l=!1!==i.colorPicker,c=new IE(t.locale,{borderColors:o,backgroundColors:a,defaultTableCellProperties:e,colorPickerConfig:!!l&&(i.colorPicker||{}),showScopedHeaderOptions:n}),d=t.t;c.render(),this.listenTo(c,"submit",()=>{this._hideView()}),this.listenTo(c,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()}),c.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),Yu({emitter:c,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const u=vE(d),h=yE(d);c.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),c.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:c.borderColorInput,commandName:"tableCellBorderColor",errorText:u,validator:kE})),c.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:c.borderWidthInput,commandName:"tableCellBorderWidth",errorText:h,validator:AE})),c.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:c.paddingInput,commandName:"tableCellPadding",errorText:h,validator:CE})),c.on("change:width",this._getValidatedPropertyChangeCallback({viewField:c.widthInput,commandName:"tableCellWidth",errorText:h,validator:CE})),c.on("change:height",this._getValidatedPropertyChangeCallback({viewField:c.heightInput,commandName:"tableCellHeight",errorText:h,validator:CE})),c.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:c.backgroundInput,commandName:"tableCellBackgroundColor",errorText:u,validator:kE})),c.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),c.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment"));const m=t.commands.get("tableCellType");return m&&(c.cellTypeDropdown.bind("isEnabled").to(m,"isEnabled"),c.on("change:cellType",this._getPropertyChangeCallback("tableCellType"))),c}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(NE).flatMap(([t,i])=>{const n=e.get(i);if(!n)return[];const s=t;let o;o="cellType"===s?"":this.view===this._viewWithContentTableDefaults?this._defaultContentTableCellProperties[s]||"":this._defaultLayoutTableCellProperties[s]||"";return[[t,n.value||o]]}).forEach(([e,i])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,i)}),this._isReady=!0}_showView(){const e=this.editor,t=hE(e.editing.view.document.selection),i=t&&e.editing.mapper.toModelElement(t),n=!i||"layout"!==i.getAttribute("tableType");n&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableCellProperties):n||this._viewWithLayoutTableDefaults||(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableCellProperties)),this.view=n?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:ME(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;gE(e.editing.view.document.selection)?this._isViewVisible&&VE(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,i,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:i,validator:n,errorText:s}=e,o=Ci(()=>{i.errorText=s},500);return(e,s,r)=>{o.cancel(),this._isReady&&(n(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),i.errorText=null):o())}}}class DE extends Tc{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,i){switch(super(e),this.attributeName=t,this._defaultContentTableValue=i,t){case"tableCellType":this._defaultLayoutTableValue="data";break;case"tableCellBorderStyle":this._defaultLayoutTableValue="none";break;case"tableCellHorizontalAlignment":this._defaultLayoutTableValue="left";break;case"tableCellVerticalAlignment":this._defaultLayoutTableValue="middle";break;default:this._defaultLayoutTableValue=void 0}}refresh(){const e=this.editor.model.document.selection,t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e),i=IA(e);this._defaultValue=i&&"layout"===i.getAttribute("tableType")?this._defaultLayoutTableValue:this._defaultContentTableValue,this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(e={}){const{value:t,batch:i}=e,n=this.editor.model,s=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(n.document.selection),o=this._getValueToSet(t);n.enqueueChange(i,e=>{o?s.forEach(t=>e.setAttribute(this.attributeName,o,t)):s.forEach(t=>e.removeAttribute(this.attributeName,t)),this.fire("afterExecute",{writer:e,tableCells:s,valueToSet:o})})}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every(e=>this._getAttribute(e)===t)?t:void 0}}class zE extends DE{constructor(e,t){super(e,"tableCellWidth",t)}_getValueToSet(e){if((e=hT(e,"px"))!==this._defaultValue)return e}}class HE extends Cc{static get pluginName(){return"TableCellWidthEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[QT]}init(){const e=this.editor,t=fT(e.config.get("table.tableCellProperties.defaultProperties"));SA(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",attributeName:"width",attributeType:"length",defaultValue:t.width}),e.commands.add("tableCellWidth",new zE(e,t.width))}}class $E extends DE{constructor(e,t){super(e,"tableCellPadding",t)}_getAttribute(e){if(!e)return;const t=uT(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=hT(e,"px");if(t!==this._defaultValue)return t}}class WE extends DE{constructor(e,t){super(e,"tableCellHeight",t)}_getValueToSet(e){const t=hT(e,"px");if(t!==this._defaultValue)return t}}class jE extends DE{constructor(e,t){super(e,"tableCellBackgroundColor",t)}}class UE extends DE{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}}class qE extends DE{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}}class KE extends DE{constructor(e,t){super(e,"tableCellBorderStyle",t)}_getAttribute(e){if(!e)return;const t=uT(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class GE extends DE{constructor(e,t){super(e,"tableCellBorderColor",t)}_getAttribute(e){if(!e)return;const t=uT(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class JE extends DE{constructor(e,t){super(e,"tableCellBorderWidth",t)}_getAttribute(e){if(!e)return;const t=uT(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=hT(e,"px");if(t!==this._defaultValue)return t}}class YE extends DE{constructor(e){super(e,"tableCellType","data"),this.on("afterExecute",(e,t)=>{const{writer:i,tableCells:n}=t,s=this.editor.plugins.get(oT),o=function(e){const t=new Map;for(const i of e){const e=i.findAncestor("table");t.has(e)||t.set(e,[]),t.get(e).push(i)}return t}(n);QE(s,i,o.keys())})}refresh(){super.refresh();const e=IA(this.editor.model.document.selection);this.isEnabled&&e&&"layout"===e.getAttribute("tableType")&&(this.isEnabled=!1)}_getAttribute(e){return e?.getAttribute(this.attributeName)||"data"}}function QE(e,t,i){let n=!1;for(const s of i){let i=s.getAttribute("headingRows")||0,o=s.getAttribute("headingColumns")||0;const r=s.getAttribute("footerRows")||0,a=e.getRows(s)-r,l=o>i;if(l){const r=XE(e,s,"column",o,i);r!==o&&(e.setHeadingColumnsCount(t,s,r,{updateCellType:!1}),o=r,n=!0)}let c=XE(e,s,"row",i,o);if(r>0&&(c=Math.min(c,a)),c!==i&&(e.setHeadingRowsCount(t,s,c,{updateCellType:!1}),i=c,n=!0),!l){const r=XE(e,s,"column",o,i);r!==o&&(e.setHeadingColumnsCount(t,s,r,{updateCellType:!1}),n=!0)}}return n}function XE(e,t,i,n,s){const o="row"===i?e.getRows(t):e.getColumns(t);let r=n;for(let e=0;e<o;e++){const n=new CA(t,{[i]:e});let o=!0,a=!1;for(const{cell:e,row:t,column:r}of n){if(!TA(e.getAttribute("tableCellType"))){o=!1;break}("row"===i?r:t)>=s&&(a=!0)}if(!o)return Math.min(r,e);a&&(r=Math.max(r,e+1))}return Math.min(r,o)}const ZE=/^(top|middle|bottom)$/,ex=/^(left|center|right|justify)$/;class tx extends Cc{static get pluginName(){return"TableCellPropertiesEditing"}static get licenseFeatureCode(){return"TCP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[QT,HE]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const n=fT(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection});e.data.addStyleProcessorRules(Xl),function(e,t){const{conversion:i}=e,{schema:n}=e.model,s={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};n.extend("tableCell",{allowAttributes:Object.values(s)});for(const e of Object.values(s))n.setAttributeProperties(e,{isFormatting:!0});dA(e,"td",s,t),dA(e,"th",s,t),uA(i,{modelElement:"tableCell",modelAttribute:s.style,styleName:"border-style"}),uA(i,{modelElement:"tableCell",modelAttribute:s.color,styleName:"border-color"}),uA(i,{modelElement:"tableCell",modelAttribute:s.width,styleName:"border-width"})}(e,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableCellBorderStyle",new KE(e,n.borderStyle)),e.commands.add("tableCellBorderColor",new GE(e,n.borderColor)),e.commands.add("tableCellBorderWidth",new JE(e,n.borderWidth)),SA(t,i,{modelAttribute:"tableCellHeight",styleName:"height",attributeName:"height",attributeType:"length",defaultValue:n.height}),e.commands.add("tableCellHeight",new WE(e,n.height)),e.data.addStyleProcessorRules(cc),SA(t,i,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),function(e,t){fA(e,"td",t),fA(e,"th",t)}(e,n.padding),e.commands.add("tableCellPadding",new $E(e,n.padding)),e.data.addStyleProcessorRules(ql),SA(t,i,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",attributeName:"bgcolor",attributeType:"color",defaultValue:n.backgroundColor}),e.commands.add("tableCellBackgroundColor",new jE(e,n.backgroundColor)),function(e,t,i){e.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),e.setAttributeProperties("tableCellHorizontalAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:e=>({key:"style",value:{"text-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":ex}},model:{key:"tableCellHorizontalAlignment",value:(e,t,n)=>{const s=mA(i,"left",n),o=e.getStyle("text-align");if(o!==s)return o;t.consumable.consume(e,{styles:"text-align"})}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:ex}},model:{key:"tableCellHorizontalAlignment",value:(e,t,n)=>{const s=mA(i,"left",n),o=e.getAttribute("align");if(o!==s)return o;t.consumable.consume(e,{attributes:"align"})}}})}(t,i,n.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new qE(e,n.horizontalAlignment)),function(e,t,i){e.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),e.setAttributeProperties("tableCellVerticalAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:e=>({key:"style",value:{"vertical-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":ZE}},model:{key:"tableCellVerticalAlignment",value:(e,t,n)=>{const s=mA(i,"middle",n),o=e.getStyle("vertical-align");if(o!==s)return o;t.consumable.consume(e,{styles:"vertical-align"})}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:ZE}},model:{key:"tableCellVerticalAlignment",value:(e,t,n)=>{const s=mA(i,"middle",n),o=e.getAttribute("valign");if(o!==s)return o;t.consumable.consume(e,{attributes:"valign"})}}})}(t,i,n.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new UE(e,n.verticalAlignment)),function(e){const{model:t,conversion:i,editing:n,config:s}=e,{schema:o}=t;s.define("table.tableCellProperties.scopedHeaders",!0);const r=!!s.get("table.tableCellProperties.scopedHeaders"),a=e.plugins.get(oT);o.extend("tableCell",{allowAttributes:["tableCellType"]}),o.setAttributeProperties("tableCellType",{isFormatting:!0}),o.addAttributeCheck(e=>{const t=Array.from(e).reverse().find(e=>"table"===e.name);if("layout"===t?.getAttribute("tableType"))return!1},"tableCellType"),i.for("upcast").add(e=>{e.on("element:th",(e,t,i)=>{const{writer:n}=i,{modelRange:s}=t,o=s?.start.nodeAfter;o?.is("element","tableCell")&&!o.hasAttribute("tableCellType")&&n.setAttribute("tableCellType","header",o)}),e.on("element:table",(e,t,i)=>{const{writer:n}=i,{modelRange:s}=t,o=s?.start.nodeAfter;if(o?.is("element","table")&&"layout"===o.getAttribute("tableType"))for(const{cell:e}of new CA(o)){if(TA(e.getAttribute("tableCellType"))){n.setAttribute("tableType","content",o);break}}},{priority:me.low-1})}),r&&(i.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellType"},view:e=>{switch(e){case"header-row":return{key:"scope",value:"row"};case"header-column":return{key:"scope",value:"col"}}}}),i.for("upcast").add(e=>{e.on("element:th",(e,t,i)=>{const{writer:n,consumable:s}=i,{viewItem:o,modelRange:r}=t,a=r.start.nodeAfter,l=a?.getAttribute("tableCellType");if("header"===l&&s.consume(o,{attributes:["scope"]})){switch(o.getAttribute("scope")){case"row":n.setAttribute("tableCellType","header-row",a);break;case"col":n.setAttribute("tableCellType","header-column",a)}}})}));t.document.registerPostFixer(e=>{const i=t.document.differ.getChanges(),n=new Set;for(const e of i){if("attribute"===e.type&&("headingRows"===e.attributeKey||"headingColumns"===e.attributeKey)){const t=e.range.start.nodeAfter;t?.is("element","table")&&"$graveyard"!==t.root.rootName&&n.add(t)}if("attribute"===e.type&&"tableCellType"===e.attributeKey){const t=e.range.start.nodeAfter;if(t?.is("element","tableCell")&&"$graveyard"!==t.root.rootName){const e=t.findAncestor("table");e&&n.add(e)}}if("insert"===e.type&&e.position.nodeAfter)for(const{item:i}of t.createRangeOn(e.position.nodeAfter))if(i.is("element","tableCell")&&i.getAttribute("tableCellType")&&"$graveyard"!==i.root.rootName){const e=i.findAncestor("table");e&&n.add(e)}}return QE(a,e,n)}),t.document.on("change:data",()=>{const{differ:e}=t.document,i=new Set;for(const t of e.getChanges())if("attribute"===t.type&&"tableCellType"===t.attributeKey){const e=t.range.start.nodeAfter;e.is("element","tableCell")&&i.add(e)}for(const e of i){const t=n.mapper.toViewElement(e),i=TA(e.getAttribute("tableCellType"))?"th":"td";t?.name!==i&&n.reconvertItem(e)}})}(e),e.commands.add("tableCellType",new YE(e))}}class ix extends Tc{refresh(){this.isEnabled=!0}execute(e={}){const{model:t,plugins:i}=this.editor;let{table:n=t.document.selection.getSelectedElement(),columnWidths:s,tableWidth:o}=e;s&&(s=Array.isArray(s)?s:s.split(",")),t.change(e=>{o?e.setAttribute("tableWidth",o,n):e.removeAttribute("tableWidth",n);const t=i.get("TableColumnResizeEditing").getColumnGroupElement(n);if(!s&&!t)return;if(!s)return e.remove(t);const r=eT(s);if(t)Array.from(t.getChildren()).forEach((t,i)=>e.setAttribute("columnWidth",r[i],t));else{const t=e.createElement("tableColumnGroup");r.forEach(i=>e.appendElement("tableColumn",{columnWidth:i},t)),e.append(t,n)}})}}function nx(e){return t=>t.on("element:colgroup",(t,i,n)=>{const s=i.modelCursor.findAncestor("table"),o=nT(s);if(!o)return;const r=sT(o),a=e.getColumns(s);let l=(c=o,d=n.writer,sT(c).reduce((e,t)=>{const i=t.getAttribute("columnWidth"),n=t.getAttribute("colSpan");if(!n)return e.push(i),e;for(let t=0;t<n;t++)e.push(i);return d.removeAttribute("colSpan",t),e},[]));var c,d;l=Array.from({length:a},(e,t)=>l[t]||"auto"),(l.length!=r.length||l.includes("auto"))&&iT(r,o,eT(l),n.writer)},{priority:"low"})}const sx=yt("px");class ox extends Cc{_isResizingActive;_resizingData;_domEmitter;_tableUtilsPlugin;_initialMouseEventData=null;static get requires(){return[QT,oT]}static get pluginName(){return"TableColumnResizeEditing"}static get licenseFeatureCode(){return"TCR"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new(tt()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",(t,i,n)=>{const s=n?"removeClass":"addClass";e.editing.view.change(t=>{for(const i of e.editing.view.document.roots)t[s]("ck-column-resize_disabled",e.editing.view.document.getRoot(i.rootName))})})}init(){this._extendSchema(),this._registerPostFixer(),this._registerConverters(),this._registerResizingListeners(),this._registerResizerInserter();const e=this.editor,t=e.plugins.get("TableColumnResize");e.plugins.get("TableEditing").registerAdditionalSlot({filter:e=>e.is("element","tableColumnGroup"),positionOffset:0});const i=new ix(e);e.commands.add("resizeTableWidth",i),e.commands.add("resizeColumnWidths",i),this.bind("_isResizingAllowed").to(e,"isReadOnly",t,"isEnabled",i,"isEnabled",(e,t,i)=>!e&&t&&i)}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return nT(e)}getTableColumnElements(e){return sT(e)}getTableColumnsWidths(e){return function(e){return sT(e).map(e=>e.getAttribute("columnWidth"))}(e)}_extendSchema(){const e=this.editor.model.schema;e.extend("table",{allowAttributes:["tableWidth"]}),e.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),e.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0}),e.setAttributeProperties("columnWidth",{isFormatting:!0})}_registerPostFixer(){const e=this.editor.model;function t(e,t,i){const n=i._tableUtilsPlugin.getColumns(t);if(0===n-e.length)return e;const s=e.map(e=>Number(e.replace("%",""))),o=function(e,t){const i=new Set;for(const n of e.getChanges())if("insert"==n.type&&n.position.nodeAfter&&"tableCell"==n.position.nodeAfter.name&&n.position.nodeAfter.getAncestors().includes(t))i.add(n.position.nodeAfter);else if("remove"==n.type){const e=n.position.nodeBefore||n.position.nodeAfter;"tableCell"==e.name&&e.getAncestors().includes(t)&&i.add(e)}return i}(i.editor.model.document.differ,t);for(const e of o){const o=n-s.length;if(0===o)continue;const r=o>0,a=i._tableUtilsPlugin.getCellLocation(e).column;if(r){const e=XA(o,KA(t,i.editor));s.splice(a,0,...e)}else{const e=s.splice(a,Math.abs(o));s[a]+=ZA(e)}}return s.map(e=>e+"%")}e.document.registerPostFixer(i=>{let n=!1;for(const s of function(e){const t=new Set;for(const i of e.document.differ.getChanges()){let n=null;switch(i.type){case"insert":n=["table","tableRow","tableCell"].includes(i.name)?i.position:null;break;case"remove":n=["tableRow","tableCell"].includes(i.name)?i.position:null;break;case"attribute":i.range.start.nodeAfter&&(n=["table","tableRow","tableCell"].includes(i.range.start.nodeAfter.name)?i.range.start:null)}if(!n)continue;const s=n.nodeAfter&&n.nodeAfter.is("element","table")?n.nodeAfter:n.findAncestor("table");for(const i of e.createRangeOn(s).getItems())i.is("element","table")&&nT(i)&&t.add(i)}return t}(e)){const e=this.getColumnGroupElement(s),o=this.getTableColumnElements(e),r=this.getTableColumnsWidths(e);let a=eT(r);a=t(a,s,this),Xi(r,a)||(iT(o,e,a,i),n=!0)}return n})}_registerConverters(){const e=this.editor.conversion;e.for("upcast").attributeToAttribute({view:{name:/^(figure|table)$/,styles:{width:/[\s\S]+/}},model:{key:"tableWidth",value:e=>{if(!e.parent.is("element","figure"))return e.getStyle("width")}}}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:e=>({name:"figure",key:"style",value:{width:e}})}),e.elementToElement({model:"tableColumnGroup",view:"colgroup"}),e.elementToElement({model:"tableColumn",view:"col"}),e.for("downcast").add(e=>e.on("insert:table",(e,t,i)=>{const n=i.writer,s=t.item,o=i.mapper.toViewElement(s),r=o.is("element","table")?o:Array.from(o.getChildren()).find(e=>e.is("element","table"));nT(s)?n.addClass("ck-table-resized",r):n.removeClass("ck-table-resized",r)},{priority:"low"})),e.for("upcast").add(e=>{e.on("element:table",(e,t,i)=>{i.consumable.consume(t.viewItem,{classes:"ck-table-resized"})})}),e.for("upcast").add(nx(this._tableUtilsPlugin)),e.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:e=>{const t=e.getStyle("width");return t&&(t.endsWith("%")||t.endsWith("pt"))?t:"auto"}}}),e.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),e.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:e=>({key:"style",value:{width:e}})})}_registerResizingListeners(){const e=this.editor.editing.view;e.addObserver(lE),e.document.on("mouseover",this._onMouseOverHandler.bind(this),{priority:"high"}),e.document.on("mousedown",this._onMouseDownHandler.bind(this),{priority:"high"}),e.document.on("mouseout",this._onMouseOutHandler.bind(this),{priority:"high"}),this._domEmitter.listenTo(G.window.document,"mousemove",Ai(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(G.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_recalculateResizerElement(e){const t=this.editor,i=t.editing.view.domConverter,n=i.mapViewToDom(e.findAncestor("table")),s=i.mapViewToDom(e.findAncestor(e=>["td","th"].includes(e.name))),o=new ht(n),r=new ht(s),a=sx(Number((o.top-r.top).toFixed(4))),l=sx(Number((r.bottom-o.bottom).toFixed(4)));t.editing.view.change(t=>{t.setStyle("top",a,e),t.setStyle("bottom",l,e)})}_resetResizerStyles(e){this.editor.editing.view.change(t=>{t.removeStyle("top",e),t.removeStyle("bottom",e)})}_onMouseOverHandler(e,t){const i=t.target;i.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&this._recalculateResizerElement(i)}_onMouseOutHandler(e,t){const i=t.target;i.hasClass("ck-table-column-resizer")&&this._isResizingAllowed&&(this._isResizingActive||this._resetResizerStyles(i))}_onMouseDownHandler(e,t){const i=t.target;if(!i.hasClass("ck-table-column-resizer"))return;if(!this._isResizingAllowed)return;const n=this.editor,s=n.editing.mapper.toModelElement(i.findAncestor("figure"));n.model.canEditAt(s)&&(t.preventDefault(),e.stop(),this._initialMouseEventData=t)}_startResizingAfterThreshold(){const e=this._initialMouseEventData,{target:t}=e,i=this.editor.editing.mapper.toModelElement(t.findAncestor("figure")),n=t.findAncestor("table"),s=function(e,t,i){const n=Array(t.getColumns(e)),s=new CA(e);for(const e of s){const t=i.editing.mapper.toViewElement(e.cell),s=tT(i.editing.view.domConverter.mapViewToDom(t));(!n[e.column]||s<n[e.column])&&(n[e.column]=QA(s))}return n}(i,this._tableUtilsPlugin,this.editor);Array.from(n.getChildren()).find(e=>e.is("element","colgroup"))||this.editor.editing.view.change(e=>{!function(e,t,i){const n=e.createContainerElement("colgroup");for(let i=0;i<t.length;i++){const s=e.createEmptyElement("col"),o=`${QA(t[i]/ZA(t)*100)}%`;e.setStyle("width",o,s),e.insert(e.createPositionAt(n,"end"),s)}e.insert(e.createPositionAt(i,0),n)}(e,s,n)}),this._isResizingActive=!0,this._resizingData=this._getResizingData(e,s),this.editor.editing.view.change(e=>function(e,t,i){const n=i.widths.viewFigureWidth/i.widths.viewFigureParentWidth;e.addClass("ck-table-resized",t),e.addClass("ck-table-column-resizer__active",i.elements.viewResizer),e.setStyle("width",`${QA(100*n)}%`,t.findAncestor("figure"))}(e,n,this._resizingData))}_onMouseMoveHandler(e,t){if(this._initialMouseEventData){const e=this._initialMouseEventData.domEvent;if(!(Math.abs(t.clientX-e.clientX)>=3))return;this._startResizingAfterThreshold(),this._initialMouseEventData=null}if(!this._isResizingActive)return;if(!this._isResizingAllowed)return void this._onMouseUpHandler();const{columnPosition:i,flags:{isRightEdge:n,isTableCentered:s,isLtrContent:o},elements:{viewFigure:r,viewLeftColumn:a,viewRightColumn:l,viewResizer:c},widths:{viewFigureParentWidth:d,tableWidth:u,leftColumnWidth:h,rightColumnWidth:m}}=this._resizingData,g=40-h,f=n?d-u:m-40,p=(o?1:-1)*(n&&s?2:1),b=(w=(t.clientX-i)*p,_=Math.min(g,0),v=Math.max(f,0),QA(w<=_?_:w>=v?v:w));var w,_,v;0!==b&&(this.editor.editing.view.change(e=>{const t=QA(100*(h+b)/u);if(e.setStyle("width",`${t}%`,a),n){const t=QA(100*(u+b)/d);e.setStyle("width",`${t}%`,r)}else{const t=QA(100*(m-b)/u);e.setStyle("width",`${t}%`,l)}}),this._recalculateResizerElement(c))}_onMouseUpHandler(){if(this._initialMouseEventData=null,!this._isResizingActive)return;const{viewResizer:e,modelTable:t,viewFigure:i,viewColgroup:n}=this._resizingData.elements,s=this.editor,o=s.editing.view,r=this.getColumnGroupElement(t),a=Array.from(n.getChildren()).filter(e=>e.is("view:element")),l=r?this.getTableColumnsWidths(r):null,c=a.map(e=>e.getStyle("width")),d=!Xi(l,c),u=t.getAttribute("tableWidth"),h=i.getStyle("width"),m=u!==h;(d||m)&&(this._isResizingAllowed?s.execute("resizeTableWidth",{table:t,tableWidth:`${QA(h)}%`,columnWidths:c}):o.change(e=>{if(l)for(const t of a)e.setStyle("width",l.shift(),t);else e.remove(n);m&&(u?e.setStyle("width",u,i):e.removeStyle("width",i)),l||u||e.removeClass("ck-table-resized",[...i.getChildren()].find(e=>"table"===e.name))})),o.change(t=>{t.removeClass("ck-table-column-resizer__active",e)});o.domConverter.mapViewToDom(e).matches(":hover")||this._resetResizerStyles(e),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,t){const i=this.editor,n=e.domEvent.clientX,s=e.target,o=s.findAncestor("td")||s.findAncestor("th"),r=i.editing.mapper.toModelElement(o),a=r.findAncestor("table"),l=function(e,t){const i=t.getCellLocation(e).column;return{leftEdge:i,rightEdge:i+(e.getAttribute("colspan")||1)-1}}(r,this._tableUtilsPlugin).rightEdge,c=this._tableUtilsPlugin.getColumns(a)-1;let d=a.getAttribute("tableAlignment");"layout"!==a.getAttribute("tableType")&&(d||=i.config.get("table.tableProperties.defaultProperties.alignment"),d||="center");const u=l===c,h="rtl"!==i.locale.contentLanguageDirection,m="center"===d,g=o.findAncestor("table"),f=g.findAncestor("figure"),p=[...g.getChildren()].find(e=>e.is("element","colgroup")),b=p.getChild(l),w=u?void 0:p.getChild(l+1);return{columnPosition:n,flags:{isRightEdge:u,isTableCentered:m,isLtrContent:h},elements:{viewResizer:s,modelTable:a,viewFigure:f,viewColgroup:p,viewLeftColumn:b,viewRightColumn:w},widths:{viewFigureParentWidth:YA(i.editing.view.domConverter.mapViewToDom(f.parent)),viewFigureWidth:YA(i.editing.view.domConverter.mapViewToDom(f)),tableWidth:GA(a,i),leftColumnWidth:t[l],rightColumnWidth:u?void 0:t[l+1]}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add(e=>{e.on("insert:tableCell",(e,t,i)=>{const n=t.item,s=i.mapper.toViewElement(n),o=i.writer;o.insert(o.createPositionAt(s,"end"),o.createUIElement("div",{class:"ck-table-column-resizer"}))},{priority:"lowest"})})}}class rx extends Cc{static get requires(){return[ox,HE]}static get pluginName(){return"TableColumnResize"}static get isOfficialPlugin(){return!0}}class ax extends Tc{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,i){super(e),this.attributeName=t,this._defaultContentTableValue=i,this._defaultLayoutTableValue="tableBorderStyle"===t?"none":void 0}refresh(){const e=IA(this.editor.model.document.selection);this._defaultValue=e&&"layout"===e.getAttribute("tableType")?this._defaultLayoutTableValue:this._defaultContentTableValue,this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){const t=this.editor.model,i=t.document.selection,{value:n,batch:s}=e,o=IA(i),r=this._getValueToSet(n);t.enqueueChange(s,e=>{r?e.setAttribute(this.attributeName,r,o):e.removeAttribute(this.attributeName,o)})}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}}class lx extends ax{constructor(e,t){super(e,"tableBackgroundColor",t)}}class cx extends ax{constructor(e,t){super(e,"tableBorderColor",t)}_getValue(e){if(!e)return;const t=uT(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class dx extends ax{constructor(e,t){super(e,"tableBorderStyle",t)}_getValue(e){if(!e)return;const t=uT(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class ux extends ax{constructor(e,t){super(e,"tableBorderWidth",t)}_getValue(e){if(!e)return;const t=uT(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=hT(e,"px");if(t!==this._defaultValue)return t}}class hx extends ax{constructor(e,t){super(e,"tableWidth",t)}_getValueToSet(e){if((e=hT(e,"px"))!==this._defaultValue)return e}}class mx extends ax{constructor(e,t){super(e,"tableHeight",t)}_getValueToSet(e){if((e=hT(e,"px"))!==this._defaultValue)return e}}class gx extends ax{constructor(e,t){super(e,"tableAlignment",t)}}class fx extends Cc{static get pluginName(){return"TablePropertiesEditing"}static get licenseFeatureCode(){return"TCP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[QT]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const n=gT(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),s=!0===e.config.get("table.tableProperties.alignment.useInlineStyles");e.data.addStyleProcessorRules(lc),e.data.addStyleProcessorRules(Xl),function(e,t){const{conversion:i}=e,{schema:n}=e.model,s={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};n.extend("table",{allowAttributes:Object.values(s)});for(const e of Object.values(s))n.setAttributeProperties(e,{isFormatting:!0});dA(e,"table",s,t),hA(i,{modelAttribute:s.color,styleName:"border-color"}),hA(i,{modelAttribute:s.style,styleName:"border-style"}),hA(i,{modelAttribute:s.width,styleName:"border-width"})}(e,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableBorderColor",new cx(e,n.borderColor)),e.commands.add("tableBorderStyle",new dx(e,n.borderStyle)),e.commands.add("tableBorderWidth",new ux(e,n.borderWidth)),function(e,t,i,n){e.extend("table",{allowAttributes:["tableAlignment"]}),e.setAttributeProperties("tableAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right","blockLeft","blockRight"]},view:{left:n?{key:"style",value:{float:"left","margin-right":"var(--ck-content-table-style-spacing, 1.5em)"}}:{key:"class",value:pA.className},right:n?{key:"style",value:{float:"right","margin-left":"var(--ck-content-table-style-spacing, 1.5em)"}}:{key:"class",value:wA.className},center:n?{key:"style",value:{"margin-left":"auto","margin-right":"auto"}}:{key:"class",value:bA.className},blockLeft:n?{key:"style",value:{"margin-left":"0","margin-right":"auto"}}:{key:"class",value:_A.className},blockRight:n?{key:"style",value:{"margin-left":"auto","margin-right":"0"}}:{key:"class",value:vA.className}},converterPriority:"high"}),yA.forEach(e=>{t.for("upcast").attributeToAttribute({view:e.view,model:{key:"tableAlignment",value:(t,n,s)=>{if(function(e){return"figure"==e.name&&!e.hasClass("table")}(t))return;const o=mA(i,"",s),r=e.getAlign(t),a=e.getConsumables(t);return n.consumable.consume(t,a),r!==o?r:void 0}}})}),t.for("upcast").add(function(e){return t=>{t.on("element:div",(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,attributes:"align"}))return;const s=jA(i.viewItem);if(!s||!n.consumable.test(s,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,attributes:"align"});const o=n.convertItem(s,i.modelCursor),r=si(o.modelRange.getItems());if(!r||!r.is("element","table"))return n.consumable.revert(i.viewItem,{name:!0,attributes:"align"}),void(o.modelRange&&!o.modelRange.isCollapsed&&(i.modelRange=o.modelRange,i.modelCursor=o.modelCursor));const a=function(e,t,i){if(e)switch(e){case"right":return"right"===t?"right":"left"===t?"left":"blockRight";case"center":return"center";case"left":return void 0===t?"blockLeft":"left";default:return i}return}(i.viewItem.getAttribute("align"),s.getAttribute("align"),mA(e,"",i));a&&n.writer.setAttribute("tableAlignment",a,r),n.convertChildren(i.viewItem,n.writer.createPositionAt(r,"end")),n.updateConversionResult(r,i)})}}(i))}(t,i,n.alignment,s),e.commands.add("tableAlignment",new gx(e,n.alignment)),wx(t,i,{modelAttribute:"tableWidth",styleName:"width",attributeName:"width",attributeType:"length",defaultValue:n.width}),e.commands.add("tableWidth",new hx(e,n.width)),wx(t,i,{modelAttribute:"tableHeight",styleName:"height",attributeName:"height",attributeType:"length",defaultValue:n.height}),e.commands.add("tableHeight",new mx(e,n.height)),e.data.addStyleProcessorRules(ql),function(e,t,i){const{modelAttribute:n}=i;e.extend("table",{allowAttributes:[n]}),e.setAttributeProperties(n,{isFormatting:!0}),cA(t,{viewElement:"table",...i}),hA(t,i)}(t,i,{modelAttribute:"tableBackgroundColor",styleName:"background-color",attributeName:"bgcolor",attributeType:"color",defaultValue:n.backgroundColor}),e.commands.add("tableBackgroundColor",new lx(e,n.backgroundColor)),fA(e,"table");const o=e.editing.view.document;this.listenTo(o,"clipboardOutput",(t,i)=>{e.editing.view.change(e=>{for(const{item:t}of e.createRangeIn(i.content))px(t,e);i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content))})},{priority:"lowest"})}}function px(e,t){if(!e.is("element","table"))return;const i=e.getAttribute("align"),n=e.getStyle("float"),s=e.getStyle("margin-left"),o=e.getStyle("margin-right");i&&"center"===i||n&&"right"===n&&i&&"right"===i?bx(t,i,e):void 0===n&&"auto"===s&&"0"===o&&bx(t,"right",e)}function bx(e,t,i){const n=e.createPositionBefore(i),s=e.createContainerElement("div",{align:t},i);e.insert(n,s)}function wx(e,t,i){const{modelAttribute:n}=i;e.extend("table",{allowAttributes:[n]}),e.setAttributeProperties(n,{isFormatting:!0}),cA(t,{viewElement:/^(table|figure)$/,shouldUpcast:e=>!("table"==e.name&&"figure"==e.parent.name||"figure"==e.name&&!e.hasClass("table")),...i}),uA(t,{modelElement:"table",...i})}class _x extends Uu{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;widthInput;heightInput;alignmentToolbar;saveButtonView;cancelButtonView;backButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:n,borderColorInput:s,borderRowLabel:o}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:a}=this._createBackgroundFields(),{widthInput:l,operatorLabel:c,heightInput:d,dimensionsLabel:u}=this._createDimensionFields(),{alignmentToolbar:h,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new oi,this.keystrokes=new ci,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=n,this.borderColorInput=s,this.backgroundInput=a,this.widthInput=l,this.heightInput=d,this.alignmentToolbar=h;const{saveButtonView:g,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=f,this.backButtonView=this._createBackButton(),this._focusables=new yu,this._focusCycler=new ch({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const p=new lh(e,{label:this.t("Table properties")});p.children.add(this.backButtonView,0),this.children.add(p),this.children.add(new pg(e,{labelView:o,children:[o,i,n,s],class:"ck-table-form__border-row"})),this.children.add(new pg(e,{children:[new pg(e,{labelView:u,children:[u,l,c,d],class:"ck-table-form__dimensions-row"}),new pg(e,{labelView:r,children:[r,a],class:"ck-table-form__background-row"})]})),this.children.add(new pg(e,{labelView:m,children:[m,h],class:"ck-table-properties-form__alignment-row"})),this.children.add(new pg(e,{children:[this.cancelButtonView,this.saveButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Zu({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderWidthInput,this.borderColorInput,this.widthInput,this.heightInput,this.backgroundInput,this.alignmentToolbar,this.cancelButtonView,this.saveButtonView,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()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},i=PE({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,s=this.t,o=s("Style"),r=new th(n);r.text=s("Border");const a=_E(s),l=new Yh(n,xm);l.set({label:o,class:"ck-table-form__border-style"}),l.fieldView.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),l.fieldView.buttonView.bind("label").to(this,"borderStyle",e=>a[e||"none"]),l.fieldView.on("execute",e=>{this.borderStyle=e.source._borderStyleValue}),l.bind("isEmpty").to(this,"borderStyle",e=>!e),vm(l.fieldView,TE(this,t.style),{role:"menu",ariaLabel:o});const c=new Yh(n,Tm);c.set({label:s("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",vx),c.fieldView.on("input",()=>{this.borderWidth=c.fieldView.element.value});const d=new Yh(n,i);return d.set({label:s("Color"),class:"ck-table-form__border-color"}),d.fieldView.bind("value").to(this,"borderColor"),d.bind("isEnabled").to(this,"borderStyle",vx),d.fieldView.on("input",()=>{this.borderColor=d.fieldView.value}),this.on("change:borderStyle",(e,i,n,s)=>{vx(n)||(this.borderColor="",this.borderWidth=""),vx(s)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:r,borderStyleDropdown:l,borderColorInput:d,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new th(e);i.text=t("Background");const n=PE({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),s=new Yh(e,n);return s.set({label:t("Color"),class:"ck-table-properties-form__background"}),s.fieldView.bind("value").to(this,"backgroundColor"),s.fieldView.on("input",()=>{this.backgroundColor=s.fieldView.value}),{backgroundRowLabel:i,backgroundInput:s}}_createDimensionFields(){const e=this.locale,t=this.t,i=new th(e);i.text=t("Dimensions");const n=new Yh(e,Tm);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",()=>{this.width=n.fieldView.element.value});const s=new Uu(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const o=new Yh(e,Tm);return o.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),o.fieldView.bind("value").to(this,"height"),o.fieldView.on("input",()=>{this.height=o.fieldView.element.value}),{dimensionsLabel:i,widthInput:n,operatorLabel:s,heightInput:o}}_createAlignmentFields(){const e=this.locale,t=this.t,i=new th(e);i.text=t("Table Alignment");const n=new hm(e);return n.set({role:"radiogroup",isCompact:!0,ariaLabel:t("Table alignment toolbar")}),EE({view:this,icons:{left:md,center:hd,right:gd,blockLeft:pd,blockRight:bd},toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:i,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,i=new rh(e),n=new rh(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return i.set({label:t("Save"),class:"ck-button-action",type:"submit",withText:!0}),i.bind("isEnabled").toMany(s,"errorText",(...e)=>e.every(e=>!e)),n.set({label:t("Cancel"),withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:n}}_createBackButton(){const e=this.locale.t,t=new rh(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:_d,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}get _alignmentLabels(){const e=this.locale,t=this.t,i=t("Align table to the left with no text wrapping"),n=t("Align table to the right with no text wrapping"),s=t("Align table to the left with text wrapping"),o=t("Center table with no text wrapping"),r=t("Align table to the right with text wrapping");return"rtl"===e.uiLanguageDirection?{right:r,left:s,blockRight:n,center:o,blockLeft:i}:{blockLeft:i,center:o,blockRight:n,left:s,right:r}}}function vx(e){return"none"!==e}const yx={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class kx extends Cc{_defaultContentTableProperties;_defaultLayoutTableProperties;_balloon;view=null;_viewWithContentTableDefaults=null;_viewWithLayoutTableDefaults=null;_undoStepBatch;_isReady;static get requires(){return[vg]}static get pluginName(){return"TablePropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:xE,backgroundColors:xE})}init(){const e=this.editor;this._defaultContentTableProperties=gT(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._defaultLayoutTableProperties=mT(),this._balloon=e.plugins.get(vg),e.ui.componentFactory.add("tableProperties",()=>this._createTablePropertiesButton())}_createTablePropertiesButton(){const e=this.editor,t=e.t,i=new rh(e.locale);i.set({label:t("Table properties"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M8 2v5h4V2h1v5h5v1h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5H7v-5H2v-1h5V8H2V7h5V2zm4 6H8v4h4z" opacity=".6"/><path d="m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43zM17 1a2 2 0 0 1 2 2v9.475l-.85-.124-.857-1.736a2 2 0 0 0-.292-.44L17 3H3v14h7.808l.402.392L10.935 19H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2z"/></svg>',tooltip:!0}),this.listenTo(i,"execute",()=>this._showView());const n=Object.values(yx).map(t=>e.commands.get(t));return i.bind("isEnabled").toMany(n,"isEnabled",(...e)=>e.some(e=>e)),i}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,i=t.config.get("table.tableProperties"),n=jh(i.borderColors),s=Wh(t.locale,n),o=jh(i.backgroundColors),r=Wh(t.locale,o),a=!1!==i.colorPicker,l=new _x(t.locale,{borderColors:s,backgroundColors:r,defaultTableProperties:e,colorPickerConfig:!!a&&(i.colorPicker||{})}),c=t.t;l.render(),this.listenTo(l,"submit",()=>{this._hideView()}),this.listenTo(l,"cancel",()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()}),l.keystrokes.set("Esc",(e,t)=>{this._hideView(),t()}),Yu({emitter:l,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const d=vE(c),u=yE(c);return l.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),l.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:l.borderColorInput,commandName:"tableBorderColor",errorText:d,validator:kE})),l.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:l.borderWidthInput,commandName:"tableBorderWidth",errorText:u,validator:AE})),l.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:l.backgroundInput,commandName:"tableBackgroundColor",errorText:d,validator:kE})),l.on("change:width",this._getValidatedPropertyChangeCallback({viewField:l.widthInput,commandName:"tableWidth",errorText:u,validator:CE})),l.on("change:height",this._getValidatedPropertyChangeCallback({viewField:l.heightInput,commandName:"tableHeight",errorText:u,validator:CE})),l.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),l}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(yx).map(([t,i])=>{const n=t,s=this.view===this._viewWithContentTableDefaults?this._defaultContentTableProperties[n]||"":this._defaultLayoutTableProperties[n]||"";return[n,e.get(i).value||s]}).forEach(([e,i])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,i)}),this._isReady=!0}_showView(){const e=this.editor,t=hE(e.editing.view.document.selection),i=t&&e.editing.mapper.toModelElement(t),n=!i||"layout"!==i.getAttribute("tableType");n&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableProperties):n||this._viewWithLayoutTableDefaults||(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableProperties)),this.view=n?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:BE(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;hE(e.editing.view.document.selection)?this._isViewVisible&&VE(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,i,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:i,validator:n,errorText:s}=e,o=Ci(()=>{i.errorText=s},500);return(e,s,r)=>{o.cancel(),this._isReady&&(n(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),i.errorText=null):o())}}}function Cx(e){e.document.registerPostFixer(t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;for(const t of i){if("insert"!=t.type)continue;const i=t.position.parent;if(i.is("element","table")||"table"==t.name){const s="table"==t.name?t.position.nodeAfter:i,o=Array.from(s.getChildren()).filter(e=>e.is("element","caption")),r=o.shift();if(!r)continue;for(const t of o)e.move(e.createRangeIn(t),r,"end"),e.remove(t);r.nextSibling&&(e.move(e.createRangeOn(r),s,"end"),n=!0),n=!!o.length||n}}return n}(t,e))}function Ax(e){return!!e&&e.is("element","table")}function Tx(e){for(const t of e.getChildren())if(t.is("element","caption"))return t;return null}function Ex(e){const t=e.parent;return"figcaption"==e.name&&t&&t.is("element","figure")&&t.hasClass("table")||"caption"==e.name&&t&&t.is("element","table")?{name:!0}:null}class xx extends Tc{refresh(){const e=this.editor,t=IA(e.model.document.selection);this.isEnabled=!!t&&e.model.schema.checkChild(t,"caption"),this.isEnabled?this.value=!!Tx(t):this.value=!1}execute({focusCaptionOnShow:e=!1}={}){this.editor.model.change(t=>{this.value?this._hideTableCaption(t):this._showTableCaption(t,e)})}_showTableCaption(e,t){const i=this.editor.model,n=IA(i.document.selection),s=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(n)||e.createElement("caption");i.insertContent(s,n,"end"),t&&e.setSelection(s,"in")}_hideTableCaption(e){const t=this.editor.model,i=IA(t.document.selection),n=this.editor.plugins.get("TableCaptionEditing"),s=Tx(i);n._saveCaption(i,s),t.deleteContent(e.createSelection(s,"on"))}}class Px extends Cc{_savedCaptionsMap=new WeakMap;_captionIdsMapping=new WeakMap;static get pluginName(){return"TableCaptionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.editing.view,n=e.t,s=e.config.get("table.tableCaption.useCaptionElement");if(t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new xx(this.editor)),s){e.plugins.get("TableEditing").registerAdditionalSlot({filter:e=>e.is("element","caption"),positionOffset:"end"})}e.conversion.for("upcast").elementToElement({view:Ex,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>Ax(e.parent)?t.createContainerElement(s?"caption":"figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if(!Ax(e.parent))return null;const o=t.createEditableElement(s?"caption":"figcaption");return t.setCustomProperty("tableCaption",!0,o),o.placeholder=n("Enter table caption"),sn({view:i,element:o,keepOnFocus:!0}),yp(o,t)}}),e.conversion.for("editingDowncast").add(e=>{e.on("insert:table",(e,t,{writer:i,mapper:n})=>{const s=t.item,o=n.toViewElement(s);if(!o)return;const r=Array.from(o.getChildren()).find(e=>e.is("element","table"));if(!r)return;const a=Tx(s);if(!a)return void i.removeAttribute("aria-labelledby",r);const l=n.toViewElement(a);if(!l)return;let c;c=l.hasAttribute("id")?l.getAttribute("id"):this._captionIdsMapping.get(a)??`ck-editor__caption_${he()}`,this._captionIdsMapping.set(a,c),i.setAttribute("id",c,l),i.setAttribute("aria-labelledby",c,r)},{priority:"low"})}),Cx(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?$o.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}}class Sx extends Cc{static get pluginName(){return"TableCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=e.t;e.ui.componentFactory.add("toggleTableCaption",n=>{const s=e.commands.get("toggleTableCaption"),o=new rh(n);return o.set({icon:id,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(s,"value","isEnabled"),o.bind("label").to(s,"value",e=>i(e?"Toggle caption off":"Toggle caption on")),this.listenTo(o,"execute",()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),s.value){const i=function(e){const t=IA(e);return t?Tx(t):null}(e.model.document.selection),n=e.editing.mapper.toViewElement(i);if(!n)return;t.scrollToTheSelection(),t.change(e=>{e.addClass("table__caption_highlighted",n)})}e.editing.view.focus()}),o})}}const Ix="removeFormat";class Ox extends Cc{static get pluginName(){return"RemoveFormatUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add(Ix,()=>{const e=this._createButton(rh);return e.set({tooltip:!0}),e}),e.ui.componentFactory.add(`menuBar:${Ix}`,()=>this._createButton(Eh))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get(Ix),s=new e(t.locale),o=i.t;return s.set({label:o("Remove Format"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M8.69 14.915q.08.078.36.093a.366.366 0 0 1 .345.485l-.003.01a.74.74 0 0 1-.697.497h-2.67a.374.374 0 0 1-.353-.496l.013-.038a.68.68 0 0 1 .644-.458q.295-.018.386-.093a.3.3 0 0 0 .072-.11L9.592 4.5H6.269q-.538-.026-.75.09-.213.117-.442.563c-.192.29-.516.464-.864.464H4.17a.43.43 0 0 1-.407-.569L4.46 3h13.08l-.62 2.043a.81.81 0 0 1-.775.574h-.114a.486.486 0 0 1-.486-.486q.002-.426-.167-.54-.168-.114-.766-.091h-3.28l-2.68 10.257q-.009.111.038.158M3 17h8a.5.5 0 1 1 0 1H3a.5.5 0 1 1 0-1m11.299 1.17a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.06-1.06l1.415 1.414 1.414-1.415a.75.75 0 1 1 1.06 1.06l-1.413 1.415 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414z"/></svg>'}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute(Ix),t.editing.view.focus()}),s}}class Rx extends Tc{_customAttributesHandlers=[];refresh(){const e=this.editor.model;this.isEnabled=!!si(this._getFormattingItems(e.document.selection))}execute(){const e=this.editor.model;e.change(t=>{for(const i of this._getFormattingItems(e.document.selection))if(i.is("selection"))for(const e of this._getFormattingAttributes(i))t.removeSelectionAttribute(e);else{const e=t.createRangeOn(i);for(const n of this._getFormattingAttributes(i))this._removeFormatting(n,i,e,t)}})}registerCustomAttribute(e,t){this._customAttributesHandlers.push({isFormatting:e,removeFormatting:t})}_removeFormatting(e,t,i,n){let s=!1;const o=Vx(e);for(const{isFormatting:r,removeFormatting:a}of this._customAttributesHandlers)r(o,t)&&(a(e,i,n),s=!0);s||n.removeAttribute(e,i)}*_getFormattingItems(e){const t=this.editor.model,i=t.schema,n=e=>!!si(this._getFormattingAttributes(e));for(const s of e.getRanges())for(const e of s.getItems())i.isBlock(e)&&s.end.isTouching(t.createPositionAt(e,0))||n(e)&&(yield e);for(const t of e.getSelectedBlocks())n(t)&&(yield t);n(e)&&(yield e)}*_getFormattingAttributes(e){const{schema:t}=this.editor.model;for(const[i]of e.getAttributes()){const n=Vx(i);for(const{isFormatting:t}of this._customAttributesHandlers)t(n,e)&&(yield i);const s=t.getAttributeProperties(n);s&&s.isFormatting&&(yield i)}}}function Vx(e){return e.replace(/^selection:/,"")}class Bx extends Cc{static get pluginName(){return"RemoveFormatEditing"}static get licenseFeatureCode(){return"RF"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){const e=this.editor;e.commands.add("removeFormat",new Rx(e))}}const Mx="SourceEditingMode";function Fx(e){return function(e){return e.startsWith("<")}(e)?gi(e):e}class Nx extends Fr{constructor(e,t,i){super(e),this._htmlDP=new Fr(e),this._initialValue=t,this._transformedInitialValue=i}setTransformedInitialValue(e){this._transformedInitialValue=e}toData(e){const t=this._htmlDP.toData(e);return t===this._transformedInitialValue?this._initialValue:t}}class Lx extends Cc{static get pluginName(){return"Disabler"}init(){const e=this.editor;e.ui.on("ready",()=>{Lx.processDisabling(e,t)});const t=e.sourceElement;$("#"+t.id).on("update",function(){Lx.processDisabling(e,t)})}static processDisabling(e,t){const i=$(e.ui.element);"function"==typeof i.block&&(t.disabled?i.block({message:"",blockMsgClass:"",enableValidation:!0,baseZ:9999,overlayCSS:{backgroundColor:"#ccd6e066"}}):i.unblock()),t.disabled?e.enableReadOnlyMode("ibo"):e.disableReadOnlyMode("ibo")}}class Dx extends Tc{execute(e){const t=this.editor.data.processor.toView(e),i=this.editor.data.toModel(t);this.editor.model.change(e=>{const t=this.editor.model.document.selection.getFirstPosition();null!==t&&this.editor.model.insertContent(i,t)})}}const zx=[{color:"#000000",label:"Black"},{color:"#4D4D4D",label:"Dim grey"},{color:"#999999",label:"Grey"},{color:"#E6E6E6",label:"Light grey"},{color:"#FFFFFF",label:"White"},{color:"#E64D4D",label:"Red"},{color:"#E6994D",label:"Orange"},{color:"#E6E64D",label:"Yellow"},{color:"#99E64D",label:"Light green"},{color:"#4DE64D",label:"Green"},{color:"#4DE699",label:"Aquamarine"},{color:"#4DE6E6",label:"Turquoise"},{color:"#4D99E6",label:"Light blue"},{color:"#4D4DE6",label:"Blue"},{color:"#994DE6",label:"Purple"}];class Hx extends Mg{}Hx.builtinPlugins=[class extends Cc{static get requires(){return[$g,jg]}static get pluginName(){return"Alignment"}static get isOfficialPlugin(){return!0}},aC,class extends Cc{static get requires(){return[ep,tp]}static get pluginName(){return"BlockQuote"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[Af,xf]}static get pluginName(){return"Bold"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[Sb,Rb]}static get pluginName(){return"CodeBlock"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[xh,gb,Uf,Lb,Jf,cf,qb]}static get pluginName(){return"Essentials"}static get isOfficialPlugin(){return!0}},Tw,yw,lw,pw,class extends Cc{static get pluginName(){return"GeneralHtmlSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[c_,f_,p_,b_,__,v_,y_,C_,T_,E_,S_,I_,O_]}init(){const e=this.editor,t=e.plugins.get(c_);t.loadAllowedEmptyElementsConfig(e.config.get("htmlSupport.allowEmpty")||[]),t.loadAllowedConfig(e.config.get("htmlSupport.allow")||[]),t.loadDisallowedConfig(e.config.get("htmlSupport.disallow")||[])}afterInit(){const e=this.editor.commands.get("removeFormat");e?.registerCustomAttribute(e=>e.startsWith("html")&&e.endsWith("Attributes"),Yw)}getGhsAttributeNameForElement(e){const t=this.editor.plugins.get("DataSchema"),i=Array.from(t.getDefinitionsForView(e,!1)),n=i.find(e=>e.isInline&&!i[0].isObject);return n?n.model:Qw(e)}addModelHtmlClass(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of R_(n,i,s))Jw(e,o,s,"classes",e=>{for(const i of ei(t))e.add(i)})})}removeModelHtmlClass(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of R_(n,i,s))Jw(e,o,s,"classes",e=>{for(const i of ei(t))e.delete(i)})})}setModelHtmlAttributes(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of R_(n,i,s))Jw(e,o,s,"attributes",e=>{for(const[i,n]of Object.entries(t))e.set(i,n)})})}removeModelHtmlAttributes(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of R_(n,i,s))Jw(e,o,s,"attributes",e=>{for(const i of ei(t))e.delete(i)})})}setModelHtmlStyles(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of R_(n,i,s))Jw(e,o,s,"styles",e=>{for(const[i,n]of Object.entries(t))e.set(i,n)})})}removeModelHtmlStyles(e,t,i){const n=this.editor.model,s=this.getGhsAttributeNameForElement(e);n.change(e=>{for(const o of R_(n,i,s))Jw(e,o,s,"styles",e=>{for(const i of ei(t))e.delete(i)})})}},class extends Cc{static get requires(){return[Vw,Mw]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[Nw,Lw]}static get pluginName(){return"Highlight"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[Hw,$w,Mp]}static get pluginName(){return"HorizontalLine"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[pv,wv]}static get pluginName(){return"Image"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[yv,kv]}static get pluginName(){return"ImageCaption"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[Lv,Uv,Yv,zv]}static get pluginName(){return"ImageResize"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[oy,ry]}static get pluginName(){return"ImageStyle"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[Np,Y_]}static get pluginName(){return"ImageToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,n=e.plugins.get(Np),s=e.plugins.get("ImageUtils");var o;n.register("image",{ariaLabel:t("Image toolbar"),items:(o=e.config.get("image.toolbar")||[],o.map(e=>i(e)?e.name:e)),getRelatedElement:e=>s.getClosestSelectedImageWidget(e)})}},Fv,class extends Cc{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[bk,wk]}},class extends Cc{constructor(e){super(e),e.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}static get isOfficialPlugin(){return!0}static get requires(){return[Ek]}init(){const e=this.editor,t=e.config.get("indentBlock");t.classes&&t.classes.length?(this._setupConversionUsingClasses(t.classes),e.commands.add("indentBlock",new _k(e,new yk({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlock",new _k(e,new yk({direction:"backward",classes:t.classes})))):(e.data.addStyleProcessorRules(lc),this._setupConversionUsingOffset(),e.commands.add("indentBlock",new _k(e,new vk({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlock",new _k(e,new vk({direction:"backward",offset:t.offset,unit:t.unit}))))}afterInit(){const e=this.editor,t=e.model.schema,i=e.commands.get("indent"),n=e.commands.get("outdent"),s=e.config.get("heading.options");(s&&s.map(e=>e.model)||Sk).forEach(e=>{t.isRegistered(e)&&t.extend(e,{allowAttributes:"blockIndent"})}),t.setAttributeProperties("blockIndent",{isFormatting:!0}),i.registerChildCommand(e.commands.get("indentBlock")),n.registerChildCommand(e.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const e=this.editor.conversion,t="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";e.for("upcast").attributeToAttribute({view:{styles:{[t]:/[\s\S]+/}},model:{key:"blockIndent",value:e=>{if(!e.is("element","li"))return e.getStyle(t)}}}),e.for("downcast").attributeToAttribute({model:"blockIndent",view:e=>({key:"style",value:{[t]:e}})})}_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)}},class extends Cc{static get requires(){return[Sf,Of]}static get pluginName(){return"Italic"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[Qk,sC,aC]}static get pluginName(){return"Link"}static get isOfficialPlugin(){return!0}},class extends Cc{static get requires(){return[lk,hk]}static get pluginName(){return"List"}static get isOfficialPlugin(){return!0}},class extends Cc{toMentionAttribute(e,t){return mC(e,t)}static get pluginName(){return"Mention"}static get isOfficialPlugin(){return!0}static get requires(){return[uC,CC]}},Sw,class extends Cc{static get pluginName(){return"PasteFromOffice"}static get licenseFeatureCode(){return"PFO"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[Zp]}init(){const e=this.editor,t=e.plugins.get("ClipboardPipeline"),i=e.editing.view.document,n=[],s=this.editor.plugins.has("MultiLevelListEditing"),o=this.editor.plugins.has("TablePropertiesEditing");n.push(new XC(i,s,o)),n.push(new sA(i)),n.push(new rA(i)),t.on("inputTransformation",(t,s)=>{if(s._isTransformedWithPasteFromOffice)return;if(e.model.document.selection.getFirstPosition().parent.is("element","codeBlock"))return;const o=s.dataTransfer.getData("text/html"),r=n.find(e=>e.isActive(o));r&&(s._parsedData||(s._parsedData=lA(o,i.stylesProcessor)),r.execute(s),s._isTransformedWithPasteFromOffice=!0)},{priority:"high"})}},class extends Cc{static get requires(){return[Vf,Mf]}static get pluginName(){return"Strikethrough"}static get isOfficialPlugin(){return!0}},uE,class extends Cc{static get pluginName(){return"TableCaption"}static get isOfficialPlugin(){return!0}static get requires(){return[Px,Sx]}},class extends Cc{static get pluginName(){return"TableCellProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[tx,LE]}},rx,class extends Cc{static get pluginName(){return"TableProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[fx,kx]}},class extends Cc{static get requires(){return[Np]}static get pluginName(){return"TableToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(Np),n=e.config.get("table.contentToolbar"),s=e.config.get("table.tableToolbar");n&&i.register("tableContent",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:gE}),s&&i.register("table",{ariaLabel:t("Table toolbar"),items:s,getRelatedElement:mE})}},class extends Cc{static get requires(){return[Nf,Df]}static get pluginName(){return"Underline"}static get isOfficialPlugin(){return!0}},qb,class extends Cc{static get requires(){return[Bx,Ox]}static get pluginName(){return"RemoveFormat"}static get isOfficialPlugin(){return!0}},class extends Cc{static get pluginName(){return"SourceEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Gc]}_elementReplacer;_replacedRoots;_dataFromRoots;constructor(e){super(e),this.set("isSourceEditingMode",!1),this._elementReplacer=new je,this._replacedRoots=new Map,this._dataFromRoots=new Map,e.config.define("sourceEditing.allowCollaborationFeatures",!1)}init(){this._checkCompatibility();const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("sourceEditing",()=>{const e=this._createButton(rh);return e.set({label:t("Source"),icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="m12.5 0 5 4.5v15.003h-16V0zM3 1.5v3.25l-1.497 1-.003 8 1.5 1v3.254L7.685 18l-.001 1.504H17.5V8.002L16 9.428l-.004-4.22-4.222-3.692z"/><path d="M4.06 6.64a.75.75 0 0 1 .958 1.15l-.085.07L2.29 9.75l2.646 1.89c.302.216.4.62.232.951l-.058.095a.75.75 0 0 1-.951.232l-.095-.058-3.5-2.5V9.14zm4.194 6.22a.75.75 0 0 1-.958-1.149l.085-.07 2.643-1.89-2.646-1.89a.75.75 0 0 1-.232-.952l.058-.095a.75.75 0 0 1 .95-.232l.096.058 3.5 2.5v1.22zm7.644-.836 2.122 2.122-5.825 5.809-2.125-.005.003-2.116zm2.539-1.847 1.414 1.414a.5.5 0 0 1 0 .707l-1.06 1.06-2.122-2.12 1.061-1.061a.5.5 0 0 1 .707 0"/></svg>',tooltip:!0,class:"ck-source-editing-button"}),e}),e.ui.componentFactory.add("menuBar:sourceEditing",()=>{const e=this._createButton(Eh);return e.set({label:t("Show source"),role:"menuitemcheckbox"}),e}),this._isAllowedToHandleSourceEditingMode()&&(this.on("change:isSourceEditingMode",(e,t,i)=>{i?(this._hideVisibleDialog(),this._showSourceEditing(),this._disableCommands()):(this._hideSourceEditing(),this._enableCommands())}),this.on("change:isEnabled",(e,t,i)=>this._handleReadOnlyMode(!i)),this.listenTo(e,"change:isReadOnly",(e,t,i)=>this._handleReadOnlyMode(i))),e.data.on("get",()=>{this.isSourceEditingMode&&this.updateEditorData()},{priority:"high"})}updateEditorData(){const e=this.editor,t={};for(const[e,i]of this._replacedRoots){const n=this._dataFromRoots.get(e),s=i.dataset.value;n!==s&&(t[e]=s,this._dataFromRoots.set(e,s))}Object.keys(t).length&&e.data.set(t,{batchType:{isUndoable:!0},suppressErrorInCollaboration:!0})}_checkCompatibility(){const e=this.editor,t=e.config.get("sourceEditing.allowCollaborationFeatures");if(!t&&e.plugins.has("RealTimeCollaborativeEditing"))throw new fe("source-editing-incompatible-with-real-time-collaboration",null);!t&&["CommentsEditing","TrackChangesEditing","RevisionHistory"].some(t=>e.plugins.has(t))&&console.warn("You initialized the editor with the source editing feature and at least one of the collaboration features. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the collaboration features."),e.plugins.has("RestrictedEditingModeEditing")&&console.warn("You initialized the editor with the source editing feature and restricted editing feature. Please be advised that the source editing feature may not work, and be careful when editing document source that contains markers created by the restricted editing feature.")}_showSourceEditing(){const e=this.editor,t=e.editing.view,i=e.model;i.change(e=>{e.setSelection(null),e.removeSelectionAttribute(i.document.selection.getAttributeKeys())});for(const[i,n]of t.domRoots){const s=Fx(e.data.get({rootName:i})),o=Ge(n.ownerDocument,"textarea",{rows:"1","aria-label":"Source code editing area"}),r=Ge(n.ownerDocument,"div",{class:"ck-source-editing-area","data-value":s},[o]);o.value=s,o.setSelectionRange(0,0),o.addEventListener("input",()=>{r.dataset.value=o.value,e.ui.update()}),t.change(e=>{const n=t.document.getRoot(i);e.addClass("ck-hidden",n)}),e.ui.setEditableElement("sourceEditing:"+i,o),this._replacedRoots.set(i,r),this._elementReplacer.replace(n,r),this._dataFromRoots.set(i,s)}this._hideDocumentOutline(),this._refreshAnnotationsVisibility(),this._focusSourceEditing()}_hideSourceEditing(){const e=this.editor.editing.view;this.updateEditorData(),e.change(t=>{for(const[i]of this._replacedRoots)t.removeClass("ck-hidden",e.document.getRoot(i))}),this._elementReplacer.restore(),this._replacedRoots.clear(),this._dataFromRoots.clear(),this._showDocumentOutline(),this._refreshAnnotationsVisibility(),e.focus()}_hideDocumentOutline(){this.editor.plugins.has("DocumentOutlineUI")&&(this.editor.plugins.get("DocumentOutlineUI").view.element.style.display="none")}_showDocumentOutline(){this.editor.plugins.has("DocumentOutlineUI")&&(this.editor.plugins.get("DocumentOutlineUI").view.element.style.display="")}_refreshAnnotationsVisibility(){this.editor.plugins.has("Annotations")&&this.editor.plugins.get("Annotations").refreshVisibility()}_focusSourceEditing(){const e=this.editor,[t]=this._replacedRoots.values(),i=t.querySelector("textarea");e.editing.view.document.isFocused=!1,i.focus()}_disableCommands(){const e=this.editor;for(const t of e.commands.commands())t.forceDisabled(Mx);e.plugins.has("CommentsArchiveUI")&&e.plugins.get("CommentsArchiveUI").forceDisabled(Mx)}_enableCommands(){const e=this.editor;for(const t of e.commands.commands())t.clearForceDisabled(Mx);e.plugins.has("CommentsArchiveUI")&&e.plugins.get("CommentsArchiveUI").clearForceDisabled(Mx)}_handleReadOnlyMode(e){if(this.isSourceEditingMode)for(const[,t]of this._replacedRoots)t.querySelector("textarea").readOnly=e}_isAllowedToHandleSourceEditingMode(){const e=this.editor.ui.view.editable;return e&&!e.hasExternalElement}_hideVisibleDialog(){if(this.editor.plugins.has("Dialog")){const e=this.editor.plugins.get("Dialog");e.isOpen&&e.hide()}}_createButton(e){const t=this.editor,i=new e(t.locale);return i.set({withText:!0,isToggleable:!0}),i.bind("isOn").to(this,"isSourceEditingMode"),i.bind("isEnabled").to(this,"isEnabled",t,"isReadOnly",t.plugins.get(Gc),"hasAny",(e,t,i)=>!!e&&(!t&&!i)),this.listenTo(i,"execute",()=>{this.isSourceEditingMode=!this.isSourceEditingMode}),i}},class extends Cc{static get pluginName(){return"AppendITopClasses"}init(){const e=this.editor;e.editing.view.change(t=>{const i=e.editing.view.document.getRoot();if(null!==i){const e=document.body.getAttribute("data-gui-type");"backoffice"===e?t.addClass("ibo-is-html-content",i):"portal"===e&&t.addClass("ipb-is-html-content",i)}})}},class extends Cc{static get pluginName(){return"KeyboardShortcut"}init(){const e=this.editor;e.keystrokes.set("Ctrl+Enter",(t,i)=>{if(null!==e.ui.element){const t=e.ui.element.closest("form");if(null!==t){const e=new Event("submit");t.dispatchEvent(e)}}})}},class extends Cc{static get pluginName(){return"MentionsMarkup"}init(){const e=this.editor;e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0,"data-role":!0,"data-object-class":!0,"data-object-id":!0,"data-object-key":!0}},model:{key:"mention",value:t=>e.plugins.get("Mention").toMentionAttribute(t,{link:t.getAttribute("href"),id:t.getAttribute("data-object-id"),class_name:t.getAttribute("data-object-class"),key:t.getAttribute("data-object-key"),mention:"object-mention"})},converterPriority:"high"}),e.conversion.for("downcast").attributeToElement({model:"mention",view:(e,{writer:t,options:i})=>{if(e)return t.createAttributeElement("a",{"data-role":"object-mention","data-object-class":e.class_name,"data-object-id":e.id,"data-object-key":e.key,href:e.link,...!i.isClipboardPipeline&&{"data-mention-uid":e.uid}},{priority:20,id:e.uid})},converterPriority:"high"})}},class extends Cc{static get pluginName(){return"TriggerUpdateOnReady"}init(){const e=this.editor;e.ui.on("ready",()=>{if(null!==e.ui.element){const t=new Event("update");e.ui.element.dispatchEvent(t)}for(const e of document.getElementsByClassName("ck-body-wrapper"))e.classList.add("ck-reset_all-excluded")})}},class extends Cc{static get requires(){return[N_,D_]}static get pluginName(){return"Fullscreen"}static get isOfficialPlugin(){return!0}},class extends Cc{static get pluginName(){return"InsertHtmlContent"}init(){const e=this.editor;e.commands.add("insert-html",new Dx(e))}},class extends Cc{constructor(e){super(e);const t=e.config.get("detectChanges.initialValue");if(!t||""===t)return;const i=new Nx(e.data.viewDocument,t,e.getData());e.data.processor=i,this._processor=i}init(){const e=this.editor;e.model.document.once("change:data",()=>{this._processor&&this._processor.setTransformedInitialValue(e.getData())})}static get pluginName(){return"DetectChanges"}},class extends Cc{static get pluginName(){return"UpdateInputOnChange"}init(){const e=this.editor;if(void 0!==e.sourceElement){const t=e.sourceElement;e.model.document.on("change:data",i=>{this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.debounceTimeout=window.setTimeout(()=>{t.value!==e.getData()&&(t.value=e.getData())},2e3)})}}},Lx,class extends Cc{init(){const e=this.editor,t=["codeBlock","div","pre"];e.model.document.on("change:data",(i,n)=>{if(n.isLocal){const i=e.model.document.selection.getFirstPosition(),n=e.model.document.differ.getChanges().pop();if(void 0!==n&&"insert"===n.type&&null!==n.position.nodeAfter&&(s=n.position.nodeAfter,t.some(e=>s.is("element",e)))){let t=!1;if(t=null===n.position.nodeAfter.nextSibling||(e=>e.is("element","codeBlock"))(n.position.nodeAfter.nextSibling),t){const t=e.model.createPositionAfter(n.position.nodeAfter);e.model.change(i=>{e.execute("insertParagraph",{position:t})}),e.model.change(e=>{e.setSelection(i)})}}}var s})}}],Hx.defaultConfig={toolbar:{items:["fullscreen","|","undo","redo","|","heading","|","alignment","|",{label:"Fonts",icon:"text",items:["fontfamily","fontSize","fontColor"]},"|","bold","italic","underline","highlight","strikethrough","RemoveFormat","|","horizontalLine","link","imageUpload","codeBlock","insertTable",{label:"Lists",items:["bulletedList","numberedList","outdent","indent"]},"|","SourceEditing"],shouldNotGroupWhenFull:!0},language:"en",fontColor:{colors:zx},indentBlock:{offset:1,unit:"em"},image:{toolbar:["resizeImage:25","resizeImage:50","resizeImage:original","|","toggleImageCaption"],resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"}]},table:{contentToolbar:["tableColumn","tableRow","mergeTableCells","|","tableCellProperties","tableProperties","|","toggleTableCaption"],tableCellProperties:{borderColors:zx,backgroundColors:zx}},htmlSupport:{allow:[{name:/.*/,attributes:!0,classes:!0,styles:!0}]},link:{defaultProtocol:"http://"},highlight:{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"#FDFD77",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"#62f962",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"#FC7899",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"#72CCFD",type:"marker"}]},codeBlock:{languages:[{language:"plaintext",label:"Plain text"},{language:"abap",label:"ABAP"},{language:"apache",label:"Apache"},{language:"bash",label:"Bash"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"ciscocli",label:"Cisco CLI"},{language:"coffeescript",label:"CoffeeScript"},{language:"curl",label:"cURL"},{language:"diff",label:"Diff"},{language:"dnszonefile",label:"DNS Zone File"},{language:"html",label:"HTML"},{language:"http",label:"HTTP"},{language:"ini",label:"Ini"},{language:"json",label:"JSON"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"makefile",label:"Makefile"},{language:"markdown",label:"Markdown"},{language:"nginx",label:"Nginx"},{language:"objectivec",label:"Objective C"},{language:"php",label:"PHP"},{language:"perl",label:"Perl"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"rust",label:"Rust"},{language:"scss",label:"SCSS"},{language:"sql",label:"SQL"},{language:"toml",label:"TOML"},{language:"twig",label:"TWIG"},{language:"typescript",label:"TypeScript"},{language:"vba",label:"VBA"},{language:"vbscript",label:"VBScript"},{language:"xml",label:"XML"},{language:"yaml",label:"YAML"}]},fullscreen:{menuBar:{isVisible:!1}}};const $x=Hx;return t=t.default})()); |