Files

491 lines
1.3 MiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var W0=Object.defineProperty,j0=(n,e,t)=>e in n?W0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,h=(n,e,t)=>j0(n,typeof e!="symbol"?e+"":e,t);function U0(n,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const o in i)if(o!=="default"&&!(o in n)){const s=Object.getOwnPropertyDescriptor(i,o);s&&Object.defineProperty(n,o,s.get?s:{enumerable:!0,get:()=>i[o]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}function q0(n,e){const t={};for(let i=0;i<n.length;i++){const o=n[i],s=e(o);Object.hasOwn(t,s)||(t[s]=[]),t[s].push(o)}return t}function qn(n){return n}function kr(){}function Vc(n){return n==null||typeof n!="object"&&typeof n!="function"}function Rc(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function Oc(n){if(Vc(n))return n;if(Array.isArray(n)||Rc(n)||n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer)return n.slice(0);const e=Object.getPrototypeOf(n),t=e.constructor;if(n instanceof Date||n instanceof Map||n instanceof Set)return new t(n);if(n instanceof RegExp){const i=new t(n);return i.lastIndex=n.lastIndex,i}if(n instanceof DataView)return new t(n.buffer.slice(0));if(n instanceof Error){const i=new t(n.message);return i.stack=n.stack,i.name=n.name,i.cause=n.cause,i}if(typeof File<"u"&&n instanceof File)return new t([n],n.name,{type:n.type,lastModified:n.lastModified});if(typeof n=="object"){const i=Object.create(e);return Object.assign(i,n)}return n}function Qu(n){if(!n||typeof n!="object")return!1;const e=Object.getPrototypeOf(n);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(n)==="[object Object]":!1}function Il(n){return typeof n=="object"&&n!==null}function Cr(n){return Object.getOwnPropertySymbols(n).filter(e=>Object.prototype.propertyIsEnumerable.call(n,e))}function Ar(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const cg="[object RegExp]",Bc="[object String]",Mc="[object Number]",Lc="[object Boolean]",xr="[object Arguments]",ug="[object Symbol]",hg="[object Date]",dg="[object Map]",mg="[object Set]",fg="[object Array]",G0="[object Function]",gg="[object ArrayBuffer]",cr="[object Object]",K0="[object Error]",pg="[object DataView]",wg="[object Uint8Array]",bg="[object Uint8ClampedArray]",_g="[object Uint16Array]",vg="[object Uint32Array]",Z0="[object BigUint64Array]",yg="[object Int8Array]",kg="[object Int16Array]",Cg="[object Int32Array]",J0="[object BigInt64Array]",Ag="[object Float32Array]",xg="[object Float64Array]";function Q0(n,e){return eo(n,void 0,n,new Map,e)}function eo(n,e,t,i=new Map,o=void 0){const s=o?.(n,e,t,i);if(s!=null)return s;if(Vc(n))return n;if(i.has(n))return i.get(n);if(Array.isArray(n)){const r=new Array(n.length);i.set(n,r);for(let a=0;a<n.length;a++)r[a]=eo(n[a],a,t,i,o);return Object.hasOwn(n,"index")&&(r.index=n.index),Object.hasOwn(n,"input")&&(r.input=n.input),r}if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp){const r=new RegExp(n.source,n.flags);return r.lastIndex=n.lastIndex,r}if(n instanceof Map){const r=new Map;i.set(n,r);for(const[a,l]of n)r.set(a,eo(l,a,t,i,o));return r}if(n instanceof Set){const r=new Set;i.set(n,r);for(const a of n)r.add(eo(a,void 0,t,i,o));return r}if(typeof Buffer<"u"&&Buffer.isBuffer(n))return n.subarray();if(Rc(n)){const r=new(Object.getPrototypeOf(n)).constructor(n.length);i.set(n,r);for(let a=0;a<n.length;a++)r[a]=eo(n[a],a,t,i,o);return r}if(n instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&n instanceof SharedArrayBuffer)return n.slice(0);if(n instanceof DataView){const r=new DataView(n.buffer.slice(0),n.byteOffset,n.byteLength);return i.set(n,r),gn(r,n,t,i,o),r}if(typeof File<"u"&&n instanceof File){const r=new File([n],n.name,{type:n.type});return i.set(n,r),gn(r,n,t,i,o),r}if(n instanceof Blob){const r=new Blob([n],{type:n.type});return i.set(n,r),gn(r,n,t,i,o),r}if(n instanceof Error){const r=new n.constructor;return i.set(n,r),r.message=n.message,r.name=n.name,r.stack=n.stack,r.cause=n.cause,gn(r,n,t,i,o),r}if(typeof n=="object"&&Y0(n)){const r=Object.create(Object.getPrototypeOf(n));return i.set(n,r),gn(r,n,t,i,o),r}return n}function gn(n,e,t=n,i,o){const s=[...Object.keys(e),...Cr(e)];for(let r=0;r<s.length;r++){const a=s[r],l=Object.getOwnPropertyDescriptor(n,a);(l==null||l.writable)&&(n[a]=eo(e[a],a,t,i,o))}}function Y0(n){switch(Ar(n)){case xr:case fg:case gg:case pg:case Lc:case hg:case Ag:case xg:case yg:case kg:case Cg:case dg:case Mc:case cr:case cg:case mg:case Bc:case ug:case wg:case bg:case _g:case vg:return!0;default:return!1}}function Tg(n,e){return n===e||Number.isNaN(n)&&Number.isNaN(e)}function Eg(n,e,t){return Wo(n,e,void 0,void 0,void 0,void 0,t)}function Wo(n,e,t,i,o,s,r){const a=r(n,e,t,i,o,s);if(a!==void 0)return a;if(typeof n==typeof e)switch(typeof n){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return n===e;case"number":return n===e||Object.is(n,e);case"function":return n===e;case"object":return Ko(n,e,s,r)}return Ko(n,e,s,r)}function Ko(n,e,t,i){if(Object.is(n,e))return!0;let o=Ar(n),s=Ar(e);if(o===xr&&(o=cr),s===xr&&(s=cr),o!==s)return!1;switch(o){case Bc:return n.toString()===e.toString();case Mc:{const l=n.valueOf(),c=e.valueOf();return Tg(l,c)}case Lc:case hg:case ug:return Object.is(n.valueOf(),e.valueOf());case cg:return n.source===e.source&&n.flags===e.flags;case G0:return n===e}t=t??new Map;const r=t.get(n),a=t.get(e);if(r!=null&&a!=null)return r===e;t.set(n,e),t.set(e,n);try{switch(o){case dg:{if(n.size!==e.size)return!1;for(const[l,c]of n.entries())if(!e.has(l)||!Wo(c,e.get(l),l,n,e,t,i))return!1;return!0}case mg:{if(n.size!==e.size)return!1;const l=Array.from(n.values()),c=Array.from(e.values());for(let u=0;u<l.length;u++){const d=l[u],m=c.findIndex(f=>Wo(d,f,void 0,n,e,t,i));if(m===-1)return!1;c.splice(m,1)}return!0}case fg:case wg:case bg:case _g:case vg:case Z0:case yg:case kg:case Cg:case J0:case Ag:case xg:{if(typeof Buffer<"u"&&Buffer.isBuffer(n)!==Buffer.isBuffer(e)||n.length!==e.length)return!1;for(let l=0;l<n.length;l++)if(!Wo(n[l],e[l],l,n,e,t,i))return!1;return!0}case gg:return n.byteLength!==e.byteLength?!1:Ko(new Uint8Array(n),new Uint8Array(e),t,i);case pg:return n.byteLength!==e.byteLength||n.byteOffset!==e.byteOffset?!1:Ko(new Uint8Array(n),new Uint8Array(e),t,i);case K0:return n.name===e.name&&n.message===e.message;case cr:{if(!(Ko(n.constructor,e.constructor,t,i)||Qu(n)&&Qu(e)))return!1;const l=[...Object.keys(n),...Cr(n)],c=[...Object.keys(e),...Cr(e)];if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++){const d=l[u],m=n[d];if(!Object.hasOwn(e,d))return!1;const f=e[d];if(!Wo(m,f,d,n,e,t,i))return!1}return!0}default:return!1}}finally{t.delete(n),t.delete(e)}}function lo(n,e){return Eg(n,e,kr)}function Tr(n){return typeof n=="function"}function X0(n){return Number.isSafeInteger(n)&&n>=0}const e_=new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+","gu");function t_(n){return Array.from(n.match(e_)??[])}function i_(n){return n!=null&&typeof n!="function"&&X0(n.length)}function Sg(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}function Pg(n){return Object.is(n,-0)?"-0":n.toString()}function Fc(n){const e=[],t=n.length;if(t===0)return e;let i=0,o="",s="",r=!1;for(n.charCodeAt(0)===46&&(e.push(""),i++);i<t;){const a=n[i];s?a==="\\"&&i+1<t?(i++,o+=n[i]):a===s?s="":o+=a:r?a==='"'||a==="'"?s=a:a==="]"?(r=!1,e.push(o),o=""):o+=a:a==="["?(r=!0,o&&(e.push(o),o="")):a==="."?o&&(e.push(o),o=""):o+=a,i++}return o&&e.push(o),e}function Ki(n,e,t){if(n==null)return t;switch(typeof e){case"string":{const i=n[e];return i===void 0?Sg(e)?Ki(n,Fc(e),t):t:i}case"number":case"symbol":{typeof e=="number"&&(e=Pg(e));const i=n[e];return i===void 0?t:i}default:{if(Array.isArray(e))return n_(n,e,t);Object.is(e?.valueOf(),-0)?e="-0":e=String(e);const i=n[e];return i===void 0?t:i}}}function n_(n,e,t){if(e.length===0)return t;let i=n;for(let o=0;o<e.length;o++){if(i==null)return t;i=i[e[o]]}return i===void 0?t:i}function o_(n){return function(e){return Ki(e,n)}}function Et(n){return n!==null&&(typeof n=="object"||typeof n=="function")}function Xr(n,e){return Q0(n,(t,i,o,s)=>{const r=e?.(t,i,o,s);if(r!=null)return r;if(typeof n=="object")switch(Object.prototype.toString.call(n)){case Mc:case Bc:case Lc:{const a=new n.constructor(n?.valueOf());return gn(a,n),a}case xr:{const a={};return gn(a,n),a.length=n.length,a[Symbol.iterator]=n[Symbol.iterator],a}default:return}})}function mt(n){return Xr(n)}const s_=/^(?:0|[1-9]\d*)$/;function r_(n,e=Number.MAX_SAFE_INTEGER){switch(typeof n){case"number":return Number.isInteger(n)&&n>=0&&n<e;case"symbol":return!1;case"string":return s_.test(n)}}function Yu(n){return n!==null&&typeof n=="object"&&Ar(n)==="[object Arguments]"}function a_(n){return typeof n=="symbol"||n instanceof Symbol}function l_(n){return a_(n)?NaN:Number(n)}function c_(n){return n?(n=l_(n),n===1/0||n===-1/0?(n<0?-1:1)*Number.MAX_VALUE:n===n?n:0):n===0?n:0}function u_(n){const e=c_(n),t=e%1;return t?e-t:e}function Xu(n){return typeof n=="string"||n instanceof String}function Ig(n,e,t){const i=Array.isArray(e)?e:typeof e=="string"?Fc(e):[e];let o=n;for(let r=0;r<i.length-1;r++){const a=i[r],l=i[r+1];o[a]==null&&(o[a]=r_(l)?[]:{}),o=o[a]}const s=i[i.length-1];return o[s]=t,n}function h_(n,e,{signal:t,edges:i}={}){let o,s=null;const r=i!=null&&i.includes("leading"),a=i==null||i.includes("trailing"),l=()=>{s!==null&&(n.apply(o,s),o=void 0,s=null)},c=()=>{a&&l(),f()};let u=null;const d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,c()},e)},m=()=>{u!==null&&(clearTimeout(u),u=null)},f=()=>{m(),o=void 0,s=null},g=()=>{m(),l()},p=function(..._){if(t!=null&&t.aborted)return;o=this,s=_;const v=u==null;d(),r&&v&&l()};return p.schedule=d,p.cancel=f,p.flush=g,t?.addEventListener("abort",f,{once:!0}),p}function St(n,e=0,t={}){typeof t!="object"&&(t={});const{signal:i,leading:o=!1,trailing:s=!0,maxWait:r}=t,a=Array(2);o&&(a[0]="leading"),s&&(a[1]="trailing");let l,c=null;const u=h_(function(...f){l=n.apply(this,f),c=null},e,{signal:i,edges:a}),d=function(...f){if(r!=null){if(c===null)c=Date.now();else if(Date.now()-c>=r)return l=n.apply(this,f),c=Date.now(),u.cancel(),u.schedule(),l}return u.apply(this,f),l},m=()=>(u.flush(),l);return d.cancel=u.cancel,d.flush=m,d}function co(n,e=0,t={}){typeof t!="object"&&(t={});const{leading:i=!0,trailing:o=!0,signal:s}=t;return St(n,e,{leading:i,trailing:o,signal:s,maxWait:e})}function ea(n){if(n==null)return"";if(Array.isArray(n))return n.map(ea).join(",");const e=String(n);return e==="0"&&Object.is(Number(n),-0)?"-0":e}function d_(n){return typeof Buffer<"u"&&Buffer.isBuffer(n)}function m_(n){const e=n?.constructor,t=typeof e=="function"?e.prototype:Object.prototype;return n===t}function Vg(n){return Rc(n)}function f_(n,e){if(n=u_(n),n<1||!Number.isSafeInteger(n))return[];const t=new Array(n);for(let i=0;i<n;i++)t[i]=typeof e=="function"?e(i):i;return t}function g_(n){if(n==null)return[];switch(typeof n){case"object":case"function":return i_(n)?w_(n):m_(n)?p_(n):Er(n);default:return Er(Object(n))}}function Er(n){const e=[];for(const t in n)e.push(t);return e}function p_(n){return Er(n).filter(e=>e!=="constructor")}function w_(n){const e=f_(n.length,i=>`${i}`),t=new Set(e);return d_(n)&&(t.add("offset"),t.add("parent")),Vg(n)&&(t.add("buffer"),t.add("byteLength"),t.add("byteOffset")),[...e,...Er(n).filter(i=>!t.has(i))]}function Rg(n,...e){for(let t=0;t<e.length;t++)b_(n,e[t]);return n}function b_(n,e){const t=g_(e);for(let i=0;i<t.length;i++){const o=t[i];Tg(n[o],e[o])||(n[o]=e[o])}}function eh(n,e){const t={},i=Object.keys(n);for(let o=0;o<i.length;o++){const s=i[o],r=n[s];t[s]=e(r,s,n)}return t}function __(n,e){switch(e=e??qn,typeof e){case"string":case"symbol":case"number":case"object":return eh(n,o_(e));case"function":return eh(n,e)}}function Ut(n){var e;if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!((e=Object.getOwnPropertyDescriptor(n,Symbol.toStringTag))!=null&&e.writable)?!1:n.toString()===`[object ${i}]`}let t=n;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function Og(n,...e){const t=e.slice(0,-1),i=e[e.length-1];let o=n;for(let s=0;s<t.length;s++){const r=t[s];o=Vl(o,r,i,new Map)}return o}function Vl(n,e,t,i){if(Vc(n)&&(n=Object(n)),e==null||typeof e!="object")return n;if(i.has(e))return Oc(i.get(e));if(i.set(e,n),Array.isArray(e)){e=e.slice();for(let s=0;s<e.length;s++)e[s]=e[s]??void 0}const o=[...Object.keys(e),...Cr(e)];for(let s=0;s<o.length;s++){const r=o[s];let a=e[r],l=n[r];if(Yu(a)&&(a={...a}),Yu(l)&&(l={...l}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=mt(a)),Array.isArray(a))if(typeof l=="object"&&l!=null){const u=[],d=Reflect.ownKeys(l);for(let m=0;m<d.length;m++){const f=d[m];u[f]=l[f]}l=u}else l=[];const c=t(l,a,r,n,e,i);c!=null?n[r]=c:Array.isArray(a)||Il(l)&&Il(a)?n[r]=Vl(l,a,t,i):l==null&&Ut(a)?n[r]=Vl({},a,t,i):l==null&&Vg(a)?n[r]=mt(a):(l===void 0||a!==void 0)&&(n[r]=a)}return n}function Nc(n,...e){return Og(n,...e,kr)}function v_(n,e){if(n==null)return!0;switch(typeof e){case"symbol":case"number":case"object":{if(Array.isArray(e))return th(n,e);if(typeof e=="number"?e=Pg(e):typeof e=="object"&&(Object.is(e?.valueOf(),-0)?e="-0":e=String(e)),n?.[e]===void 0)return!0;try{return delete n[e],!0}catch{return!1}}case"string":{if(n?.[e]===void 0&&Sg(e))return th(n,Fc(e));try{return delete n[e],!0}catch{return!1}}}}function th(n,e){const t=Ki(n,e.slice(0,-1),n),i=e[e.length-1];if(t?.[i]===void 0)return!0;try{return delete t[i],!0}catch{return!1}}function xi(n){return Il(n)&&n.nodeType===1&&!Ut(n)}function y_(n,e){if(!Number.isInteger(n)||n<0)throw new Error("n must be a non-negative integer.");let t=0;return(...i)=>{if(++t>=n)return e(...i)}}function Bg(n,e,t=kr){return typeof t!="function"&&(t=kr),Eg(n,e,(...i)=>{const o=t(...i);if(o!==void 0)return!!o;if(n instanceof Map&&e instanceof Map||n instanceof Set&&e instanceof Set)return Bg(Array.from(n),Array.from(e),y_(2,t))})}function k_(n){return typeof n!="string"&&(n=ea(n)),n.replace(/['\u2019]/g,"")}function C_(n){return n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}function ta(n){return C_(ea(n))}function A_(n){const e=t_(k_(n).trim());let t="";for(let i=0;i<e.length;i++){const o=e[i];t&&(t+=" "),o===o.toUpperCase()?t+=o:t+=o[0].toUpperCase()+o.slice(1).toLowerCase()}return t}function x_(n){return n.substring(0,1).toUpperCase()+n.substring(1)}function T_(n){return x_(ea(n))}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/let Rl;try{Rl={window,document}}catch{/* istanbul ignore next -- @preserve */Rl={window:{},document:{}}}var I=Rl;function E_(){try{return navigator.userAgent.toLowerCase()}catch{return""}}const sn=E_(),N={isMac:Mg(sn),isWindows:S_(sn),isGecko:P_(sn),isSafari:I_(sn),isiOS:V_(sn),isAndroid:R_(sn),isBlink:O_(sn),get isMediaForcedColors(){return B_()}};function Mg(n){return n.indexOf("macintosh")>-1}function S_(n){return n.indexOf("windows")>-1}function P_(n){return!!n.match(/gecko\/\d+/)}function I_(n){return n.indexOf(" applewebkit/")>-1&&n.indexOf("chrome")===-1}function V_(n){return!!n.match(/iphone|ipad/i)||Mg(n)&&navigator.maxTouchPoints>0}function R_(n){return n.indexOf("android")>-1}function O_(n){return n.indexOf("chrome/")>-1&&n.indexOf("edge/")<0}function B_(){return I.window.matchMedia?I.window.matchMedia("(forced-colors: active)").matches:!1}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Lg(n,e,t,i){t=t||function(a,l){return a===l};const o=Array.isArray(n)?n:Array.prototype.slice.call(n),s=Array.isArray(e)?e:Array.prototype.slice.call(e),r=M_(o,s,t);return i?F_(r,s.length):L_(s,r)}function M_(n,e,t){const i=ih(n,e,t);if(i===-1)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const o=nh(n,i),s=nh(e,i),r=ih(o,s,t),a=n.length-r,l=e.length-r;return{firstIndex:i,lastIndexOld:a,lastIndexNew:l}}function ih(n,e,t){for(let i=0;i<Math.max(n.length,e.length);i++)if(n[i]===void 0||e[i]===void 0||!t(n[i],e[i]))return i;return-1}function nh(n,e){return n.slice(e).reverse()}function L_(n,e){const t=[],{firstIndex:i,lastIndexOld:o,lastIndexNew:s}=e;return s-i>0&&t.push({index:i,type:"insert",values:n.slice(i,s)}),o-i>0&&t.push({index:i+(s-i),type:"delete",howMany:o-i}),t}function F_(n,e){const{firstIndex:t,lastIndexOld:i,lastIndexNew:o}=n;if(t===-1)return Array(e).fill("equal");let s=[];return t>0&&(s=s.concat(Array(t).fill("equal"))),o-t>0&&(s=s.concat(Array(o-t).fill("insert"))),i-t>0&&(s=s.concat(Array(i-t).fill("delete"))),o<e&&(s=s.concat(Array(e-o).fill("equal"))),s}function oo(n,e,t){t=t||function(p,_){return p===_};const i=n.length,o=e.length;if(i>200||o>200||i+o>300)return oo.fastDiff(n,e,t,!0);let s,r;if(o<i){const p=n;n=e,e=p,s="delete",r="insert"}else s="insert",r="delete";const a=n.length,l=e.length,c=l-a,u={},d={};function m(p){const _=(d[p-1]!==void 0?d[p-1]:-1)+1,v=d[p+1]!==void 0?d[p+1]:-1,E=_>v?-1:1;u[p+E]&&(u[p]=u[p+E].slice(0)),u[p]||(u[p]=[]),u[p].push(_>v?s:r);let M=Math.max(_,v),G=M-p;for(;G<a&&M<l&&t(n[G],e[M]);)G++,M++,u[p].push("equal");return M}let f=0,g;do{for(g=-f;g<c;g++)d[g]=m(g);for(g=c+f;g>c;g--)d[g]=m(g);d[c]=m(c),f++}while(d[c]!==l);return u[c].slice(1)}oo.fastDiff=Lg;/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function oh(){return function n(){n.called=!0}}class Ti{constructor(e,t){h(this,"source"),h(this,"name"),h(this,"path"),h(this,"stop"),h(this,"off"),h(this,"return"),this.source=e,this.name=t,this.path=[],this.stop=oh(),this.off=oh()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Qe=new Array(256).fill("").map((n,e)=>("0"+e.toString(16)).slice(-2));function ze(){const[n,e,t,i]=crypto.getRandomValues(new Uint32Array(4));return"e"+Qe[n>>0&255]+Qe[n>>8&255]+Qe[n>>16&255]+Qe[n>>24&255]+Qe[e>>0&255]+Qe[e>>8&255]+Qe[e>>16&255]+Qe[e>>24&255]+Qe[t>>0&255]+Qe[t>>8&255]+Qe[t>>16&255]+Qe[t>>24&255]+Qe[i>>0&255]+Qe[i>>8&255]+Qe[i>>16&255]+Qe[i>>24&255]}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const kt={get(n="normal"){return typeof n!="number"?this[n]||this.normal:n},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function Fg(n,e){const t=kt.get(e.priority);let i=0,o=n.length;for(;i<o;){const s=i+o>>1;kt.get(n[s].priority)<t?o=s:i=s+1}n.splice(i,0,e)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const N_="https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html";class b extends Error{constructor(e,t,i){super(z_(e,i)),h(this,"context"),h(this,"data"),this.name="CKEditorError",this.context=t,this.data=i}is(e){return e==="CKEditorError"}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const i=new b(e.message,t);throw i.stack=e.stack,i}}function J(n,e){console.warn(...Dg(n,e))}function D_(n,e){console.error(...Dg(n,e))}function Ng(n){return`
Read more: ${N_}#error-${n}`}function z_(n,e){const t=new WeakSet,i=e?` ${JSON.stringify(e,(s,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return`[object ${r.constructor.name}]`;t.add(r)}return r})}`:"",o=Ng(n);return n+i+o}function Dg(n,e){const t=Ng(n);return e?[n,e,t]:[n,t]}const zg="45.2.0",H_=new Date(2025,5,4);/* istanbul ignore next -- @preserve */if(globalThis.CKEDITOR_VERSION)throw new b("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION=zg;const Gn=Symbol("listeningTo"),Ol=Symbol("emitterId"),fi=Symbol("delegations"),Hg=ge(Object);function ge(n){if(!n)return Hg;class e extends n{on(i,o,s){this.listenTo(this,i,o,s)}once(i,o,s){let r=!1;const a=(l,...c)=>{r||(r=!0,l.off(),o.call(this,l,...c))};this.listenTo(this,i,a,s)}off(i,o){this.stopListening(this,i,o)}listenTo(i,o,s,r={}){let a,l;this[Gn]||(this[Gn]={});const c=this[Gn];Sa(i)||$g(i);const u=Sa(i);(a=c[u])||(a=c[u]={emitter:i,callbacks:{}}),(l=a.callbacks[o])||(l=a.callbacks[o]=[]),l.push(s),q_(this,i,o,s,r)}stopListening(i,o,s){const r=this[Gn];let a=i&&Sa(i);const l=r&&a?r[a]:void 0,c=l&&o?l.callbacks[o]:void 0;if(!(!r||i&&!l||o&&!c))if(s)Pa(this,i,o,s),c.indexOf(s)!==-1&&(c.length===1?delete l.callbacks[o]:Pa(this,i,o,s));else if(c){for(;s=c.pop();)Pa(this,i,o,s);delete l.callbacks[o]}else if(l){for(o in l.callbacks)this.stopListening(i,o);delete r[a]}else{for(a in r)this.stopListening(r[a].emitter);delete this[Gn]}}fire(i,...o){try{const s=i instanceof Ti?i:new Ti(this,i),r=s.name;let a=U_(this,r);if(s.path.push(this),a){a=a.slice();for(let c=0;c<a.length;c++){const u=a[c].callback;if(u.call(this,s,...o),s.off.called&&(delete s.off.called,this._removeEventListener(r,u)),s.stop.called)break}}const l=this[fi];if(l){const c=l.get(r),u=l.get("*");c&&sh(c,s,o),u&&sh(u,s,o)}return s.return}catch(s){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(s,this)}}delegate(...i){return{to:(o,s)=>{this[fi]||(this[fi]=new Map),i.forEach(r=>{const a=this[fi].get(r);a?a.set(o,s):this[fi].set(r,new Map([[o,s]]))})}}}stopDelegating(i,o){if(this[fi])if(!i)this[fi].clear();else if(!o)this[fi].delete(i);else{const s=this[fi].get(i);s&&s.delete(o)}}_addEventListener(i,o,s){j_(this,i);const r=Bl(this,i),a=kt.get(s.priority),l={callback:o,priority:a};for(const c of r)Fg(c,l)}_removeEventListener(i,o){const s=Bl(this,i);for(const r of s)for(let a=0;a<r.length;a++)r[a].callback==o&&(r.splice(a,1),a--)}}return e}["on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(n=>{ge[n]=Hg.prototype[n]});function $_(n,e){const t=n[Gn];return t&&t[e]?t[e].emitter:null}function $g(n,e){n[Ol]||(n[Ol]=e||ze())}function Sa(n){return n[Ol]}function Wg(n){return n._events||Object.defineProperty(n,"_events",{value:{}}),n._events}function W_(){return{callbacks:[],childEvents:[]}}function j_(n,e){const t=Wg(n);if(t[e])return;let i=e,o=null;const s=[];for(;i!==""&&!t[i];)t[i]=W_(),s.push(t[i]),o&&t[i].childEvents.push(o),o=i,i=i.substr(0,i.lastIndexOf(":"));if(i!==""){for(const r of s)r.callbacks=t[i].callbacks.slice();t[i].childEvents.push(o)}}function Bl(n,e){const t=Wg(n)[e];if(!t)return[];let i=[t.callbacks];for(let o=0;o<t.childEvents.length;o++){const s=Bl(n,t.childEvents[o]);i=i.concat(s)}return i}function U_(n,e){if(!n._events)return null;let t=e;do{const i=n._events[t];if(i&&i.callbacks&&i.callbacks.length)return i.callbacks;const o=t.lastIndexOf(":");t=o>-1?t.substring(0,o):""}while(t);return null}function sh(n,e,t){for(let[i,o]of n){o?typeof o=="function"&&(o=o(e.name)):o=e.name;const s=new Ti(e.source,o);s.path=[...e.path],i.fire(s,...t)}}function q_(n,e,t,i,o){e._addEventListener?e._addEventListener(t,i,o):n._addEventListener.call(e,t,i,o)}function Pa(n,e,t,i){e._removeEventListener?e._removeEventListener(t,i):n._removeEventListener.call(e,t,i)}const Zo=Symbol("observableProperties"),as=Symbol("boundObservables"),Jo=Symbol("boundProperties"),rn=Symbol("decoratedMethods"),rh=Symbol("decoratedOriginal"),jg=ue(ge());function ue(n){var e,t,i,o,s;if(!n)return jg;class r extends(s=n,o=Zo,i=rn,t=Jo,e=as,s){constructor(){super(...arguments),h(this,o),h(this,i),h(this,t),h(this,e)}set(l,c){if(Et(l)){Object.keys(l).forEach(d=>{this.set(d,l[d])},this);return}Ia(this);const u=this[Zo];if(l in this&&!u.has(l))throw new b("observable-set-cannot-override",this);Object.defineProperty(this,l,{enumerable:!0,configurable:!0,get(){return u.get(l)},set(d){const m=u.get(l);let f=this.fire(`set:${l}`,l,d,m);f===void 0&&(f=d),(m!==f||!u.has(l))&&(u.set(l,f),this.fire(`change:${l}`,l,f,m))}}),this[l]=c}bind(...l){if(!l.length||!ah(l))throw new b("observable-bind-wrong-properties",this);if(new Set(l).size!==l.length)throw new b("observable-bind-duplicate-properties",this);Ia(this);const c=this[Jo];l.forEach(d=>{if(c.has(d))throw new b("observable-bind-rebind",this)});const u=new Map;return l.forEach(d=>{const m={property:d,to:[]};c.set(d,m),u.set(d,m)}),{to:G_,toMany:K_,_observable:this,_bindProperties:l,_to:[],_bindings:u}}unbind(...l){if(!this[Zo])return;const c=this[Jo],u=this[as];if(l.length){if(!ah(l))throw new b("observable-unbind-wrong-properties",this);l.forEach(d=>{const m=c.get(d);m&&(m.to.forEach(([f,g])=>{const p=u.get(f),_=p[g];_.delete(m),_.size||delete p[g],Object.keys(p).length||(u.delete(f),this.stopListening(f,"change"))}),c.delete(d))})}else u.forEach((d,m)=>{this.stopListening(m,"change")}),u.clear(),c.clear()}decorate(l){Ia(this);const c=this[l];if(!c)throw new b("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:l});this.on(l,(u,d)=>{u.return=c.apply(this,d)}),this[l]=function(...u){return this.fire(l,u)},this[l][rh]=c,this[rn]||(this[rn]=[]),this[rn].push(l)}stopListening(l,c,u){if(!l&&this[rn]){for(const d of this[rn])this[d]=this[d][rh];delete this[rn]}super.stopListening(l,c,u)}}return r}["set","bind","unbind","decorate","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(n=>{ue[n]=jg.prototype[n]});function Ia(n){n[Zo]||(Object.defineProperty(n,Zo,{value:new Map}),Object.defineProperty(n,as,{value:new Map}),Object.defineProperty(n,Jo,{value:new Map}))}function G_(...n){const e=J_(...n),t=Array.from(this._bindings.keys()),i=t.length;if(!e.callback&&e.to.length>1)throw new b("observable-bind-to-no-callback",this);if(i>1&&e.callback)throw new b("observable-bind-to-extra-callback",this);e.to.forEach(o=>{if(o.properties.length&&o.properties.length!==i)throw new b("observable-bind-to-properties-length",this);o.properties.length||(o.properties=this._bindProperties)}),this._to=e.to,e.callback&&(this._bindings.get(t[0]).callback=e.callback),X_(this._observable,this._to),Y_(this),this._bindProperties.forEach(o=>{Ug(this._observable,o)})}function K_(n,e,t){if(this._bindings.size>1)throw new b("observable-bind-to-many-not-one-binding",this);this.to(...Z_(n,e),t)}function Z_(n,e){const t=n.map(i=>[i,e]);return Array.prototype.concat.apply([],t)}function ah(n){return n.every(e=>typeof e=="string")}function J_(...n){if(!n.length)throw new b("observable-bind-to-parse-error",null);const e={to:[]};let t;return typeof n[n.length-1]=="function"&&(e.callback=n.pop()),n.forEach(i=>{if(typeof i=="string")t.properties.push(i);else if(typeof i=="object")t={observable:i,properties:[]},e.to.push(t);else throw new b("observable-bind-to-parse-error",null)}),e}function Q_(n,e,t,i){const o=n[as],s=o.get(t),r=s||{};r[i]||(r[i]=new Set),r[i].add(e),s||o.set(t,r)}function Y_(n){let e;n._bindings.forEach((t,i)=>{n._to.forEach(o=>{e=o.properties[t.callback?0:n._bindProperties.indexOf(i)],t.to.push([o.observable,e]),Q_(n._observable,t,o.observable,e)})})}function Ug(n,e){const t=n[Jo].get(e);let i;t.callback?i=t.callback.apply(n,t.to.map(o=>o[0][o[1]])):(i=t.to[0],i=i[0][i[1]]),Object.prototype.hasOwnProperty.call(n,e)?n[e]=i:n.set(e,i)}function X_(n,e){e.forEach(t=>{const i=n[as];let o;i.get(t.observable)||n.listenTo(t.observable,"change",(s,r)=>{o=i.get(t.observable)[r],o&&o.forEach(a=>{Ug(n,a.property)})})})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ml(n){let e=0;for(const t of n)e++;return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Xe(n,e){const t=Math.min(n.length,e.length);for(let i=0;i<t;i++)if(n[i]!=e[i])return i;return n.length==e.length?"same":n.length<e.length?"prefix":"extension"}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Pt(n){return!!(n&&n[Symbol.iterator])}function Ll(n,e,t={},i=[]){const o=t&&t.xmlns,s=o?n.createElementNS(o,e):n.createElement(e);for(const r in t)s.setAttribute(r,t[r]);(Xu(i)||!Pt(i))&&(i=[i]);for(let r of i)Xu(r)&&(r=n.createTextNode(r)),s.appendChild(r);return s}class qg{constructor(e,t){h(this,"_config"),this._config=Object.create(null),t&&this.define(lh(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,o=!1){if(Ut(t)){this._setObjectToTarget(e,t,o);return}const s=t.split(".");t=s.pop();for(const r of s)Ut(e[r])||(e[r]=Object.create(null)),e=e[r];if(Ut(i)){Ut(e[t])||(e[t]=Object.create(null)),e=e[t],this._setObjectToTarget(e,i,o);return}o&&typeof e[t]<"u"||(e[t]=i)}_getFromSource(e,t){const i=t.split(".");t=i.pop();for(const o of i){if(!Ut(e[o])){e=null;break}e=e[o]}return e?lh(e[t]):void 0}_setObjectToTarget(e,t,i){Object.keys(t).forEach(o=>{this._setToTarget(e,o,t[o],i)})}}function lh(n){return Xr(n,ev)}function ev(n){return xi(n)||typeof n=="function"?n:void 0}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Zi(n){if(n){if(n.defaultView)return n instanceof n.defaultView.Document;if(n.ownerDocument&&n.ownerDocument.defaultView)return n instanceof n.ownerDocument.defaultView.Node}return!1}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Sr(n){const e=Object.prototype.toString.apply(n);return e=="[object Window]"||e=="[object global]"}const Gg=st(ge());function st(n){if(!n)return Gg;class e extends n{listenTo(i,o,s,r={}){if(Zi(i)||Sr(i)||i instanceof I.window.EventTarget){const a={capture:!!r.useCapture,passive:!!r.usePassive},l=this._getProxyEmitter(i,a)||new tv(i,a);this.listenTo(l,o,s,r)}else super.listenTo(i,o,s,r)}stopListening(i,o,s){if(Zi(i)||Sr(i)||i instanceof I.window.EventTarget){const r=this._getAllProxyEmitters(i);for(const a of r)this.stopListening(a,o,s)}else super.stopListening(i,o,s)}_getProxyEmitter(i,o){return $_(this,Kg(i,o))}_getAllProxyEmitters(i){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map(o=>this._getProxyEmitter(i,o)).filter(o=>!!o)}}return e}["_getProxyEmitter","_getAllProxyEmitters","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach(n=>{st[n]=Gg.prototype[n]});class tv extends ge(){constructor(e,t){super(),h(this,"_domNode"),h(this,"_options"),h(this,"_domListeners"),$g(this,Kg(e,t)),this._domNode=e,this._options=t}attach(e){if(this._domListeners&&this._domListeners[e])return;const t=this._createDomListener(e);this._domNode.addEventListener(e,t,this._options),this._domListeners||(this._domListeners={}),this._domListeners[e]=t}detach(e){let t;this._domListeners[e]&&(!(t=this._events[e])||!t.callbacks.length)&&this._domListeners[e].removeListener()}_addEventListener(e,t,i){this.attach(e),ge().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){ge().prototype._removeEventListener.call(this,e,t),this.detach(e)}_createDomListener(e){const t=i=>{this.fire(e,i)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}}function iv(n){return n["data-ck-expando"]||(n["data-ck-expando"]=ze())}function Kg(n,e){let t=iv(n);for(const i of Object.keys(e).sort())e[i]&&(t+="-"+i);return t}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Zg(n){const e=[];let t=n;for(;t&&t.nodeType!=Node.DOCUMENT_NODE;)e.unshift(t),t=t.parentNode;return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Jg(n){return n instanceof HTMLTextAreaElement?n.value:n.innerHTML}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Dc(n){const e=n.ownerDocument.defaultView.getComputedStyle(n);return{top:parseInt(e.borderTopWidth,10),right:parseInt(e.borderRightWidth,10),bottom:parseInt(e.borderBottomWidth,10),left:parseInt(e.borderLeftWidth,10)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Qg(n){if(!n.target)return null;const e=n.target.ownerDocument,t=n.clientX,i=n.clientY;let o=null;return e.caretRangeFromPoint&&e.caretRangeFromPoint(t,i)?o=e.caretRangeFromPoint(t,i):n.rangeParent&&(o=e.createRange(),o.setStart(n.rangeParent,n.rangeOffset),o.collapse(!0)),o}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function xe(n){return Object.prototype.toString.call(n)=="[object Text]"}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ia(n){return Object.prototype.toString.apply(n)=="[object Range]"}function Yg(n){return!n||!n.parentNode||n.offsetParent===I.document.body?null:n.offsetParent}const Xg=["top","right","bottom","left","width","height"];class z{constructor(e){h(this,"top"),h(this,"right"),h(this,"bottom"),h(this,"left"),h(this,"width"),h(this,"height"),h(this,"_source");const t=ia(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),Fl(e)||t)if(t){const i=z.getDomRangeRects(e);Ns(this,z.getBoundingRect(i))}else Ns(this,e.getBoundingClientRect());else if(Sr(e)){const{innerWidth:i,innerHeight:o}=e;Ns(this,{top:0,right:i,bottom:o,left:0,width:i,height:o})}else Ns(this,e)}clone(){return new z(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left),width:0,height:0};if(t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0)return null;{const i=new z(t);return i._source=this._source,i}}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(ch(e))return t;let i=e,o=e.parentNode||e.commonAncestorContainer,s;for(;o&&!ch(o);){const r=nv(o)==="visible";i instanceof HTMLElement&&uh(i)==="absolute"&&(s=i);const a=uh(o);if(r||s&&(a==="relative"&&r||a!=="relative")){i=o,o=o.parentNode;continue}const l=new z(o),c=t.getIntersection(l);if(c)c.getArea()<t.getArea()&&(t=c);else return null;i=o,o=o.parentNode}return t}isEqual(e){for(const t of Xg)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}=I.window,i=this.clone().moveBy(e,t);if(Fl(i._source)){const o=Yg(i._source);o&&ov(i,o)}return i}excludeScrollbarsAndBorders(){const e=this._source;let t,i,o;if(Sr(e))t=e.innerWidth-e.document.documentElement.clientWidth,i=e.innerHeight-e.document.documentElement.clientHeight,o=e.getComputedStyle(e.document.documentElement).direction;else{const s=Dc(e);t=e.offsetWidth-e.clientWidth-s.left-s.right,i=e.offsetHeight-e.clientHeight-s.top-s.bottom,o=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,o==="ltr"?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 o of i)t.push(new z(o));else{let o=e.startContainer;xe(o)&&(o=o.parentNode);const s=new z(o.getBoundingClientRect());s.right=s.left,s.width=0,t.push(s)}return t}static getBoundingRect(e){const t={left:Number.POSITIVE_INFINITY,top:Number.POSITIVE_INFINITY,right:Number.NEGATIVE_INFINITY,bottom:Number.NEGATIVE_INFINITY,width:0,height:0};let i=0;for(const o of e)i++,t.left=Math.min(t.left,o.left),t.top=Math.min(t.top,o.top),t.right=Math.max(t.right,o.right),t.bottom=Math.max(t.bottom,o.bottom);return i==0?null:(t.width=t.right-t.left,t.height=t.bottom-t.top,new z(t))}}function Ns(n,e){for(const t of Xg)n[t]=e[t]}function ch(n){return Fl(n)?n===n.ownerDocument.body:!1}function Fl(n){return n!==null&&typeof n=="object"&&n.nodeType===1&&typeof n.getBoundingClientRect=="function"}function uh(n){return n instanceof HTMLElement?n.ownerDocument.defaultView.getComputedStyle(n).position:"static"}function nv(n){return n instanceof HTMLElement?n.ownerDocument.defaultView.getComputedStyle(n).overflow:"visible"}function ov(n,e){const t=new z(e),i=Dc(e);let o=0,s=0;o-=t.left,s-=t.top,o+=e.scrollLeft,s+=e.scrollTop,o-=i.left,s-=i.top,n.moveBy(o,s)}const Nl=class Be{constructor(e,t){h(this,"_element"),h(this,"_callback"),Be._observerInstance||Be._createObserver(),this._element=e,this._callback=t,Be._addElementCallback(e,t),Be._observerInstance.observe(e)}get element(){return this._element}destroy(){Be._deleteElementCallback(this._element,this._callback)}static _addElementCallback(e,t){Be._elementCallbacks||(Be._elementCallbacks=new Map);let i=Be._elementCallbacks.get(e);i||(i=new Set,Be._elementCallbacks.set(e,i)),i.add(t)}static _deleteElementCallback(e,t){const i=Be._getElementCallbacks(e);i&&(i.delete(t),i.size||(Be._elementCallbacks.delete(e),Be._observerInstance.unobserve(e))),Be._elementCallbacks&&!Be._elementCallbacks.size&&(Be._observerInstance=null,Be._elementCallbacks=null)}static _getElementCallbacks(e){return Be._elementCallbacks?Be._elementCallbacks.get(e):null}static _createObserver(){Be._observerInstance=new I.window.ResizeObserver(e=>{for(const t of e){const i=Be._getElementCallbacks(t.target);if(i)for(const o of i)o(t)}})}};h(Nl,"_observerInstance",null),h(Nl,"_elementCallbacks",null);let bo=Nl;/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function hh(n,e){n instanceof HTMLTextAreaElement&&(n.value=e),n.innerHTML=e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Vi(n){return e=>e+n}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function to(n){let e=0;for(;n.previousSibling;)n=n.previousSibling,e++;return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ep(n,e,t){n.insertBefore(t,n.childNodes[e]||null)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Qo(n){return n&&n.nodeType===Node.COMMENT_NODE}function tp(n){try{I.document.createAttribute(n)}catch{return!1}return!0}function Gt(n){return n?xe(n)?Gt(n.parentElement):n.getClientRects?!!n.getClientRects().length:!1:!1}function zc({element:n,target:e,positions:t,limiter:i,fitInViewport:o,viewportOffsetConfig:s}){Tr(e)&&(e=e()),Tr(i)&&(i=i());const r=Yg(n),a=sv(s),l=new z(n),c=dh(e,a);let u;if(!c||!a.getIntersection(c))return null;const d={targetRect:c,elementRect:l,positionedElementAncestor:r,viewportRect:a};if(!i&&!o)u=new ip(t[0],d);else{if(i){const m=dh(i,a);m&&(d.limiterRect=m)}u=rv(t,d)}return u}function dh(n,e){const t=new z(n).getVisible();return t?t.getIntersection(e):null}function sv(n){n=Object.assign({top:0,bottom:0,left:0,right:0},n);const e=new z(I.window);return e.top+=n.top,e.height-=n.top,e.bottom-=n.bottom,e.height-=n.bottom,e}function rv(n,e){const{elementRect:t}=e,i=t.getArea(),o=n.map(a=>new ip(a,e)).filter(a=>!!a.name);let s=0,r=null;for(const a of o){const{limiterIntersectionArea:l,viewportIntersectionArea:c}=a;if(l===i)return a;const u=c**2+l**2;u>s&&(s=u,r=a)}return r}class ip{constructor(e,t){h(this,"name"),h(this,"config"),h(this,"_positioningFunctionCoordinates"),h(this,"_options"),h(this,"_cachedRect"),h(this,"_cachedAbsoluteRect");const i=e(t.targetRect,t.elementRect,t.viewportRect,t.limiterRect);if(!i)return;const{left:o,top:s,name:r,config:a}=i;this.name=r,this.config=a,this._positioningFunctionCoordinates={left:o,top:s},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;return e?e.getIntersectionArea(this._rect):0}get viewportIntersectionArea(){return this._options.viewportRect.getIntersectionArea(this._rect)}get _rect(){return this._cachedRect?this._cachedRect:(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCoordinates.left,this._positioningFunctionCoordinates.top),this._cachedRect)}get _absoluteRect(){return this._cachedAbsoluteRect?this._cachedAbsoluteRect:(this._cachedAbsoluteRect=this._rect.toAbsoluteRect(),this._cachedAbsoluteRect)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function mh(n){const e=n.parentNode;e&&e.removeChild(n)}function av(){const n=I.window.visualViewport;if(!n||!(N.isiOS||N.isSafari))return{left:0,top:0};const e=Math.max(Math.round(n.offsetLeft),0),t=Math.max(Math.round(n.offsetTop),0);return{left:e,top:t}}function np({target:n,viewportOffset:e=0,ancestorOffset:t=0,alignToTop:i,forceScroll:o}){const s=Hc(n);let r=s,a=null;for(e=uv(e);r;){let l;r==s?l=fh(n):l=fh(a),cv({parent:l,getRect:()=>Va(n,r),alignToTop:i,ancestorOffset:t,forceScroll:o});let c=Va(n,r);const u=Va(l,r);if(c.height>u.height){const d=c.getIntersection(u);d&&(c=d)}if(lv({window:r,rect:c,viewportOffset:e,alignToTop:i,forceScroll:o}),r.parent!=r){if(a=r.frameElement,r=r.parent,!a)return}else r=null}}function lv({window:n,rect:e,alignToTop:t,forceScroll:i,viewportOffset:o}){const s=e.clone().moveBy(0,o.bottom),r=e.clone().moveBy(0,-o.top),a=new z(n).excludeScrollbarsAndBorders(),l=[r,s],c=t&&i,u=l.every(p=>a.contains(p));let{scrollX:d,scrollY:m}=n;const f=d,g=m;c?m-=a.top-e.top+o.top:u||(sp(r,a)?m-=a.top-e.top+o.top:op(s,a)&&(t?m+=e.top-a.top-o.top:m+=e.bottom-a.bottom+o.bottom)),u||(rp(e,a)?d-=a.left-e.left+o.left:ap(e,a)&&(d+=e.right-a.right+o.right)),(d!=f||m!==g)&&n.scrollTo(d,m)}function cv({parent:n,getRect:e,alignToTop:t,forceScroll:i,ancestorOffset:o=0,limiterElement:s}){const r=Hc(n),a=t&&i;let l,c,u;const d=s||r.document.body;for(;n!=d;)c=e(),l=new z(n).excludeScrollbarsAndBorders(),u=l.contains(c),a?n.scrollTop-=l.top-c.top+o:u||(sp(c,l)?n.scrollTop-=l.top-c.top+o:op(c,l)&&(t?n.scrollTop+=c.top-l.top-o:n.scrollTop+=c.bottom-l.bottom+o)),u||(rp(c,l)?n.scrollLeft-=l.left-c.left+o:ap(c,l)&&(n.scrollLeft+=c.right-l.right+o)),n=n.parentNode}function op(n,e){return n.bottom>e.bottom}function sp(n,e){return n.top<e.top}function rp(n,e){return n.left<e.left}function ap(n,e){return n.right>e.right}function Hc(n){return ia(n)?n.startContainer.ownerDocument.defaultView:n.ownerDocument.defaultView}function fh(n){if(ia(n)){let e=n.commonAncestorContainer;return xe(e)&&(e=e.parentNode),e}else return n.parentNode}function Va(n,e){const t=Hc(n),i=new z(n);if(t===e)return i;{let o=t;for(;o!=e;){const s=o.frameElement,r=new z(s).excludeScrollbarsAndBorders();i.moveBy(r.left,r.top),o=o.parent}}return i}function uv(n){return typeof n=="number"?{top:n,bottom:n,left:n,right:n}:n}const hv={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},dv={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},gh={37:"←",38:"↑",39:"→",40:"↓",9:"⇥",33:"Page Up",34:"Page Down"},Z=wv(),mv=Object.fromEntries(Object.entries(Z).map(([n,e])=>{let t;return e in gh?t=gh[e]:t=n.charAt(0).toUpperCase()+n.slice(1),[e,t]}));function yn(n){let e;if(typeof n=="string"){if(e=Z[n.toLowerCase()],!e)throw new b("keyboard-unknown-key",null,{key:n})}else e=n.keyCode+(n.altKey?Z.alt:0)+(n.ctrlKey?Z.ctrl:0)+(n.shiftKey?Z.shift:0)+(n.metaKey?Z.cmd:0);return e}function na(n){return typeof n=="string"&&(n=bv(n)),n.map(e=>typeof e=="string"?gv(e):e).reduce((e,t)=>t+e,0)}function ph(n,e){let t=na(n);const i=N.isMac||N.isiOS;return Object.entries(i?hv:dv).reduce((o,[s,r])=>((t&Z[s])!=0&&(t&=~Z[s],o+=r),o),"")+(t?mv[t]:"")}function fv(n){return n==Z.arrowright||n==Z.arrowleft||n==Z.arrowup||n==Z.arrowdown}function oa(n,e){const t=e==="ltr";switch(n){case Z.arrowleft:return t?"left":"right";case Z.arrowright:return t?"right":"left";case Z.arrowup:return"up";case Z.arrowdown:return"down"}}function gv(n){if(n.endsWith("!"))return yn(n.slice(0,-1));const e=yn(n);return(N.isMac||N.isiOS)&&e==Z.ctrl?Z.cmd:e}function pv(n,e){const t=oa(n,e);return t==="down"||t==="right"}function wv(){const n={pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let e=65;e<=90;e++){const t=String.fromCharCode(e);n[t.toLowerCase()]=e}for(let e=48;e<=57;e++)n[e-48]=e;for(let e=112;e<=123;e++)n["f"+(e-111)]=e;return Object.assign(n,{"'":222,",":108,"-":109,".":110,"/":111,";":186,"=":187,"[":219,"\\":220,"]":221,"`":223}),n}function bv(n){return n.split("+").map(e=>e.trim())}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const _v=["ar","ara","dv","div","fa","per","fas","he","heb","ku","kur","ug","uig","ur","urd"];function Dl(n){return _v.includes(n)?"rtl":"ltr"}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function he(n){return Array.isArray(n)?n:[n]}/* istanbul ignore else -- @preserve */I.window.CKEDITOR_TRANSLATIONS||(I.window.CKEDITOR_TRANSLATIONS={});function vv(n,e,t=1,i){if(typeof t!="number")throw new b("translation-service-quantity-not-a-number",null,{quantity:t});const o=i||I.window.CKEDITOR_TRANSLATIONS,s=Cv(o);s===1&&(n=Object.keys(o)[0]);const r=e.id||e.string;if(s===0||!kv(n,r,o))return t!==1?e.plural:e.string;const a=o[n].dictionary,l=o[n].getPluralForm||(d=>d===1?0:1),c=a[r];if(typeof c=="string")return c;const u=Number(l(t));return c[u]}function yv(n){return Array.isArray(n)?n.reduce((e,t)=>Nc(e,t)):n}function kv(n,e,t){return!!t[n]&&!!t[n].dictionary[e]}function Cv(n){return Object.keys(n).length}class lp{constructor({uiLanguage:e="en",contentLanguage:t,translations:i}={}){h(this,"uiLanguage"),h(this,"uiLanguageDirection"),h(this,"contentLanguage"),h(this,"contentLanguageDirection"),h(this,"t"),h(this,"translations"),this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=Dl(this.uiLanguage),this.contentLanguageDirection=Dl(this.contentLanguage),this.translations=yv(i),this.t=(o,s)=>this._t(o,s)}get language(){return console.warn("locale-deprecated-language-property: The Locale#language property has been deprecated and will be removed in the near future. Please use #uiLanguage and #contentLanguage properties instead."),this.uiLanguage}_t(e,t=[]){t=he(t),typeof e=="string"&&(e={string:e});const i=e.plural?t[0]:1,o=vv(this.uiLanguage,e,i,this.translations);return Av(o,t)}}function Av(n,e){return n.replace(/%(\d+)/g,(t,i)=>i<e.length?e[i]:t)}class _e extends ge(){constructor(e={},t={}){super(),h(this,"_items"),h(this,"_itemMap"),h(this,"_idProperty"),h(this,"_bindToCollection"),h(this,"_bindToExternalToInternalMap"),h(this,"_bindToInternalToExternalMap"),h(this,"_skippedIndexesFromExternal");const i=Pt(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 o of e)this._items.push(o),this._itemMap.set(this._getItemIdBeforeAdding(o),o)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(e,t){return this.addMany([e],t)}addMany(e,t){if(t===void 0)t=this._items.length;else if(t>this._items.length||t<0)throw new b("collection-add-item-invalid-index",this);let i=0;for(const o of e){const s=this._getItemIdBeforeAdding(o),r=t+i;this._items.splice(r,0,o),this._itemMap.set(s,o),this.fire("add",o,r),i++}return this.fire("change",{added:e,removed:[],index:t}),this}get(e){let t;if(typeof e=="string")t=this._itemMap.get(e);else if(typeof e=="number")t=this._items[e];else throw new b("collection-get-invalid-arg",this);return t||null}has(e){if(typeof e=="string")return this._itemMap.has(e);{const t=this._idProperty,i=e[t];return i&&this._itemMap.has(i)}}getIndex(e){let t;return typeof e=="string"?t=this._itemMap.get(e):t=e,t?this._items.indexOf(t):-1}remove(e){const[t,i]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:i}),t}map(e,t){return this._items.map(e,t)}forEach(e,t){this._items.forEach(e,t)}find(e,t){return this._items.find(e,t)}filter(e,t){return this._items.filter(e,t)}clear(){this._bindToCollection&&(this.stopListening(this._bindToCollection),this._bindToCollection=null);const e=Array.from(this._items);for(;this.length;)this._remove(0);this.fire("change",{added:[],removed:e,index:0})}bindTo(e){if(this._bindToCollection)throw new b("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:t=>{this._setUpBindToBinding(i=>new t(i))},using:t=>{typeof t=="function"?this._setUpBindToBinding(t):this._setUpBindToBinding(i=>i[t])}}}_setUpBindToBinding(e){const t=this._bindToCollection,i=(o,s,r)=>{const a=t._bindToCollection==this,l=t._bindToInternalToExternalMap.get(s);if(a&&l)this._bindToExternalToInternalMap.set(s,l),this._bindToInternalToExternalMap.set(l,s);else{const c=e(s);if(!c){this._skippedIndexesFromExternal.push(r);return}let u=r;for(const d of this._skippedIndexesFromExternal)r>d&&u--;for(const d of t._skippedIndexesFromExternal)u>=d&&u++;this._bindToExternalToInternalMap.set(s,c),this._bindToInternalToExternalMap.set(c,s),this.add(c,u);for(let d=0;d<t._skippedIndexesFromExternal.length;d++)u<=t._skippedIndexesFromExternal[d]&&t._skippedIndexesFromExternal[d]++}};for(const o of t)i(null,o,t.getIndex(o));this.listenTo(t,"add",i),this.listenTo(t,"remove",(o,s,r)=>{const a=this._bindToExternalToInternalMap.get(s);a&&this.remove(a),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce((l,c)=>(r<c&&l.push(c-1),r>c&&l.push(c),l),[])})}_getItemIdBeforeAdding(e){const t=this._idProperty;let i;if(t in e){if(i=e[t],typeof i!="string")throw new b("collection-add-invalid-id",this);if(this.get(i))throw new b("collection-add-item-already-exists",this)}else e[t]=i=ze();return i}_remove(e){let t,i,o,s=!1;const r=this._idProperty;if(typeof e=="string"?(i=e,o=this._itemMap.get(i),s=!o,o&&(t=this._items.indexOf(o))):typeof e=="number"?(t=e,o=this._items[t],s=!o,o&&(i=o[r])):(o=e,i=o[r],t=this._items.indexOf(o),s=t==-1||!this._itemMap.get(i)),s)throw new b("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const a=this._bindToInternalToExternalMap.get(o);return this._bindToInternalToExternalMap.delete(o),this._bindToExternalToInternalMap.delete(a),this.fire("remove",o,t),[o,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ae(n){const e=n.next();return e.done?null:e.value}class ee extends st(ue()){constructor(){super(),h(this,"_elements",new Set),h(this,"_externalViews",new Set),h(this,"_blurTimeout",null),this.set("isFocused",!1),this.set("focusedElement",null)}get elements(){return Array.from(this._elements.values())}get externalViews(){return Array.from(this._externalViews.values())}add(e){if(bh(e))this._addElement(e);else if(wh(e))this._addView(e);else{if(!e.element)throw new b("focustracker-add-view-missing-element",{focusTracker:this,view:e});this._addElement(e.element)}}remove(e){bh(e)?this._removeElement(e):wh(e)?this._removeView(e):this._removeElement(e.element)}_addElement(e){if(this._elements.has(e))throw new b("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",()=>{const t=this.externalViews.find(i=>xv(e,i));t?this._focus(t.element):this._focus(e)},{useCapture:!0}),this.listenTo(e,"blur",()=>{this._blur()},{useCapture:!0}),this._elements.add(e)}_removeElement(e){this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e)),e===this.focusedElement&&this._blur()}_addView(e){e.element&&this._addElement(e.element),this.listenTo(e.focusTracker,"change:focusedElement",()=>{e.focusTracker.focusedElement?e.element&&this._focus(e.element):this._blur()}),this._externalViews.add(e)}_removeView(e){e.element&&this._removeElement(e.element),this.stopListening(e.focusTracker),this._externalViews.delete(e)}destroy(){this.stopListening(),this._elements.clear(),this._externalViews.clear(),this.isFocused=!1,this.focusedElement=null}_focus(e){this._clearBlurTimeout(),this.focusedElement=e,this.isFocused=!0}_blur(){this.elements.find(e=>e.contains(document.activeElement))||this.externalViews.find(e=>e.focusTracker.isFocused&&!e.focusTracker._blurTimeout)||(this._clearBlurTimeout(),this._blurTimeout=setTimeout(()=>{this.focusedElement=null,this.isFocused=!1},0))}_clearBlurTimeout(){clearTimeout(this._blurTimeout),this._blurTimeout=null}}function wh(n){return"focusTracker"in n&&n.focusTracker instanceof ee}function bh(n){return xi(n)}function xv(n,e){return _h(n,e)?!0:!!e.focusTracker.externalViews.find(t=>_h(n,t))}function _h(n,e){return!!e.element&&e.element.contains(document.activeElement)&&n.contains(e.element)}class te{constructor(){h(this,"_listener"),this._listener=new(st())}listenTo(e){this._listener.listenTo(e,"keydown",(t,i)=>{this._listener.fire("_keydown:"+yn(i),i)})}set(e,t,i={}){const o=na(e),s=i.priority;this._listener.listenTo(this._listener,"_keydown:"+o,(r,a)=>{i.filter&&!i.filter(a)||(t(a,()=>{a.preventDefault(),a.stopPropagation(),r.stop()}),r.return=!0)},{priority:s})}press(e){return!!this._listener.fire("_keydown:"+yn(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Tv(n){const e=new Map;for(const t in n)e.set(t,n[t]);return e}function ri(n){return Pt(n)?new Map(n):Tv(n)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function vh(n,e,t){const i=n.length,o=e.length;for(let s=i-1;s>=t;s--)n[s+o]=n[s];for(let s=0;s<o;s++)n[t+s]=e[s]}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function $c(n,e){let t;function i(...o){i.cancel(),t=setTimeout(()=>n(...o),e)}return i.cancel=()=>{clearTimeout(t)},i}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Wc(n){try{if(!n.startsWith("ey"))return null;const e=atob(n.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(e)}catch{return null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ev(){const n=[];for(let e=0;e<256;e++){let t=e;for(let i=0;i<8;i++)t&1?t=3988292384^t>>>1:t=t>>>1;n[e]=t}return n}function Sv(n){const e=Array.isArray(n)?n:[n],t=Ev();let i=-1;const o=e.map(s=>Array.isArray(s)?s.join(""):String(s)).join("");for(let s=0;s<o.length;s++){const r=o.charCodeAt(s);i=i>>>8^t[(i^r)&255]}return i=(i^-1)>>>0,i.toString(16).padStart(8,"0")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Pv(n){return!!n&&n.length==1&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(n)}function Iv(n){return!!n&&n.length==1&&/[\ud800-\udbff]/.test(n)}function Vv(n){return!!n&&n.length==1&&/[\udc00-\udfff]/.test(n)}function jc(n,e){return Iv(n.charAt(e-1))&&Vv(n.charAt(e))}function Uc(n,e){return Pv(n.charAt(e))}const Rv=Ov();function cp(n,e){const t=String(n).matchAll(Rv);return Array.from(t).some(i=>i.index<e&&e<i.index+i[0].length)}function Ov(){const n=[new RegExp("\\p{Emoji}[\\u{E0020}-\\u{E007E}]+\\u{E007F}","u"),new RegExp("\\p{Emoji}\\u{FE0F}?\\u{20E3}","u"),new RegExp("\\p{Emoji}\\u{FE0F}","u"),new RegExp("(?=\\p{General_Category=Other_Symbol})\\p{Emoji}\\p{Emoji_Modifier}*","u")],e=new RegExp("\\p{Regional_Indicator}{2}","u").source,t="(?:"+n.map(o=>o.source).join("|")+")",i=`${e}|${t}(?:‍${t})*`;return new RegExp(i,"ug")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const To=new WeakMap;let yh=!1;function sa({view:n,element:e,text:t,isDirectHost:i=!0,keepOnFocus:o=!1}){const s=n.document;To.has(s)||(To.set(s,new Map),s.registerPostFixer(a=>Ra(To.get(s),a)),s.on("change:isComposing",()=>{n.change(a=>Ra(To.get(s),a))},{priority:"high"})),e.is("editableElement")&&e.on("change:placeholder",(a,l,c)=>r(c)),e.placeholder?r(e.placeholder):t&&r(t),t&&Dv();function r(a){const l={text:a,isDirectHost:i,keepOnFocus:o,hostElement:i?e:null};To.get(s).set(e,l),n.change(c=>Ra([[e,l]],c))}}function Bv(n,e){return e.hasClass("ck-placeholder")?!1:(n.addClass("ck-placeholder",e),!0)}function Mv(n,e){return e.hasClass("ck-placeholder")?(n.removeClass("ck-placeholder",e),!0):!1}function Lv(n,e){if(!n.isAttached()||Fv(n))return!1;const t=n.document,i=t.selection.anchor;return t.isComposing&&i&&i.parent===n?!1:e||!t.isFocused?!0:!!i&&i.parent!==n}function Fv(n){for(const e of n.getChildren())if(!e.is("uiElement"))return!0;return!1}function Ra(n,e){const t=[];let i=!1;for(const[o,s]of n)s.isDirectHost&&(t.push(o),kh(e,o,s)&&(i=!0));for(const[o,s]of n){if(s.isDirectHost)continue;const r=Nv(o);r&&(t.includes(r)||(s.hostElement=r,kh(e,o,s)&&(i=!0)))}return i}function kh(n,e,t){const{text:i,isDirectHost:o,hostElement:s}=t;let r=!1;return s.getAttribute("data-placeholder")!==i&&(n.setAttribute("data-placeholder",i,s),r=!0),(o||e.childCount==1)&&Lv(s,t.keepOnFocus)?Bv(n,s)&&(r=!0):Mv(n,s)&&(r=!0),r}function Nv(n){if(n.childCount){const e=n.getChild(0);if(e.is("element")&&!e.is("uiElement")&&!e.is("attributeElement"))return e}return null}function Dv(){yh||J("enableplaceholder-deprecated-text-option"),yh=!0}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/let Cn=class{is(){throw new Error("is() method is abstract")}},An=class extends ge(Cn){constructor(n){super(),h(this,"document"),h(this,"parent"),this.document=n,this.parent=null}get index(){let n;if(!this.parent)return null;if((n=this.parent.getChildIndex(this))==-1)throw new b("view-node-not-found-in-parent",this);return n}get nextSibling(){const n=this.index;return n!==null&&this.parent.getChild(n+1)||null}get previousSibling(){const n=this.index;return n!==null&&this.parent.getChild(n-1)||null}get root(){let n=this;for(;n.parent;)n=n.parent;return n}isAttached(){return this.root.is("rootElement")}getPath(){const n=[];let e=this;for(;e.parent;)n.unshift(e.index),e=e.parent;return n}getAncestors(n={}){const e=[];let t=n.includeSelf?this:this.parent;for(;t;)e[n.parentFirst?"push":"unshift"](t),t=t.parent;return e}getCommonAncestor(n,e={}){const t=this.getAncestors(e),i=n.getAncestors(e);let o=0;for(;t[o]==i[o]&&t[o];)o++;return o===0?null:t[o-1]}isBefore(n){if(this==n||this.root!==n.root)return!1;const e=this.getPath(),t=n.getPath(),i=Xe(e,t);switch(i){case"prefix":return!0;case"extension":return!1;default:return e[i]<t[i]}}isAfter(n){return this==n||this.root!==n.root?!1:!this.isBefore(n)}_remove(){this.parent._removeChildren(this.index)}_fireChange(n,e,t){this.fire(`change:${n}`,e,t),this.parent&&this.parent._fireChange(n,e,t)}toJSON(){const n=Oc(this);return delete n.parent,n}};An.prototype.is=function(n){return n==="node"||n==="view:node"};let Ge=class zl extends An{constructor(e,t){super(e),h(this,"_textData"),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 zl?this===e||this.data===e.data:!1}_clone(){return new zl(this.document,this.data)}};Ge.prototype.is=function(n){return n==="$text"||n==="view:$text"||n==="text"||n==="view:text"||n==="node"||n==="view:node"};let _i=class extends Cn{constructor(n,e,t){if(super(),h(this,"textNode"),h(this,"data"),h(this,"offsetInText"),this.textNode=n,e<0||e>n.data.length)throw new b("view-textproxy-wrong-offsetintext",this);if(t<0||e+t>n.data.length)throw new b("view-textproxy-wrong-length",this);this.data=n.data.substring(e,e+t),this.offsetInText=e}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(n={}){const e=[];let t=n.includeSelf?this.textNode:this.parent;for(;t!==null;)e[n.parentFirst?"push":"unshift"](t),t=t.parent;return e}};_i.prototype.is=function(n){return n==="$textProxy"||n==="view:$textProxy"||n==="textProxy"||n==="view:textProxy"};class Pr{constructor(){h(this,"_consumables",new Map)}add(e,t){let i;if(e.is("$text")||e.is("documentFragment")){this._consumables.set(e,!0);return}this._consumables.has(e)?i=this._consumables.get(e):(i=new zv(e),this._consumables.set(e,i)),i.add(t?jo(t):e._getConsumables())}test(e,t){const i=this._consumables.get(e);return i===void 0?null:e.is("$text")||e.is("documentFragment")?i:i.test(jo(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return this.test(e,t)?(this._consumables.set(e,!1),!0):!1;const i=this._consumables.get(e);return i===void 0?!1:i.consume(jo(t))}revert(e,t){const i=this._consumables.get(e);i!==void 0&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(jo(t)))}static createFrom(e,t){if(t||(t=new Pr),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment")){t.add(e);for(const i of e.getChildren())Pr.createFrom(i,t)}return t}}class zv{constructor(e){h(this,"element"),h(this,"_canConsumeName",null),h(this,"_attributes",new Map),this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes)if(i){let o=this._attributes.get(t);(!o||typeof o=="boolean")&&(o=new Map,this._attributes.set(t,o)),o.set(i,!0)}else{if(t=="style"||t=="class")throw new b("viewconsumable-invalid-attribute",this);this._attributes.set(t,!0)}}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const[t,i]of e.attributes){const o=this._attributes.get(t);if(o===void 0)return null;if(o===!1)return!1;if(o!==!0){if(i){const s=o.get(i);if(s===void 0)return null;if(!s)return!1}else for(const s of o.values())if(!s)return!1}}return!0}consume(e){if(!this.test(e))return!1;e.name&&(this._canConsumeName=!1);for(const[t,i]of e.attributes){const o=this._attributes.get(t);if(typeof o=="boolean")for(const[s]of this.element._getConsumables(t,i).attributes)this._attributes.set(s,!1);else if(i)for(const[,s]of this.element._getConsumables(t,i).attributes)o.set(s,!1);else for(const s of o.keys())o.set(s,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes){const o=this._attributes.get(t);if(o===!1){this._attributes.set(t,!0);continue}if(!(o===void 0||o===!0))if(i)o.get(i)===!1&&o.set(i,!0);else for(const s of o.keys())o.set(s,!0)}}}function jo(n){const e=[];return"attributes"in n&&n.attributes&&Oa(e,n.attributes),"classes"in n&&n.classes&&Oa(e,n.classes,"class"),"styles"in n&&n.styles&&Oa(e,n.styles,"style"),{name:n.name||!1,attributes:e}}function Oa(n,e,t){if(typeof e=="string"){n.push(t?[t,e]:[e]);return}for(const i of e)Array.isArray(i)?n.push(i):n.push(t?[t,i]:[i])}class ft{constructor(...e){h(this,"_patterns",[]),this.add(...e)}add(...e){for(let t of e)(typeof t=="string"||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const i of this._patterns){const o=this._isElementMatching(t,i);if(o)return{element:t,pattern:i,match:o}}return null}matchAll(...e){const t=[];for(const i of e)for(const o of this._patterns){const s=this._isElementMatching(i,o);s&&t.push({element:i,pattern:o,match:s})}return t.length>0?t:null}getElementName(){if(this._patterns.length!==1)return null;const e=this._patterns[0],t=e.name;return typeof e!="function"&&t&&!(t instanceof RegExp)?t:null}_isElementMatching(e,t){if(typeof t=="function"){const s=t(e);return!s||typeof s!="object"?s:jo(s)}const i={};if(t.name&&(i.name=Hv(t.name,e.name),!i.name))return null;const o=[];return t.attributes&&!$v(t.attributes,e,o)||t.classes&&!Wv(t.classes,e,o)||t.styles&&!jv(t.styles,e,o)?null:(o.length&&(i.attributes=o),i)}}function Ir(n,e){return n===!0||n===e||n instanceof RegExp&&!!String(e).match(n)}function Hv(n,e){return n instanceof RegExp?!!e.match(n):n===e}function qc(n,e){if(Array.isArray(n))return n.map(i=>typeof i!="object"||i instanceof RegExp?e?[e,i,!0]:[i,!0]:((i.key===void 0||i.value===void 0)&&J("matcher-pattern-missing-key-or-value",i),e?[e,i.key,i.value]:[i.key,i.value]));if(typeof n!="object"||n instanceof RegExp)return[e?[e,n,!0]:[n,!0]];const t=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&t.push(e?[e,i,n[i]]:[i,n[i]]);return t}function $v(n,e,t){let i;return typeof n=="object"&&!(n instanceof RegExp)&&!Array.isArray(n)?(n.style!==void 0&&J("matcher-pattern-deprecated-attributes-style-key",n),n.class!==void 0&&J("matcher-pattern-deprecated-attributes-class-key",n)):i=["class","style"],e._collectAttributesMatch(qc(n),t,i)}function Wv(n,e,t){return e._collectAttributesMatch(qc(n,"class"),t)}function jv(n,e,t){return e._collectAttributesMatch(qc(n,"style"),t)}class so{constructor(e){h(this,"_styles"),h(this,"_cachedStyleNames",null),h(this,"_cachedExpandedStyleNames",null),h(this,"_styleProcessor"),this._styles={},this._styleProcessor=e}get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=qv(e);for(const[i,o]of t)this._styleProcessor.toNormalizedForm(i,o,this._styles);return this}has(e){if(this.isEmpty)return!1;const t=this._styleProcessor.getReducedForm(e,this._styles).find(([i])=>i===e);return Array.isArray(t)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,Et(e))for(const[i,o]of Object.entries(e))this._styleProcessor.toNormalizedForm(i,o,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){for(const t of he(e)){this._cachedStyleNames=null,this._cachedExpandedStyleNames=null;const i=Hl(t);v_(this._styles,i),delete this._styles[t],this._cleanEmptyObjectsOnPath(i)}}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this.getStylesEntries().map(e=>e.join(":")).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!Et(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find(([i])=>i===e);if(Array.isArray(t))return t[1]}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||(this._cachedExpandedStyleNames=this._styleProcessor.getStyleNames(this._styles)),this._cachedExpandedStyleNames):(this._cachedStyleNames||(this._cachedStyleNames=this.getStylesEntries().map(([t])=>t)),this._cachedStyleNames)}keys(){return this.getStyleNames()}clear(){this._styles={},this._cachedStyleNames=null,this._cachedExpandedStyleNames=null}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.getStyleNames())if(!e.has(t)||e.getAsString(t)!==this.getAsString(t))return!1;return!0}getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_clone(){const e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){const i=[];for(const o of this.getStyleNames(!0))if(Ir(e,o)){if(t===!0){i.push(o);continue}const s=this.getAsString(o);Ir(t,s)&&i.push(o)}return i.length?i:void 0}_getConsumables(e){const t=[];if(e){t.push(e);for(const i of this._styleProcessor.getRelatedStyles(e))t.push(i)}else for(const i of this.getStyleNames()){for(const o of this._styleProcessor.getRelatedStyles(i))t.push(o);t.push(i)}return t}_canMergeFrom(e){for(const t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(const t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(const t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),o=Ki(this._styles,i);o&&!Object.keys(o).length&&this.remove(i)}}class Uv{constructor(){h(this,"_normalizers"),h(this,"_extractors"),h(this,"_reducers"),h(this,"_consumables"),this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(Et(t)){Ba(i,Hl(e),t);return}if(this._normalizers.has(e)){const o=this._normalizers.get(e),{path:s,value:r}=o(t);Ba(i,s,r)}else Ba(i,e,t)}getNormalized(e,t){if(!e)return Nc({},t);if(t[e]!==void 0)return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if(typeof i=="string")return Ki(t,i);const o=i(e,t);if(o)return o}return Ki(t,Hl(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);return i===void 0?[]:this._reducers.has(e)?this._reducers.get(e)(i):[[e,i]]}getStyleNames(e){const t=new Set;for(const i of this._consumables.keys()){const o=this.getNormalized(i,e);o&&(typeof o!="object"||Object.keys(o).length)&&t.add(i)}for(const i of Object.keys(e))t.add(i);return Array.from(t)}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function qv(n){let e=null,t=0,i=0,o=null;const s=new Map;if(n==="")return s;n.charAt(n.length-1)!=";"&&(n=n+";");for(let r=0;r<n.length;r++){const a=n.charAt(r);if(e===null)switch(a){case":":o||(o=n.substr(t,r-t),i=r+1);break;case'"':case"'":e=a;break;case";":{const l=n.substr(i,r-i);o&&s.set(o.trim(),l.trim()),o=null,t=r+1;break}}else a===e&&(e=null)}return s}function Hl(n){return n.replace("-",".")}function Ba(n,e,t){let i=t;Et(t)&&(i=Nc({},Ki(n,e),t)),Ig(n,e,i)}class Ma{constructor(){h(this,"_set",new Set)}get isEmpty(){return this._set.size==0}get size(){return this._set.size}has(e){return this._set.has(e)}keys(){return Array.from(this._set.keys())}setTo(e){this.clear();for(const t of e.split(/\s+/))t&&this._set.add(t);return this}set(e){for(const t of he(e))t&&this._set.add(t)}remove(e){for(const t of he(e))this._set.delete(t)}clear(){this._set.clear()}toString(){return Array.from(this._set).join(" ")}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.keys())if(!e.has(t))return!1;return!0}_clone(){const e=new this.constructor;return e._set=new Set(this._set),e}_getTokensMatch(e){const t=[];if(e===!0){for(const i of this._set.keys())t.push(i);return t}if(typeof e=="string"){for(const i of e.split(/\s+/))if(this._set.has(i))t.push(i);else return;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}}let ai=class up extends An{constructor(e,t,i,o){super(e),h(this,"name"),h(this,"_unsafeAttributesToRender",[]),h(this,"_attrs"),h(this,"_children"),h(this,"_customProperties",new Map),this.name=t,this._attrs=this._parseAttributes(i),this._children=[],o&&this._insertChild(0,o)}get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}get childCount(){return this._children.length}get isEmpty(){return this._children.length===0}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes&&(yield"class"),this._styles&&(yield"style");for(const e of this._attrs.keys())e!="class"&&e!="style"&&(yield e)}*getAttributes(){for(const[e,t]of this._attrs.entries())yield[e,String(t)]}getAttribute(e){return this._attrs.has(e)?String(this._attrs.get(e)):void 0}hasAttribute(e,t){return this._attrs.has(e)?t!==void 0?Ln(this.name,e)||Eo(this.name,e)?this._attrs.get(e).has(t):this._attrs.get(e)===t:!0:!1}isSimilar(e){if(!(e instanceof up))return!1;if(this===e)return!0;if(this.name!=e.name||this._attrs.size!==e._attrs.size)return!1;for(const[t,i]of this._attrs){const o=e._attrs.get(t);if(o===void 0)return!1;if(typeof i=="string"||typeof o=="string"){if(o!==i)return!1}else if(!i.isSimilar(o))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 ft(...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(([o])=>o!="style"&&o!="class").map(o=>`${o[0]}="${o[1]}"`).sort().join(" ");return this.name+(e==""?"":` class="${e}"`)+(t?` style="${t}"`:"")+(i==""?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const o of this.getChildren())t.push(o._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this,{index:e});let i=0;const o=Gv(this.document,t);for(const s of o)s.parent!==null&&s._remove(),s.parent=this,s.document=this.document,this._children.splice(e,0,s),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let i=e;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),Ln(this.name,e)||Eo(this.name,e)){let o=this._attrs.get(e);o||(o=Ln(this.name,e)?new so(this.document.stylesProcessor):new Ma,this._attrs.set(e,o)),i?o.setTo(String(t)):Ln(this.name,e)?Array.isArray(t)?o.set(t[0],t[1]):o.set(t):o.set(typeof t=="string"?t.split(/\s+/):t)}else this._attrs.set(e,String(t))}_removeAttribute(e,t){if(this._fireChange("attributes",this),t!==void 0&&(Ln(this.name,e)||Eo(this.name,e))){const i=this._attrs.get(e);return i?(Eo(this.name,e)&&typeof t=="string"&&(t=t.split(/\s+/)),i.remove(t),i.isEmpty?this._attrs.delete(e):!1):!1}return this._attrs.delete(e)}_addClass(e){this._setAttribute("class",e,!1)}_removeClass(e){this._removeAttribute("class",e)}_setStyle(e,t){typeof e!="string"?this._setAttribute("style",e,!1):this._setAttribute("style",[e,t],!1)}_removeStyle(e){this._removeAttribute("style",e)}_collectAttributesMatch(e,t,i){for(const[o,s,r]of e){let a=!1,l=!1;for(const[c,u]of this._attrs)if(!(i&&i.includes(c)||!Ir(o,c)))if(a=!0,typeof u=="string"){if(Ir(s,u))t.push([c]),l=!0;else if(!(o instanceof RegExp))return!1}else{const d=u._getTokensMatch(s,r||!0);if(d){l=!0;for(const m of d)t.push([c,m])}else if(!(o instanceof RegExp))return!1}if(!a||!l)return!1}return!0}_getConsumables(e,t){const i=[];if(e){const o=this._attrs.get(e);if(o!==void 0)if(typeof o=="string")i.push([e]);else for(const s of o._getConsumables(t))i.push([e,s])}else for(const[o,s]of this._attrs)if(typeof s=="string")i.push([o]);else for(const r of s._getConsumables())i.push([o,r]);return{name:!e,attributes:i}}_canMergeAttributesFrom(e){if(this.name!=e.name)return!1;for(const[t,i]of e._attrs){const o=this._attrs.get(t);if(o!==void 0){if(typeof o=="string"||typeof i=="string"){if(o!==i)return!1}else if(!o._canMergeFrom(i))return!1}}return!0}_mergeAttributesFrom(e){this._fireChange("attributes",this);for(const[t,i]of e._attrs){const o=this._attrs.get(t);o===void 0||typeof o=="string"||typeof i=="string"?this._setAttribute(t,i):o._mergeFrom(i)}}_canSubtractAttributesOf(e){if(this.name!=e.name)return!1;for(const[t,i]of e._attrs){const o=this._attrs.get(t);if(o===void 0)return!1;if(typeof o=="string"||typeof i=="string"){if(o!==i)return!1}else if(!o._isMatching(i))return!1}return!0}_subtractAttributesOf(e){this._fireChange("attributes",this);for(const[t,i]of e._attrs){const o=this._attrs.get(t);typeof o=="string"||typeof i=="string"?this._attrs.delete(t):(o.remove(i.keys()),o.isEmpty&&this._attrs.delete(t))}}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}_parseAttributes(e){const t=ri(e);for(const[i,o]of t)if(o===null)t.delete(i);else if(Ln(this.name,i)){const s=o instanceof so?o._clone():new so(this.document.stylesProcessor).setTo(String(o));t.set(i,s)}else if(Eo(this.name,i)){const s=o instanceof Ma?o._clone():new Ma().setTo(String(o));t.set(i,s)}else typeof o!="string"&&t.set(i,String(o));return t}};ai.prototype.is=function(n,e){return e?e===this.name&&(n==="element"||n==="view:element"):n==="element"||n==="view:element"||n==="node"||n==="view:node"};function Gv(n,e){if(typeof e=="string")return[new Ge(n,e)];Pt(e)||(e=[e]);const t=[];for(const i of e)typeof i=="string"?t.push(new Ge(n,i)):i instanceof _i?t.push(new Ge(n,i.data)):t.push(i);return t}function Eo(n,e){return e=="class"||n=="a"&&e=="rel"}function Ln(n,e){return e=="style"}class ls extends ai{constructor(e,t,i,o){super(e,t,i,o),this.getFillerOffset=Kv}}ls.prototype.is=function(n,e){return e?e===this.name&&(n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"):n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function Kv(){const n=[...this.getChildren()],e=n[this.childCount-1];if(e&&e.is("element","br"))return this.childCount;for(const t of n)if(!t.is("uiElement"))return null;return this.childCount}class ra extends ue(ls){constructor(e,t,i,o){super(e,t,i,o),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",s=>s&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}}ra.prototype.is=function(n,e){return e?e===this.name&&(n==="editableElement"||n==="view:editableElement"||n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"):n==="editableElement"||n==="view:editableElement"||n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};const Ch=Symbol("rootName");class hp extends ra{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(Ch)}set rootName(e){this._setCustomProperty(Ch,e)}set _name(e){this.name=e}}hp.prototype.is=function(n,e){return e?e===this.name&&(n==="rootElement"||n==="view:rootElement"||n==="editableElement"||n==="view:editableElement"||n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"):n==="rootElement"||n==="view:rootElement"||n==="editableElement"||n==="view:editableElement"||n==="containerElement"||n==="view:containerElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};let bn=class{constructor(n={}){if(h(this,"direction"),h(this,"boundaries"),h(this,"singleCharacters"),h(this,"shallow"),h(this,"ignoreElementEnd"),h(this,"_position"),h(this,"_boundaryStartParent"),h(this,"_boundaryEndParent"),!n.boundaries&&!n.startPosition)throw new b("view-tree-walker-no-start-position",null);if(n.direction&&n.direction!="forward"&&n.direction!="backward")throw new b("view-tree-walker-unknown-direction",n.startPosition,{direction:n.direction});this.boundaries=n.boundaries||null,n.startPosition?this._position=V._createAt(n.startPosition):this._position=V._createAt(n.boundaries[n.direction=="backward"?"end":"start"]),this.direction=n.direction||"forward",this.singleCharacters=!!n.singleCharacters,this.shallow=!!n.shallow,this.ignoreElementEnd=!!n.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(n){let e,t;do t=this.position,e=this.next();while(!e.done&&n(e.value));e.done||(this._position=t)}jumpTo(n){this._boundaryStartParent&&n.isBefore(this.boundaries.start)?n=this.boundaries.start:this._boundaryEndParent&&n.isAfter(this.boundaries.end)&&(n=this.boundaries.end),this._position=n.clone()}next(){return this.direction=="forward"?this._next():this._previous()}_next(){let n=this.position.clone();const e=this.position,t=n.parent;if(t.parent===null&&n.offset===t.childCount)return{done:!0,value:void 0};if(t===this._boundaryEndParent&&n.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let i;if(t&&t.is("view:$text")){if(n.isAtEnd)return this._position=V._createAfter(t),this._next();i=t.data[n.offset]}else i=t.getChild(n.offset);if(typeof i=="string"){let o;this.singleCharacters?o=1:o=(t===this._boundaryEndParent?this.boundaries.end.offset:t.data.length)-n.offset;const s=new _i(t,n.offset,o);return n.offset+=o,this._position=n,this._formatReturnValue("text",s,e,n,o)}if(i&&i.is("view:element")){if(!this.shallow)n=new V(i,0);else{if(this.boundaries&&this.boundaries.end.isBefore(n))return{done:!0,value:void 0};n.offset++}return this._position=n,this._formatReturnValue("elementStart",i,e,n,1)}if(i&&i.is("view:$text")){if(this.singleCharacters)return n=new V(i,0),this._position=n,this._next();let o=i.data.length,s;return i==this._boundaryEndParent?(o=this.boundaries.end.offset,s=new _i(i,0,o),n=V._createAfter(s)):(s=new _i(i,0,i.data.length),n.offset++),this._position=n,this._formatReturnValue("text",s,e,n,o)}return n=V._createAfter(t),this._position=n,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",t,e,n)}_previous(){let n=this.position.clone();const e=this.position,t=n.parent;if(t.parent===null&&n.offset===0)return{done:!0,value:void 0};if(t==this._boundaryStartParent&&n.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let i;if(t.is("view:$text")){if(n.isAtStart)return this._position=V._createBefore(t),this._previous();i=t.data[n.offset-1]}else i=t.getChild(n.offset-1);if(typeof i=="string"){let o;if(this.singleCharacters)o=1;else{const r=t===this._boundaryStartParent?this.boundaries.start.offset:0;o=n.offset-r}n.offset-=o;const s=new _i(t,n.offset,o);return this._position=n,this._formatReturnValue("text",s,e,n,o)}if(i&&i.is("view:element"))return this.shallow?(n.offset--,this._position=n,this._formatReturnValue("elementStart",i,e,n,1)):(n=new V(i,i.childCount),this._position=n,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",i,e,n));if(i&&i.is("view:$text")){if(this.singleCharacters)return n=new V(i,i.data.length),this._position=n,this._previous();let o=i.data.length,s;if(i==this._boundaryStartParent){const r=this.boundaries.start.offset;s=new _i(i,r,i.data.length-r),o=s.data.length,n=V._createBefore(s)}else s=new _i(i,0,i.data.length),n.offset--;return this._position=n,this._formatReturnValue("text",s,e,n,o)}return n=V._createBefore(t),this._position=n,this._formatReturnValue("elementStart",t,e,n,1)}_formatReturnValue(n,e,t,i,o){return e.is("view:$textProxy")&&(e.offsetInText+e.data.length==e.textNode.data.length&&(this.direction=="forward"&&!(this.boundaries&&this.boundaries.end.isEqual(this.position))?(i=V._createAfter(e.textNode),this._position=i):t=V._createAfter(e.textNode)),e.offsetInText===0&&(this.direction=="backward"&&!(this.boundaries&&this.boundaries.start.isEqual(this.position))?(i=V._createBefore(e.textNode),this._position=i):t=V._createBefore(e.textNode))),{done:!1,value:{type:n,item:e,previousPosition:t,nextPosition:i,length:o}}}},V=class pi extends Cn{constructor(e,t){super(),h(this,"parent"),h(this,"offset"),this.parent=e,this.offset=t}get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return this.offset===0}get isAtEnd(){const e=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===e}get root(){return this.parent.root}get editableElement(){let e=this.parent;for(;!(e instanceof ra);)if(e.parent)e=e.parent;else return null;return e}getShiftedBy(e){const t=pi._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new bn(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let o=0;for(;t[o]==i[o]&&t[o];)o++;return o===0?null:t[o-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return this.compareWith(e)=="before"}isAfter(e){return this.compareWith(e)=="after"}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const o=Xe(t,i);switch(o){case"prefix":return"before";case"extension":return"after";default:return t[o]<i[o]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new bn(e)}clone(){return new pi(this.parent,this.offset)}static _createAt(e,t){if(e instanceof pi)return new this(e.parent,e.offset);{const i=e;if(t=="end")t=i.is("$text")?i.data.length:i.childCount;else{if(t=="before")return this._createBefore(i);if(t=="after")return this._createAfter(i);if(t!==0&&!t)throw new b("view-createpositionat-offset-required",i)}return new pi(i,t)}}static _createAfter(e){if(e.is("$textProxy"))return new pi(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new b("view-position-after-root",e,{root:e});return new pi(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new pi(e.textNode,e.offsetInText);if(!e.parent)throw new b("view-position-before-root",e,{root:e});return new pi(e.parent,e.index)}};V.prototype.is=function(n){return n==="position"||n==="view:position"};let Q=class Di extends Cn{constructor(e,t=null){super(),h(this,"start"),h(this,"end"),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(Ds,{direction:"backward"}),t=this.end.getLastMatchingPosition(Ds);return e.parent.is("$text")&&e.isAtStart&&(e=V._createBefore(e.parent)),t.parent.is("$text")&&t.isAtEnd&&(t=V._createAfter(t.parent)),new Di(e,t)}getTrimmed(){let e=this.start.getLastMatchingPosition(Ds);if(e.isAfter(this.end)||e.isEqual(this.end))return new Di(e,e);let t=this.end.getLastMatchingPosition(Ds,{direction:"backward"});const i=e.nodeAfter,o=t.nodeBefore;return i&&i.is("$text")&&(e=new V(i,0)),o&&o.is("$text")&&(t=new V(o,o.data.length)),new Di(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),o=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&o}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new Di(this.start,e.start)),this.containsPosition(e.end)&&t.push(new Di(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 Di(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 Di(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new bn(e);for(const i of t)yield i.item}*getPositions(e={}){e.boundaries=this;const t=new bn(e);yield t.position;for(const i of t)yield i.nextPosition}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}static _createFromParentsAndOffsets(e,t,i,o){return new this(new V(e,t),new V(i,o))}static _createFromPositionAndShift(e,t){const i=e,o=e.getShiftedBy(t);return t>0?new this(i,o):new this(o,i)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(V._createBefore(e),t)}};Q.prototype.is=function(n){return n==="range"||n==="view:range"};function Ds(n){return!!(n.item.is("attributeElement")||n.item.is("uiElement"))}let ki=class dp extends ge(Cn){constructor(...e){super(),h(this,"_ranges"),h(this,"_lastRangeBackward"),h(this,"_isFake"),h(this,"_fakeSelectionLabel"),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return this.rangeCount===1&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake||this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel||this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const o of e._ranges)if(t.isEqual(o)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Ml(this.getRanges()),i=Ml(e.getRanges());if(t!=i)return!1;if(t==0)return!0;for(let o of this.getRanges()){o=o.getTrimmed();let s=!1;for(let r of e.getRanges())if(r=r.getTrimmed(),o.start.isEqual(r.start)&&o.end.isEqual(r.end)){s=!0;break}if(!s)return!1}return!0}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,o]=e;if(typeof i=="object"&&(o=i,i=void 0),t===null)this._setRanges([]),this._setFakeOptions(o);else if(t instanceof dp||t instanceof Gc)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Q)this._setRanges([t],o&&o.backward),this._setFakeOptions(o);else if(t instanceof V)this._setRanges([new Q(t)]),this._setFakeOptions(o);else if(t instanceof An){const s=!!o&&!!o.backward;let r;if(i===void 0)throw new b("view-selection-setto-required-second-parameter",this);i=="in"?r=Q._createIn(t):i=="on"?r=Q._createOn(t):r=new Q(V._createAt(t,i)),this._setRanges([r],s),this._setFakeOptions(o)}else if(Pt(t))this._setRanges(t,o&&o.backward),this._setFakeOptions(o);else throw new b("view-selection-setto-not-selectable",this);this.fire("change")}setFocus(e,t){if(this.anchor===null)throw new b("view-selection-setfocus-no-ranges",this);const i=V._createAt(e,t);if(i.compareWith(this.focus)=="same")return;const o=this.anchor;this._ranges.pop(),i.compareWith(o)=="before"?this._addRange(new Q(i,o),!0):this._addRange(new Q(o,i)),this.fire("change")}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const i of e)this._addRange(i);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof Q))throw new b("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(const t of this._ranges)if(e.isIntersecting(t))throw new b("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Q(e.start,e.end))}};ki.prototype.is=function(n){return n==="selection"||n==="view:selection"};let Gc=class extends ge(Cn){constructor(...n){super(),h(this,"_selection"),this._selection=new ki,this._selection.delegate("change").to(this),n.length&&this._selection.setTo(...n)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(n){return this._selection.isEqual(n)}isSimilar(n){return this._selection.isSimilar(n)}_setTo(...n){this._selection.setTo(...n)}_setFocus(n,e){this._selection.setFocus(n,e)}};Gc.prototype.is=function(n){return n==="selection"||n=="documentSelection"||n=="view:selection"||n=="view:documentSelection"};class xn extends Ti{constructor(e,t,i){super(e,t),h(this,"startRange"),h(this,"_eventPhase"),h(this,"_currentTarget"),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const La=Symbol("bubbling contexts");function $l(n){class e extends n{fire(i,...o){try{const s=i instanceof Ti?i:new Ti(this,i),r=Fa(this);if(!r.size)return;if(So(s,"capturing",this),Fn(r,"$capture",s,...o))return s.return;const a=s.startRange||this.selection.getFirstRange(),l=a?a.getContainedElement():null,c=l?!!mp(r,l):!1;let u=l||Zv(a);if(So(s,"atTarget",u),!c){if(Fn(r,"$text",s,...o))return s.return;So(s,"bubbling",u)}for(;u;){if(u.is("rootElement")){if(Fn(r,"$root",s,...o))return s.return}else if(u.is("element")&&Fn(r,u.name,s,...o))return s.return;if(Fn(r,u,s,...o))return s.return;u=u.parent,So(s,"bubbling",u)}return So(s,"bubbling",this),Fn(r,"$document",s,...o),s.return}catch(s){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(s,this)}}_addEventListener(i,o,s){const r=he(s.context||"$document"),a=Fa(this);for(const l of r){let c=a.get(l);c||(c=new(ge()),a.set(l,c)),this.listenTo(c,i,o,s)}}_removeEventListener(i,o){const s=Fa(this);for(const r of s.values())this.stopListening(r,i,o)}}return e}{const n=$l(Object);["fire","_addEventListener","_removeEventListener"].forEach(e=>{$l[e]=n.prototype[e]})}function So(n,e,t){n instanceof xn&&(n._eventPhase=e,n._currentTarget=t)}function Fn(n,e,t,...i){const o=typeof e=="string"?n.get(e):mp(n,e);return o?(o.fire(t,...i),t.stop.called):!1}function mp(n,e){for(const[t,i]of n)if(typeof t=="function"&&t(e))return i;return null}function Fa(n){return n[La]||(n[La]=new Map),n[La]}function Zv(n){if(!n)return null;const e=n.start.parent,t=n.end.parent,i=e.getPath(),o=t.getPath();return i.length>o.length?e:t}let aa=class extends $l(ue()){constructor(n){super(),h(this,"selection"),h(this,"roots"),h(this,"stylesProcessor"),h(this,"_postFixers",new Set),this.selection=new Gc,this.roots=new _e({idProperty:"rootName"}),this.stylesProcessor=n,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(n="main"){return this.roots.get(n)}registerPostFixer(n){this._postFixers.add(n)}destroy(){this.roots.forEach(n=>n.destroy()),this.stopListening()}_callPostFixers(n){let e=!1;do for(const t of this._postFixers)if(e=t(n),e)break;while(e)}};const fp=10;class _n extends ai{constructor(e,t,i,o){super(e,t,i,o),h(this,"_priority",fp),h(this,"_id",null),h(this,"_clonesGroup",null),this.getFillerOffset=Jv}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(this.id===null)throw new b("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return this.id!==null||e.id!==null?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canSubtractAttributesOf(e)}}h(_n,"DEFAULT_PRIORITY",fp);_n.prototype.is=function(n,e){return e?e===this.name&&(n==="attributeElement"||n==="view:attributeElement"||n==="element"||n==="view:element"):n==="attributeElement"||n==="view:attributeElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function Jv(){if(Na(this))return null;let n=this.parent;for(;n&&n.is("attributeElement");){if(Na(n)>1)return null;n=n.parent}return!n||Na(n)>1?null:this.childCount}function Na(n){return Array.from(n.getChildren()).filter(e=>!e.is("uiElement")).length}class Kc extends ai{constructor(e,t,i,o){super(e,t,i,o),this.getFillerOffset=Qv}_insertChild(e,t){if(t&&(t instanceof An||Array.from(t).length>0))throw new b("view-emptyelement-cannot-add",[this,t]);return 0}}Kc.prototype.is=function(n,e){return e?e===this.name&&(n==="emptyElement"||n==="view:emptyElement"||n==="element"||n==="view:element"):n==="emptyElement"||n==="view:emptyElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function Qv(){return null}class la extends ai{constructor(e,t,i,o){super(e,t,i,o),this.getFillerOffset=Xv}_insertChild(e,t){if(t&&(t instanceof An||Array.from(t).length>0))throw new b("view-uielement-cannot-add",[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){const t=e.createElement(this.name);for(const i of this.getAttributeKeys())t.setAttribute(i,this.getAttribute(i));return t}}la.prototype.is=function(n,e){return e?e===this.name&&(n==="uiElement"||n==="view:uiElement"||n==="element"||n==="view:element"):n==="uiElement"||n==="view:uiElement"||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function Yv(n){n.document.on("arrowKey",(e,t)=>ey(e,t,n.domConverter),{priority:"low"})}function Xv(){return null}function ey(n,e,t){if(e.keyCode==Z.arrowright){const i=e.domTarget.ownerDocument.defaultView.getSelection(),o=i.rangeCount==1&&i.getRangeAt(0).collapsed;if(o||e.shiftKey){const s=i.focusNode,r=i.focusOffset,a=t.domPositionToView(s,r);if(a===null)return;let l=!1;const c=a.getLastMatchingPosition(u=>(u.item.is("uiElement")&&(l=!0),!!(u.item.is("uiElement")||u.item.is("attributeElement"))));if(l){const u=t.viewPositionToDom(c);o?i.collapse(u.parent,u.offset):i.extend(u.parent,u.offset)}}}}class Zc extends ai{constructor(e,t,i,o){super(e,t,i,o),this.getFillerOffset=ty}_insertChild(e,t){if(t&&(t instanceof An||Array.from(t).length>0))throw new b("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}Zc.prototype.is=function(n,e){return e?e===this.name&&(n==="rawElement"||n==="view:rawElement"||n==="element"||n==="view:element"):n==="rawElement"||n==="view:rawElement"||n===this.name||n==="view:"+this.name||n==="element"||n==="view:element"||n==="node"||n==="view:node"};function ty(){return null}let vn=class extends ge(Cn){constructor(n,e){super(),h(this,"document"),h(this,"_children",[]),h(this,"_customProperties",new Map),this.document=n,e&&this._insertChild(0,e)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return this.childCount===0}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(n){return this._customProperties.get(n)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(n){return this._insertChild(this.childCount,n)}getChild(n){return this._children[n]}getChildIndex(n){return this._children.indexOf(n)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(n,e){this._fireChange("children",this,{index:n});let t=0;const i=iy(this.document,e);for(const o of i)o.parent!==null&&o._remove(),o.parent=this,this._children.splice(n,0,o),n++,t++;return t}_removeChildren(n,e=1){this._fireChange("children",this,{index:n});for(let t=n;t<n+e;t++)this._children[t].parent=null;return this._children.splice(n,e)}_fireChange(n,e,t){this.fire(`change:${n}`,e,t)}_setCustomProperty(n,e){this._customProperties.set(n,e)}_removeCustomProperty(n){return this._customProperties.delete(n)}};vn.prototype.is=function(n){return n==="documentFragment"||n==="view:documentFragment"};function iy(n,e){return typeof e=="string"?[new Ge(n,e)]:(Pt(e)||(e=[e]),Array.from(e).map(t=>typeof t=="string"?new Ge(n,t):t instanceof _i?new Ge(n,t.data):t))}class gp{constructor(e){h(this,"document"),h(this,"_cloneGroups",new Map),h(this,"_slotFactory",null),this.document=e}setSelection(...e){this.document.selection._setTo(...e)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new vn(this.document,e)}createText(e){return new Ge(this.document,e)}createAttributeElement(e,t,i={}){const o=new _n(this.document,e,t);return typeof i.priority=="number"&&(o._priority=i.priority),i.id&&(o._id=i.id),i.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),o}createContainerElement(e,t,i={},o={}){let s=null;Ut(i)?o=i:s=i;const r=new ls(this.document,e,t,s);return o.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...o.renderUnsafeAttributes),r}createEditableElement(e,t,i={}){const o=new ra(this.document,e,t);return i.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),o}createEmptyElement(e,t,i={}){const o=new Kc(this.document,e,t);return i.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),o}createUIElement(e,t,i){const o=new la(this.document,e,t);return i&&(o.render=i),o}createRawElement(e,t,i,o={}){const s=new Zc(this.document,e,t);return i&&(s.render=i),o.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...o.renderUnsafeAttributes),s}setAttribute(e,t,i,o){o!==void 0?o._setAttribute(e,t,i):i._setAttribute(e,t)}removeAttribute(e,t,i){i!==void 0?i._removeAttribute(e,t):t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){Ut(e)&&i===void 0?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof V?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new b("view-writer-break-non-container-element",this.document);if(!t.parent)throw new b("view-writer-break-root",this.document);if(e.isAtStart)return V._createBefore(t);if(!e.isAtEnd){const i=t._clone(!1);this.insert(V._createAfter(t),i);const o=new Q(e,V._createAt(t,"end")),s=new V(i,0);this.move(o,s)}return V._createAfter(t)}mergeAttributes(e){const t=e.offset,i=e.parent;if(i.is("$text"))return e;if(i.is("attributeElement")&&i.childCount===0){const r=i.parent,a=i.index;return i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new V(r,a))}const o=i.getChild(t-1),s=i.getChild(t);if(!o||!s)return e;if(o.is("$text")&&s.is("$text"))return xh(o,s);if(o.is("attributeElement")&&s.is("attributeElement")&&o.isSimilar(s)){const r=o.childCount;return o._appendChild(s.getChildren()),s._remove(),this._removeFromClonedElementsGroup(s),this.mergeAttributes(new V(o,r))}return e}mergeContainers(e){const t=e.nodeBefore,i=e.nodeAfter;if(!t||!i||!t.is("containerElement")||!i.is("containerElement"))throw new b("view-writer-merge-containers-invalid-position",this.document);const o=t.getChild(t.childCount-1),s=o instanceof Ge?V._createAt(o,"end"):V._createAt(t,"end");return this.move(Q._createIn(i),V._createAt(t,"end")),this.remove(Q._createOn(i)),s}insert(e,t){t=Pt(t)?[...t]:[t],pp(t,this.document);const i=t.reduce((r,a)=>{const l=r[r.length-1],c=!a.is("uiElement");return!l||l.breakAttributes!=c?r.push({breakAttributes:c,nodes:[a]}):l.nodes.push(a),r},[]);let o=null,s=e;for(const{nodes:r,breakAttributes:a}of i){const l=this._insertNodes(s,r,a);o||(o=l.start),s=l.end}return o?new Q(o,s):new Q(e)}remove(e){const t=e instanceof Q?e:Q._createOn(e);if(Po(t,this.document),t.isCollapsed)return new vn(this.document);const{start:i,end:o}=this._breakAttributesRange(t,!0),s=i.parent,r=o.offset-i.offset,a=s._removeChildren(i.offset,r);for(const c of a)this._removeFromClonedElementsGroup(c);const l=this.mergeAttributes(i);return t.start=l,t.end=l.clone(),new vn(this.document,a)}clear(e,t){Po(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const o of i){const s=o.item;let r;if(s.is("element")&&t.isSimilar(s))r=Q._createOn(s);else if(!o.nextPosition.isAfter(e.start)&&s.is("$textProxy")){const a=s.getAncestors().find(l=>l.is("element")&&t.isSimilar(l));a&&(r=Q._createIn(a))}r&&(r.end.isAfter(e.end)&&(r.end=e.end),r.start.isBefore(e.start)&&(r.start=e.start),this.remove(r))}}move(e,t){let i;if(t.isAfter(e.end)){t=this._breakAttributes(t,!0);const o=t.parent,s=o.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=o.childCount-s}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof _n))throw new b("view-writer-wrap-invalid-attribute",this.document);if(Po(e,this.document),e.isCollapsed){let i=e.start;i.parent.is("element")&&!ny(i.parent)&&(i=i.getLastMatchingPosition(s=>s.item.is("uiElement"))),i=this._wrapPosition(i,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(i),new Q(i)}else return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof _n))throw new b("view-writer-unwrap-invalid-attribute",this.document);if(Po(e,this.document),e.isCollapsed)return e;const{start:i,end:o}=this._breakAttributesRange(e,!0),s=i.parent,r=this._unwrapChildren(s,i.offset,o.offset,t),a=this.mergeAttributes(r.start);a.isEqual(r.start)||r.end.offset--;const l=this.mergeAttributes(r.end);return new Q(a,l)}rename(e,t){const i=new ls(this.document,e,t.getAttributes());return this.insert(V._createAfter(t),i),this.move(Q._createIn(t),V._createAt(i,0)),this.remove(Q._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return V._createAt(e,t)}createPositionAfter(e){return V._createAfter(e)}createPositionBefore(e){return V._createBefore(e)}createRange(e,t){return new Q(e,t)}createRangeOn(e){return Q._createOn(e)}createRangeIn(e){return Q._createIn(e)}createSelection(...e){return new ki(...e)}createSlot(e="children"){if(!this._slotFactory)throw new b("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let o;if(i?o=Wl(e):o=e.parent.is("$text")?e.parent.parent:e.parent,!o)throw new b("view-writer-invalid-position-container",this.document);let s;i?s=this._breakAttributes(e,!0):s=e.parent.is("$text")?Da(e):e;const r=o._insertChild(s.offset,t);for(const u of t)this._addToClonedElementsGroup(u);const a=s.getShiftedBy(r),l=this.mergeAttributes(s);l.isEqual(s)||a.offset--;const c=this.mergeAttributes(a);return new Q(l,c)}_wrapChildren(e,t,i,o){let s=t;const r=[];for(;s<i;){const l=e.getChild(s),c=l.is("$text"),u=l.is("attributeElement");if(u&&l._canMergeAttributesFrom(o))l._mergeAttributesFrom(o),r.push(new V(e,s));else if(c||!u||oy(o,l)){const d=o._clone();l._remove(),d._appendChild(l),e._insertChild(s,d),this._addToClonedElementsGroup(d),r.push(new V(e,s))}else this._wrapChildren(l,0,l.childCount,o);s++}let a=0;for(const l of r)l.offset-=a,l.offset!=t&&(this.mergeAttributes(l).isEqual(l)||(a++,i--));return Q._createFromParentsAndOffsets(e,t,e,i)}_unwrapChildren(e,t,i,o){let s=t;const r=[];for(;s<i;){const l=e.getChild(s);if(!l.is("attributeElement")){s++;continue}if(l.isSimilar(o)){const c=l.getChildren(),u=l.childCount;l._remove(),e._insertChild(s,c),this._removeFromClonedElementsGroup(l),r.push(new V(e,s),new V(e,s+u)),s+=u,i+=u-1;continue}if(l._canSubtractAttributesOf(o)){l._subtractAttributesOf(o),r.push(new V(e,s),new V(e,s+1)),s++;continue}this._unwrapChildren(l,0,l.childCount,o),s++}let a=0;for(const l of r)l.offset-=a,!(l.offset==t||l.offset==i)&&(this.mergeAttributes(l).isEqual(l)||(a++,i--));return Q._createFromParentsAndOffsets(e,t,e,i)}_wrapRange(e,t){const{start:i,end:o}=this._breakAttributesRange(e,!0),s=i.parent,r=this._wrapChildren(s,i.offset,o.offset,t),a=this.mergeAttributes(r.start);a.isEqual(r.start)||r.end.offset--;const l=this.mergeAttributes(r.end);return new Q(a,l)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return Ah(e.clone());e.parent.is("$text")&&(e=Da(e));const i=this.createAttributeElement("_wrapPosition-fake-element");i._priority=Number.POSITIVE_INFINITY,i.isSimilar=()=>!1,e.parent._insertChild(e.offset,i);const o=new Q(e,e.getShiftedBy(1));this.wrap(o,t);const s=new V(i.parent,i.index);i._remove();const r=s.nodeBefore,a=s.nodeAfter;return r&&r.is("view:$text")&&a&&a.is("view:$text")?xh(r,a):Ah(s)}_breakAttributesRange(e,t=!1){const i=e.start,o=e.end;if(Po(e,this.document),e.isCollapsed){const l=this._breakAttributes(e.start,t);return new Q(l,l)}const s=this._breakAttributes(o,t),r=s.parent.childCount,a=this._breakAttributes(i,t);return s.offset+=s.parent.childCount-r,new Q(a,s)}_breakAttributes(e,t=!1){const i=e.offset,o=e.parent;if(e.parent.is("emptyElement"))throw new b("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new b("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new b("view-writer-cannot-break-raw-element",this.document);if(!t&&o.is("$text")&&jl(o.parent)||jl(o))return e.clone();if(o.is("$text"))return this._breakAttributes(Da(e),t);const s=o.childCount;if(i==s){const r=new V(o.parent,o.index+1);return this._breakAttributes(r,t)}else if(i===0){const r=new V(o.parent,o.index);return this._breakAttributes(r,t)}else{const r=o.index+1,a=o._clone();o.parent._insertChild(r,a),this._addToClonedElementsGroup(a);const l=o.childCount-i,c=o._removeChildren(i,l);a._appendChild(c);const u=new V(o.parent,r);return this._breakAttributes(u,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const o of e.getChildren())this._addToClonedElementsGroup(o);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const o of e.getChildren())this._removeFromClonedElementsGroup(o);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function ny(n){return Array.from(n.getChildren()).some(e=>!e.is("uiElement"))}function Wl(n){let e=n.parent;for(;!jl(e);){if(!e)return;e=e.parent}return e}function oy(n,e){return n.priority<e.priority?!0:n.priority>e.priority?!1:n.getIdentity()<e.getIdentity()}function Ah(n){const e=n.nodeBefore;if(e&&e.is("$text"))return new V(e,e.data.length);const t=n.nodeAfter;return t&&t.is("$text")?new V(t,0):n}function Da(n){if(n.offset==n.parent.data.length)return new V(n.parent.parent,n.parent.index+1);if(n.offset===0)return new V(n.parent.parent,n.parent.index);const e=n.parent.data.slice(n.offset);return n.parent._data=n.parent.data.slice(0,n.offset),n.parent.parent._insertChild(n.parent.index+1,new Ge(n.root.document,e)),new V(n.parent.parent,n.parent.index+1)}function xh(n,e){const t=n.data.length;return n._data+=e.data,e._remove(),new V(n,t)}const sy=[Ge,_n,ls,Kc,Zc,la];function pp(n,e){for(const t of n){if(!sy.some(i=>t instanceof i))throw new b("view-writer-insert-invalid-node-type",e);t.is("$text")||pp(t.getChildren(),e)}}function jl(n){return n&&(n.is("containerElement")||n.is("documentFragment"))}function Po(n,e){const t=Wl(n.start),i=Wl(n.end);if(!t||!i||t!==i)throw new b("view-writer-invalid-range-container",e)}const wp=n=>n.createTextNode(" "),bp=n=>{const e=n.createElement("span");return e.dataset.ckeFiller="true",e.innerText=" ",e},_p=n=>{const e=n.createElement("br");return e.dataset.ckeFiller="true",e},Ct=7,cs="⁠".repeat(Ct);function it(n){return typeof n=="string"?n.substr(0,Ct)===cs:xe(n)&&n.data.substr(0,Ct)===cs}function io(n){return n.data.length==Ct&&it(n)}function Th(n){const e=typeof n=="string"?n:n.data;return it(n)?e.slice(Ct):e}function ry(n){n.document.on("arrowKey",ay,{priority:"low"})}function ay(n,e){if(e.keyCode==Z.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(t.rangeCount==1&&t.getRangeAt(0).collapsed){const i=t.getRangeAt(0).startContainer,o=t.getRangeAt(0).startOffset;it(i)&&o<=Ct&&t.collapse(i,0)}}}class ly extends ue(){constructor(e,t){super(),h(this,"domDocuments",new Set),h(this,"domConverter"),h(this,"markedAttributes",new Set),h(this,"markedChildren",new Set),h(this,"markedTexts",new Set),h(this,"selection"),h(this,"_inlineFiller",null),h(this,"_fakeSelectionContainer",null),this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),N.isBlink&&!N.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}markToSync(e,t){if(e==="text")this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if(e==="attributes")this.markedAttributes.add(t);else if(e==="children")this.markedChildren.add(t);else throw new b("view-renderer-unknown-type",this)}}render(){if(this.isComposing&&!N.isAndroid)return;let e=null;const t=N.isBlink&&!N.isAndroid?!this.isSelecting:!0;for(const i of this.markedChildren)this._updateChildrenMappings(i);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=V._createBefore(e.parent)));for(const i of this.markedAttributes)this._updateAttrs(i);for(const i of this.markedChildren)this._updateChildren(i,{inlineFillerPosition:e});for(const i of this.markedTexts)!this.markedChildren.has(i.parent)&&this.domConverter.mapViewToDom(i.parent)&&this._updateText(i,{inlineFillerPosition:e});if(t)if(e){const i=this.domConverter.viewPositionToDom(e),o=i.parent.ownerDocument;it(i.parent)?this._inlineFiller=i.parent:this._inlineFiller=Eh(o,i.parent,i.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.childNodes),o=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),s=this._diffNodeLists(i,o),r=this._findUpdateActions(s,i,o,uy);if(r.indexOf("update")!==-1){const a={equal:0,insert:0,delete:0};for(const l of r)if(l==="update"){const c=a.equal+a.insert,u=a.equal+a.delete,d=e.getChild(c);d&&!d.is("uiElement")&&!d.is("rawElement")&&this._updateElementMappings(d,i[u]),mh(o[c]),a.equal++}else a[l]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?V._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&xe(t.parent)&&it(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!it(e))throw new b("view-renderer-filler-was-lost",this);io(e)?e.remove():e.data=e.data.substr(Ct),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root)||!t.is("element")||!cy(t))return!1;const o=e.nodeBefore,s=e.nodeAfter;return!(o instanceof Ge||s instanceof Ge||i===t.getFillerOffset()&&(!o||!o.is("element","br"))||N.isAndroid&&(o||s))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let o=this.domConverter.viewToDom(e).data;const s=t.inlineFillerPosition;s&&s.parent==e.parent&&s.offset==e.index&&(o=cs+o),this._updateTextNode(i,o)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(t){for(const i of Array.from(t.attributes)){const o=i.name;e.hasAttribute(o)||this.domConverter.removeDomElementAttribute(t,o)}for(const i of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e)}}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;if(N.isAndroid){let d=null;for(const m of Array.from(i.childNodes)){if(d&&xe(d)&&xe(m)){i.normalize();break}d=m}}const o=t.inlineFillerPosition,s=i.childNodes,r=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));o&&o.parent===e&&Eh(i.ownerDocument,r,o.offset);const a=this._diffNodeLists(s,r),l=this._findUpdateActions(a,s,r,hy);let c=0;const u=new Set;for(const d of l)d==="delete"?(u.add(s[c]),mh(s[c])):(d==="equal"||d==="update")&&c++;c=0;for(const d of l)d==="insert"?(ep(i,c,r[c]),c++):d==="update"?(this._updateTextNode(s[c],r[c].data),c++):d==="equal"&&(this._markDescendantTextToSync(this.domConverter.domToView(r[c])),c++);for(const d of u)d.parentNode||this.domConverter.unbindDomElement(d)}_diffNodeLists(e,t){return e=fy(e,this._fakeSelectionContainer),oo(e,t,dy.bind(null,this.domConverter))}_findUpdateActions(e,t,i,o){if(e.indexOf("insert")===-1||e.indexOf("delete")===-1)return e;let s=[],r=[],a=[];const l={equal:0,insert:0,delete:0};for(const c of e)c==="insert"?a.push(i[l.equal+l.insert]):c==="delete"?r.push(t[l.equal+l.delete]):(s=s.concat(oo(r,a,o).map(u=>u==="equal"?"update":u)),s.push("equal"),r=[],a=[]),l[c]++;return s.concat(oo(r,a,o).map(c=>c==="equal"?"update":c))}_updateTextNode(e,t){const i=e.data;i!=t&&(N.isAndroid&&this.isComposing&&i.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){const i=Lg(e.data,t);for(const o of i)o.type==="insert"?e.insertData(o.index,o.values.join("")):e.deleteData(o.index,o.howMany)}_markDescendantTextToSync(e){if(e){if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}}_updateSelection(){if(N.isBlink&&!N.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(this.selection.rangeCount===0){this._removeDomSelection(),this._removeFakeSelection();return}const e=this.domConverter.mapViewToDom(this.selection.editableElement);if(!this.isFocused||!e){!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection();return}this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&N.isAndroid||this._updateDomSelection(e)}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=gy(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;(!i.parentElement||i.parentElement!=e)&&e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const o=t.getSelection(),s=t.createRange();o.removeAllRanges(),s.selectNodeContents(i),o.addRange(s)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),o=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,o.parent,o.offset),N.isGecko&&my(o,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||i.anchorNode!==t&&!t.contains(i.anchorNode)?!0:t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,o=this.domConverter.mapDomToView(i);i&&o&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function cy(n){if(n.getAttribute("contenteditable")=="false")return!1;const e=n.findAncestor(t=>t.hasAttribute("contenteditable"));return!e||e.getAttribute("contenteditable")=="true"}function Eh(n,e,t){const i=e instanceof Array?e:e.childNodes,o=i[t];if(xe(o))return o.data=cs+o.data,o;{const s=n.createTextNode(cs);return Array.isArray(e)?i.splice(t,0,s):ep(e,t,s),s}}function uy(n,e){return Zi(n)&&Zi(e)&&!xe(n)&&!xe(e)&&!Qo(n)&&!Qo(e)&&n.tagName.toLowerCase()===e.tagName.toLowerCase()}function hy(n,e){return Zi(n)&&Zi(e)&&xe(n)&&xe(e)}function dy(n,e,t){return e===t?!0:xe(e)&&xe(t)?e.data===t.data:!!(n.isBlockFiller(e)&&n.isBlockFiller(t))}function my(n,e){let t=n.parent,i=n.offset;if(xe(t)&&io(t)&&(i=to(t)+1,t=t.parentNode),t.nodeType!=Node.ELEMENT_NODE||i!=t.childNodes.length-1)return;const o=t.childNodes[i];o&&o.tagName=="BR"&&e.addRange(e.getRangeAt(0))}function fy(n,e){const t=Array.from(n);return t.length==0||!e||t[t.length-1]==e&&t.pop(),t}function gy(n){const e=n.createElement("div");return e.className="ck-fake-selection-container",Object.assign(e.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),e.textContent=" ",e}const py=_p(I.document),wy=wp(I.document),by=bp(I.document),zs="data-ck-unsafe-attribute-",Sh="data-ck-unsafe-element";class ca{constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){h(this,"document"),h(this,"renderingMode"),h(this,"blockFillerMode"),h(this,"preElements"),h(this,"blockElements"),h(this,"inlineObjectElements"),h(this,"unsafeElements"),h(this,"_domDocument"),h(this,"_domToViewMapping",new WeakMap),h(this,"_viewToDomMapping",new WeakMap),h(this,"_fakeSelectionMapping",new WeakMap),h(this,"_rawContentElementMatcher",new ft),h(this,"_inlineObjectElementMatcher",new ft),h(this,"_elementsWithTemporaryCustomProperties",new Set),this.document=e,this.renderingMode=i,this.blockFillerMode=t||(i==="editing"?"br":"nbsp"),this.preElements=["pre","textarea"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument=this.renderingMode==="editing"?I.document:I.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new ki(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const i of e.children)this.unbindDomElement(i)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return this.renderingMode==="data"?!0:(e=e.toLowerCase(),e.startsWith("on")||e==="srcdoc"&&t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i)?!1:i==="img"&&(e==="src"||e==="srcset")||i==="source"&&e==="srcset"?!0:!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){if(this.renderingMode==="data"){e.innerHTML=t;return}const i=new DOMParser().parseFromString(t,"text/html"),o=i.createDocumentFragment(),s=i.body.childNodes;for(;s.length>0;)o.appendChild(s[0]);const r=i.createTreeWalker(o,NodeFilter.SHOW_ELEMENT),a=[];let l;for(;l=r.nextNode();)a.push(l);for(const c of a){for(const d of c.getAttributeNames())this.setDomElementAttribute(c,d,c.getAttribute(d));const u=c.tagName.toLowerCase();this._shouldRenameElement(u)&&(Rh(u),c.replaceWith(this._createReplacementDomElement(u,c)))}for(;e.firstChild;)e.firstChild.remove();e.append(o)}viewToDom(e,t={}){if(e.is("$text")){const i=this._processDataFromViewText(e);return this._domDocument.createTextNode(i)}else{const i=e;if(this.mapViewToDom(i))if(i.getCustomProperty("editingPipeline:doNotReuseOnce"))this._elementsWithTemporaryCustomProperties.add(i);else return this.mapViewToDom(i);let o;if(i.is("documentFragment"))o=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(o,i);else{if(i.is("uiElement"))return i.name==="$comment"?o=this._domDocument.createComment(i.getCustomProperty("$rawContent")):o=i.render(this._domDocument,this),t.bind&&this.bindElements(o,i),o;this._shouldRenameElement(i.name)?(Rh(i.name),o=this._createReplacementDomElement(i.name)):i.hasAttribute("xmlns")?o=this._domDocument.createElementNS(i.getAttribute("xmlns"),i.name):o=this._domDocument.createElement(i.name),i.is("rawElement")&&i.render(o,this),t.bind&&this.bindElements(o,i);for(const s of i.getAttributeKeys())this.setDomElementAttribute(o,s,i.getAttribute(s),i)}if(t.withChildren!==!1)for(const s of this.viewChildrenToDom(i,t))o instanceof HTMLTemplateElement?o.content.appendChild(s):o.appendChild(s);return o}}setDomElementAttribute(e,t,i,o){const s=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||o&&o.shouldRenderUnsafeAttribute(t);if(s||J("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),!tp(t)){J("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i});return}e.hasAttribute(t)&&!s?e.removeAttribute(t):e.hasAttribute(zs+t)&&s&&e.removeAttribute(zs+t),e.setAttribute(s?t:zs+t,i)}removeDomElementAttribute(e,t){t!=Sh&&(e.removeAttribute(t),e.removeAttribute(zs+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let o=0;for(const s of e.getChildren()){i===o&&(yield this._getBlockFiller());const r=s.is("element")&&!!s.getCustomProperty("dataPipeline:transparentRendering")&&!ae(s.getAttributes());if(r&&this.renderingMode=="data")if(s.is("rawElement")){const a=this._domDocument.createElement(s.name);s.render(a,this),yield*[...a.childNodes]}else yield*this.viewChildrenToDom(s,t);else r&&J("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:s}),yield this.viewToDom(s,t);o++}i===o&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),o=this._domDocument.createRange();return o.setStart(t.parent,t.offset),o.setEnd(i.parent,i.offset),o}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let o=e.offset;return it(i)&&(o+=Ct),{parent:i,offset:o}}else{let i,o,s;if(e.offset===0){if(i=this.mapViewToDom(t),!i)return null;s=i.childNodes[0]}else{const a=e.nodeBefore;if(o=a.is("$text")?this.findCorrespondingDomText(a):this.mapViewToDom(a),!o)return null;i=o.parentNode,s=o.nextSibling}if(xe(s)&&it(s))return{parent:s,offset:Ct};const r=o?to(o)+1:0;return{parent:i,offset:r}}}domToView(e,t={}){const i=[],o=this._domToView(e,t,i),s=o.next().value;return!s||(o.next(),this._processDomInlineNodes(null,i,t),this.blockFillerMode=="br"&&Ih(s))||s.is("$text")&&s.data.length==0?null:s}*domChildrenToView(e,t={},i=[]){let o=[];e instanceof HTMLTemplateElement?o=[...e.content.childNodes]:o=[...e.childNodes];for(let s=0;s<o.length;s++){const r=o[s],a=this._domToView(r,t,i),l=a.next().value;l!==null&&(this._isBlockViewElement(l)&&this._processDomInlineNodes(e,i,t),this.blockFillerMode=="br"&&Ih(l)||(yield l),a.next())}this._processDomInlineNodes(e,i,t)}domSelectionToView(e){if(Cy(e))return new ki([]);if(e.rangeCount===1){let o=e.getRangeAt(0).startContainer;xe(o)&&(o=o.parentNode);const s=this.fakeSelectionToView(o);if(s)return s}const t=this.isDomSelectionBackward(e),i=[];for(let o=0;o<e.rangeCount;o++){const s=e.getRangeAt(o),r=this.domRangeToView(s);r&&i.push(r)}return new ki(i,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),i=this.domPositionToView(e.endContainer,e.endOffset);return t&&i?new Q(t,i):null}domPositionToView(e,t=0){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,to(e));const i=this.mapDomToView(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return V._createBefore(i);if(xe(e)){if(io(e))return this.domPositionToView(e.parentNode,to(e));const o=this.findCorrespondingViewText(e);let s=t;return o?(it(e)&&(s-=Ct,s=s<0?0:s),new V(o,s)):null}else{if(t===0){const o=this.mapDomToView(e);if(o)return new V(o,0)}else{const o=e.childNodes[t-1];if(xe(o)&&io(o)||o&&this.isBlockFiller(o))return this.domPositionToView(o.parentNode,to(o));const s=xe(o)?this.findCorrespondingViewText(o):this.mapDomToView(o);if(s&&s.parent)return new V(s.parent,s.index+1)}return null}}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(io(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 o=this.mapDomToView(i);if(o){const s=o.nextSibling;return s instanceof Ge?s:null}}else{const o=this.mapDomToView(e.parentNode);if(o){const s=o.getChild(0);return s instanceof Ge?s: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:o}=I.window,s=[];Ph(t,r=>{const{scrollLeft:a,scrollTop:l}=r;s.push([a,l])}),t.focus(),Ph(t,r=>{const[a,l]=s.shift();r.scrollLeft=a,r.scrollTop=l}),I.window.scrollTo(i,o)}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return this.blockFillerMode=="br"?e.isEqualNode(py):Vh(e,this.blockElements)?!0:e.isEqualNode(by)||vy(e,this.blockElements)}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch{return!1}const i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=Zg(e);for(t.pop();t.length;){const i=t.pop(),o=this._domToViewMapping.get(i);if(o&&(o.is("uiElement")||o.is("rawElement")))return o}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return wp(this._domDocument);case"markedNbsp":return bp(this._domDocument);case"br":return _p(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(xe(e)&&it(e)&&t<Ct||this.isElement(e)&&it(e.childNodes[t]))return!1;const i=this.mapDomToView(e);return!(i&&(i.is("uiElement")||i.is("rawElement")))}*_domToView(e,t,i){if(this.blockFillerMode!="br"&&Vh(e,this.blockElements))return null;const o=this.getHostViewElement(e);if(o)return o;if(Qo(e)&&t.skipComments)return null;if(xe(e)){if(io(e))return null;{const s=e.data;if(s==="")return null;const r=new Ge(this.document,s);return i.push(r),r}}else{let s=this.mapDomToView(e);if(s)return this._isInlineObjectElement(s)&&i.push(s),s;if(this.isDocumentFragment(e))s=new vn(this.document),t.bind&&this.bindDocumentFragments(e,s);else{s=this._createViewElement(e,t),t.bind&&this.bindElements(e,s);const a=e.attributes;if(a)for(let l=a.length,c=0;c<l;c++)s._setAttribute(a[c].name,a[c].value);if(this._isViewElementWithRawContent(s,t))return s._setCustomProperty("$rawContent",e.innerHTML),this._isBlockViewElement(s)||i.push(s),s;if(Qo(e))return s._setCustomProperty("$rawContent",e.data),s}yield s;const r=[];if(t.withChildren!==!1)for(const a of this.domChildrenToView(e,t,r))s._appendChild(a);if(this._isInlineObjectElement(s))i.push(s),this._processDomInlineNodes(null,r,t);else for(const a of r)i.push(a)}}_processDomInlineNodes(e,t,i){if(!t.length||e&&!this.isDocumentFragment(e)&&!this._isBlockDomElement(e))return;let o=!1;for(let s=0;s<t.length;s++){const r=t[s];if(!r.is("$text")){o=!1;continue}let a,l=!1;if(this._isPreFormatted(r))a=Th(r.data);else{a=r.data.replace(/[ \n\t\r]{1,}/g," "),l=/[^\S\u00A0]/.test(a.charAt(a.length-1));const c=s>0?t[s-1]:null,u=s+1<t.length?t[s+1]:null,d=!c||c.is("element")&&c.name=="br"||o,m=u?!1:!it(r.data);i.withChildren!==!1&&(d&&(a=a.replace(/^ /,"")),m&&(a=a.replace(/ $/,""))),a=Th(a),this.blockFillerMode!="br"&&r.parent&&(ky(r.parent,a)?(a="",r.parent.parent&&(r.parent.parent._setCustomProperty("$hasBlockFiller",!0),r.parent._remove())):yy(r.parent,a,this.blockElements)&&(a="",r.parent._setCustomProperty("$hasBlockFiller",!0))),a=a.replace(/ \u00A0/g," ");const f=u&&u.is("element")&&u.name!="br",g=u&&u.is("$text")&&u.data.charAt(0)==" ";(/[ \u00A0]\u00A0$/.test(a)||!u||f||g)&&(a=a.replace(/\u00A0$/," ")),(d||c&&c.is("element")&&c.name!="br")&&(a=a.replace(/^\u00A0/," "))}a.length==0&&r.parent?(r._remove(),t.splice(s,1),s--):(r._data=a,o=l)}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),o=i&&i.is("$textProxy")&&i.data.charAt(0)==" ";(t.charAt(t.length-2)==" "||!i||o)&&(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(_y(e,this.preElements))return!0;for(const t of e.getAncestors({parentFirst:!0}))if(!(!t.is("element")||!t.hasStyle("white-space")||t.getStyle("white-space")==="inherit"))return["pre","pre-wrap","break-spaces"].includes(t.getStyle("white-space"));return!1}_getTouchingInlineViewNode(e,t){const i=new bn({startPosition:t?V._createAfter(e):V._createBefore(e),direction:t?"forward":"backward"});for(const{item:o}of i){if(o.is("$textProxy"))return o;if(!(o.is("element")&&o.getCustomProperty("dataPipeline:transparentRendering"))){if(o.is("element","br"))return null;if(this._isInlineObjectElement(o))return o;if(o.is("containerElement"))return null}}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return e.is("element")?e.name=="br"||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e):!1}_createViewElement(e,t){if(Qo(e))return new la(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new ai(this.document,i)}_isViewElementWithRawContent(e,t){return t.withChildren!==!1&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return this.renderingMode==="editing"&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const i=this._domDocument.createElement("span");if(i.setAttribute(Sh,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const o of t.getAttributeNames())i.setAttribute(o,t.getAttribute(o))}return i}}function _y(n,e){return n.getAncestors().some(t=>t.is("element")&&e.includes(t.name))}function Ph(n,e){let t=n;for(;t;)e(t),t=t.parentElement}function vy(n,e){return n.isEqualNode(wy)&&vp(n,e)&&n.parentNode.childNodes.length===1}function vp(n,e){const t=n.parentNode;return!!t&&!!t.tagName&&e.includes(t.tagName.toLowerCase())}function yy(n,e,t){return e==" "&&n&&n.is("element")&&n.childCount==1&&t.includes(n.name)}function ky(n,e){return e==" "&&n&&n.is("element","span")&&n.childCount==1&&n.hasAttribute("data-cke-filler")}function Ih(n){return n.is("element","br")&&n.hasAttribute("data-cke-filler")}function Vh(n,e){return n.tagName==="BR"&&vp(n,e)&&n.parentNode.childNodes.length===1}function Rh(n){n==="script"&&J("domconverter-unsafe-script-element-detected"),n==="style"&&J("domconverter-unsafe-style-element-detected")}function Cy(n){if(!N.isGecko||!n.rangeCount)return!1;const e=n.getRangeAt(0).startContainer;try{Object.prototype.toString.call(e)}catch{return!0}return!1}class Zt extends st(){constructor(e){super(),h(this,"view"),h(this,"document"),h(this,"_isEnabled",!1),this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&e.nodeType===3&&(e=e.parentNode),!e||e.nodeType!==1?!1:e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}class kn{constructor(e,t,i){h(this,"view"),h(this,"document"),h(this,"domEvent"),h(this,"domTarget"),this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,Rg(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class ui extends Zt{constructor(){super(...arguments),h(this,"useCapture",!1),h(this,"usePassive",!1)}observe(e){(typeof this.domEventType=="string"?[this.domEventType]:this.domEventType).forEach(t=>{this.listenTo(e,t,(i,o)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(o.target)&&this.onDomEvent(o)},{useCapture:this.useCapture,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new kn(this.view,t,i))}}class Ay extends ui{constructor(){super(...arguments),h(this,"domEventType",["keydown","keyup"])}onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return yn(this)}};this.fire(e.type,e,t)}}class xy extends Zt{constructor(e){super(e),h(this,"_fireSelectionChangeDoneDebounced"),this._fireSelectionChangeDoneDebounced=St(t=>{this.document.fire("selectionChangeDone",t)},200)}observe(){const e=this.document;e.on("arrowKey",(t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()},{context:"$capture"}),e.on("arrowKey",(t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)},{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new ki(t.getRanges(),{backward:t.isBackward,fake:!1});(e==Z.arrowleft||e==Z.arrowup)&&i.setTo(i.getFirstPosition()),(e==Z.arrowright||e==Z.arrowdown)&&i.setTo(i.getLastPosition());const o={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",o),this._fireSelectionChangeDoneDebounced(o)}}let yp=class extends Zt{constructor(n){super(n),h(this,"domConverter"),h(this,"_config"),h(this,"_domElements"),h(this,"_mutationObserver"),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=n.domConverter,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(n){this._domElements.add(n),this.isEnabled&&this._mutationObserver.observe(n,this._config)}stopObserving(n){if(this._domElements.delete(n),this.isEnabled){this._mutationObserver.disconnect();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}}enable(){super.enable();for(const n of this._domElements)this._mutationObserver.observe(n,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(n){if(n.length===0)return;const e=this.domConverter,t=new Set,i=new Set;for(const s of n){const r=e.mapDomToView(s.target);r&&(r.is("uiElement")||r.is("rawElement")||s.type==="childList"&&!this._isBogusBrMutation(s)&&i.add(r))}for(const s of n){const r=e.mapDomToView(s.target);if(!(r&&(r.is("uiElement")||r.is("rawElement")))&&s.type==="characterData"){const a=e.findCorrespondingViewText(s.target);a&&!i.has(a.parent)?t.add(a):!a&&it(s.target)&&i.add(e.mapDomToView(s.target.parentNode))}}const o=[];for(const s of t)o.push({type:"text",node:s});for(const s of i){const r=e.mapViewToDom(s),a=Array.from(s.getChildren()),l=Array.from(e.domChildrenToView(r,{withChildren:!1}));Bg(a,l,Ty)||o.push({type:"children",node:s})}o.length&&this.document.fire("mutations",{mutations:o})}_isBogusBrMutation(n){let e=null;return n.nextSibling===null&&n.removedNodes.length===0&&n.addedNodes.length==1&&(e=this.domConverter.domToView(n.addedNodes[0],{withChildren:!1})),e&&e.is("element","br")}};function Ty(n,e){if(!Array.isArray(n))return n===e?!0:n.is("$text")&&e.is("$text")?n.data===e.data:!1}class Vr extends ui{constructor(e){super(e),h(this,"_renderTimeoutId",null),h(this,"_isFocusChanging",!1),h(this,"domEventType",["focus","blur"]),this.useCapture=!0;const t=this.document;t.on("focus",()=>this._handleFocus()),t.on("blur",(i,o)=>this._handleBlur(o)),t.on("beforeinput",()=>{t.isFocused||this._handleFocus()},{priority:"highest"})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._clearTimeout(),super.destroy()}_handleFocus(){this._clearTimeout(),this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this._renderTimeoutId=null,this.flush(),this.view.change(()=>{})},50)}_handleBlur(e){const t=this.document.selection.editableElement;(t===null||t===e.target)&&(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class Ey extends Zt{constructor(e){super(e),h(this,"mutationObserver"),h(this,"focusObserver"),h(this,"selection"),h(this,"domConverter"),h(this,"_documents",new WeakSet),h(this,"_fireSelectionChangeDoneDebounced"),h(this,"_clearInfiniteLoopInterval"),h(this,"_documentIsSelectingInactivityTimeoutDebounced"),h(this,"_loopbackCounter",0),h(this,"_pendingSelectionChange",new Set),this.mutationObserver=e.getObserver(yp),this.focusObserver=e.getObserver(Vr),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=St(t=>{this.document.fire("selectionChangeDone",t)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=St(()=>this.document.isSelecting=!1,5e3),this.view.document.on("change:isFocused",(t,i,o)=>{if(o&&this._pendingSelectionChange.size){for(const s of Array.from(this._pendingSelectionChange))this._handleSelectionChange(s);this._pendingSelectionChange.clear()}})}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},o=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",i,{priority:"highest"}),this.listenTo(e,"keydown",o,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",o,{priority:"highest",useCapture:!0}),!this._documents.has(t)&&(this.listenTo(t,"mouseup",o,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",()=>{this.document.isComposing&&!N.isAndroid||(this._handleSelectionChange(t),this._documentIsSelectingInactivityTimeoutDebounced())}),this.listenTo(this.view.document,"compositionstart",()=>{this._handleSelectionChange(t)},{priority:"lowest"}),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e){if(!this.isEnabled)return;const t=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(t.anchorNode))return;this.mutationObserver.flush();const i=this.domConverter.domSelectionToView(t);if(i.rangeCount==0){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.view.document.isFocused&&!this.view.document.isReadOnly){this._pendingSelectionChange.add(e);return}if(this._pendingSelectionChange.delete(e),!(this.selection.isEqual(i)&&this.domConverter.isDomSelectionCorrect(t))){if(++this._loopbackCounter>60){this._reportInfiniteLoop();return}if(this.selection.isSimilar(i))this.view.forceRender();else{const o={oldSelection:this.selection,newSelection:i,domSelection:t};this.document.fire("selectionChange",o),this._fireSelectionChangeDoneDebounced(o)}}}_clearInfiniteLoop(){this._loopbackCounter=0}}class Sy extends ui{constructor(e){super(e),h(this,"domEventType",["compositionstart","compositionupdate","compositionend"]);const t=this.document;t.on("compositionstart",()=>{t.isComposing=!0}),t.on("compositionend",()=>{t.isComposing=!1})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class kp{constructor(e,t={}){h(this,"_files"),h(this,"_native"),this._files=t.cacheFiles?Oh(e):null,this._native=e}get files(){return this._files||(this._files=Oh(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return this._native.dropEffect=="none"||!!this._native.mozUserCancelled}}function Oh(n){const e=Array.from(n.files||[]),t=Array.from(n.items||[]);return e.length?e:t.filter(i=>i.kind==="file").map(i=>i.getAsFile())}class Py extends ui{constructor(){super(...arguments),h(this,"domEventType","beforeinput")}onDomEvent(e){const t=e.getTargetRanges(),i=this.view,o=i.document;let s=null,r=null,a=[];if(e.dataTransfer&&(s=new kp(e.dataTransfer)),e.data!==null?r=e.data:s&&(r=s.getData("text/plain")),o.selection.isFake)a=Array.from(o.selection.getRanges()),e.preventDefault();else if(t.length)a=t.map(l=>{let c=i.domConverter.domPositionToView(l.startContainer,l.startOffset);const u=i.domConverter.domPositionToView(l.endContainer,l.endOffset);if(c&&it(l.startContainer)&&l.startOffset<Ct){e.preventDefault();let d=Ct-l.startOffset;c=c.getLastMatchingPosition(m=>!!(m.item.is("attributeElement")||m.item.is("uiElement")||m.item.is("$textProxy")&&d--),{direction:"backward",singleCharacters:!0})}if(Iy(l.endContainer,l.endOffset)&&e.preventDefault(),c)return i.createRange(c,u);if(u)return i.createRange(u)}).filter(l=>!!l);else if(N.isAndroid){const l=e.target.ownerDocument.defaultView.getSelection();a=Array.from(i.domConverter.domSelectionToView(l).getRanges())}if(N.isAndroid&&e.inputType=="insertCompositionText"&&r&&r.endsWith(`
`)){this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(a[0].end)]});return}if(["insertText","insertReplacementText"].includes(e.inputType)&&r&&r.includes(`
`)){const l=r.split(/\n{1,2}/g);let c=a;e.preventDefault();for(let u=0;u<l.length;u++){const d=l[u];d!=""&&(this.fire(e.type,e,{data:d,dataTransfer:s,targetRanges:c,inputType:e.inputType,isComposing:e.isComposing}),c=[o.selection.getFirstRange()]),u+1<l.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:c}),c=[o.selection.getFirstRange()])}return}this.fire(e.type,e,{data:r,dataTransfer:s,targetRanges:a,inputType:e.inputType,isComposing:e.isComposing})}}function Iy(n,e){for(;n.parentNode;){if(xe(n)){if(e!=n.data.length)return!1}else if(e!=n.childNodes.length)return!1;if(e=to(n)+1,n=n.parentNode,e<n.childNodes.length&&it(n.childNodes[e]))return!0}return!1}class Vy extends Zt{constructor(e){super(e),this.document.on("keydown",(t,i)=>{if(this.isEnabled&&fv(i.keyCode)){const o=new xn(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(o,i),o.stop.called&&t.stop()}})}observe(){}stopObserving(){}}class Ry extends Zt{constructor(e){super(e);const t=this.document;t.on("keydown",(i,o)=>{if(!this.isEnabled||o.keyCode!=Z.tab||o.ctrlKey)return;const s=new xn(t,"tab",t.selection.getFirstRange());t.fire(s,o),s.stop.called&&i.stop()})}observe(){}stopObserving(){}}let Oy=class extends ue(){constructor(n){super(),h(this,"document"),h(this,"domConverter"),h(this,"domRoots",new Map),h(this,"_renderer"),h(this,"_initialDomRootAttributes",new WeakMap),h(this,"_observers",new Map),h(this,"_writer"),h(this,"_ongoingChange",!1),h(this,"_postFixersInProgress",!1),h(this,"_renderingDisabled",!1),h(this,"_hasChangedSinceTheLastRendering",!1),this.document=new aa(n),this.domConverter=new ca(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new ly(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new gp(this.document),this.addObserver(yp),this.addObserver(Vr),this.addObserver(Ey),this.addObserver(Ay),this.addObserver(xy),this.addObserver(Sy),this.addObserver(Vy),this.addObserver(Py),this.addObserver(Ry),ry(this),Yv(this),this.on("render",()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1}),this.listenTo(this.document.selection,"change",()=>{this._hasChangedSinceTheLastRendering=!0}),this.listenTo(this.document,"change:isFocused",()=>{this._hasChangedSinceTheLastRendering=!0}),N.isiOS&&this.listenTo(this.document,"blur",(e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(e,{mutations:t})=>{t.forEach(i=>this._renderer.markToSync(i.type,i.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(n,e="main"){const t=this.document.getRoot(e);t._name=n.tagName.toLowerCase();const i={};for(const{name:s,value:r}of Array.from(n.attributes))i[s]=r,s==="class"?this._writer.addClass(r.split(" "),t):t.hasAttribute(s)||this._writer.setAttribute(s,r,t);this._initialDomRootAttributes.set(n,i);const o=()=>{this._writer.setAttribute("contenteditable",(!t.isReadOnly).toString(),t),t.isReadOnly?this._writer.addClass("ck-read-only",t):this._writer.removeClass("ck-read-only",t)};o(),this.domRoots.set(e,n),this.domConverter.bindElements(n,t),this._renderer.markToSync("children",t),this._renderer.markToSync("attributes",t),this._renderer.domDocuments.add(n.ownerDocument),t.on("change:children",(s,r)=>this._renderer.markToSync("children",r)),t.on("change:attributes",(s,r)=>this._renderer.markToSync("attributes",r)),t.on("change:text",(s,r)=>this._renderer.markToSync("text",r)),t.on("change:isReadOnly",()=>this.change(o)),t.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const s of this._observers.values())s.observe(n,e)}detachDomRoot(n){const e=this.domRoots.get(n);Array.from(e.attributes).forEach(({name:i})=>e.removeAttribute(i));const t=this._initialDomRootAttributes.get(e);for(const i in t)e.setAttribute(i,t[i]);this.domRoots.delete(n),this.domConverter.unbindDomElement(e);for(const i of this._observers.values())i.stopObserving(e)}getDomRoot(n="main"){return this.domRoots.get(n)}addObserver(n){let e=this._observers.get(n);if(e)return e;e=new n(this),this._observers.set(n,e);for(const[t,i]of this.domRoots)e.observe(i,t);return e.enable(),e}getObserver(n){return this._observers.get(n)}disableObservers(){for(const n of this._observers.values())n.disable()}enableObservers(){for(const n of this._observers.values())n.enable()}scrollToTheSelection({alignToTop:n,forceScroll:e,viewportOffset:t=20,ancestorOffset:i=20}={}){const o=this.document.selection.getFirstRange();if(!o)return;const s=mt({alignToTop:n,forceScroll:e,viewportOffset:t,ancestorOffset:i});typeof t=="number"&&(t={top:t,bottom:t,left:t,right:t});const r={target:this.domConverter.viewRangeToDom(o),viewportOffset:t,ancestorOffset:i,alignToTop:n,forceScroll:e};this.fire("scrollToTheSelection",r,s),np(r)}focus(){if(!this.document.isFocused){const n=this.document.selection.editableElement;n&&(this.domConverter.focus(n),this.forceRender())}}change(n){if(this.isRenderingInProgress||this._postFixersInProgress)throw new b("cannot-change-view-tree",this);try{if(this._ongoingChange)return n(this._writer);this._ongoingChange=!0;const e=n(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),e}catch(e){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Vr).flush(),this.change(()=>{})}destroy(){for(const n of this._observers.values())n.destroy();this.document.destroy(),this.stopListening()}createPositionAt(n,e){return V._createAt(n,e)}createPositionAfter(n){return V._createAfter(n)}createPositionBefore(n){return V._createBefore(n)}createRange(n,e){return new Q(n,e)}createRangeOn(n){return Q._createOn(n)}createRangeIn(n){return Q._createIn(n)}createSelection(...n){return new ki(...n)}_disableRendering(n){this._renderingDisabled=n,n==!1&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}};/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Yi{is(){throw new Error("is() method is abstract")}}class Lt extends Yi{constructor(e,t,i){if(super(),h(this,"textNode"),h(this,"data"),h(this,"offsetInText"),this.textNode=e,t<0||t>e.offsetSize)throw new b("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new b("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return this.textNode.startOffset!==null?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return this.startOffset!==null?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}Lt.prototype.is=function(n){return n==="$textProxy"||n==="model:$textProxy"||n==="textProxy"||n==="model:textProxy"};class yi{constructor(e){if(h(this,"direction"),h(this,"boundaries"),h(this,"singleCharacters"),h(this,"shallow"),h(this,"ignoreElementEnd"),h(this,"_position"),h(this,"_boundaryStartParent"),h(this,"_boundaryEndParent"),h(this,"_visitedParent"),!e||!e.boundaries&&!e.startPosition)throw new b("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if(t!="forward"&&t!="backward")throw new b("model-tree-walker-unknown-direction",e,{direction:t});this.direction=t,this.boundaries=e.boundaries||null,e.startPosition?this._position=e.startPosition.clone():this._position=C._createAt(this.boundaries[this.direction=="backward"?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i,o,s;do o=this.position,s=this._visitedParent,{done:t,value:i}=this.next();while(!t&&e(i));t||(this._position=o,this._visitedParent=s)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone(),this._visitedParent=e.parent}next(){return this.direction=="forward"?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(i.parent===null&&t.offset===i.maxOffset)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const o=Yo(t,i),s=o||Cp(t,i,o);if(s&&s.is("model:element")){if(!this.shallow)t.path.push(0),this._visitedParent=s;else{if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}return this._position=t,an("elementStart",s,e,t,1)}if(s&&s.is("model:$text")){let r;if(this.singleCharacters)r=1;else{let c=s.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offset<c&&(c=this.boundaries.end.offset),r=c-t.offset}const a=t.offset-s.startOffset,l=new Lt(s,a,r);return t.offset+=r,this._position=t,an("text",l,e,t,r)}return t.path.pop(),t.offset++,this._position=t,this._visitedParent=i.parent,this.ignoreElementEnd?this._next():an("elementEnd",i,e,t)}_previous(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(i.parent===null&&t.offset===0)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};const o=t.parent,s=Yo(t,o),r=s||Ap(t,o,s);if(r&&r.is("model:element"))return t.offset--,this.shallow?(this._position=t,an("elementStart",r,e,t,1)):(t.path.push(r.maxOffset),this._position=t,this._visitedParent=r,this.ignoreElementEnd?this._previous():an("elementEnd",r,e,t));if(r&&r.is("model:$text")){let a;if(this.singleCharacters)a=1;else{let u=r.startOffset;this._boundaryStartParent==i&&this.boundaries.start.offset>u&&(u=this.boundaries.start.offset),a=t.offset-u}const l=t.offset-r.startOffset,c=new Lt(r,l-a,a);return t.offset-=a,this._position=t,an("text",c,e,t,a)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,an("elementStart",i,e,t,1)}}function an(n,e,t,i,o){return{done:!1,value:{type:n,item:e,previousPosition:t,nextPosition:i,length:o}}}class C extends Yi{constructor(e,t,i="toNone"){if(super(),h(this,"root"),h(this,"path"),h(this,"stickiness"),!e.is("element")&&!e.is("documentFragment"))throw new b("model-position-root-invalid",e);if(!Array.isArray(t)||t.length===0)throw new b("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)throw new b("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new b("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return Yo(this,this.parent)}get nodeAfter(){const e=this.parent;return Cp(this,e,Yo(this,e))}get nodeBefore(){const e=this.parent;return Ap(this,e,Yo(this,e))}get isAtStart(){return this.offset===0}get isAtEnd(){return this.offset==this.parent.maxOffset}isValid(){if(this.offset<0)return!1;let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)return!1;return this.offset<=e.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=Xe(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 yi(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=Xe(this.path,e.path),i=typeof t=="string"?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 o=0;for(;t[o]==i[o]&&t[o];)o++;return o===0?null:t[o-1]}getShiftedBy(e){const t=this.clone(),i=t.offset+e;return t.offset=i<0?0:i,t}isAfter(e){return this.compareWith(e)=="after"}isBefore(e){return this.compareWith(e)=="before"}isEqual(e){return this.compareWith(e)=="same"}isTouching(e){if(this.root!==e.root)return!1;const t=Math.min(this.path.length,e.path.length);for(let i=0;i<t;i++){const o=this.path[i]-e.path[i];if(o<-1||o>1)return!1;if(o===1)return Bh(e,this,i);if(o===-1)return Bh(this,e,i)}return this.path.length===e.path.length?!0:this.path.length>e.path.length?Ul(this.path,t):Ul(e.path,t)}hasSameParentAs(e){if(this.root!==e.root)return!1;const t=this.getParentPath(),i=e.getParentPath();return Xe(t,i)=="same"}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=C._createAt(this);break}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&this.stickiness=="toNext"?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange,i=t.containsPosition(this)||t.start.isEqual(this);let o;return i?(o=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(o=o._getTransformedByDeletion(e.deletionPosition,1))):this.isEqual(e.deletionPosition)?o=C._createAt(e.deletionPosition):o=this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),o}_getTransformedByDeletion(e,t){const i=C._createAt(this);if(this.root!=e.root)return i;if(Xe(e.getParentPath(),this.getParentPath())=="same"){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;i.offset-=t}}else if(Xe(e.getParentPath(),this.getParentPath())=="prefix"){const o=e.path.length-1;if(e.offset<=this.path[o]){if(e.offset+t>this.path[o])return null;i.path[o]-=t}}return i}_getTransformedByInsertion(e,t){const i=C._createAt(this);if(this.root!=e.root)return i;if(Xe(e.getParentPath(),this.getParentPath())=="same")(e.offset<this.offset||e.offset==this.offset&&this.stickiness!="toPrevious")&&(i.offset+=t);else if(Xe(e.getParentPath(),this.getParentPath())=="prefix"){const o=e.path.length-1;e.offset<=this.path[o]&&(i.path[o]+=t)}return i}_getTransformedByMove(e,t,i){if(t=t._getTransformedByDeletion(e,i),e.isEqual(t))return C._createAt(this);const o=this._getTransformedByDeletion(e,i);return o===null||e.isEqual(this)&&this.stickiness=="toNext"||e.getShiftedBy(i).isEqual(this)&&this.stickiness=="toPrevious"?this._getCombined(e,t):o._getTransformedByInsertion(t,i)}_getCombined(e,t){const i=e.path.length-1,o=C._createAt(t);return o.stickiness=this.stickiness,o.offset=o.offset+this.path[i]-e.offset,o.path=[...o.path,...this.path.slice(i+1)],o}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 C(e.root,e.path,e.stickiness);{const o=e;if(t=="end")t=o.maxOffset;else{if(t=="before")return this._createBefore(o,i);if(t=="after")return this._createAfter(o,i);if(t!==0&&!t)throw new b("model-createpositionat-offset-required",[this,e])}if(!o.is("element")&&!o.is("documentFragment"))throw new b("model-position-parent-incorrect",[this,e]);const s=o.getPath();return s.push(t),new this(o.root,s,i)}}static _createAfter(e,t){if(!e.parent)throw new b("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 b("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,t)}static fromJSON(e,t){if(e.root==="$graveyard"){const i=new C(t.graveyard,e.path);return i.stickiness=e.stickiness,i}if(!t.getRoot(e.root))throw new b("model-position-fromjson-no-root",t,{rootName:e.root});return new C(t.getRoot(e.root),e.path,e.stickiness)}}C.prototype.is=function(n){return n==="position"||n==="model:position"};function Yo(n,e){const t=e.getChildAtOffset(n.offset);return t&&t.is("$text")&&t.startOffset<n.offset?t:null}function Cp(n,e,t){return t!==null?null:e.getChildAtOffset(n.offset)}function Ap(n,e,t){return t!==null?null:e.getChild(e.offsetToIndex(n.offset)-1)}function Bh(n,e,t){return!(t+1===n.path.length||!Ul(e.path,t+1)||!By(n,t+1))}function Ul(n,e){for(;e<n.length;){if(n[e]!==0)return!1;e++}return!0}function By(n,e){let t=n.parent,i=n.path.length-1,o=0;for(;i>=e;){if(n.path[i]+o!==t.maxOffset)return!1;o=1,i--,t=t.parent}return!0}class y extends Yi{constructor(e,t){super(),h(this,"start"),h(this,"end"),this.start=C._createAt(e),this.end=t?C._createAt(t):C._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new yi({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){const e=this.start.getParentPath(),t=this.end.getParentPath();return Xe(e,t)=="same"}get root(){return this.start.root}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),o=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&o}containsItem(e){const t=C._createBefore(e);return this.containsPosition(t)||this.start.isEqual(t)}isEqual(e){return this.start.isEqual(e.start)&&this.end.isEqual(e.end)}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new y(this.start,e.start)),this.containsPosition(e.end)&&t.push(new y(e.end,this.end))):t.push(new y(this.start,this.end)),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,i=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(i=e.end),new y(t,i)}return null}getJoined(e,t=!1){let i=this.isIntersecting(e);if(i||(this.start.isBefore(e.start)?i=t?this.end.isTouching(e.start):this.end.isEqual(e.start):i=t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!i)return null;let o=this.start,s=this.end;return e.start.isBefore(o)&&(o=e.start),e.end.isAfter(s)&&(s=e.end),new y(o,s)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,i=C._createAt(this.start);let o=i.parent;for(;i.path.length>t+1;){const s=o.maxOffset-i.offset;s!==0&&e.push(new y(i,i.getShiftedBy(s))),i.path=i.path.slice(0,-1),i.offset++,o=o.parent}for(;i.path.length<=this.end.path.length;){const s=this.end.path[i.path.length-1],r=s-i.offset;r!==0&&e.push(new y(i,i.getShiftedBy(r))),i.offset=s,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new yi(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new yi(e);for(const i of t)yield i.item}*getPositions(e={}){e.boundaries=this;const t=new yi(e);yield t.position;for(const i of t)yield i.nextPosition}getTransformedByOperation(e){switch(e.type){case"insert":return this._getTransformedByInsertOperation(e);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(e);case"split":return[this._getTransformedBySplitOperation(e)];case"merge":return[this._getTransformedByMergeOperation(e)]}return[new y(this.start,this.end)]}getTransformedByOperations(e){const t=[new y(this.start,this.end)];for(const i of e)for(let o=0;o<t.length;o++){const s=t[o].getTransformedByOperation(i);t.splice(o,1,...s),o+=s.length-1}for(let i=0;i<t.length;i++){const o=t[i];for(let s=i+1;s<t.length;s++){const r=t[s];(o.containsRange(r)||r.containsRange(o)||o.isEqual(r))&&t.splice(s,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,o=e.howMany,s=e.targetPosition;return this._getTransformedByMove(i,s,o,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 y(t,i)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new y(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=C._createAt(i),t.offset=0):(e.deletionPosition.isEqual(t)||(i=e.deletionPosition),t=e.targetPosition),new y(t,i)):new y(t,i)}_getTransformedByInsertion(e,t,i=!1){if(i&&this.containsPosition(e))return[new y(this.start,e),new y(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const o=new y(this.start,this.end);return o.start=o.start._getTransformedByInsertion(e,t),o.end=o.end._getTransformedByInsertion(e,t),[o]}}_getTransformedByMove(e,t,i,o=!1){if(this.isCollapsed){const d=this.start._getTransformedByMove(e,t,i);return[new y(d)]}const s=y._createFromPositionAndShift(e,i),r=t._getTransformedByDeletion(e,i);if(this.containsPosition(t)&&!o&&(s.containsPosition(this.start)||s.containsPosition(this.end))){const d=this.start._getTransformedByMove(e,t,i),m=this.end._getTransformedByMove(e,t,i);return[new y(d,m)]}let a;const l=this.getDifference(s);let c=null;const u=this.getIntersection(s);if(l.length==1?c=new y(l[0].start._getTransformedByDeletion(e,i),l[0].end._getTransformedByDeletion(e,i)):l.length==2&&(c=new y(this.start,this.end._getTransformedByDeletion(e,i))),c?a=c._getTransformedByInsertion(r,i,u!==null||o):a=[],u){const d=new y(u.start._getCombined(s.start,r),u.end._getCombined(s.start,r));a.length==2?a.splice(1,0,d):a.push(d)}return a}_getTransformedByDeletion(e,t){let i=this.start._getTransformedByDeletion(e,t),o=this.end._getTransformedByDeletion(e,t);return i==null&&o==null?null:(i==null&&(i=e),o==null&&(o=e),new y(i,o))}static _createFromPositionAndShift(e,t){const i=e,o=e.getShiftedBy(t);return t>0?new this(i,o):new this(o,i)}static _createIn(e){return new this(C._createAt(e,0),C._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(C._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(e.length===0)throw new b("range-create-from-ranges-empty-array",null);if(e.length==1)return e[0].clone();const t=e[0];e.sort((s,r)=>s.start.isAfter(r.start)?1:-1);const i=e.indexOf(t),o=new this(t.start,t.end);for(let s=i-1;s>=0&&e[s].end.isEqual(o.start);s--)o.start=C._createAt(e[s].start);for(let s=i+1;s<e.length&&e[s].start.isEqual(o.end);s++)o.end=C._createAt(e[s].end);return o}static fromJSON(e,t){return new this(C.fromJSON(e.start,t),C.fromJSON(e.end,t))}}y.prototype.is=function(n){return n==="range"||n==="model:range"};class xp extends ge(){constructor(){super(),h(this,"_modelToViewMapping",new WeakMap),h(this,"_viewToModelMapping",new WeakMap),h(this,"_viewToModelLengthCallbacks",new Map),h(this,"_markerNameToElements",new Map),h(this,"_elementToMarkerNames",new Map),h(this,"_deferredBindingRemovals",new Map),h(this,"_unboundMarkerNames",new Set),h(this,"_cache",new My),this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new b("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),o=this._viewToModelMapping.get(i),s=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=C._createAt(o,s)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const o of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(o);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)&&this._cache.stopTracking(t)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const o=this._elementToMarkerNames.get(e)||new Set;o.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,o)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),i.size==0&&this._markerNameToElements.delete(t));const o=this._elementToMarkerNames.get(e);o&&(o.delete(t),o.size==0&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new y(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Q(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const o of t)if(o.is("attributeElement"))for(const s of o.getElementsWithSameId())i.add(s);else i.add(o);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e){const s=this._toModelOffset(e.parent,e.index,i),r=this._toModelOffset(e,t,e);return s+r}if(e.is("$text"))return t;let o=0;for(let s=0;s<t;s++)o+=this.getModelLength(e.getChild(s));return o}getModelLength(e){const t=[e];let i=0;for(;t.length>0;){const o=t.pop(),s=o.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(o.name);if(s)i+=s(o);else if(this._viewToModelMapping.has(o))i+=1;else if(o.is("$text"))i+=o.data.length;else{if(o.is("uiElement"))continue;for(const r of o.getChildren())t.push(r)}}return i}findPositionIn(e,t){if(t===0)return this._moveViewPositionToTextNode(new V(e,0));if(this._viewToModelLengthCallbacks.size==0&&this._viewToModelMapping.has(e)){const i=this._cache.getClosest(e,t);return this._findPositionStartingFrom(i.viewPosition,i.modelOffset,t,e,!0)}else return this._findPositionStartingFrom(new V(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,i,o,s){let r=e.parent,a=e.offset;if(r.is("$text"))return new V(r,i-t);let l,c=t,u=0;for(;c<i;){if(l=r.getChild(a),!l){if(r==o)throw new b("mapping-model-offset-not-found",this,{modelOffset:i,viewContainer:o});a=r.parent.getChildIndex(r)+1,r=r.parent;continue}u=this.getModelLength(l),c+=u,a++,s&&this._cache.save(r,a,o,c)}return c==i?this._moveViewPositionToTextNode(new V(r,a)):this._findPositionStartingFrom(new V(l,0),c-u,i,o,s)}_moveViewPositionToTextNode(e){const t=e.nodeBefore,i=e.nodeAfter;return t&&t.is("view:$text")?new V(t,t.data.length):i&&i.is("view:$text")?new V(i,0):e}}class My extends ge(){constructor(){super(...arguments),h(this,"_cachedMapping",new WeakMap),h(this,"_nodeToCacheListIndex",new WeakMap),h(this,"_invalidateOnChildrenChangeCallback",(e,t,i)=>{this._clearCacheInsideParent(t,i.index)}),h(this,"_invalidateOnTextChangeCallback",(e,t)=>{this._clearCacheStartingBefore(t)})}save(e,t,i,o){const s=this._cachedMapping.get(i),r=s.cacheMap.get(o);if(r){const c=e.getChild(t-1),u=r.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(r.viewPosition.nodeBefore):0;this._nodeToCacheListIndex.set(c,u);return}const a={viewPosition:new V(e,t),modelOffset:o};s.maxModelOffset=o>s.maxModelOffset?o:s.maxModelOffset,s.cacheMap.set(o,a);let l=s.cacheList.length-1;for(;l>=0&&s.cacheList[l].modelOffset>o;)l--;if(s.cacheList.splice(l+1,0,a),t>0){const c=e.getChild(t-1);this._nodeToCacheListIndex.set(c,l+1)}}getClosest(e,t){const i=this._cachedMapping.get(e);let o;if(i)if(t>i.maxModelOffset)o=i.cacheList[i.cacheList.length-1];else{const r=i.cacheMap.get(t);r?o=r:o=this._findInCacheList(i.cacheList,t)}else o=this.startTracking(e);const s=this._hoistViewPosition(o.viewPosition);return{modelOffset:o.modelOffset,viewPosition:s}}_hoistViewPosition(e){for(;e.parent.parent&&!this._cachedMapping.has(e.parent)&&e.isAtEnd;){const t=e.parent.parent,i=t.getChildIndex(e.parent)+1;e=new V(t,i)}return e}startTracking(e){const t={viewPosition:new V(e,0),modelOffset:0},i={maxModelOffset:0,cacheList:[t],cacheMap:new Map([[0,t]])};return this._cachedMapping.set(e,i),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),t}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(t==0)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheStartingBefore(e);else{const i=e.getChild(t-1);this._clearCacheStartingBefore(i)}}_clearCacheAll(e){const t=this._cachedMapping.get(e);t.maxModelOffset>0&&(t.maxModelOffset=0,t.cacheList.length=1,t.cacheMap.clear(),t.cacheMap.set(0,t.cacheList[0]))}_clearCacheStartingBefore(e){const t=this._nodeToCacheListIndex.get(e);if(t===void 0){const o=e.parent;this._cachedMapping.has(o)||this._clearCacheStartingBefore(o);return}let i=e.parent;for(;!this._cachedMapping.has(i);)i=i.parent;this._clearCacheFromIndex(i,t)}_clearCacheFromIndex(e,t){t===0&&(t=1);const i=this._cachedMapping.get(e),o=i.cacheList[t-1];if(!o)return;i.maxModelOffset=o.modelOffset;const s=i.cacheList.splice(t);for(const r of s){i.cacheMap.delete(r.modelOffset);const a=r.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(a)}}_findInCacheList(e,t){let i=0,o=e.length-1,s=o-i>>1,r=e[s];for(;i<o;)r.modelOffset<t?i=s+1:o=s-1,s=i+(o-i>>1),r=e[s];return r.modelOffset<=t?r:e[s-1]}}class Ly{constructor(){h(this,"_consumable",new Map),h(this,"_textProxyRegistry",new Map)}add(e,t){t=Hs(t),e instanceof Lt&&(e=this._getSymbolForTextProxy(e)),this._consumable.has(e)||this._consumable.set(e,new Map),this._consumable.get(e).set(t,!0)}consume(e,t){return t=Hs(t),e instanceof Lt&&(e=this._getSymbolForTextProxy(e)),this.test(e,t)?(this._consumable.get(e).set(t,!1),!0):!1}test(e,t){t=Hs(t),e instanceof Lt&&(e=this._getSymbolForTextProxy(e));const i=this._consumable.get(e);if(i===void 0)return null;const o=i.get(t);return o===void 0?null:o}revert(e,t){t=Hs(t),e instanceof Lt&&(e=this._getSymbolForTextProxy(e));const i=this.test(e,t);return i===!1?(this._consumable.get(e).set(t,!0),!0):i===!0?!1:null}verifyAllConsumed(e){const t=[];for(const[i,o]of this._consumable)for(const[s,r]of o){const a=s.split(":")[0];r&&e==a&&t.push({event:s,item:i.name||i.description})}if(t.length)throw new b("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const i=this._textProxyRegistry.get(e.startOffset);if(i){const o=i.get(e.endOffset);o&&(t=o.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,i=e.endOffset,o=e.parent,s=Symbol("$textProxy:"+e.data);let r,a;return r=this._textProxyRegistry.get(t),r||(r=new Map,this._textProxyRegistry.set(t,r)),a=r.get(i),a||(a=new Map,r.set(i,a)),a.set(o,s),s}}function Hs(n){const e=n.split(":");return e[0]=="insert"?e[0]:e[0]=="addMarker"||e[0]=="removeMarker"?n:e.length>1?e[0]+":"+e[1]:e[0]}class Tp extends ge(){constructor(e){super(),h(this,"_conversionApi"),h(this,"_firedEventsMap"),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const o=this._createConversionApi(i,e.getRefreshedItems());for(const r of e.getMarkersToRemove())this._convertMarkerRemove(r.name,r.range,o);const s=this._reduceChanges(e.getChanges());for(const r of s)r.type==="insert"?this._convertInsert(y._createFromPositionAndShift(r.position,r.length),o):r.type==="reinsert"?this._convertReinsert(y._createFromPositionAndShift(r.position,r.length),o):r.type==="remove"?this._convertRemove(r.position,r.length,r.name,o):this._convertAttribute(r.range,r.attributeKey,r.attributeOldValue,r.attributeNewValue,o);o.mapper.flushDeferredBindings();for(const r of o.mapper.flushUnboundMarkerNames()){const a=t.get(r).getRange();this._convertMarkerRemove(r,a,o),this._convertMarkerAdd(r,a,o)}for(const r of e.getMarkersToAdd())this._convertMarkerAdd(r.name,r.range,o);o.consumable.verifyAllConsumed("insert")}convert(e,t,i,o={}){const s=this._createConversionApi(i,void 0,o);this._convertInsert(e,s);for(const[r,a]of t)this._convertMarkerAdd(r,a,s);s.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const o=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},o);const s=e.getFirstPosition().root;if(!o.mapper.toViewElement(s))return;const r=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(o.consumable,e,r),this.fire("selection",{selection:e},o),!!e.isCollapsed){for(const a of r)if(o.consumable.test(e,"addMarker:"+a.name)){const l=a.getRange();if(!Fy(e.getFirstPosition(),a,o.mapper))continue;const c={item:e,markerName:a.name,markerRange:l};this.fire(`addMarker:${a.name}`,c,o)}for(const a of e.getAttributeKeys())if(o.consumable.test(e,"attribute:"+a)){const l={item:e,range:e.getFirstRange(),attributeKey:a,attributeOldValue:null,attributeNewValue:e.getAttribute(a)};this.fire(`attribute:${a}:$text`,l,o)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const o of e.getWalker({shallow:!0}))this._testAndFire("insert",Mh(o),t)}_convertRemove(e,t,i,o){this.fire(`remove:${i}`,{position:e,length:t},o)}_convertAttribute(e,t,i,o,s){this._addConsumablesForRange(s.consumable,e,`attribute:${t}`);for(const r of e){const a={item:r.item,range:y._createFromPositionAndShift(r.previousPosition,r.length),attributeKey:t,attributeOldValue:i,attributeNewValue:o};this._testAndFire(`attribute:${t}`,a,s)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const o of i.map(Mh))this._testAndFire("insert",{...o,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if(t.root.rootName=="$graveyard")return;const o=`addMarker:${e}`;if(i.consumable.add(t,o),this.fire(o,{markerName:e,markerRange:t},i),!!i.consumable.consume(t,o)){this._addConsumablesForRange(i.consumable,t,o);for(const s of t.getItems()){if(!i.consumable.test(s,o))continue;const r={item:s,range:y._createOn(s),markerName:e,markerRange:t};this.fire(o,r,i)}}}_convertMarkerRemove(e,t,i){t.root.rootName!="$graveyard"&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const i of t){const o=i.item;if(e.test(o,"insert")===null){e.add(o,"insert");for(const s of o.getAttributeKeys())e.add(o,"attribute:"+s)}}return e}_addConsumablesForRange(e,t,i){for(const o of t.getItems())e.add(o,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const o of i)e.add(t,"addMarker:"+o.name);for(const o of t.getAttributeKeys())e.add(t,"attribute:"+o);return e}_testAndFire(e,t,i){const o=Ny(e,t),s=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,r=this._firedEventsMap.get(i),a=r.get(s);if(!a)r.set(s,new Set([o]));else if(!a.has(o))a.add(o);else return;this.fire(o,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:y._createOn(e)};for(const o of i.item.getAttributeKeys())i.attributeKey=o,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(o),this._testAndFire(`attribute:${o}`,i,t)}_createConversionApi(e,t=new Set,i={}){const o={...this._conversionApi,consumable:new Ly,writer:e,options:i,convertItem:s=>this._convertInsert(y._createOn(s),o),convertChildren:s=>this._convertInsert(y._createIn(s),o,{doNotAddConsumables:!0}),convertAttributes:s=>this._testAndFireAddAttributes(s,o),canReuseView:s=>!t.has(o.mapper.toModelElement(s))};return this._firedEventsMap.set(o,new Map),o}}function Fy(n,e,t){const i=e.getRange(),o=Array.from(n.getAncestors());return o.shift(),o.reverse(),!o.some(s=>{if(i.containsItem(s))return!!t.toViewElement(s).getCustomProperty("addHighlight")})}function Ny(n,e){const t=e.item.is("element")?e.item.name:"$text";return`${n}:${t}`}function Mh(n){return{item:n.item,range:y._createFromPositionAndShift(n.previousPosition,n.length)}}let Tn=class extends Yi{constructor(n){super(),h(this,"parent",null),h(this,"_attrs"),h(this,"_index",null),h(this,"_startOffset",null),this._attrs=ri(n)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return this.startOffset===null?null:this.startOffset+this.offsetSize}get nextSibling(){const n=this.index;return n!==null&&this.parent.getChild(n+1)||null}get previousSibling(){const n=this.index;return n!==null&&this.parent.getChild(n-1)||null}get root(){let n=this;for(;n.parent;)n=n.parent;return n}isAttached(){return this.parent===null?!1:this.root.isAttached()}getPath(){const n=[];let e=this;for(;e.parent;)n.unshift(e.startOffset),e=e.parent;return n}getAncestors(n={}){const e=[];let t=n.includeSelf?this:this.parent;for(;t;)e[n.parentFirst?"push":"unshift"](t),t=t.parent;return e}getCommonAncestor(n,e={}){const t=this.getAncestors(e),i=n.getAncestors(e);let o=0;for(;t[o]==i[o]&&t[o];)o++;return o===0?null:t[o-1]}isBefore(n){if(this==n||this.root!==n.root)return!1;const e=this.getPath(),t=n.getPath(),i=Xe(e,t);switch(i){case"prefix":return!0;case"extension":return!1;default:return e[i]<t[i]}}isAfter(n){return this==n||this.root!==n.root?!1:!this.isBefore(n)}hasAttribute(n){return this._attrs.has(n)}getAttribute(n){return this._attrs.get(n)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){const n={};return this._attrs.size&&(n.attributes=Array.from(this._attrs).reduce((e,t)=>(e[t[0]]=t[1],e),{})),n}_clone(n){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(n,e){this._attrs.set(n,e)}_setAttributesTo(n){this._attrs=ri(n)}_removeAttribute(n){return this._attrs.delete(n)}_clearAttributes(){this._attrs.clear()}};Tn.prototype.is=function(n){return n==="node"||n==="model:node"};class yt extends ge(Yi){constructor(...e){super(),h(this,"_lastRangeBackward",!1),h(this,"_attrs",new Map),h(this,"_ranges",[]),e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return this._ranges.length===1?this._ranges[0].isCollapsed:!1}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const o of e._ranges)if(t.isEqual(o)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new y(e.start,e.end)}getFirstRange(){let e=null;for(const t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?new y(e.start,e.end):null}getLastRange(){let e=null;for(const t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?new y(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,i,o]=e;if(typeof i=="object"&&(o=i,i=void 0),t===null)this._setRanges([]);else if(t instanceof yt)this._setRanges(t.getRanges(),t.isBackward);else if(t&&typeof t.getRanges=="function")this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof y)this._setRanges([t],!!o&&!!o.backward);else if(t instanceof C)this._setRanges([new y(t)]);else if(t instanceof Tn){const s=!!o&&!!o.backward;let r;if(i=="in")r=y._createIn(t);else if(i=="on")r=y._createOn(t);else if(i!==void 0)r=new y(C._createAt(t,i));else throw new b("model-selection-setto-required-second-parameter",[this,t]);this._setRanges([r],s)}else if(Pt(t))this._setRanges(t,o&&!!o.backward);else throw new b("model-selection-setto-not-selectable",[this,t])}_setRanges(e,t=!1){const i=Array.from(e),o=i.some(s=>{if(!(s instanceof y))throw new b("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(r=>!r.isEqual(s))});i.length===this._ranges.length&&!o||(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(this.anchor===null)throw new b("model-selection-setfocus-no-ranges",[this,e]);const i=C._createAt(e,t);if(i.compareWith(this.focus)=="same")return;const o=this.anchor;this._ranges.length&&this._popRange(),i.compareWith(o)=="before"?(this._pushRange(new y(i,o)),this._lastRangeBackward=!0):(this._pushRange(new y(o,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=Lh(t.start,e);zy(i,t)&&(yield i);const o=t.getWalker();for(const r of o){const a=r.item;r.type=="elementEnd"&&Dy(a,e,t)?yield a:r.type=="elementStart"&&a.is("model:element")&&a.root.document.model.schema.isBlock(a)&&o.jumpTo(C._createAt(a,"end"))}const s=Lh(t.end,e);Hy(s,t)&&(yield s)}}containsEntireContent(e=this.anchor.root){const t=C._createAt(e,0),i=C._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new y(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new b("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()}}yt.prototype.is=function(n){return n==="selection"||n==="model:selection"};function Ep(n,e){return e.has(n)?!1:(e.add(n),n.root.document.model.schema.isBlock(n)&&!!n.parent)}function Dy(n,e,t){return Ep(n,e)&&Jc(n,t)}function Lh(n,e){const t=n.parent.root.document.model.schema,i=n.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const s=i.find(r=>o?!1:(o=t.isLimit(r),!o&&Ep(r,e)));return i.forEach(r=>e.add(r)),s}function Jc(n,e){const t=$y(n);return t?!e.containsRange(y._createOn(t),!0):!0}function zy(n,e){return n?e.isCollapsed||n.isEmpty?!0:e.start.isTouching(C._createAt(n,n.maxOffset))?!1:Jc(n,e):!1}function Hy(n,e){return n?e.isCollapsed||n.isEmpty?!0:e.end.isTouching(C._createAt(n,0))?!1:Jc(n,e):!1}function $y(n){const e=n.root.document.model.schema;let t=n.parent;for(;t;){if(e.isBlock(t))return t;t=t.parent}}class ht extends ge(y){constructor(e,t){super(e,t),Wy.call(this)}detach(){this.stopListening()}toRange(){return new y(this.start,this.end)}static fromRange(e){return new ht(e.start,e.end)}}ht.prototype.is=function(n){return n==="liveRange"||n==="model:liveRange"||n=="range"||n==="model:range"};function Wy(){this.listenTo(this.root.document.model,"applyOperation",(n,e)=>{const t=e[0];t.isDocumentOperation&&jy.call(this,t)},{priority:"low"})}function jy(n){const e=this.getTransformedByOperation(n),t=y._createFromRanges(e),i=!t.isEqual(this),o=Uy(this,n);let s=null;if(i){t.root.rootName=="$graveyard"&&(n.type=="remove"?s=n.sourcePosition:s=n.deletionPosition);const r=this.toRange();this.start=t.start,this.end=t.end,this.fire("change:range",r,{deletionPosition:s})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:s})}function Uy(n,e){switch(e.type){case"insert":return n.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return n.containsPosition(e.sourcePosition)||n.start.isEqual(e.sourcePosition)||n.containsPosition(e.targetPosition);case"split":return n.containsPosition(e.splitPosition)||n.containsPosition(e.insertionPosition)}return!1}class Ce extends Tn{constructor(e,t){super(t),h(this,"_data"),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new Ce(this.data,this.getAttributes())}static fromJSON(e){return new Ce(e.data,e.attributes)}}Ce.prototype.is=function(n){return n==="$text"||n==="model:$text"||n==="text"||n==="model:text"||n==="node"||n==="model:node"};const us="selection:";class Kt extends ge(Yi){constructor(e){super(),h(this,"_selection"),this._selection=new qy(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return us+e}static _isStoreAttributeKey(e){return e.startsWith(us)}}Kt.prototype.is=function(n){return n==="selection"||n=="model:selection"||n=="documentSelection"||n=="model:documentSelection"};class qy extends yt{constructor(e){super(),h(this,"markers",new _e({idProperty:"name"})),h(this,"_model"),h(this,"_document"),h(this,"_attributePriority",new Map),h(this,"_selectionRestorePosition",null),h(this,"_hasChangedRange",!1),h(this,"_overriddenGravityRegister",new Set),h(this,"_observedMarkers",new Set),this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",(t,i)=>{const o=i[0];!o.isDocumentOperation||o.type=="marker"||o.type=="rename"||o.type=="noop"||(this._ranges.length==0&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))},{priority:"lowest"}),this.on("change:range",()=>{this._validateSelectionRanges(this.getRanges())}),this.listenTo(this._model.markers,"update",(t,i,o,s)=>{this._updateMarker(i,s)}),this.listenTo(this._document,"change",(t,i)=>{Gy(this._model,i)})}get isCollapsed(){return this._ranges.length===0?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e<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 i=[e];this.fire("change:attribute",{attributeKeys:i,directChange:!0})}}removeAttribute(e){if(this._removeAttribute(e)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}overrideGravity(){const e=ze();return this._overriddenGravityRegister.add(e),this._overriddenGravityRegister.size===1&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new b("document-selection-gravity-wrong-restore",this,{uid:e});this._overriddenGravityRegister.delete(e),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(e){this._observedMarkers.add(e),this.updateMarkers()}_replaceAllRanges(e){this._validateSelectionRanges(e),super._replaceAllRanges(e)}_popRange(){this._ranges.pop().detach()}_pushRange(e){const t=this._prepareRange(e);t&&this._ranges.push(t)}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new b("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=ht.fromRange(e);return t.on("change:range",(i,o,s)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=s.deletionPosition;const r=this._ranges.indexOf(t);this._ranges.splice(r,1),t.detach()}}),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const o of this._model.markers){const s=o.name.split(":",1)[0];if(!this._observedMarkers.has(s))continue;const r=o.getRange();for(const a of this.getRanges())r.containsRange(a,!a.isCollapsed)&&e.push(o)}const i=Array.from(this.markers);for(const o of e)this.markers.has(o)||(this.markers.add(o),t=!0);for(const o of Array.from(this.markers))e.includes(o)||(this.markers.remove(o),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let o=!1;const s=Array.from(this.markers),r=this.markers.has(e);if(!t)r&&(this.markers.remove(e),o=!0);else{let a=!1;for(const l of this.getRanges())if(t.containsRange(l,!l.isCollapsed)){a=!0;break}a&&!r?(this.markers.add(e),o=!0):!a&&r&&(this.markers.remove(e),o=!0)}o&&this.fire("change:marker",{oldMarkers:s,directChange:!1})}_updateAttributes(e){const t=ri(this._getSurroundingAttributes()),i=ri(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[s,r]of this._attributePriority)r=="low"&&(this._attrs.delete(s),this._attributePriority.delete(s));this._setAttributesTo(t);const o=[];for(const[s,r]of this.getAttributes())(!i.has(s)||i.get(s)!==r)&&o.push(s);for(const[s]of i)this.hasAttribute(s)||o.push(s);o.length>0&&this.fire("change:attribute",{attributeKeys:o,directChange:!1})}_setAttribute(e,t,i=!0){const o=i?"normal":"low";return o=="low"&&this._attributePriority.get(e)=="normal"||super.getAttribute(e)===t?!1:(this._attrs.set(e,t),this._attributePriority.set(e,o),!0)}_removeAttribute(e,t=!0){const i=t?"normal":"low";return i=="low"&&this._attributePriority.get(e)=="normal"||(this._attributePriority.set(e,i),!super.hasAttribute(e))?!1:(this._attrs.delete(e),!0)}_setAttributesTo(e){const t=new Set;for(const[i,o]of this.getAttributes())e.get(i)!==o&&this._removeAttribute(i,!1);for(const[i,o]of e)this._setAttribute(i,o,!1)&&t.add(i);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())t.startsWith(us)&&(yield[t.substr(us.length),e.getAttribute(t)])}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if(e.root.rootName=="$graveyard")return null;let i=null;if(this.isCollapsed){const o=e.textNode?e.textNode:e.nodeBefore,s=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=Io(o,t)),i||(i=Io(s,t)),!this.isGravityOverridden&&!i){let r=o;for(;r&&!i;)r=r.previousSibling,i=Io(r,t)}if(!i){let r=s;for(;r&&!i;)r=r.nextSibling,i=Io(r,t)}i||(i=this.getStoredAttributes())}else{const o=this.getFirstRange();for(const s of o){if(s.item.is("element")&&t.isObject(s.item)){i=Io(s.item,t);break}if(s.type=="text"){i=s.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Io(n,e){if(!n)return null;if(n instanceof Lt||n instanceof Ce)return n.getAttributes();if(!e.isInline(n))return null;if(!e.isObject(n))return[];const t=[];for(const[i,o]of n.getAttributes())e.checkAttribute("$text",i)&&e.getAttributeProperties(i).copyFromObject!==!1&&t.push([i,o]);return t}function Gy(n,e){const t=n.document.differ;for(const i of t.getChanges()){if(i.type!="insert")continue;const o=i.position.parent;i.length===o.maxOffset&&n.enqueueChange(e,s=>{const r=Array.from(o.getAttributeKeys()).filter(a=>a.startsWith(us));for(const a of r)s.removeAttribute(a,o)})}}class Xo{constructor(e){h(this,"_nodes",[]),h(this,"_offsetToNode",[]),e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._offsetToNode.length}getNode(e){return this._nodes[e]||null}getNodeAtOffset(e){return this._offsetToNode[e]||null}getNodeIndex(e){return e.index}getNodeStartOffset(e){return e.startOffset}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new b("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){if(e==this._offsetToNode.length)return this._nodes.length;const t=this._offsetToNode[e];if(!t)throw new b("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}_insertNodes(e,t){const i=[];for(const s of t){if(!(s instanceof Tn))throw new b("model-nodelist-insertnodes-not-node",this);i.push(s)}let o=this.indexToOffset(e);vh(this._nodes,i,e),vh(this._offsetToNode,Ky(i),o);for(let s=e;s<this._nodes.length;s++)this._nodes[s]._index=s,this._nodes[s]._startOffset=o,o+=this._nodes[s].offsetSize}_removeNodes(e,t=1){if(t==0)return[];let i=this.indexToOffset(e);const o=this._nodes.splice(e,t),s=o[o.length-1],r=s.startOffset+s.offsetSize-i;this._offsetToNode.splice(i,r);for(const a of o)a._index=null,a._startOffset=null;for(let a=e;a<this._nodes.length;a++)this._nodes[a]._index=a,this._nodes[a]._startOffset=i,i+=this._nodes[a].offsetSize;return o}_removeNodesArray(e){if(e.length==0)return;for(const i of e)i._index=null,i._startOffset=null;this._nodes=this._nodes.filter(i=>i.index!==null),this._offsetToNode=this._offsetToNode.filter(i=>i.index!==null);let t=0;for(let i=0;i<this._nodes.length;i++)this._nodes[i]._index=i,this._nodes[i]._startOffset=t,t+=this._nodes[i].offsetSize}toJSON(){return this._nodes.map(e=>e.toJSON())}}function Ky(n){const e=[];let t=0;for(const i of n)for(let o=0;o<i.offsetSize;o++)e[t++]=i;return e}class ne extends Tn{constructor(e,t,i){super(t),h(this,"name"),h(this,"_children",new Xo),this.name=e,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const 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?Jy(this._children):void 0;return new ne(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=Zy(t);for(const o of i)o.parent!==null&&o._remove(),o.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const o of i)o.parent=null;return i}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}static fromJSON(e){let t;if(e.children){t=[];for(const i of e.children)i.name?t.push(ne.fromJSON(i)):t.push(Ce.fromJSON(i))}return new ne(e.name,e.attributes,t)}}ne.prototype.is=function(n,e){return e?e===this.name&&(n==="element"||n==="model:element"):n==="element"||n==="model:element"||n==="node"||n==="model:node"};function Zy(n){if(typeof n=="string")return[new Ce(n)];Pt(n)||(n=[n]);const e=[];for(const t of n)typeof t=="string"?e.push(new Ce(t)):t instanceof Lt?e.push(new Ce(t.data,t.getAttributes())):e.push(t);return e}function Jy(n){const e=[];for(const t of n)e.push(t._clone(!0));return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Sp{constructor(e){h(this,"_dispatchers"),this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class Qy extends Sp{elementToElement(e){return this.add(gk(e))}elementToStructure(e){return this.add(pk(e))}attributeToElement(e){return this.add(wk(e))}attributeToAttribute(e){return this.add(bk(e))}markerToElement(e){return this.add(_k(e))}markerToHighlight(e){return this.add(yk(e))}markerToData(e){return this.add(vk(e))}}function Pp(){return(n,e,t)=>{if(!t.consumable.consume(e.item,n.name))return;const i=t.writer,o=t.mapper.toViewPosition(e.range.start),s=i.createText(e.item.data);i.insert(o,s)}}function Ip(){return(n,e,t)=>{t.convertAttributes(e.item),!e.reconversion&&e.item.is("element")&&!e.item.isEmpty&&t.convertChildren(e.item)}}function Yy(){return(n,e,t)=>{const i=t.mapper.toViewPosition(e.position),o=e.position.getShiftedBy(e.length),s=t.mapper.toViewPosition(o,{isPhantom:!0}),r=t.writer.createRange(i,s),a=t.writer.remove(r.getTrimmed());for(const l of t.writer.createRangeIn(a).getItems())t.mapper.unbindViewElement(l,{defer:!0})}}function Vp(n,e){const t=n.createAttributeElement("span",e.attributes);return e.classes&&t._addClass(e.classes),typeof e.priority=="number"&&(t._priority=e.priority),t._id=e.id,t}function Xy(){return(n,e,t)=>{const i=e.selection;if(i.isCollapsed||!t.consumable.consume(i,"selection"))return;const o=[];for(const s of i.getRanges())o.push(t.mapper.toViewRange(s));t.writer.setSelection(o,{backward:i.isBackward})}}function ek(){return(n,e,t)=>{const i=e.selection;if(!i.isCollapsed||!t.consumable.consume(i,"selection"))return;const o=t.writer,s=i.getFirstPosition(),r=t.mapper.toViewPosition(s),a=o.breakAttributes(r);o.setSelection(a)}}function tk(){return(n,e,t)=>{const i=t.writer,o=i.document.selection;for(const s of o.getRanges())s.isCollapsed&&s.end.parent.isAttached()&&t.writer.mergeAttributes(s.start);i.setSelection(null)}}function ik(n){return(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const o=n(t.attributeOldValue,i,t),s=n(t.attributeNewValue,i,t);if(!o&&!s)return;i.consumable.consume(t.item,e.name);const r=i.writer,a=r.document.selection;if(t.item instanceof yt||t.item instanceof Kt)r.wrap(a.getFirstRange(),s);else{let l=i.mapper.toViewRange(t.range);t.attributeOldValue!==null&&o&&(l=r.unwrap(l,o)),t.attributeNewValue!==null&&s&&r.wrap(l,s)}}}function nk(n,e=Sk){return(t,i,o)=>{if(!e(i.item,o.consumable,{preflight:!0}))return;const s=n(i.item,o,i);if(!s)return;e(i.item,o.consumable);const r=o.mapper.toViewPosition(i.range.start);o.mapper.bindElements(i.item,s),o.writer.insert(r,s),o.convertAttributes(i.item),Lp(s,i.item.getChildren(),o,{reconversion:i.reconversion})}}function ok(n,e){return(t,i,o)=>{if(!e(i.item,o.consumable,{preflight:!0}))return;const s=new Map;o.writer._registerSlotFactory(Ak(i.item,s,o));const r=n(i.item,o,i);if(o.writer._clearSlotFactory(),!r)return;xk(i.item,s,o),e(i.item,o.consumable);const a=o.mapper.toViewPosition(i.range.start);o.mapper.bindElements(i.item,r),o.writer.insert(a,r),o.convertAttributes(i.item),Tk(r,s,o,{reconversion:i.reconversion})}}function sk(n){return(e,t,i)=>{t.isOpening=!0;const o=n(t,i);t.isOpening=!1;const s=n(t,i);if(!o||!s)return;const r=t.markerRange;if(r.isCollapsed&&!i.consumable.consume(r,e.name))return;for(const c of r)if(!i.consumable.consume(c.item,e.name))return;const a=i.mapper,l=i.writer;l.insert(a.toViewPosition(r.start),o),i.mapper.bindElementToMarker(o,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),s),i.mapper.bindElementToMarker(s,t.markerName)),e.stop()}}function rk(){return(n,e,t)=>{const i=t.mapper.markerNameToElements(e.markerName);if(i){for(const o of i)t.mapper.unbindElementFromMarkerName(o,e.markerName),t.writer.clear(t.writer.createRangeOn(o),o);t.writer.clearClonedElementsGroup(e.markerName),n.stop()}}}function ak(n){return(e,t,i)=>{const o=n(t.markerName,i);if(!o)return;const s=t.markerRange;i.consumable.consume(s,e.name)&&(Fh(s,!1,i,t,o),Fh(s,!0,i,t,o),e.stop())}}function Fh(n,e,t,i,o){const s=e?n.start:n.end,r=s.nodeAfter&&s.nodeAfter.is("element")?s.nodeAfter:null,a=s.nodeBefore&&s.nodeBefore.is("element")?s.nodeBefore:null;if(r||a){let c,u;e&&r||!e&&!a?(c=r,u=!0):(c=a,u=!1);const d=t.mapper.toViewElement(c);if(d){lk(d,e,u,t,i,o);return}}const l=t.mapper.toViewPosition(s);ck(l,e,t,i,o)}function lk(n,e,t,i,o,s){const r=`data-${s.group}-${e?"start":"end"}-${t?"before":"after"}`,a=n.hasAttribute(r)?n.getAttribute(r).split(","):[];a.unshift(s.name),i.writer.setAttribute(r,a.join(","),n),i.mapper.bindElementToMarker(n,o.markerName)}function ck(n,e,t,i,o){const s=`${o.group}-${e?"start":"end"}`,r=o.name?{name:o.name}:null,a=t.writer.createUIElement(s,r);t.writer.insert(n,a),t.mapper.bindElementToMarker(a,i.markerName)}function uk(n){return(e,t,i)=>{const o=n(t.markerName,i);if(!o)return;const s=i.mapper.markerNameToElements(t.markerName);if(!s)return;for(const a of s)i.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("containerElement")?(r(`data-${o.group}-start-before`,a),r(`data-${o.group}-start-after`,a),r(`data-${o.group}-end-before`,a),r(`data-${o.group}-end-after`,a)):i.writer.clear(i.writer.createRangeOn(a),a);i.writer.clearClonedElementsGroup(t.markerName),e.stop();function r(a,l){if(l.hasAttribute(a)){const c=new Set(l.getAttribute(a).split(","));c.delete(o.name),c.size==0?i.writer.removeAttribute(a,l):i.writer.setAttribute(a,Array.from(c).join(","),l)}}}}function hk(n){return(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const o=n(t.attributeOldValue,i,t),s=n(t.attributeNewValue,i,t);if(!o&&!s)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new b("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(t.attributeOldValue!==null&&o){let l=o.value;o.key=="style"&&(typeof o.value=="string"?l=new so(a.document.stylesProcessor).setTo(o.value).getStylesEntries().map(([c])=>c):l=Object.keys(o.value)),a.removeAttribute(o.key,l,r)}if(t.attributeNewValue!==null&&s){let l=s.value;s.key=="style"&&typeof s.value=="string"&&(l=Object.fromEntries(new so(a.document.stylesProcessor).setTo(s.value).getStylesEntries())),a.setAttribute(s.key,l,!1,r)}}}function dk(n){return(e,t,i)=>{if(!t.item||!(t.item instanceof yt||t.item instanceof Kt)&&!t.item.is("$textProxy"))return;const o=Qc(n,t,i);if(!o||!i.consumable.consume(t.item,e.name))return;const s=i.writer,r=Vp(s,o),a=s.document.selection;if(t.item instanceof yt||t.item instanceof Kt)s.wrap(a.getFirstRange(),r);else{const l=i.mapper.toViewRange(t.range),c=s.wrap(l,r);for(const u of c.getItems())if(u.is("attributeElement")&&u.isSimilar(r)){i.mapper.bindElementToMarker(u,t.markerName);break}}}}function mk(n){return(e,t,i)=>{if(!t.item||!(t.item instanceof ne))return;const o=Qc(n,t,i);if(!o||!i.consumable.test(t.item,e.name))return;const s=i.mapper.toViewElement(t.item);if(s&&s.getCustomProperty("addHighlight")){i.consumable.consume(t.item,e.name);for(const r of y._createIn(t.item))i.consumable.consume(r.item,e.name);s.getCustomProperty("addHighlight")(s,o,i.writer),i.mapper.bindElementToMarker(s,t.markerName)}}}function fk(n){return(e,t,i)=>{if(t.markerRange.isCollapsed)return;const o=Qc(n,t,i);if(!o)return;const s=Vp(i.writer,o),r=i.mapper.markerNameToElements(t.markerName);if(r){for(const a of r)i.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("attributeElement")?i.writer.unwrap(i.writer.createRangeOn(a),s):a.getCustomProperty("removeHighlight")(a,o.id,i.writer);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}}function gk(n){const e=Rp(n.model),t=hs(n.view,"container");return e.attributes.length&&(e.children=!0),i=>{i.on(`insert:${e.name}`,nk(t,Mp(e)),{priority:n.converterPriority||"normal"}),(e.children||e.attributes.length)&&i.on("reduceChanges",Bp(e),{priority:"low"})}}function pk(n){const e=Rp(n.model),t=hs(n.view,"container");return e.children=!0,i=>{if(i._conversionApi.schema.checkChild(e.name,"$text"))throw new b("conversion-element-to-structure-disallowed-text",i,{elementName:e.name});i.on(`insert:${e.name}`,ok(t,Mp(e)),{priority:n.converterPriority||"normal"}),i.on("reduceChanges",Bp(e),{priority:"low"})}}function wk(n){n=mt(n);let e=n.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const o of e.values)n.view[o]=hs(n.view[o],"attribute");else n.view=hs(n.view,"attribute");const i=Op(n);return o=>{o.on(t,ik(i),{priority:n.converterPriority||"normal"})}}function bk(n){n=mt(n);let e=n.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const o of e.values)n.view[o]=Nh(n.view[o]);else n.view=Nh(n.view);const i=Op(n);return o=>{o.on(t,hk(i),{priority:n.converterPriority||"normal"})}}function _k(n){const e=hs(n.view,"ui");return t=>{t.on(`addMarker:${n.model}`,sk(e),{priority:n.converterPriority||"normal"}),t.on(`removeMarker:${n.model}`,rk(),{priority:n.converterPriority||"normal"})}}function vk(n){n=mt(n);const e=n.model;let t=n.view;return t||(t=i=>({group:e,name:i.substr(n.model.length+1)})),i=>{i.on(`addMarker:${e}`,ak(t),{priority:n.converterPriority||"normal"}),i.on(`removeMarker:${e}`,uk(t),{priority:n.converterPriority||"normal"})}}function yk(n){return e=>{e.on(`addMarker:${n.model}`,dk(n.view),{priority:n.converterPriority||"normal"}),e.on(`addMarker:${n.model}`,mk(n.view),{priority:n.converterPriority||"normal"}),e.on(`removeMarker:${n.model}`,fk(n.view),{priority:n.converterPriority||"normal"})}}function Rp(n){return typeof n=="string"&&(n={name:n}),{name:n.name,attributes:n.attributes?he(n.attributes):[],children:!!n.children}}function hs(n,e){return typeof n=="function"?n:(t,i)=>kk(n,i,e)}function kk(n,e,t){typeof n=="string"&&(n={name:n});let i;const o=e.writer,s=Object.assign({},n.attributes);if(t=="container")i=o.createContainerElement(n.name,s);else if(t=="attribute"){const r={priority:n.priority||_n.DEFAULT_PRIORITY};i=o.createAttributeElement(n.name,s,r)}else i=o.createUIElement(n.name,s);if(n.styles){const r=Object.keys(n.styles);for(const a of r)o.setStyle(a,n.styles[a],i)}if(n.classes){const r=n.classes;if(typeof r=="string")o.addClass(r,i);else for(const a of r)o.addClass(a,i)}return i}function Op(n){return n.model.values?(e,t,i)=>{const o=n.view[e];return o?o(e,t,i):null}:n.view}function Nh(n){return typeof n=="string"?e=>({key:n,value:e}):typeof n=="object"?n.value?()=>n:e=>({key:n.key,value:e}):n}function Qc(n,e,t){const i=typeof n=="function"?n(e,t):n;return i?(i.priority||(i.priority=10),i.id||(i.id=e.markerName),i):null}function Ck(n){return(e,t)=>{if(!e.is("element",n.name))return!1;if(t.type=="attribute"){if(n.attributes.includes(t.attributeKey))return!0}else{/* istanbul ignore else: This is always true because otherwise it would not register a reducer callback. -- @preserve */if(n.children)return!0}return!1}}function Bp(n){const e=Ck(n);return(t,i)=>{const o=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const s of i.changes){const r=s.type=="attribute"?s.range.start.nodeAfter:s.position.parent;if(!r||!e(r,s)){o.push(s);continue}if(!i.reconvertedElements.has(r)){i.reconvertedElements.add(r);const a=C._createBefore(r);let l=o.length;for(let c=o.length-1;c>=0;c--){const u=o[c],d=(u.type=="attribute"?u.range.start:u.position).compareWith(a);if(d=="before"||u.type=="remove"&&d=="same")break;l=c}o.splice(l,0,{type:"remove",name:r.name,position:a,length:1},{type:"reinsert",name:r.name,position:a,length:1})}}i.changes=o}}function Mp(n){return(e,t,i={})=>{const o=["insert"];for(const s of n.attributes)e.hasAttribute(s)&&o.push(`attribute:${s}`);return o.every(s=>t.test(e,s))?(i.preflight||o.forEach(s=>t.consume(e,s)),!0):!1}}function Ak(n,e,t){return(i,o)=>{const s=i.createContainerElement("$slot");let r=null;if(o==="children")r=Array.from(n.getChildren());else if(typeof o=="function")r=Array.from(n.getChildren()).filter(a=>o(a));else throw new b("conversion-slot-mode-unknown",t.dispatcher,{modeOrFilter:o});return e.set(s,r),s}}function xk(n,e,t){const i=Array.from(e.values()).flat(),o=new Set(i);if(o.size!=i.length)throw new b("conversion-slot-filter-overlap",t.dispatcher,{element:n});if(o.size!=n.childCount)throw new b("conversion-slot-filter-incomplete",t.dispatcher,{element:n})}function Tk(n,e,t,i){t.mapper.on("modelToViewPosition",r,{priority:"highest"});let o=null,s=null;for([o,s]of e)Lp(n,s,t,i),t.writer.move(t.writer.createRangeIn(o),t.writer.createPositionBefore(o)),t.writer.remove(o);t.mapper.off("modelToViewPosition",r);function r(a,l){const c=l.modelPosition.nodeAfter,u=s.indexOf(c);u<0||(l.viewPosition=l.mapper.findPositionIn(o,u))}}function Lp(n,e,t,i){for(const o of e)Ek(n.root,o,t,i)||t.convertItem(o)}function Ek(n,e,t,i){const{writer:o,mapper:s}=t;if(!i.reconversion)return!1;const r=s.toViewElement(e);return!r||r.root==n||!t.canReuseView(r)?!1:(o.move(o.createRangeOn(r),s.toViewPosition(C._createBefore(e))),!0)}function Sk(n,e,{preflight:t}={}){return t?e.test(n,"insert"):e.consume(n,"insert")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Fp(n){const{schema:e,document:t}=n.model;for(const i of t.getRoots())if(i.isEmpty&&!e.checkChild(i,"$text")&&e.checkChild(i,"paragraph"))return n.insertElement("paragraph",i),!0;return!1}function Np(n,e,t){const i=t.createContext(n);return!(!t.checkChild(i,"paragraph")||!t.checkChild(i.push("paragraph"),e))}function Dp(n,e){const t=e.createElement("paragraph");return e.insert(t,n),e.createPositionAt(t,0)}class Pk extends Sp{elementToElement(e){return this.add(zp(e))}elementToAttribute(e){return this.add(Rk(e))}attributeToAttribute(e){return this.add(Ok(e))}elementToMarker(e){return this.add(Bk(e))}dataToMarker(e){return this.add(Mk(e))}}function Dh(){return(n,e,t)=>{if(!e.modelRange&&t.consumable.consume(e.viewItem,{name:!0})){const{modelRange:i,modelCursor:o}=t.convertChildren(e.viewItem,e.modelCursor);e.modelRange=i,e.modelCursor=o}}}function Ik(){return(n,e,{schema:t,consumable:i,writer:o})=>{let s=e.modelCursor;if(!i.test(e.viewItem))return;if(!t.checkChild(s,"$text")){if(!Np(s,"$text",t)||e.viewItem.data.trim().length==0)return;s=Dp(s,o)}i.consume(e.viewItem);const r=o.createText(e.viewItem.data);o.insert(r,s),e.modelRange=o.createRange(s,s.getShiftedBy(r.offsetSize)),e.modelCursor=e.modelRange.end}}function Vk(n,e){return(t,i)=>{const o=i.newSelection,s=[];for(const a of o.getRanges())s.push(e.toModelRange(a));const r=n.createSelection(s,{backward:o.isBackward});r.isEqual(n.document.selection)||n.change(a=>{a.setSelection(r)})}}function zp(n){n=mt(n);const e=ql(n),t=Yc(n.view),i=t?`element:${t}`:"element";return o=>{o.on(i,e,{priority:n.converterPriority||"normal"})}}function Rk(n){n=mt(n),Hp(n);const e=$p(n,!1),t=Yc(n.view),i=t?`element:${t}`:"element";return o=>{o.on(i,e,{priority:n.converterPriority||"low"})}}function Ok(n){n=mt(n);let e=null;(typeof n.view=="string"||n.view.key)&&(e=Nk(n)),Hp(n,e);const t=$p(n,!0);return i=>{i.on("element",t,{priority:n.converterPriority||"low"})}}function Bk(n){const e=Hk(n.model);return zp({...n,model:e})}function Mk(n){n=mt(n),n.model||(n.model=o=>o?n.view+":"+o:n.view);const e={view:n.view,model:n.model},t=ql(zh(e,"start")),i=ql(zh(e,"end"));return o=>{o.on(`element:${n.view}-start`,t,{priority:n.converterPriority||"normal"}),o.on(`element:${n.view}-end`,i,{priority:n.converterPriority||"normal"});const s=kt.low,r=kt.highest,a=kt.get(n.converterPriority)/r;o.on("element",Lk(e),{priority:s+a})}}function Lk(n){return(e,t,i)=>{const o=`data-${n.view}`;if(!i.consumable.test(t.viewItem,{attributes:o+"-end-after"})&&!i.consumable.test(t.viewItem,{attributes:o+"-start-after"})&&!i.consumable.test(t.viewItem,{attributes:o+"-end-before"})&&!i.consumable.test(t.viewItem,{attributes:o+"-start-before"}))return;t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor)),i.consumable.consume(t.viewItem,{attributes:o+"-end-after"})&&s(t.modelRange.end,t.viewItem.getAttribute(o+"-end-after").split(",")),i.consumable.consume(t.viewItem,{attributes:o+"-start-after"})&&s(t.modelRange.end,t.viewItem.getAttribute(o+"-start-after").split(",")),i.consumable.consume(t.viewItem,{attributes:o+"-end-before"})&&s(t.modelRange.start,t.viewItem.getAttribute(o+"-end-before").split(",")),i.consumable.consume(t.viewItem,{attributes:o+"-start-before"})&&s(t.modelRange.start,t.viewItem.getAttribute(o+"-start-before").split(","));function s(r,a){for(const l of a){const c=n.model(l,i),u=i.writer.createElement("$marker",{"data-name":c});i.writer.insert(u,r),t.modelCursor.isEqual(r)?t.modelCursor=t.modelCursor.getShiftedBy(1):t.modelCursor=t.modelCursor._getTransformedByInsertion(r,1),t.modelRange=t.modelRange._getTransformedByInsertion(r,1)[0]}}}}function Yc(n){return typeof n=="string"?n:typeof n=="object"&&typeof n.name=="string"?n.name:null}function ql(n){const e=new ft(n.view);return(t,i,o)=>{const s=e.match(i.viewItem);if(!s)return;const r=s.match;if(r.name=!0,!o.consumable.test(i.viewItem,r))return;const a=Fk(n.model,i.viewItem,o);a&&o.safeInsert(a,i.modelCursor)&&(o.consumable.consume(i.viewItem,r),o.convertChildren(i.viewItem,a),o.updateConversionResult(a,i))}}function Fk(n,e,t){return n instanceof Function?n(e,t):t.writer.createElement(n)}function Nk(n){typeof n.view=="string"&&(n.view={key:n.view});const e=n.view.key,t=typeof n.view.value>"u"?/[\s\S]*/:n.view.value;let i;return e=="class"||e=="style"?i={[e=="class"?"classes":"styles"]:t}:i={attributes:{[e]:t}},n.view.name&&(i.name=n.view.name),n.view=i,e}function Hp(n,e=null){const t=e===null?!0:s=>s.getAttribute(e),i=typeof n.model!="object"?n.model:n.model.key,o=typeof n.model!="object"||typeof n.model.value>"u"?t:n.model.value;n.model={key:i,value:o}}function $p(n,e){const t=new ft(n.view);return(i,o,s)=>{if(!o.modelRange&&e)return;const r=t.match(o.viewItem);if(!r||(Dk(n.view,o.viewItem)?r.match.name=!0:delete r.match.name,!s.consumable.test(o.viewItem,r.match)))return;const a=n.model.key,l=typeof n.model.value=="function"?n.model.value(o.viewItem,s,o):n.model.value;l!==null&&(o.modelRange||Object.assign(o,s.convertChildren(o.viewItem,o.modelCursor)),zk(o.modelRange,{key:a,value:l},e,s)&&(s.consumable.test(o.viewItem,{name:!0})&&(r.match.name=!0),s.consumable.consume(o.viewItem,r.match)))}}function Dk(n,e){const t=typeof n=="function"?n(e):n;return typeof t=="object"&&!Yc(t)?!1:!t.classes&&!t.attributes&&!t.styles}function zk(n,e,t,i){let o=!1;for(const s of Array.from(n.getItems({shallow:t})))i.schema.checkAttribute(s,e.key)&&(o=!0,!s.hasAttribute(e.key)&&i.writer.setAttribute(e.key,e.value,s));return o}function Hk(n){return(e,t)=>{const i=typeof n=="string"?n:n(e,t);return t.writer.createElement("$marker",{"data-name":i})}}function zh(n,e){const t=(i,o)=>{const s=i.getAttribute("name"),r=n.model(s,o);return o.writer.createElement("$marker",{"data-name":r})};return{view:`${n.view}-${e}`,model:t}}function $k(n){n.document.registerPostFixer(e=>Wk(e,n))}function Wk(n,e){const t=e.document.selection,i=e.schema,o=[];let s=!1;for(const r of t.getRanges()){const a=Wp(r,i);a&&!a.isEqual(r)?(o.push(a),s=!0):o.push(r)}return s&&n.setSelection(Gk(o),{backward:t.isBackward}),!1}function Wp(n,e){return n.isCollapsed?jk(n,e):Uk(n,e)}function jk(n,e){const t=n.start,i=e.getNearestSelectionRange(t);if(!i){const s=t.getAncestors().reverse().find(r=>e.isObject(r));return s?y._createOn(s):null}if(!i.isCollapsed)return i;const o=i.start;return t.isEqual(o)?null:new y(o)}function Uk(n,e){const{start:t,end:i}=n,o=e.checkChild(t,"$text"),s=e.checkChild(i,"$text"),r=e.getLimitElement(t),a=e.getLimitElement(i);if(r===a){if(o&&s)return null;if(qk(t,i,e)){const u=t.nodeAfter&&e.isSelectable(t.nodeAfter)?null:e.getNearestSelectionRange(t,"forward"),d=i.nodeBefore&&e.isSelectable(i.nodeBefore)?null:e.getNearestSelectionRange(i,"backward"),m=u?u.start:t,f=d?d.end:i;return new y(m,f)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const u=t.nodeAfter&&i.nodeBefore&&t.nodeAfter.parent===i.nodeBefore.parent,d=l&&(!u||!$h(t.nodeAfter,e)),m=c&&(!u||!$h(i.nodeBefore,e));let f=t,g=i;return d&&(f=C._createBefore(Hh(r,e))),m&&(g=C._createAfter(Hh(a,e))),new y(f,g)}return null}function Hh(n,e){let t=n,i=t;for(;e.isLimit(i)&&i.parent;)t=i,i=i.parent;return t}function qk(n,e,t){const i=n.nodeAfter&&!t.isLimit(n.nodeAfter)||t.checkChild(n,"$text"),o=e.nodeBefore&&!t.isLimit(e.nodeBefore)||t.checkChild(e,"$text");return i||o}function Gk(n){const e=[...n],t=new Set;let i=1;for(;i<e.length;){const o=e[i],s=e.slice(0,i);for(const[r,a]of s.entries())if(!t.has(r)){if(o.isEqual(a))t.add(r);else if(o.isIntersecting(a)){t.add(r),t.add(i);const l=o.getJoined(a);e.push(l)}}i++}return e.filter((o,s)=>!t.has(s))}function $h(n,e){return n&&e.isSelectable(n)}class Kk extends ue(){constructor(e,t){super(),h(this,"model"),h(this,"view"),h(this,"mapper"),h(this,"downcastDispatcher"),this.model=e,this.view=new Oy(t),this.mapper=new xp,this.downcastDispatcher=new Tp({mapper:this.mapper,schema:e.schema});const i=this.model.document,o=i.selection,s=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(i,"change",()=>{this.view.change(r=>{this.downcastDispatcher.convertChanges(i.differ,s,r),this.downcastDispatcher.convertSelection(o,s,r)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",Vk(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",Zk(this.mapper,this.model.schema,this.view),{priority:"high"}),this.downcastDispatcher.on("insert:$text",Pp(),{priority:"lowest"}),this.downcastDispatcher.on("insert",Ip(),{priority:"lowest"}),this.downcastDispatcher.on("remove",Yy(),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",tk()),this.downcastDispatcher.on("selection",Xy(),{priority:"low"}),this.downcastDispatcher.on("selection",ek(),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(r=>{if(r.rootName=="$graveyard")return null;const a=new hp(this.view.document,r.name);return a.rootName=r.rootName,this.mapper.bindElements(r,a),a})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t=typeof e=="string"?e:e.name,i=this.model.markers.get(t);if(!i)throw new b("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(i)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}function Zk(n,e,t){return(i,o)=>{if(!(t.document.isComposing&&!N.isAndroid))for(let s=0;s<o.targetRanges.length;s++){const r=o.targetRanges[s],a=n.toModelRange(r),l=Wp(a,e);!l||l.isEqual(a)||(o.targetRanges[s]=n.toViewRange(l))}}}class Jk extends ue(){constructor(){super(),h(this,"_sourceDefinitions",{}),h(this,"_attributeProperties",Object.create(null)),h(this,"_customChildChecks",new Map),h(this,"_customAttributeChecks",new Map),h(this,"_genericCheckSymbol",Symbol("$generic")),h(this,"_compiledDefinitions"),this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,t)=>{t[0]=new Ui(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new Ui(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new b("schema-cannot-register-item-twice",this,{itemName:e});this._sourceDefinitions[e]=[Object.assign({},t)],this._clearCache()}extend(e,t){if(!this._sourceDefinitions[e])throw new b("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return typeof e=="string"?t=e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?t="$text":t=e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!!(t&&t.isBlock)}isLimit(e){const t=this.getDefinition(e);return t?!!(t.isLimit||t.isObject):!1}isObject(e){const t=this.getDefinition(e);return t?!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent):!1}isInline(e){const t=this.getDefinition(e);return!!(t&&t.isInline)}isSelectable(e){const t=this.getDefinition(e);return t?!!(t.isSelectable||t.isObject):!1}isContent(e){const t=this.getDefinition(e);return t?!!(t.isContent||t.isObject):!1}checkChild(e,t){return t?this._checkContextMatch(e,t):!1}checkAttribute(e,t){const i=this.getDefinition(e.last);if(!i)return!1;const o=this._evaluateAttributeChecks(e,t);return o!==void 0?o:i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof C){const i=e.nodeBefore,o=e.nodeAfter;if(!(i instanceof ne))throw new b("schema-check-merge-no-element-before",this);if(!(o instanceof ne))throw new b("schema-check-merge-no-element-after",this);return this.checkMerge(i,o)}if(this.isLimit(e)||this.isLimit(t))return!1;for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e,t){const i=t!==void 0?t:this._genericCheckSymbol,o=this._customChildChecks.get(i)||[];o.push(e),this._customChildChecks.set(i,o)}addAttributeCheck(e,t){const i=t!==void 0?t:this._genericCheckSymbol,o=this._customAttributeChecks.get(i)||[];o.push(e),this._customAttributeChecks.set(i,o)}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||Object.create(null)}getLimitElement(e){let t;for(e instanceof C?t=e.parent:t=(e instanceof y?[e]:Array.from(e.getRanges())).reduce((i,o)=>{const s=o.getCommonAncestor();return i?i.getCommonAncestor(s,{includeSelf:!0}):s},null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Ce("",e.getAttributes())];return this.checkAttribute(i,t)}else{const i=e.getRanges();for(const o of i)for(const s of o)if(this.checkAttribute(s.item,t))return!0}return!1}*getValidRanges(e,t){e=d2(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if(e.root.rootName=="$graveyard")return null;if(this.checkChild(e,"$text"))return new y(e);let i,o;const s=e.getAncestors().reverse().find(r=>this.isLimit(r))||e.root;(t=="both"||t=="backward")&&(i=new yi({boundaries:y._createIn(s),startPosition:e,direction:"backward"})),(t=="both"||t=="forward")&&(o=new yi({boundaries:y._createIn(s),startPosition:e}));for(const r of h2(i,o)){const a=r.walker==i?"elementEnd":"elementStart",l=r.value;if(l.type==a&&this.isObject(l.item))return y._createOn(l.item);if(this.checkChild(l.nextPosition,"$text"))return new y(l.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}setAllowedAttributes(e,t,i){const o=i.model;for(const[s,r]of Object.entries(t))o.schema.checkAttribute(e,s)&&i.setAttribute(s,r,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))Wh(this,i,t);else{const o=y._createIn(i).getPositions();for(const s of o){const r=s.nodeBefore||s.parent;Wh(this,r,t)}}}getAttributesWithProperty(e,t,i){const o={};for(const[s,r]of e.getAttributes()){const a=this.getAttributeProperties(s);a[t]!==void 0&&(i===void 0||i===a[t])&&(o[s]=r)}return o}createContext(e){return new Ui(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const s of i)e[s]=Qk(t[s],s);const o=Object.values(e);for(const s of o)Yk(e,s),Xk(e,s),e2(e,s),t2(e,s);for(const s of o)i2(e,s);for(const s of o)n2(e,s);for(const s of o)o2(e,s);for(const s of o)r2(e,s);for(const s of o)a2(e,s);this._compiledDefinitions=s2(e)}_checkContextMatch(e,t){const i=e.last;let o=this._evaluateChildChecks(e,t);if(o=o!==void 0?o:t.allowIn.includes(i.name),!o)return!1;const s=this.getDefinition(i),r=e.trimLast();return s?r.length==0?!0:this._checkContextMatch(r,s):!1}_evaluateChildChecks(e,t){const i=this._customChildChecks.get(this._genericCheckSymbol)||[],o=this._customChildChecks.get(t.name)||[];for(const s of[...i,...o]){const r=s(e,t);if(r!==void 0)return r}}_evaluateAttributeChecks(e,t){const i=this._customAttributeChecks.get(this._genericCheckSymbol)||[],o=this._customAttributeChecks.get(t)||[];for(const s of[...i,...o]){const r=s(e,t);if(r!==void 0)return r}}*_getValidRangesForRange(e,t){let i=e.start,o=e.start;for(const s of e.getItems({shallow:!0}))s.is("element")&&(yield*this._getValidRangesForRange(y._createIn(s),t)),this.checkAttribute(s,t)||(i.isEqual(o)||(yield new y(i,o)),i=C._createAfter(s)),o=C._createAfter(s);i.isEqual(o)||(yield new y(i,o))}findOptimalInsertionRange(e,t){const i=e.getSelectedElement();if(i&&this.isObject(i)&&!this.isInline(i))return t=="before"||t=="after"?new y(C._createAt(i,t)):y._createOn(i);const o=ae(e.getSelectedBlocks());if(!o)return new y(e.focus);if(o.isEmpty)return new y(C._createAt(o,0));const s=C._createAfter(o);return e.focus.isTouching(s)?new y(s):new y(C._createBefore(o))}}class Ui{constructor(e){if(h(this,"_items"),e instanceof Ui)return e;let t;typeof e=="string"?t=[e]:Array.isArray(e)?t=e:t=e.getAncestors({includeSelf:!0}),this._items=t.map(u2)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(e){const t=new Ui([e]);return t._items=[...this._items,...t._items],t}trimLast(){const e=new Ui([]);return e._items=this._items.slice(0,-1),e}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function Qk(n,e){const t={name:e,allowIn:new Set,allowChildren:new Set,disallowIn:new Set,disallowChildren:new Set,allowContentOf:new Set,allowWhere:new Set,allowAttributes:new Set,disallowAttributes:new Set,allowAttributesOf:new Set,inheritTypesFrom:new Set};return l2(n,t),Qt(n,t,"allowIn"),Qt(n,t,"allowChildren"),Qt(n,t,"disallowIn"),Qt(n,t,"disallowChildren"),Qt(n,t,"allowContentOf"),Qt(n,t,"allowWhere"),Qt(n,t,"allowAttributes"),Qt(n,t,"disallowAttributes"),Qt(n,t,"allowAttributesOf"),Qt(n,t,"inheritTypesFrom"),c2(n,t),t}function Yk(n,e){for(const t of e.allowIn){const i=n[t];i?i.allowChildren.add(e.name):e.allowIn.delete(t)}}function Xk(n,e){for(const t of e.allowChildren){const i=n[t];i?i.allowIn.add(e.name):e.allowChildren.delete(t)}}function e2(n,e){for(const t of e.disallowIn){const i=n[t];i?i.disallowChildren.add(e.name):e.disallowIn.delete(t)}}function t2(n,e){for(const t of e.disallowChildren){const i=n[t];i?i.disallowIn.add(e.name):e.disallowChildren.delete(t)}}function i2(n,e){for(const t of e.disallowChildren)e.allowChildren.delete(t);for(const t of e.disallowIn)e.allowIn.delete(t);for(const t of e.disallowAttributes)e.allowAttributes.delete(t)}function n2(n,e){for(const t of e.allowContentOf){const i=n[t];i&&(i.disallowChildren.forEach(o=>{e.allowChildren.has(o)||(e.disallowChildren.add(o),n[o].disallowIn.add(e.name))}),i.allowChildren.forEach(o=>{e.disallowChildren.has(o)||(e.allowChildren.add(o),n[o].allowIn.add(e.name))}))}}function o2(n,e){for(const t of e.allowWhere){const i=n[t];i&&(i.disallowIn.forEach(o=>{e.allowIn.has(o)||(e.disallowIn.add(o),n[o].disallowChildren.add(e.name))}),i.allowIn.forEach(o=>{e.disallowIn.has(o)||(e.allowIn.add(o),n[o].allowChildren.add(e.name))}))}}function s2(n){const e={};for(const t of Object.values(n))e[t.name]={name:t.name,isBlock:!!t.isBlock,isContent:!!t.isContent,isInline:!!t.isInline,isLimit:!!t.isLimit,isObject:!!t.isObject,isSelectable:!!t.isSelectable,allowIn:Array.from(t.allowIn).filter(i=>!!n[i]),allowChildren:Array.from(t.allowChildren).filter(i=>!!n[i]),allowAttributes:Array.from(t.allowAttributes)};return e}function r2(n,e){for(const t of e.allowAttributesOf){const i=n[t];if(!i)return;i.allowAttributes.forEach(o=>{e.disallowAttributes.has(o)||e.allowAttributes.add(o)})}}function a2(n,e){for(const t of e.inheritTypesFrom){const i=n[t];if(i){const o=Object.keys(i).filter(s=>s.startsWith("is"));for(const s of o)s in e||(e[s]=i[s])}}}function l2(n,e){for(const t of n){const i=Object.keys(t).filter(o=>o.startsWith("is"));for(const o of i)e[o]=!!t[o]}}function Qt(n,e,t){for(const i of n){let o=i[t];typeof o=="string"&&(o=[o]),Array.isArray(o)&&o.forEach(s=>e[t].add(s))}}function c2(n,e){for(const t of n){const i=t.inheritAllFrom;i&&(e.allowContentOf.add(i),e.allowWhere.add(i),e.allowAttributesOf.add(i),e.inheritTypesFrom.add(i))}}function u2(n){return typeof n=="string"||n.is("documentFragment")?{name:typeof n=="string"?n:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:n.is("element")?n.name:"$text",*getAttributeKeys(){yield*n.getAttributeKeys()},getAttribute(e){return n.getAttribute(e)}}}function*h2(n,e){let t=!1;for(;!t;){if(t=!0,n){const i=n.next();i.done||(t=!1,yield{walker:n,value:i.value})}if(e){const i=e.next();i.done||(t=!1,yield{walker:e,value:i.value})}}}function*d2(n){for(const e of n)yield*e.getMinimalFlatRanges()}function Wh(n,e,t){for(const i of e.getAttributeKeys())n.checkAttribute(e,i)||t.removeAttribute(i,e)}class m2 extends ge(){constructor(e){super(),h(this,"conversionApi"),h(this,"_splitParts",new Map),h(this,"_cursorParents",new Map),h(this,"_modelCursor",null),h(this,"_emptyElementsToKeep",new Set),this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(t,i)=>this._convertItem(t,i),convertChildren:(t,i)=>this._convertChildren(t,i),safeInsert:(t,i)=>this._safeInsert(t,i),updateConversionResult:(t,i)=>this._updateConversionResult(t,i),splitToAllowedParent:(t,i)=>this._splitToAllowedParent(t,i),getSplitParts:t=>this._getSplitParts(t),keepEmptyElement:t=>this._keepEmptyElement(t)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=g2(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=Pr.createFrom(e),this.conversionApi.store={};const{modelRange:o}=this._convertItem(e,this._modelCursor),s=t.createDocumentFragment();if(o){this._removeEmptyElements();const r=this._modelCursor.parent,a=r._removeChildren(0,r.childCount);s._insertChild(0,a),s.markers=f2(s,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,s}_convertItem(e,t){const i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof y))throw new b("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:C._createAt(t,0);const o=new y(i);for(const s of Array.from(e.getChildren())){const r=this._convertItem(s,i);r.modelRange instanceof y&&(o.end=r.modelRange.end,i=r.modelCursor)}return{modelRange:o,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return i?(this.conversionApi.writer.insert(e,i.position),!0):!1}_updateConversionResult(e,t){const i=this._getSplitParts(e),o=this.conversionApi.writer;t.modelRange||(t.modelRange=o.createRange(o.createPositionBefore(e),o.createPositionAfter(i[i.length-1])));const s=this._cursorParents.get(e);s?t.modelCursor=o.createPositionAt(s,0):t.modelCursor=t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:o}=this.conversionApi;let s=i.findAllowedParent(t,e);if(s){if(s===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(s)&&(s=null)}if(!s)return Np(t,e,i)?{position:Dp(t,o)}:null;const r=this.conversionApi.writer.split(t,s),a=[];for(const c of r.range.getWalker())if(c.type=="elementEnd")a.push(c.item);else{const u=a.pop(),d=c.item;this._registerSplitPair(u,d)}const l=r.range.end.parent;return this._cursorParents.set(e,l),{position:r.position,cursorParent:l}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return this._splitParts.has(e)?t=this._splitParts.get(e):t=[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){const e=new Map;for(const t of this._splitParts.keys())if(t.isEmpty&&!this._emptyElementsToKeep.has(t)){const i=e.get(t.parent)||[];i.push(t),this._splitParts.delete(t),e.set(t.parent,i)}for(const[t,i]of e)t._removeChildrenArray(i);e.size&&this._removeEmptyElements()}}function f2(n,e){const t=new Set,i=new Map,o=y._createIn(n).getItems();for(const s of o)s.is("element","$marker")&&t.add(s);for(const s of t){const r=s.getAttribute("data-name"),a=e.createPositionBefore(s);i.has(r)?i.get(r).end=a.clone():i.set(r,new y(a.clone())),e.remove(s)}return i}function g2(n,e){let t;for(const i of new Ui(n)){const o={};for(const r of i.getAttributeKeys())o[r]=i.getAttribute(r);const s=e.createElement(i.name,o);t&&e.insert(s,t),t=C._createAt(s,0)}return t}class p2{getHtml(e){const t=I.document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class jp{constructor(e){h(this,"domParser"),h(this,"domConverter"),h(this,"htmlWriter"),h(this,"skipComments",!0),this.domParser=new DOMParser,this.domConverter=new ca(e,{renderingMode:"data"}),this.htmlWriter=new p2}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode=e=="marked"?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`<body>${e}</body>`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),o=t.body.childNodes;for(;o.length>0;)i.appendChild(o[0]);return i}}class w2 extends ge(){constructor(e,t){super(),h(this,"model"),h(this,"mapper"),h(this,"downcastDispatcher"),h(this,"upcastDispatcher"),h(this,"viewDocument"),h(this,"stylesProcessor"),h(this,"htmlProcessor"),h(this,"processor"),h(this,"_viewWriter"),this.model=e,this.mapper=new xp,this.downcastDispatcher=new Tp({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",Pp(),{priority:"lowest"}),this.downcastDispatcher.on("insert",Ip(),{priority:"lowest"}),this.upcastDispatcher=new m2({schema:e.schema}),this.viewDocument=new aa(t),this.stylesProcessor=t,this.htmlProcessor=new jp(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new gp(this.viewDocument),this.upcastDispatcher.on("text",Ik(),{priority:"lowest"}),this.upcastDispatcher.on("element",Dh(),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",Dh(),{priority:"lowest"}),ue().prototype.decorate.call(this,"init"),ue().prototype.decorate.call(this,"set"),ue().prototype.decorate.call(this,"get"),ue().prototype.decorate.call(this,"toView"),ue().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},Fp)},{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new b("datacontroller-get-non-existent-root",this);const o=this.model.document.getRoot(t);return o.isAttached()||J("datacontroller-get-detached-root",this),i==="empty"&&!this.model.hasContent(o,{ignoreWhitespaces:!0})?"":this.stringify(o,e)}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,o=this._viewWriter;this.mapper.clearBindings();const s=y._createIn(e),r=new vn(i);this.mapper.bindElements(e,r);const a=e.is("documentFragment")?e.markers:b2(e);return this.downcastDispatcher.convert(s,a,o,t),r}init(e){if(this.model.document.version)throw new b("datacontroller-init-document-not-empty",this);let t={};if(typeof e=="string"?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new b("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},i=>{for(const o of Object.keys(t)){const s=this.model.document.getRoot(o);i.insert(this.parse(t[o],s),s,0)}}),Promise.resolve()}set(e,t={}){let i={};if(typeof e=="string"?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new b("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},o=>{o.setSelection(null),o.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const s of Object.keys(i)){const r=this.model.document.getRoot(s);o.remove(o.createRangeIn(r)),o.insert(this.parse(i[s],r),r,0)}})}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change(i=>this.upcastDispatcher.convert(e,i,t))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}}function b2(n){const e=[],t=n.root.document;if(!t)return new Map;const i=y._createIn(n);for(const o of t.model.markers){const s=o.getRange(),r=s.isCollapsed,a=s.start.isEqual(i.start)||s.end.isEqual(i.end);if(r&&a)e.push([o.name,s]);else{const l=i.getIntersection(s);l&&e.push([o.name,l])}}return e.sort(([o,s],[r,a])=>{if(s.end.compareWith(a.start)!=="after")return 1;if(s.start.compareWith(a.end)!=="before")return-1;switch(s.start.compareWith(a.start)){case"before":return 1;case"after":return-1;default:switch(s.end.compareWith(a.end)){case"before":return 1;case"after":return-1;default:return r.localeCompare(o)}}}),new Map(e)}class _2{constructor(e,t){h(this,"_helpers",new Map),h(this,"_downcast"),h(this,"_upcast"),this._downcast=he(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=he(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new b("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new b("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of za(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of za(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of za(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new b("conversion-group-exists",this);const o=i?new Qy(t):new Pk(t);this._helpers.set(e,o)}}function*za(n){if(n.model.values)for(const e of n.model.values){const t={key:n.model.key,value:e},i=n.view[e],o=n.upcastAlso?n.upcastAlso[e]:void 0;yield*jh(t,i,o)}else yield*jh(n.model,n.view,n.upcastAlso)}function*jh(n,e,t){if(yield{model:n,view:e},t)for(const i of he(t))yield{model:n,view:i}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class It{constructor(e){h(this,"baseVersion"),h(this,"isDocumentOperation"),h(this,"batch"),this.baseVersion=e,this.isDocumentOperation=this.baseVersion!==null,this.batch=null}_validate(){}toJSON(){const e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e,t){return new this(e.baseVersion)}}function Xc(n,e){const t=qp(e),i=t.reduce((r,a)=>r+a.offsetSize,0),o=n.parent;fs(n);const s=n.index;return o._insertChild(s,t),ms(o,s+t.length),ms(o,s),new y(n,n.getShiftedBy(i))}function Up(n){if(!n.isFlat)throw new b("operation-utils-remove-range-not-flat",this);const e=n.start.parent;fs(n.start),fs(n.end);const t=e._removeChildren(n.start.index,n.end.index-n.start.index);return ms(e,n.start.index),t}function ds(n,e){if(!n.isFlat)throw new b("operation-utils-move-range-not-flat",this);const t=Up(n);return e=e._getTransformedByDeletion(n.start,n.end.offset-n.start.offset),Xc(e,t)}function v2(n,e,t){fs(n.start),fs(n.end);for(const i of n.getItems({shallow:!0})){const o=i.is("$textProxy")?i.textNode:i;t!==null?o._setAttribute(e,t):o._removeAttribute(e),ms(o.parent,o.index)}ms(n.end.parent,n.end.index)}function qp(n){const e=[];function t(i){if(typeof i=="string")e.push(new Ce(i));else if(i instanceof Lt)e.push(new Ce(i.data,i.getAttributes()));else if(i instanceof Tn)e.push(i);else if(Pt(i))for(const o of i)t(o)}t(n);for(let i=1;i<e.length;i++){const o=e[i],s=e[i-1];o instanceof Ce&&s instanceof Ce&&Gp(o,s)&&(e.splice(i-1,2,new Ce(s.data+o.data,s.getAttributes())),i--)}return e}function ms(n,e){const t=n.getChild(e-1),i=n.getChild(e);if(t&&i&&t.is("$text")&&i.is("$text")&&Gp(t,i)){const o=new Ce(t.data+i.data,t.getAttributes());n._removeChildren(e-1,2),n._insertChild(e-1,o)}}function fs(n){const e=n.textNode,t=n.parent;if(e){const i=n.offset-e.startOffset,o=e.index;t._removeChildren(o,1);const s=new Ce(e.data.substr(0,i),e.getAttributes()),r=new Ce(e.data.substr(i),e.getAttributes());t._insertChild(o,[s,r])}}function Gp(n,e){const t=n.getAttributes(),i=e.getAttributes();for(const o of t){if(o[1]!==e.getAttribute(o[0]))return!1;i.next()}return i.next().done}class re extends It{constructor(e,t,i,o){super(o),h(this,"sourcePosition"),h(this,"howMany"),h(this,"targetPosition"),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=="$graveyard"?"remove":this.sourcePosition.root.rootName=="$graveyard"?"reinsert":"move"}get affectedSelectable(){return[y._createFromPositionAndShift(this.sourcePosition,this.howMany),y._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new re(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 re(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent,i=this.sourcePosition.offset,o=this.targetPosition.offset;if(i+this.howMany>e.maxOffset)throw new b("move-operation-nodes-do-not-exist",this);if(e===t&&i<o&&o<i+this.howMany)throw new b("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&Xe(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())=="prefix"){const s=this.sourcePosition.path.length-1;if(this.targetPosition.path[s]>=i&&this.targetPosition.path[s]<i+this.howMany)throw new b("move-operation-node-into-itself",this)}}_execute(){ds(y._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=C.fromJSON(e.sourcePosition,t),o=C.fromJSON(e.targetPosition,t);return new this(i,e.howMany,o,e.baseVersion)}}class je extends It{constructor(e,t,i){super(i),h(this,"position"),h(this,"nodes"),h(this,"shouldReceiveAttributes"),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new Xo(qp(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new Xo([...this.nodes].map(i=>i._clone(!0))),t=new je(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new C(e,[0]);return new re(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new b("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new Xo([...e].map(t=>t._clone(!0))),Xc(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const i=[];for(const s of e.nodes)s.name?i.push(ne.fromJSON(s)):i.push(Ce.fromJSON(s));const o=new je(C.fromJSON(e.position,t),i,e.baseVersion);return o.shouldReceiveAttributes=e.shouldReceiveAttributes,o}}class we extends It{constructor(e,t,i,o,s){super(s),h(this,"splitPosition"),h(this,"howMany"),h(this,"insertionPosition"),h(this,"graveyardPosition"),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=o?o.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new C(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new y(this.splitPosition,e)}get affectedSelectable(){const e=[y._createFromPositionAndShift(this.splitPosition,0),y._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(y._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new we(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new C(e,[0]);return new Oe(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset<t)throw new b("split-operation-position-invalid",this);if(e.parent){if(this.howMany!=e.maxOffset-this.splitPosition.offset)throw new b("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new b("split-operation-graveyard-position-invalid",this)}else throw new b("split-operation-split-in-root",this)}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)ds(y._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const i=e._clone();Xc(this.insertionPosition,i)}const t=new y(C._createAt(e,this.splitPosition.offset),C._createAt(e,e.maxOffset));ds(t,this.moveTargetPosition)}toJSON(){const e=super.toJSON();return e.splitPosition=this.splitPosition.toJSON(),e.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(e.graveyardPosition=this.graveyardPosition.toJSON()),e}static get className(){return"SplitOperation"}static getInsertionPosition(e){const t=e.path.slice(0,-1);return t[t.length-1]++,new C(e.root,t,"toPrevious")}static fromJSON(e,t){const i=C.fromJSON(e.splitPosition,t),o=C.fromJSON(e.insertionPosition,t),s=e.graveyardPosition?C.fromJSON(e.graveyardPosition,t):null;return new this(i,e.howMany,o,s,e.baseVersion)}}class Oe extends It{constructor(e,t,i,o,s){super(s),h(this,"sourcePosition"),h(this,"howMany"),h(this,"targetPosition"),h(this,"graveyardPosition"),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=o.clone()}get type(){return"merge"}get deletionPosition(){return new C(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new y(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[y._createOn(e),y._createFromPositionAndShift(this.targetPosition,0),y._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new Oe(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 C(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new we(e,this.howMany,i,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(e.parent)if(t.parent){if(this.howMany!=e.maxOffset)throw new b("merge-operation-how-many-invalid",this)}else throw new b("merge-operation-target-position-invalid",this);else throw new b("merge-operation-source-position-invalid",this)}_execute(){const e=this.sourcePosition.parent,t=y._createIn(e);ds(t,this.targetPosition),ds(y._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=C.fromJSON(e.sourcePosition,t),o=C.fromJSON(e.targetPosition,t),s=C.fromJSON(e.graveyardPosition,t);return new this(i,e.howMany,o,s,e.baseVersion)}}class ot extends It{constructor(e,t,i,o,s,r){super(r),h(this,"name"),h(this,"oldRange"),h(this,"newRange"),h(this,"affectsData"),h(this,"_markers"),this.name=e,this.oldRange=t?t.clone():null,this.newRange=i?i.clone():null,this.affectsData=s,this._markers=o}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 ot(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new ot(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 ot(e.name,e.oldRange?y.fromJSON(e.oldRange,t):null,e.newRange?y.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}class Le extends It{constructor(e,t,i,o,s){super(s),h(this,"range"),h(this,"key"),h(this,"oldValue"),h(this,"newValue"),this.range=e.clone(),this.key=t,this.oldValue=i===void 0?null:i,this.newValue=o===void 0?null:o}get type(){return this.oldValue===null?"addAttribute":this.newValue===null?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new Le(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Le(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 b("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(this.oldValue!==null&&!lo(e.getAttribute(this.key),this.oldValue))throw new b("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(this.oldValue===null&&this.newValue!==null&&e.hasAttribute(this.key))throw new b("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){lo(this.oldValue,this.newValue)||v2(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new Le(y.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}class De extends It{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new De(this.baseVersion)}getReversed(){return new De(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class dt extends It{constructor(e,t,i,o){super(o),h(this,"position"),h(this,"oldName"),h(this,"newName"),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 dt(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new dt(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(e instanceof ne){if(e.name!==this.oldName)throw new b("rename-operation-wrong-name",this)}else throw new b("rename-operation-wrong-position",this)}_execute(){const e=this.position.nodeAfter;e.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new dt(C.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class Ci extends It{constructor(e,t,i,o,s){super(s),h(this,"root"),h(this,"key"),h(this,"oldValue"),h(this,"newValue"),this.root=e,this.key=t,this.oldValue=i===void 0?null:i,this.newValue=o===void 0?null:o}get type(){return this.oldValue===null?"addRootAttribute":this.newValue===null?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new Ci(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Ci(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new b("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(this.oldValue!==null&&this.root.getAttribute(this.key)!==this.oldValue)throw new b("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(this.oldValue===null&&this.newValue!==null&&this.root.hasAttribute(this.key))throw new b("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){this.newValue!==null?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new b("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new Ci(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class ni extends It{constructor(e,t,i,o,s){if(super(s),h(this,"rootName"),h(this,"elementName"),h(this,"isAdd"),h(this,"_document"),this.rootName=e,this.elementName=t,this.isAdd=i,this._document=o,!this._document.getRoot(this.rootName)){const r=this._document.createRoot(this.elementName,this.rootName);r._isAttached=!1}}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new ni(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new ni(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 ni(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}}const zt={};zt[Le.className]=Le;zt[je.className]=je;zt[ot.className]=ot;zt[re.className]=re;zt[De.className]=De;zt[It.className]=It;zt[dt.className]=dt;zt[Ci.className]=Ci;zt[ni.className]=ni;zt[we.className]=we;zt[Oe.className]=Oe;class y2{static fromJSON(e,t){return zt[e.__className].fromJSON(e,t)}}const Gl=new Map;function ie(n,e,t){let i=Gl.get(n);i||(i=new Map,Gl.set(n,i)),i.set(e,t)}function k2(n,e){const t=Gl.get(n);return t&&t.has(e)?t.get(e):C2}function C2(n){return[n]}function Uh(n,e,t={}){const i=k2(n.constructor,e.constructor);try{return n=n.clone(),i(n,e,t)}catch(o){throw o}}function A2(n,e,t){n=n.slice(),e=e.slice();const i=new x2(t.document,t.useRelations,t.forceWeakRemove);i.setOriginalOperations(n),i.setOriginalOperations(e);const o=i.originalOperations;if(n.length==0||e.length==0)return{operationsA:n,operationsB:e,originalOperations:o};const s=new WeakMap;for(const l of n)s.set(l,0);const r={nextBaseVersionA:n[n.length-1].baseVersion+1,nextBaseVersionB:e[e.length-1].baseVersion+1,originalOperationsACount:n.length,originalOperationsBCount:e.length};let a=0;for(;a<n.length;){const l=n[a],c=s.get(l);if(c==e.length){a++;continue}const u=e[c],d=Uh(l,u,i.getContext(l,u,!0)),m=Uh(u,l,i.getContext(u,l,!1));i.updateRelation(l,u),i.setOriginalOperations(d,l),i.setOriginalOperations(m,u);for(const f of d)s.set(f,c+m.length);n.splice(a,1,...d),e.splice(c,1,...m)}return Gh(n),Gh(e),qh(n,r.nextBaseVersionB),qh(e,r.nextBaseVersionA),{operationsA:n,operationsB:e,originalOperations:o}}class x2{constructor(e,t,i=!1){h(this,"originalOperations"),h(this,"_history"),h(this,"_useRelations"),h(this,"_forceWeakRemove"),h(this,"_relations"),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 o of e)this.originalOperations.set(o,i||o)}updateRelation(e,t){if(e instanceof re)t instanceof Oe?e.targetPosition.isEqual(t.sourcePosition)||t.movedRange.containsPosition(e.targetPosition)?this._setRelation(e,t,"insertAtSource"):e.targetPosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"insertBetween"):e.targetPosition.isAfter(t.sourcePosition)&&this._setRelation(e,t,"moveTargetAfter"):t instanceof re&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof we){if(t instanceof Oe)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof re)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const i=y._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const o=i.end.offset-e.splitPosition.offset,s=e.splitPosition.offset-i.start.offset;this._setRelation(e,t,{howMany:o,offset:s})}}}else if(e instanceof Oe)t instanceof Oe?(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 we?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof re&&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 ot){const i=e.newRange;if(!i)return;if(t instanceof Oe){const o=i.start.isEqual(t.targetPosition),s=i.start.isEqual(t.deletionPosition),r=i.end.isEqual(t.deletionPosition),a=i.end.isEqual(t.sourcePosition);(o||s||r||a)&&this._setRelation(e,t,{wasInLeftElement:o,wasStartBeforeMergedElement:s,wasEndBeforeMergedElement:r,wasInRightElement:a})}}}getContext(e,t,i){return{aIsStrong:i,aWasUndone:this._wasUndone(e),bWasUndone:this._wasUndone(t),abRelation:this._useRelations?this._getRelation(e,t):null,baRelation:this._useRelations?this._getRelation(t,e):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(e){const t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){const i=this.originalOperations.get(t),o=this._history.getUndoneOperation(i);if(!o)return null;const s=this.originalOperations.get(e),r=this._relations.get(s);return r&&r.get(o)||null}_setRelation(e,t,i){const o=this.originalOperations.get(e),s=this.originalOperations.get(t);let r=this._relations.get(o);r||(r=new Map,this._relations.set(o,r)),r.set(s,i)}}function qh(n,e){for(const t of n)t.baseVersion=e++}function Gh(n){const e=new Map;for(let t=0;t<n.length;t++){const i=n[t];i instanceof ot&&(i.baseVersion!==-1?e.set(i.name,{op:i,ranges:i.newRange?[i.newRange]:[]}):(i.newRange&&e.get(i.name).ranges.push(i.newRange),n.splice(t,1),t--))}for(const{op:t,ranges:i}of e.values())i.length?t.newRange=y._createFromRanges(i):t.newRange=null}ie(Le,Le,(n,e,t)=>{if(n.key===e.key&&n.range.start.hasSameParentAs(e.range.start)){const i=n.range.getDifference(e.range).map(s=>new Le(s,n.key,n.oldValue,n.newValue,0)),o=n.range.getIntersection(e.range);return o&&t.aIsStrong&&i.push(new Le(o,e.key,e.newValue,n.newValue,0)),i.length==0?[new De(0)]:i}else return[n]});ie(Le,je,(n,e)=>{if(n.range.start.hasSameParentAs(e.position)&&n.range.containsPosition(e.position)){const t=n.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map(i=>new Le(i,n.key,n.oldValue,n.newValue,n.baseVersion));if(e.shouldReceiveAttributes){const i=Kp(e,n.key,n.oldValue);i&&t.unshift(i)}return t}return n.range=n.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[n]});function Kp(n,e,t){const i=n.nodes.getNode(0).getAttribute(e);if(i==t)return null;const o=new y(n.position,n.position.getShiftedBy(n.howMany));return new Le(o,e,i,t,0)}ie(Le,Oe,(n,e)=>{const t=[];n.range.start.hasSameParentAs(e.deletionPosition)&&(n.range.containsPosition(e.deletionPosition)||n.range.start.isEqual(e.deletionPosition))&&t.push(y._createFromPositionAndShift(e.graveyardPosition,1));const i=n.range._getTransformedByMergeOperation(e);return i.isCollapsed||t.push(i),t.map(o=>new Le(o,n.key,n.oldValue,n.newValue,n.baseVersion))});ie(Le,re,(n,e)=>T2(n.range,e).map(t=>new Le(t,n.key,n.oldValue,n.newValue,n.baseVersion)));function T2(n,e){const t=y._createFromPositionAndShift(e.sourcePosition,e.howMany);let i=null,o=[];t.containsRange(n,!0)?i=n:n.start.hasSameParentAs(t.start)?(o=n.getDifference(t),i=n.getIntersection(t)):o=[n];const s=[];for(let r of o){r=r._getTransformedByDeletion(e.sourcePosition,e.howMany);const a=e.getMovedRangeStart(),l=r.start.hasSameParentAs(a),c=r._getTransformedByInsertion(a,e.howMany,l);s.push(...c)}return i&&s.push(i._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]),s}ie(Le,we,(n,e)=>{if(n.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||n.range.end.offset++,[n];if(n.range.start.hasSameParentAs(e.splitPosition)&&n.range.containsPosition(e.splitPosition)){const t=n.clone();return t.range=new y(e.moveTargetPosition.clone(),n.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),n.range.end=e.splitPosition.clone(),n.range.end.stickiness="toPrevious",[n,t]}return n.range=n.range._getTransformedBySplitOperation(e),[n]});ie(je,Le,(n,e)=>{const t=[n];if(n.shouldReceiveAttributes&&n.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(n.position)){const i=Kp(n,e.key,e.newValue);i&&t.push(i)}return t});ie(je,je,(n,e,t)=>n.position.isEqual(e.position)&&t.aIsStrong?[n]:(n.position=n.position._getTransformedByInsertOperation(e),[n]));ie(je,re,(n,e)=>(n.position=n.position._getTransformedByMoveOperation(e),[n]));ie(je,we,(n,e)=>(n.position=n.position._getTransformedBySplitOperation(e),[n]));ie(je,Oe,(n,e)=>(n.position=n.position._getTransformedByMergeOperation(e),[n]));ie(ot,je,(n,e)=>(n.oldRange&&(n.oldRange=n.oldRange._getTransformedByInsertOperation(e)[0]),n.newRange&&(n.newRange=n.newRange._getTransformedByInsertOperation(e)[0]),[n]));ie(ot,ot,(n,e,t)=>{if(n.name==e.name)if(t.aIsStrong)n.oldRange=e.newRange?e.newRange.clone():null;else return[new De(0)];return[n]});ie(ot,Oe,(n,e)=>(n.oldRange&&(n.oldRange=n.oldRange._getTransformedByMergeOperation(e)),n.newRange&&(n.newRange=n.newRange._getTransformedByMergeOperation(e)),[n]));ie(ot,re,(n,e)=>{const t=[n];if(n.oldRange&&(n.oldRange=y._createFromRanges(n.oldRange._getTransformedByMoveOperation(e))),n.newRange){const i=n.newRange._getTransformedByMoveOperation(e);n.newRange=i[0];for(let o=1;o<i.length;o++){const s=n.clone();s.oldRange=null,s.newRange=i[o],s.baseVersion=-1,t.push(s)}}return t});ie(ot,we,(n,e,t)=>{if(n.oldRange&&(n.oldRange=n.oldRange._getTransformedBySplitOperation(e)),n.newRange){if(t.abRelation){const i=n.newRange._getTransformedBySplitOperation(e);return n.newRange.start.isEqual(e.splitPosition)?t.abRelation.wasStartBeforeMergedElement?n.newRange.start=C._createAt(e.insertionPosition):t.abRelation.wasInLeftElement?n.newRange.start=C._createAt(n.newRange.start):n.newRange.start=C._createAt(e.moveTargetPosition):n.newRange.start=i.start,n.newRange.end.isEqual(e.splitPosition)?n.newRange.end.isEqual(e.splitPosition)&&t.abRelation.wasEndBeforeMergedElement?n.newRange.end=C._createAt(e.insertionPosition):t.abRelation.wasInRightElement?n.newRange.end=C._createAt(e.moveTargetPosition):n.newRange.end=C._createAt(n.newRange.end):n.newRange.end=i.end,[n]}n.newRange=n.newRange._getTransformedBySplitOperation(e)}return[n]});ie(Oe,je,(n,e)=>(n.sourcePosition.hasSameParentAs(e.position)&&(n.howMany+=e.howMany),n.sourcePosition=n.sourcePosition._getTransformedByInsertOperation(e),n.targetPosition=n.targetPosition._getTransformedByInsertOperation(e),[n]));ie(Oe,Oe,(n,e,t)=>{if(n.sourcePosition.isEqual(e.sourcePosition)&&n.targetPosition.isEqual(e.targetPosition))if(t.bWasUndone){const i=e.graveyardPosition.path.slice();return i.push(0),n.sourcePosition=new C(e.graveyardPosition.root,i),n.howMany=0,[n]}else return[new De(0)];if(n.sourcePosition.isEqual(e.sourcePosition)&&!n.targetPosition.isEqual(e.targetPosition)&&!t.bWasUndone&&t.abRelation!="splitAtSource"){const i=n.targetPosition.root.rootName=="$graveyard",o=e.targetPosition.root.rootName=="$graveyard";if(o&&!i||!(i&&!o)&&t.aIsStrong){const s=e.targetPosition._getTransformedByMergeOperation(e),r=n.targetPosition._getTransformedByMergeOperation(e);return[new re(s,n.howMany,r,0)]}else return[new De(0)]}return n.sourcePosition.hasSameParentAs(e.targetPosition)&&(n.howMany+=e.howMany),n.sourcePosition=n.sourcePosition._getTransformedByMergeOperation(e),n.targetPosition=n.targetPosition._getTransformedByMergeOperation(e),(!n.graveyardPosition.isEqual(e.graveyardPosition)||!t.aIsStrong)&&(n.graveyardPosition=n.graveyardPosition._getTransformedByMergeOperation(e)),[n]});ie(Oe,re,(n,e,t)=>{const i=y._createFromPositionAndShift(e.sourcePosition,e.howMany);return e.type=="remove"&&!t.bWasUndone&&n.deletionPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(n.sourcePosition)?[new De(0)]:(e.sourcePosition.getShiftedBy(e.howMany).isEqual(n.sourcePosition)?n.sourcePosition.stickiness="toNone":e.targetPosition.isEqual(n.sourcePosition)&&t.abRelation=="mergeSourceAffected"?n.sourcePosition.stickiness="toNext":e.sourcePosition.isEqual(n.targetPosition)?(n.targetPosition.stickiness="toNone",n.howMany-=e.howMany):e.targetPosition.isEqual(n.targetPosition)&&t.abRelation=="mergeTargetWasBefore"?(n.targetPosition.stickiness="toPrevious",n.howMany+=e.howMany):(n.sourcePosition.hasSameParentAs(e.targetPosition)&&(n.howMany+=e.howMany),n.sourcePosition.hasSameParentAs(e.sourcePosition)&&(n.howMany-=e.howMany)),n.sourcePosition=n.sourcePosition._getTransformedByMoveOperation(e),n.targetPosition=n.targetPosition._getTransformedByMoveOperation(e),n.sourcePosition.stickiness="toPrevious",n.targetPosition.stickiness="toNext",n.graveyardPosition.isEqual(e.targetPosition)||(n.graveyardPosition=n.graveyardPosition._getTransformedByMoveOperation(e)),[n])});ie(Oe,we,(n,e,t)=>{if(e.graveyardPosition&&(n.graveyardPosition=n.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),n.deletionPosition.isEqual(e.graveyardPosition)&&(n.howMany=e.howMany)),n.targetPosition.isEqual(e.splitPosition)&&(e.graveyardPosition&&n.deletionPosition.isEqual(e.graveyardPosition)||t.abRelation=="mergeTargetNotMoved"))return n.sourcePosition=n.sourcePosition._getTransformedBySplitOperation(e),[n];if(n.sourcePosition.isEqual(e.splitPosition)){if(t.abRelation=="mergeSourceNotMoved")return n.howMany=0,n.targetPosition=n.targetPosition._getTransformedBySplitOperation(e),[n];if(t.abRelation=="mergeSameElement"||n.sourcePosition.offset>0)return n.sourcePosition=e.moveTargetPosition.clone(),n.targetPosition=n.targetPosition._getTransformedBySplitOperation(e),[n]}return n.sourcePosition.hasSameParentAs(e.splitPosition)&&(n.howMany=e.splitPosition.offset),n.sourcePosition=n.sourcePosition._getTransformedBySplitOperation(e),n.targetPosition=n.targetPosition._getTransformedBySplitOperation(e),[n]});ie(re,je,(n,e)=>{const t=y._createFromPositionAndShift(n.sourcePosition,n.howMany)._getTransformedByInsertOperation(e,!1)[0];return n.sourcePosition=t.start,n.howMany=t.end.offset-t.start.offset,n.targetPosition.isEqual(e.position)||(n.targetPosition=n.targetPosition._getTransformedByInsertOperation(e)),[n]});ie(re,re,(n,e,t)=>{const i=y._createFromPositionAndShift(n.sourcePosition,n.howMany),o=y._createFromPositionAndShift(e.sourcePosition,e.howMany);let s=t.aIsStrong,r=!t.aIsStrong;t.abRelation=="insertBefore"||t.baRelation=="insertAfter"?r=!0:(t.abRelation=="insertAfter"||t.baRelation=="insertBefore")&&(r=!1);let a;if(n.targetPosition.isEqual(e.targetPosition)&&r?a=n.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):a=n.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Kh(n,e)&&Kh(e,n))return[e.getReversed()];if(i.containsPosition(e.targetPosition)&&i.containsRange(o,!0))return i.start=i.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),i.end=i.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),no([i],a);if(o.containsPosition(n.targetPosition)&&o.containsRange(i,!0))return i.start=i.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),i.end=i.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),no([i],a);const l=Xe(n.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if(l=="prefix"||l=="extension")return i.start=i.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),i.end=i.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),no([i],a);n.type=="remove"&&e.type!="remove"&&!t.aWasUndone&&!t.forceWeakRemove?s=!0:n.type!="remove"&&e.type=="remove"&&!t.bWasUndone&&!t.forceWeakRemove&&(s=!1);const c=[],u=i.getDifference(o);for(const m of u){m.start=m.start._getTransformedByDeletion(e.sourcePosition,e.howMany),m.end=m.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const f=Xe(m.start.getParentPath(),e.getMovedRangeStart().getParentPath())=="same",g=m._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,f);c.push(...g)}const d=i.getIntersection(o);return d!==null&&s&&(d.start=d.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),d.end=d.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),c.length===0?c.push(d):c.length==1?o.start.isBefore(i.start)||o.start.isEqual(i.start)?c.unshift(d):c.push(d):c.splice(1,0,d)),c.length===0?[new De(n.baseVersion)]:no(c,a)});ie(re,we,(n,e,t)=>{let i=n.targetPosition.clone();(!n.targetPosition.isEqual(e.insertionPosition)||!e.graveyardPosition||t.abRelation=="moveTargetAfter")&&(i=n.targetPosition._getTransformedBySplitOperation(e));const o=y._createFromPositionAndShift(n.sourcePosition,n.howMany);if(o.end.isEqual(e.insertionPosition))return e.graveyardPosition||n.howMany++,n.targetPosition=i,[n];if(o.start.hasSameParentAs(e.splitPosition)&&o.containsPosition(e.splitPosition)){let r=new y(e.splitPosition,o.end);r=r._getTransformedBySplitOperation(e);const a=[new y(o.start,e.splitPosition),r];return no(a,i)}n.targetPosition.isEqual(e.splitPosition)&&t.abRelation=="insertAtSource"&&(i=e.moveTargetPosition),n.targetPosition.isEqual(e.insertionPosition)&&t.abRelation=="insertBetween"&&(i=n.targetPosition);const s=[o._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const r=o.start.isEqual(e.graveyardPosition)||o.containsPosition(e.graveyardPosition);n.howMany>1&&r&&!t.aWasUndone&&s.push(y._createFromPositionAndShift(e.insertionPosition,1))}return no(s,i)});ie(re,Oe,(n,e,t)=>{const i=y._createFromPositionAndShift(n.sourcePosition,n.howMany);if(e.deletionPosition.hasSameParentAs(n.sourcePosition)&&i.containsPosition(e.sourcePosition)){if(n.type=="remove"&&!t.forceWeakRemove){if(!t.aWasUndone){const s=[];let r=e.graveyardPosition.clone(),a=e.targetPosition._getTransformedByMergeOperation(e);const l=n.targetPosition.getTransformedByOperation(e);n.howMany>1&&(s.push(new re(n.sourcePosition,n.howMany-1,l,0)),r=r._getTransformedByMove(n.sourcePosition,l,n.howMany-1),a=a._getTransformedByMove(n.sourcePosition,l,n.howMany-1));const c=e.deletionPosition._getCombined(n.sourcePosition,l),u=new re(r,1,c,0),d=u.getMovedRangeStart().path.slice();d.push(0);const m=new C(u.targetPosition.root,d);a=a._getTransformedByMove(r,c,1);const f=new re(a,e.howMany,m,0);return s.push(u),s.push(f),s}}else if(n.howMany==1)return t.bWasUndone?(n.sourcePosition=e.graveyardPosition.clone(),n.targetPosition=n.targetPosition._getTransformedByMergeOperation(e),[n]):[new De(0)]}const o=y._createFromPositionAndShift(n.sourcePosition,n.howMany)._getTransformedByMergeOperation(e);return n.sourcePosition=o.start,n.howMany=o.end.offset-o.start.offset,n.targetPosition=n.targetPosition._getTransformedByMergeOperation(e),[n]});ie(dt,je,(n,e)=>(n.position=n.position._getTransformedByInsertOperation(e),[n]));ie(dt,Oe,(n,e)=>n.position.isEqual(e.deletionPosition)?(n.position=e.graveyardPosition.clone(),n.position.stickiness="toNext",[n]):(n.position=n.position._getTransformedByMergeOperation(e),[n]));ie(dt,re,(n,e)=>(n.position=n.position._getTransformedByMoveOperation(e),[n]));ie(dt,dt,(n,e,t)=>{if(n.position.isEqual(e.position))if(t.aIsStrong)n.oldName=e.newName;else return[new De(0)];return[n]});ie(dt,we,(n,e)=>{const t=n.position.path,i=e.splitPosition.getParentPath();if(Xe(t,i)=="same"&&!e.graveyardPosition){const o=new dt(n.position.getShiftedBy(1),n.oldName,n.newName,0);return[n,o]}return n.position=n.position._getTransformedBySplitOperation(e),[n]});ie(Ci,Ci,(n,e,t)=>{if(n.root===e.root&&n.key===e.key){if(!t.aIsStrong||n.newValue===e.newValue)return[new De(0)];n.oldValue=e.newValue}return[n]});ie(ni,ni,(n,e)=>n.rootName===e.rootName&&n.isAdd===e.isAdd?[new De(0)]:[n]);ie(we,je,(n,e)=>(n.splitPosition.hasSameParentAs(e.position)&&n.splitPosition.offset<e.position.offset&&(n.howMany+=e.howMany),n.splitPosition=n.splitPosition._getTransformedByInsertOperation(e),n.insertionPosition=n.insertionPosition._getTransformedByInsertOperation(e),[n]));ie(we,Oe,(n,e,t)=>{if(!n.graveyardPosition&&!t.bWasUndone&&n.splitPosition.hasSameParentAs(e.sourcePosition)){const i=e.graveyardPosition.path.slice();i.push(0);const o=new C(e.graveyardPosition.root,i),s=we.getInsertionPosition(new C(e.graveyardPosition.root,i)),r=new we(o,0,s,null,0);return n.splitPosition=n.splitPosition._getTransformedByMergeOperation(e),n.insertionPosition=we.getInsertionPosition(n.splitPosition),n.graveyardPosition=r.insertionPosition.clone(),n.graveyardPosition.stickiness="toNext",[r,n]}return n.splitPosition.hasSameParentAs(e.deletionPosition)&&!n.splitPosition.isAfter(e.deletionPosition)&&n.howMany--,n.splitPosition.hasSameParentAs(e.targetPosition)&&(n.howMany+=e.howMany),n.splitPosition=n.splitPosition._getTransformedByMergeOperation(e),n.insertionPosition=we.getInsertionPosition(n.splitPosition),n.graveyardPosition&&(n.graveyardPosition=n.graveyardPosition._getTransformedByMergeOperation(e)),[n]});ie(we,re,(n,e,t)=>{const i=y._createFromPositionAndShift(e.sourcePosition,e.howMany);if(n.graveyardPosition){const s=i.start.isEqual(n.graveyardPosition)||i.containsPosition(n.graveyardPosition);if(!t.bWasUndone&&s){const r=n.splitPosition._getTransformedByMoveOperation(e),a=n.graveyardPosition._getTransformedByMoveOperation(e),l=a.path.slice();l.push(0);const c=new C(a.root,l);return[new re(r,n.howMany,c,0)]}n.graveyardPosition=n.graveyardPosition._getTransformedByMoveOperation(e)}const o=n.splitPosition.isEqual(e.targetPosition);if(o&&(t.baRelation=="insertAtSource"||t.abRelation=="splitBefore"))return n.howMany+=e.howMany,n.splitPosition=n.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),n.insertionPosition=we.getInsertionPosition(n.splitPosition),[n];if(o&&t.abRelation&&t.abRelation.howMany){const{howMany:s,offset:r}=t.abRelation;return n.howMany+=s,n.splitPosition=n.splitPosition.getShiftedBy(r),[n]}if(n.splitPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(n.splitPosition)){const s=e.howMany-(n.splitPosition.offset-e.sourcePosition.offset);return n.howMany-=s,n.splitPosition.hasSameParentAs(e.targetPosition)&&n.splitPosition.offset<e.targetPosition.offset&&(n.howMany+=e.howMany),n.splitPosition=e.sourcePosition.clone(),n.insertionPosition=we.getInsertionPosition(n.splitPosition),[n]}return e.sourcePosition.isEqual(e.targetPosition)||(n.splitPosition.hasSameParentAs(e.sourcePosition)&&n.splitPosition.offset<=e.sourcePosition.offset&&(n.howMany-=e.howMany),n.splitPosition.hasSameParentAs(e.targetPosition)&&n.splitPosition.offset<e.targetPosition.offset&&(n.howMany+=e.howMany)),n.splitPosition.stickiness="toNone",n.splitPosition=n.splitPosition._getTransformedByMoveOperation(e),n.splitPosition.stickiness="toNext",n.graveyardPosition?n.insertionPosition=n.insertionPosition._getTransformedByMoveOperation(e):n.insertionPosition=we.getInsertionPosition(n.splitPosition),[n]});ie(we,we,(n,e,t)=>{if(n.splitPosition.isEqual(e.splitPosition)){if(!n.graveyardPosition&&!e.graveyardPosition)return[new De(0)];if(n.graveyardPosition&&e.graveyardPosition&&n.graveyardPosition.isEqual(e.graveyardPosition))return[new De(0)];if(t.abRelation=="splitBefore")return n.howMany=0,n.graveyardPosition=n.graveyardPosition._getTransformedBySplitOperation(e),[n]}if(n.graveyardPosition&&e.graveyardPosition&&n.graveyardPosition.isEqual(e.graveyardPosition)){const i=n.splitPosition.root.rootName=="$graveyard",o=e.splitPosition.root.rootName=="$graveyard";if(o&&!i||!(i&&!o)&&t.aIsStrong){const s=[];return e.howMany&&s.push(new re(e.moveTargetPosition,e.howMany,e.splitPosition,0)),n.howMany&&s.push(new re(n.splitPosition,n.howMany,n.moveTargetPosition,0)),s}else return[new De(0)]}if(n.graveyardPosition&&(n.graveyardPosition=n.graveyardPosition._getTransformedBySplitOperation(e)),n.splitPosition.isEqual(e.insertionPosition)&&t.abRelation=="splitBefore")return n.howMany++,[n];if(e.splitPosition.isEqual(n.insertionPosition)&&t.baRelation=="splitBefore"){const i=e.insertionPosition.path.slice();i.push(0);const o=new C(e.insertionPosition.root,i),s=new re(n.insertionPosition,1,o,0);return[n,s]}return n.splitPosition.hasSameParentAs(e.splitPosition)&&n.splitPosition.offset<e.splitPosition.offset&&(n.howMany-=e.howMany),n.splitPosition=n.splitPosition._getTransformedBySplitOperation(e),n.insertionPosition=we.getInsertionPosition(n.splitPosition),[n]});function Kh(n,e){return n.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany)===null}function no(n,e){const t=[];for(let i=0;i<n.length;i++){const o=n[i],s=new re(o.start,o.end.offset-o.start.offset,e,0);t.push(s);for(let r=i+1;r<n.length;r++)n[r]=n[r]._getTransformedByMove(s.sourcePosition,s.targetPosition,s.howMany)[0];e=e._getTransformedByMove(s.sourcePosition,s.targetPosition,s.howMany)}return t}class Me extends ge(C){constructor(e,t,i="toNone"){if(super(e,t,i),!this.root.is("rootElement"))throw new b("model-liveposition-root-not-rootelement",e);E2.call(this)}detach(){this.stopListening()}toPosition(){return new C(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}Me.prototype.is=function(n){return n==="livePosition"||n==="model:livePosition"||n=="position"||n==="model:position"};function E2(){this.listenTo(this.root.document.model,"applyOperation",(n,e)=>{const t=e[0];t.isDocumentOperation&&S2.call(this,t)},{priority:"low"})}function S2(n){const e=this.getTransformedByOperation(n);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}class Nn{constructor(e={}){h(this,"operations"),h(this,"isUndoable"),h(this,"isLocal"),h(this,"isUndo"),h(this,"isTyping"),typeof e=="string"&&(e=e==="transparent"?{isUndoable:!1}:{},J("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:o=!1,isTyping:s=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=o,this.isTyping=s}get type(){return J("batch-type-deprecated"),"default"}get baseVersion(){for(const e of this.operations)if(e.baseVersion!==null)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}const Zp=class Kl{constructor(e){h(this,"_markerCollection"),h(this,"_changesInElement",new Map),h(this,"_elementsSnapshots",new Map),h(this,"_elementChildrenSnapshots",new Map),h(this,"_elementState",new Map),h(this,"_changedMarkers",new Map),h(this,"_changedRoots",new Map),h(this,"_changeCount",0),h(this,"_cachedChanges",null),h(this,"_cachedChangesWithGraveyard",null),h(this,"_refreshedItems",new Set),this._markerCollection=e}get isEmpty(){return this._changesInElement.size==0&&this._changedMarkers.size==0&&this._changedRoots.size==0}bufferOperation(e){const t=e;switch(t.type){case"insert":{if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break}case"addAttribute":case"removeAttribute":case"changeAttribute":{for(const i of t.range.getItems({shallow:!0}))this._isInInsertedElement(i.parent)||this._markAttribute(i);break}case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const i=this._isInInsertedElement(t.sourcePosition.parent),o=this._isInInsertedElement(t.targetPosition.parent);i||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),o||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);const s=y._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const r of s.getItems({shallow:!0}))this._setElementState(r,"move");break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const i=y._createFromPositionAndShift(t.position,1);for(const o of this._markerCollection.getMarkersIntersectingRange(i)){const s=o.getData();this.bufferMarkerChange(o.name,s,s)}this._setElementState(t.position.nodeAfter,"rename");break}case"split":{const i=t.splitPosition.parent;if(!this._isInInsertedElement(i)){this._markRemove(i,t.splitPosition.offset,t.howMany);const o=y._createFromPositionAndShift(t.splitPosition,t.howMany);for(const s of o.getItems({shallow:!0}))this._setElementState(s,"move")}this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&(this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1),this._setElementState(t.graveyardPosition.nodeAfter,"move"));break}case"merge":{const i=t.sourcePosition.parent;this._isInInsertedElement(i.parent)||this._markRemove(i.parent,i.startOffset,1);const o=t.graveyardPosition.parent;this._markInsert(o,t.graveyardPosition.offset,1),this._setElementState(i,"move");const s=t.targetPosition.parent;if(!this._isInInsertedElement(s)){this._markInsert(s,t.targetPosition.offset,i.maxOffset);const r=y._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const a of r.getItems({shallow:!0}))this._setElementState(a,"move")}break}case"detachRoot":case"addRoot":{const i=t.affectedSelectable;if(!i._isLoaded||i.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const i=t.root.rootName;this._bufferRootAttributeChange(i,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let o=this._changedMarkers.get(e);o?o.newMarkerData=i:(o={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,o)),o.oldMarkerData.range==null&&i.range==null&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)i.oldMarkerData.range!=null&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)i.newMarkerData.range!=null&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}}))}hasDataChanges(){if(this.getChanges().length||this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const i=e.range&&!t.range,o=!e.range&&t.range,s=e.range&&t.range&&!e.range.isEqual(t.range);if(i||o||s)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const i of this._changesInElement.keys()){const o=this._changesInElement.get(i).sort((u,d)=>u.offset===d.offset?u.type!=d.type?u.type=="remove"?-1:1:0:u.offset<d.offset?-1:1),s=this._elementChildrenSnapshots.get(i),r=Jh(i.getChildren()),a=I2(s.length,o);let l=0,c=0;for(const u of a)if(u==="i"){const d=this._getDiffActionForNode(r[l].node,"insert"),m=this._elementsSnapshots.get(r[l].node),f=this._getInsertDiff(i,l,d,r[l],m);t.push(f),l++}else if(u==="r"){const d=this._getDiffActionForNode(s[c].node,"remove"),m=this._getRemoveDiff(i,l,d,s[c]);t.push(m),c++}else if(u==="a"){const d=s[c].attributes,m=r[l].attributes;let f;if(r[l].name=="$text")f=new y(C._createAt(i,l),C._createAt(i,l+1));else{const p=i.offsetToIndex(l);f=new y(C._createAt(i,l),C._createAt(i.getChild(p),0))}const g=this._getAttributesDiff(f,d,m);t.push(...g),l++,c++}else l++,c++}t.sort((i,o)=>i.position.root!=o.position.root?i.position.root.rootName<o.position.root.rootName?-1:1:i.position.isEqual(o.position)?i.changeCount-o.changeCount:i.position.isBefore(o.position)?-1:1);for(let i=1,o=0;i<t.length;i++){const s=t[o],r=t[i],a=s.type=="remove"&&r.type=="remove"&&s.name=="$text"&&r.name=="$text"&&s.position.isEqual(r.position),l=s.type=="insert"&&r.type=="insert"&&s.name=="$text"&&r.name=="$text"&&s.position.parent==r.position.parent&&s.position.offset+s.length==r.position.offset,c=s.type=="attribute"&&r.type=="attribute"&&s.position.parent==r.position.parent&&s.range.isFlat&&r.range.isFlat&&s.position.offset+s.length==r.position.offset&&s.attributeKey==r.attributeKey&&s.attributeOldValue==r.attributeOldValue&&s.attributeNewValue==r.attributeNewValue;a||l||c?(s.length++,c&&(s.range.end=s.range.end.getShiftedBy(1)),t[i]=null):o=i}t=t.filter(i=>i);for(const i of t)delete i.changeCount,i.type=="attribute"&&(delete i.position,delete i.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(V2),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{const t={...e};return t.state!==void 0&&delete t.attributes,t})}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementChildrenSnapshots.clear(),this._elementsSnapshots.clear(),this._elementState.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems.clear(),this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e),this._setElementState(e,"refresh");const t=y._createOn(e);for(const i of this._markerCollection.getMarkersIntersectingRange(t)){const o=i.getData();this.bufferMarkerChange(i.name,o,o)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const i=t.getData();this.bufferMarkerChange(t.name,{...i,range:null},i)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e)){this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});return}const i=this._changedRoots.get(e);i.state!==void 0?(delete i.state,i.attributes===void 0&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,o){const s=this._changedRoots.get(e)||{name:e},r=s.attributes||{};if(r[t]){const a=r[t];o===a.oldValue?delete r[t]:a.newValue=o}else r[t]={oldValue:i,newValue:o};Object.entries(r).length===0?(delete s.attributes,s.state===void 0&&this._changedRoots.delete(e)):(s.attributes=r,this._changedRoots.set(e,s))}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const o={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,o)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const o={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,o),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshots(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let o=0;o<i.length;o++)i[o].howMany<1&&(i.splice(o,1),o--)}_setElementState(e,t){if(!e.is("element"))return;const i=Kl._statesPriority.indexOf(this._elementState.get(e));Kl._statesPriority.indexOf(t)>i&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element")||!this._elementsSnapshots.has(e))return t;const i=this._elementState.get(e);return!i||i=="move"?t:i}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshots(e){if(this._elementChildrenSnapshots.has(e))return;const t=Jh(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(const i of t)this._elementsSnapshots.set(i.node,i)}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const i of t){const o=e.offset+e.howMany,s=i.offset+i.howMany;if(e.type=="insert"&&(i.type=="insert"&&(e.offset<=i.offset?i.offset+=e.howMany:e.offset<s&&(i.howMany+=e.nodesToHandle,e.nodesToHandle=0)),i.type=="remove"&&e.offset<i.offset&&(i.offset+=e.howMany),i.type=="attribute")){if(e.offset<=i.offset)i.offset+=e.howMany;else if(e.offset<s){const r=i.howMany;i.howMany=e.offset-i.offset,t.unshift({type:"attribute",offset:o,howMany:r-i.howMany,count:this._changeCount++})}}if(e.type=="remove"){if(i.type=="insert"){if(o<=i.offset)i.offset-=e.howMany;else if(o<=s)if(e.offset<i.offset){const r=o-i.offset;i.offset=e.offset,i.howMany-=r,e.nodesToHandle-=r}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 r=s-e.offset;i.howMany-=r,e.nodesToHandle-=r}}if(i.type=="remove"&&(o<=i.offset?i.offset-=e.howMany:e.offset<i.offset&&(e.nodesToHandle+=i.howMany,i.howMany=0)),i.type=="attribute"){if(o<=i.offset)i.offset-=e.howMany;else if(e.offset<i.offset){const r=o-i.offset;i.offset=e.offset,i.howMany-=r}else if(e.offset<s)if(o<=s){const r=i.howMany;i.howMany=e.offset-i.offset;const a=r-i.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:a,count:this._changeCount++})}else i.howMany-=s-e.offset}}if(e.type=="attribute"){if(i.type=="insert")if(e.offset<i.offset&&o>i.offset){if(o>s){const r={type:"attribute",offset:s,howMany:o-s,count:this._changeCount++};this._handleChange(r,t),t.push(r)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offset<s&&(o>s?(e.nodesToHandle=o-s,e.offset=s):e.nodesToHandle=0);if(i.type=="remove"&&e.offset<i.offset&&o>i.offset){const r={type:"attribute",offset:i.offset,howMany:o-i.offset,count:this._changeCount++};this._handleChange(r,t),t.push(r),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}i.type=="attribute"&&(e.offset>=i.offset&&o<=s?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&o>=s&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i,o,s){const r={type:"insert",position:C._createAt(e,t),name:o.name,attributes:new Map(o.attributes),length:1,changeCount:this._changeCount++,action:i};return i!="insert"&&s&&(r.before={name:s.name,attributes:new Map(s.attributes)}),r}_getRemoveDiff(e,t,i,o){return{type:"remove",action:i,position:C._createAt(e,t),name:o.name,attributes:new Map(o.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const o=[];i=new Map(i);for(const[s,r]of t){const a=i.has(s)?i.get(s):null;a!==r&&o.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:r,attributeNewValue:a,changeCount:this._changeCount++}),i.delete(s)}for(const[s,r]of i)o.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:s,attributeOldValue:null,attributeNewValue:r,changeCount:this._changeCount++});return o}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),o=e.startOffset;if(i){for(const s of i)if(s.type=="insert"&&o>=s.offset&&o<s.offset+s.howMany)return!0}return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,i){const o=new y(C._createAt(e,t),C._createAt(e,t+i));for(const s of o.getItems({shallow:!0}))s.is("element")&&(this._changesInElement.delete(s),this._removeAllNestedChanges(s,0,s.maxOffset))}};h(Zp,"_statesPriority",[void 0,"refresh","rename","move"]);let P2=Zp;function Zh(n){return{node:n,name:n.is("$text")?"$text":n.name,attributes:new Map(n.getAttributes())}}function Jh(n){const e=[];for(const t of n)if(t.is("$text"))for(let i=0;i<t.data.length;++i)e.push(Zh(t));else e.push(Zh(t));return e}function I2(n,e){const t=[];let i=0,o=0;for(const s of e){if(s.offset>i){for(let r=0;r<s.offset-i;r++)t.push("e");o+=s.offset-i}if(s.type=="insert"){for(let r=0;r<s.howMany;r++)t.push("i");i=s.offset+s.howMany}else if(s.type=="remove"){for(let r=0;r<s.howMany;r++)t.push("r");i=s.offset,o+=s.howMany}else{if(s.howMany>1500)for(let r=0;r<s.howMany;r++)t.push("a");else t.push(..."a".repeat(s.howMany).split(""));i=s.offset+s.howMany,o+=s.howMany}}if(o<n)for(let s=0;s<n-o-i;s++)t.push("e");return t}function V2(n){const e="position"in n&&n.position.root.rootName=="$graveyard",t="range"in n&&n.range.root.rootName=="$graveyard";return!e&&!t}class R2{constructor(){h(this,"_operations",[]),h(this,"_undoPairs",new Map),h(this,"_undoneOperations",new Set),h(this,"_baseVersionToOperationIndex",new Map),h(this,"_version",0),h(this,"_gaps",new Map)}get version(){return this._version}set version(e){this._operations.length&&e>this._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new b("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const i=this._operations[0];e===void 0&&(e=i.baseVersion);let o=t-1;for(const[a,l]of this._gaps)e>a&&e<l&&(e=l),o>a&&o<l&&(o=a-1);if(o<i.baseVersion||e>this.lastOperation.baseVersion)return[];let s=this._baseVersionToOperationIndex.get(e);s===void 0&&(s=0);let r=this._baseVersionToOperationIndex.get(o);return r===void 0&&(r=this._operations.length-1),this._operations.slice(s,r+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(t!==void 0)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class Rr extends ne{constructor(e,t,i="main"){super(t),h(this,"rootName"),h(this,"_document"),h(this,"_isAttached",!0),h(this,"_isLoaded",!0),this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}Rr.prototype.is=function(n,e){return e?e===this.name&&(n==="rootElement"||n==="model:rootElement"||n==="element"||n==="model:element"):n==="rootElement"||n==="model:rootElement"||n==="element"||n==="model:element"||n==="node"||n==="model:node"};const Qh="$graveyard";class O2 extends ge(){constructor(e){super(),h(this,"model"),h(this,"history"),h(this,"selection"),h(this,"roots"),h(this,"differ"),h(this,"isReadOnly"),h(this,"_postFixers"),h(this,"_hasSelectionChangedFromTheLastChangeBlock"),this.model=e,this.history=new R2,this.selection=new Kt(this),this.roots=new _e({idProperty:"rootName"}),this.differ=new P2(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",Qh),this.listenTo(e,"applyOperation",(t,i)=>{const o=i[0];o.isDocumentOperation&&this.differ.bufferOperation(o)},{priority:"high"}),this.listenTo(e,"applyOperation",(t,i)=>{const o=i[0];o.isDocumentOperation&&this.history.addOperation(o)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(t,i,o,s,r)=>{const a={...i.getData(),range:s};this.differ.bufferMarkerChange(i.name,r,a),o===null&&i.on("change",(l,c)=>{const u=i.getData();this.differ.bufferMarkerChange(i.name,{...u,range:c},u)})}),this.registerPostFixer(t=>{let i=!1;for(const o of this.roots)!o.isAttached()&&!o.isEmpty&&(t.remove(t.createRangeIn(o)),i=!0);for(const o of this.model.markers)o.getRange().root.isAttached()||(t.removeMarker(o),i=!0);return i})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(Qh)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new b("model-document-createroot-name-exists",this,{name:t});const i=new Rr(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(t=>t.rootName)}getRoots(e=!1){return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=Oc(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,o=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(o)||t.createRange(o)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&Yh(e.start)&&Yh(e.end)}_callPostFixers(e){let t=!1;do for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break;while(t)}}function Yh(n){const e=n.textNode;if(e){const t=e.data,i=n.offset-e.startOffset;return!jc(t,i)&&!Uc(t,i)}return!0}class B2 extends ge(){constructor(){super(...arguments),h(this,"_markers",new Map)}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Kn?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,o=!1){const s=e instanceof Kn?e.name:e;if(s.includes(","))throw new b("markercollection-incorrect-marker-name",this);const r=this._markers.get(s);if(r){const c=r.getData(),u=r.getRange();let d=!1;return u.isEqual(t)||(r._attachLiveRange(ht.fromRange(t)),d=!0),i!=r.managedUsingOperations&&(r._managedUsingOperations=i,d=!0),typeof o=="boolean"&&o!=r.affectsData&&(r._affectsData=o,d=!0),d&&this.fire(`update:${s}`,r,u,t,c),r}const a=ht.fromRange(t),l=new Kn(s,a,i,o);return this._markers.set(s,l),this.fire(`update:${s}`,l,null,t,{...l.getData(),range:null}),l}_remove(e){const t=e instanceof Kn?e.name:e,i=this._markers.get(t);return i?(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0):!1}_refresh(e){const t=e instanceof Kn?e.name:e,i=this._markers.get(t);if(!i)throw new b("markercollection-refresh-marker-not-exists",this);const o=i.getRange();this.fire(`update:${t}`,i,o,o,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)t.getRange().getIntersection(e)!==null&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class Kn extends ge(Yi){constructor(e,t,i,o){super(),h(this,"name"),h(this,"_managedUsingOperations"),h(this,"_affectsData"),h(this,"_liveRange"),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=o}get managedUsingOperations(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new b("marker-destroyed",this);return this._liveRange.toRange()}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}Kn.prototype.is=function(n){return n==="marker"||n==="model:marker"};class M2 extends It{constructor(e,t){super(null),h(this,"sourcePosition"),h(this,"howMany"),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new b("detach-operation-on-document-node",this)}_execute(){Up(y._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class ti extends Yi{constructor(e){super(),h(this,"markers",new Map),h(this,"_children",new Xo),e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChildAtOffset(i);return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(ne.fromJSON(i)):t.push(Ce.fromJSON(i));return new ti(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=L2(t);for(const o of i)o.parent!==null&&o._remove(),o.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const o of i)o.parent=null;return i}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}}ti.prototype.is=function(n){return n==="documentFragment"||n==="model:documentFragment"};function L2(n){return typeof n=="string"?[new Ce(n)]:(Pt(n)||(n=[n]),Array.from(n).map(e=>typeof e=="string"?new Ce(e):e instanceof Lt?new Ce(e.data,e.getAttributes()):e))}class F2{constructor(e,t){h(this,"model"),h(this,"batch"),this.model=e,this.batch=t}createText(e,t){return new Ce(e,t)}createElement(e,t){return new ne(e,t)}createDocumentFragment(){return new ti}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Ce&&e.data=="")return;const o=C._createAt(t,i);if(e.parent)if(td(e.root,o.root)){this.move(y._createOn(e),o);return}else{if(e.root.document)throw new b("model-writer-insert-forbidden-move",this);this.remove(e)}const s=o.root.document?o.root.document.version:null,r=e instanceof ti?e._removeChildren(0,e.childCount):e,a=new je(o,r,s);if(e instanceof Ce&&(a.shouldReceiveAttributes=!0),this.batch.addOperation(a),this.model.applyOperation(a),e instanceof ti)for(const[l,c]of e.markers){const u=C._createAt(c.root,0),d={range:new y(c.start._getCombined(u,o),c.end._getCombined(u,o)),usingOperation:!0,affectsData:!0};this.model.markers.has(l)?this.updateMarker(l,d):this.addMarker(l,d)}}insertText(e,t,i,o){t instanceof ti||t instanceof ne||t instanceof C?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,o)}insertElement(e,t,i,o){t instanceof ti||t instanceof ne||t instanceof C?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,o)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof ti||t instanceof ne?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof ti||t instanceof ne?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof y){const o=i.getMinimalFlatRanges();for(const s of o)Xh(this,e,t,s)}else ed(this,e,t,i)}setAttributes(e,t){for(const[i,o]of ri(e))this.setAttribute(i,o,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof y){const i=t.getMinimalFlatRanges();for(const o of i)Xh(this,e,null,o)}else ed(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=i=>{for(const o of i.getAttributeKeys())this.removeAttribute(o,i)};if(!(e instanceof y))t(e);else for(const i of e.getItems())t(i)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof y))throw new b("writer-move-invalid-range",this);if(!e.isFlat)throw new b("writer-move-range-not-flat",this);const o=C._createAt(t,i);if(o.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!td(e.root,o.root))throw new b("writer-move-different-document",this);const s=e.root.document?e.root.document.version:null,r=new re(e.start,e.end.offset-e.start.offset,o,s);this.batch.addOperation(r),this.model.applyOperation(r)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof y?e:y._createOn(e)).getMinimalFlatRanges().reverse();for(const i of t)this._addOperationForAffectedMarkers("move",i),N2(i.start,i.end.offset-i.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof ne))throw new b("writer-merge-no-element-before",this);if(!(i instanceof ne))throw new b("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(y._createIn(i),C._createAt(t,"end")),this.remove(i)}_merge(e){const t=C._createAt(e.nodeBefore,"end"),i=C._createAt(e.nodeAfter,0),o=e.root.document.graveyard,s=new C(o,[0]),r=e.root.document.version,a=new Oe(i,e.nodeAfter.maxOffset,t,s,r);this.batch.addOperation(a),this.model.applyOperation(a)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof ne))throw new b("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,o=new dt(C._createBefore(e),e.name,t,i);this.batch.addOperation(o),this.model.applyOperation(o)}split(e,t){this._assertWriterUsedCorrectly();let i=e.parent;if(!i.parent)throw new b("writer-split-element-no-parent",this);if(t||(t=i.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new b("writer-split-invalid-limit-element",this);let o,s;do{const r=i.root.document?i.root.document.version:null,a=i.maxOffset-e.offset,l=we.getInsertionPosition(e),c=new we(e,a,l,null,r);this.batch.addOperation(c),this.model.applyOperation(c),!o&&!s&&(o=i,s=e.parent.nextSibling),e=this.createPositionAfter(e.parent),i=e.parent}while(i!==t);return{position:e,range:new y(C._createAt(o,"end"),C._createAt(s,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new b("writer-wrap-range-not-flat",this);const i=t instanceof ne?t:new ne(t);if(i.childCount>0)throw new b("writer-wrap-element-not-empty",this);if(i.parent!==null)throw new b("writer-wrap-element-attached",this);this.insert(i,e.start);const o=new y(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(o,C._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),e.parent===null)throw new b("writer-unwrap-element-no-parent",this);this.move(y._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||typeof t.usingOperation!="boolean")throw new b("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,o=t.range,s=t.affectsData===void 0?!1:t.affectsData;if(this.model.markers.has(e))throw new b("writer-addmarker-marker-exists",this);if(!o)throw new b("writer-addmarker-no-range",this);return i?(Vo(this,e,null,o,s),this.model.markers.get(e)):this.model.markers._set(e,o,i,s)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i=typeof e=="string"?e:e.name,o=this.model.markers.get(i);if(!o)throw new b("writer-updatemarker-marker-not-exists",this);if(!t){J("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),this.model.markers._refresh(o);return}const s=typeof t.usingOperation=="boolean",r=typeof t.affectsData=="boolean",a=r?t.affectsData:o.affectsData;if(!s&&!t.range&&!r)throw new b("writer-updatemarker-wrong-options",this);const l=o.getRange(),c=t.range?t.range:l;if(s&&t.usingOperation!==o.managedUsingOperations){t.usingOperation?Vo(this,i,null,c,a):(Vo(this,i,l,null,a),this.model.markers._set(i,c,void 0,a));return}o.managedUsingOperations?Vo(this,i,l,c,a):this.model.markers._set(i,c,void 0,a)}removeMarker(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?e:e.name;if(!this.model.markers.has(t))throw new b("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations){this.model.markers._remove(t);return}const o=i.getRange();Vo(this,t,o,null,i.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new b("writer-addroot-root-exists",this);const o=this.model.document,s=new ni(e,t,!0,o,o.version);return this.batch.addOperation(s),this.model.applyOperation(s),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new b("writer-detachroot-no-root",this);for(const s of this.model.markers)s.getRange().root===t&&this.removeMarker(s);for(const s of t.getAttributeKeys())this.removeAttribute(s,t);this.remove(this.createRangeIn(t));const i=this.model.document,o=new ni(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(o),this.model.applyOperation(o)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),typeof e=="string")this._setSelectionAttribute(e,t);else for(const[i,o]of ri(e))this._setSelectionAttribute(i,o)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),typeof e=="string")this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const o=Kt._getStoreAttributeKey(e);this.setAttribute(o,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=Kt._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new b("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const o=i.getRange();let s=!1;if(e==="move"){const r=t;s=r.containsPosition(o.start)||r.start.isEqual(o.start)||r.containsPosition(o.end)||r.end.isEqual(o.end)}else{const r=t,a=r.nodeBefore,l=r.nodeAfter,c=o.start.parent==a&&o.start.isAtEnd,u=o.end.parent==l&&o.end.offset==0,d=o.end.nodeAfter==l,m=o.start.nodeAfter==l;s=c||u||d||m}s&&this.updateMarker(i.name,{range:o})}}}function Xh(n,e,t,i){const o=n.model,s=o.document;let r=i.start,a,l,c;for(const d of i.getWalker({shallow:!0}))c=d.item.getAttribute(e),a&&l!=c&&(l!=t&&u(),r=a),a=d.nextPosition,l=c;a instanceof C&&a!=r&&l!=t&&u();function u(){const d=new y(r,a),m=d.root.document?s.version:null,f=new Le(d,e,l,t,m);n.batch.addOperation(f),o.applyOperation(f)}}function ed(n,e,t,i){const o=n.model,s=o.document,r=i.getAttribute(e);let a,l;if(r!=t){if(i.root===i){const c=i.document?s.version:null;l=new Ci(i,e,r,t,c)}else{a=new y(C._createBefore(i),n.createPositionAfter(i));const c=a.root.document?s.version:null;l=new Le(a,e,r,t,c)}n.batch.addOperation(l),o.applyOperation(l)}}function Vo(n,e,t,i,o){const s=n.model,r=s.document,a=new ot(e,t,i,s.markers,!!o,r.version);n.batch.addOperation(a),s.applyOperation(a)}function N2(n,e,t,i){let o;if(n.root.document){const s=i.document,r=new C(s.graveyard,[0]);o=new re(n,e,r,s.version)}else o=new M2(n,e);t.addOperation(o),i.applyOperation(o)}function td(n,e){return n===e||n instanceof Rr&&e instanceof Rr}function D2(n,e,t={}){if(e.isCollapsed)return;const i=e.getFirstRange();if(i.root.rootName=="$graveyard")return;const o=n.schema;n.change(s=>{if(!t.doNotResetEntireContent&&K2(o,e)){G2(s,e);return}const r={};if(!t.doNotAutoparagraph){const c=e.getSelectedElement();c&&Object.assign(r,o.getAttributesWithProperty(c,"copyOnReplace",!0))}let a,l;t.doNotFixSelection?(a=Me.fromPosition(i.start,"toPrevious"),l=Me.fromPosition(i.end,"toNext")):[a,l]=z2(i),a.isTouching(l)||s.remove(s.createRange(a,l)),t.leaveUnmerged||($2(s,a,l),o.removeDisallowedAttributes(a.parent.getChildren(),s)),Xp(s,e,a),!t.doNotAutoparagraph&&U2(o,a)&&Yp(s,a,e,r),a.detach(),l.detach()})}function z2(n){const e=n.root.document.model,t=n.start;let i=n.end;if(e.hasContent(n,{ignoreMarkers:!0})){const o=H2(i);if(o&&i.isTouching(e.createPositionAt(o,0))){const s=e.createSelection(n);e.modifySelection(s,{direction:"backward"});const r=s.getLastPosition(),a=e.createRange(r,i);e.hasContent(a,{ignoreMarkers:!0})||(i=r)}}return[Me.fromPosition(t,"toPrevious"),Me.fromPosition(i,"toNext")]}function H2(n){const e=n.parent,t=e.root.document.model.schema,i=e.getAncestors({parentFirst:!0,includeSelf:!0});for(const o of i){if(t.isLimit(o))return null;if(t.isBlock(o))return o}}function $2(n,e,t){const i=n.model;if(!eu(n.model.schema,e,t))return;const[o,s]=j2(e,t);!o||!s||(!i.hasContent(o,{ignoreMarkers:!0})&&i.hasContent(s,{ignoreMarkers:!0})?Qp(n,e,t,o.parent):Jp(n,e,t,o.parent))}function Jp(n,e,t,i){const o=e.parent,s=t.parent;if(!(o==i||s==i)){for(e=n.createPositionAfter(o),t=n.createPositionBefore(s),t.isEqual(e)||n.insert(s,e),n.merge(e);t.parent.isEmpty;){const r=t.parent;t=n.createPositionBefore(r),n.remove(r)}eu(n.model.schema,e,t)&&Jp(n,e,t,i)}}function Qp(n,e,t,i){const o=e.parent,s=t.parent;if(!(o==i||s==i)){for(e=n.createPositionAfter(o),t=n.createPositionBefore(s),t.isEqual(e)||n.insert(o,t);e.parent.isEmpty;){const r=e.parent;e=n.createPositionBefore(r),n.remove(r)}t=n.createPositionBefore(s),W2(n,t),eu(n.model.schema,e,t)&&Qp(n,e,t,i)}}function W2(n,e){const t=e.nodeBefore,i=e.nodeAfter;t.name!=i.name&&n.rename(t,i.name),n.clearAttributes(t),n.setAttributes(Object.fromEntries(i.getAttributes()),t),n.merge(e)}function eu(n,e,t){const i=e.parent,o=t.parent;return i==o||n.isLimit(i)||n.isLimit(o)?!1:q2(e,t,n)}function j2(n,e){const t=n.getAncestors(),i=e.getAncestors();let o=0;for(;t[o]&&t[o]==i[o];)o++;return[t[o],i[o]]}function U2(n,e){const t=n.checkChild(e,"$text"),i=n.checkChild(e,"paragraph");return!t&&i}function q2(n,e,t){const i=new y(n,e);for(const o of i.getWalker())if(t.isLimit(o.item))return!1;return!0}function Yp(n,e,t,i={}){const o=n.createElement("paragraph");n.model.schema.setAllowedAttributes(o,i,n),n.insert(o,e),Xp(n,t,n.createPositionAt(o,0))}function G2(n,e){const t=n.model.schema.getLimitElement(e);n.remove(n.createRangeIn(t)),Yp(n,n.createPositionAt(t,0),e)}function K2(n,e){const t=n.getLimitElement(e);if(!e.containsEntireContent(t))return!1;const i=e.getFirstRange();return i.start.parent==i.end.parent?!1:n.checkChild(t,"paragraph")}function Xp(n,e,t){e instanceof Kt?n.setSelection(t):e.setTo(t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Z2(n,e){return n.change(t=>{const i=t.createDocumentFragment(),o=e.getFirstRange();if(!o||o.isCollapsed)return i;const s=o.start.root,r=o.start.getCommonPath(o.end),a=s.getNodeByPath(r);let l;o.start.parent==o.end.parent?l=o:l=t.createRange(t.createPositionAt(a,o.start.path[r.length]),t.createPositionAt(a,o.end.path[r.length]+1));const c=l.end.offset-l.start.offset;for(const u of l.getItems({shallow:!0}))u.is("$textProxy")?t.appendText(u.data,u.getAttributes(),i):t.append(t.cloneElement(u,!0),i);if(l!=o){const u=o._getTransformedByMove(l.start,t.createPositionAt(i,0),c)[0],d=t.createRange(t.createPositionAt(i,0),u.start),m=t.createRange(u.end,t.createPositionAt(i,"end"));id(m,t),id(d,t)}return i})}function id(n,e){const t=[];Array.from(n.getItems({direction:"backward"})).map(i=>e.createRangeOn(i)).filter(i=>(i.start.isAfter(n.start)||i.start.isEqual(n.start))&&(i.end.isBefore(n.end)||i.end.isEqual(n.end))).forEach(i=>{t.push(i.start.parent),e.remove(i)}),t.forEach(i=>{let o=i;for(;o.parent&&o.isEmpty;){const s=e.createRangeOn(o);o=o.parent,e.remove(s)}})}function J2(n,e,t){return n.change(i=>{const o=t||n.document.selection;o.isCollapsed||n.deleteContent(o,{doNotAutoparagraph:!0});const s=new Q2(n,i,o.anchor),r=[];let a;if(e.is("documentFragment")){if(e.markers.size){const u=[];for(const[d,m]of e.markers){const{start:f,end:g}=m,p=f.isEqual(g);u.push({position:f,name:d,isCollapsed:p},{position:g,name:d,isCollapsed:p})}u.sort(({position:d},{position:m})=>d.isBefore(m)?1:-1);for(const{position:d,name:m,isCollapsed:f}of u){let g=null,p=null;const _=d.parent===e&&d.isAtStart,v=d.parent===e&&d.isAtEnd;!_&&!v?(g=i.createElement("$marker"),i.insert(g,d)):f&&(p=_?"start":"end"),r.push({name:m,element:g,collapsed:p})}}a=e.getChildren()}else a=[e];s.handleNodes(a);let l=s.getSelectionRange();if(e.is("documentFragment")&&r.length){const u=l?ht.fromRange(l):null,d={};for(let m=r.length-1;m>=0;m--){const{name:f,element:g,collapsed:p}=r[m],_=!d[f];if(_&&(d[f]=[]),g){const v=i.createPositionAt(g,"before");d[f].push(v),i.remove(g)}else{const v=s.getAffectedRange();if(!v){p&&d[f].push(s.position);continue}p?d[f].push(v[p]):d[f].push(_?v.start:v.end)}}for(const[m,[f,g]]of Object.entries(d))f&&g&&f.root===g.root&&f.root.document&&!i.model.markers.has(m)&&i.addMarker(m,{usingOperation:!0,affectsData:!0,range:new y(f,g)});u&&(l=u.toRange(),u.detach())}/* istanbul ignore else -- @preserve */l&&(o instanceof Kt?i.setSelection(l):o.setTo(l));const c=s.getAffectedRange()||n.createRange(o.anchor);return s.destroy(),c})}class Q2{constructor(e,t,i){h(this,"model"),h(this,"writer"),h(this,"position"),h(this,"canMergeWith"),h(this,"schema"),h(this,"_documentFragment"),h(this,"_documentFragmentPosition"),h(this,"_firstNode",null),h(this,"_lastNode",null),h(this,"_lastAutoParagraph",null),h(this,"_filterAttributesOf",[]),h(this,"_affectedStart",null),h(this,"_affectedEnd",null),h(this,"_nodeToSelect",null),this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){this._lastNode=e;/* istanbul ignore if -- @preserve */if(this.position.parent!=e||!this.position.isAtEnd)throw new b("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?y._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new y(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(!this._checkAndSplitToAllowedPosition(e)){this.schema.isObject(e)||this._handleDisallowedNode(e);return}this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=Me.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleDisallowedNode(e){e.is("element")&&this.handleNodes(e.getChildren())}_appendToFragment(e){/* istanbul ignore if -- @preserve */if(!this.schema.checkChild(this.position,e))throw new b("insertcontent-wrong-position",this,{node:e,position:this.position});this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesOf.push(e)}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=Me.fromPosition(e,"toPrevious")),(!this._affectedEnd||this._affectedEnd.isBefore(e))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=Me.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof ne)||!this._canMergeLeft(e))return;const t=Me._createBefore(e);t.stickiness="toNext";const i=Me.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=Me._createAt(t.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=Me._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof ne)||!this._canMergeRight(e))return;const t=Me._createAfter(e);t.stickiness="toNext";/* istanbul ignore if -- @preserve */if(!this.position.isEqual(t))throw new b("insertcontent-invalid-insertion-position",this);this.position=C._createAt(t.nodeBefore,"end");const i=Me.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=Me._createAt(t.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=Me._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof ne&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof ne&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_insertAutoParagraph(){this._insertPartialFragment();const e=this.writer.createElement("paragraph");this.writer.insert(e,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=e,this.position=this.writer.createPositionAt(e,0)}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const i=this.position.parent;this.position=this.writer.createPositionBefore(i),i.isEmpty&&i.parent===t&&this.writer.remove(i)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const i=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=i,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){return this.schema.checkChild(e,t)||this.schema.checkChild(e,"paragraph")&&this.schema.checkChild("paragraph",t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function Y2(n,e,t,i={}){if(!n.schema.isObject(e))throw new b("insertobject-element-not-an-object",n,{object:e});const o=t||n.document.selection;let s=o;i.findOptimalPosition&&n.schema.isBlock(e)&&(s=n.createSelection(n.schema.findOptimalInsertionRange(o,i.findOptimalPosition)));const r=ae(o.getSelectedBlocks()),a={};return r&&Object.assign(a,n.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),n.change(l=>{s.isCollapsed||n.deleteContent(s,{doNotAutoparagraph:!0});let c=e;const u=s.anchor.parent;!n.schema.checkChild(u,e)&&n.schema.checkChild(u,"paragraph")&&n.schema.checkChild("paragraph",e)&&(c=l.createElement("paragraph"),l.insert(e,c)),n.schema.setAllowedAttributes(c,a,l);const d=n.insertContent(c,s);return d.isCollapsed||i.setSelection&&X2(l,e,i.setSelection,a),d})}function X2(n,e,t,i){const o=n.model;if(t=="on"){n.setSelection(e,"on");return}if(t!="after")throw new b("insertobject-invalid-place-parameter-value",o);let s=e.nextSibling;if(o.schema.isInline(e)){n.setSelection(e,"after");return}!(s&&o.schema.checkChild(s,"$text"))&&o.schema.checkChild(e.parent,"paragraph")&&(s=n.createElement("paragraph"),o.schema.setAllowedAttributes(s,i,n),o.insertContent(s,n.createPositionAfter(e))),s&&n.setSelection(s,0)}const e5=' ,.?!:;"-()';function t5(n,e,t={}){const i=n.schema,o=t.direction!="backward",s=t.unit?t.unit:"character",r=!!t.treatEmojiAsSingleUnit,a=e.focus,l=new yi({boundaries:s5(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),c={walker:l,schema:i,isForward:o,unit:s,treatEmojiAsSingleUnit:r};let u;for(;u=l.next();){if(u.done)return;const d=i5(c,u.value);if(d){e instanceof Kt?n.change(m=>{m.setSelectionFocus(d)}):e.setFocus(d);return}}}function i5(n,e){const{isForward:t,walker:i,unit:o,schema:s,treatEmojiAsSingleUnit:r}=n,{type:a,item:l,nextPosition:c}=e;if(a=="text")return n.unit==="word"?o5(i,t):n5(i,o,r);if(a==(t?"elementStart":"elementEnd")){if(s.isSelectable(l))return C._createAt(l,t?"after":"before");if(s.checkChild(c,"$text"))return c}else{if(s.isLimit(l)){i.skip(()=>!0);return}if(s.checkChild(c,"$text"))return c}}function n5(n,e,t){const i=n.position.textNode;if(i){const o=i.data;let s=n.position.offset-i.startOffset;for(;jc(o,s)||e=="character"&&Uc(o,s)||t&&cp(o,s);)n.next(),s=n.position.offset-i.startOffset}return n.position}function o5(n,e){let t=n.position.textNode;for(t||(t=e?n.position.nodeAfter:n.position.nodeBefore);t&&t.is("$text");){const i=n.position.offset-t.startOffset;if(a5(t,i,e))t=e?n.position.nodeAfter:n.position.nodeBefore;else{if(r5(t.data,i,e))break;n.next()}}return n.position}function s5(n,e){const t=n.root,i=C._createAt(t,e?"end":0);return e?new y(n,i):new y(i,n)}function r5(n,e,t){const i=e+(t?0:-1);return e5.includes(n.charAt(i))}function a5(n,e,t){return e===(t?n.offsetSize:0)}let l5=class extends ue(){constructor(){super(),h(this,"markers"),h(this,"document"),h(this,"schema"),h(this,"_pendingChanges"),h(this,"_currentWriter"),this.markers=new B2,this.document=new O2(this),this.schema=new Jk,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(n=>this.decorate(n)),this.on("applyOperation",(n,e)=>{e[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(()=>!0,"$marker"),$k(this),this.document.registerPostFixer(Fp),this.on("insertContent",(n,[e,t])=>{n.return=J2(this,e,t)}),this.on("insertObject",(n,[e,t,i])=>{n.return=Y2(this,e,t,i)}),this.on("canEditAt",n=>{const e=!this.document.isReadOnly;n.return=e,e||n.stop()})}change(n){try{return this._pendingChanges.length===0?(this._pendingChanges.push({batch:new Nn,callback:n}),this._runPendingChanges()[0]):n(this._currentWriter)}catch(e){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(e,this)}}enqueueChange(n,e){try{n?typeof n=="function"?(e=n,n=new Nn):n instanceof Nn||(n=new Nn(n)):n=new Nn,this._pendingChanges.push({batch:n,callback:e}),this._pendingChanges.length==1&&this._runPendingChanges()}catch(t){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(t,this)}}applyOperation(n){n._execute()}insertContent(n,e,t,...i){const o=Ha(e,t);return this.fire("insertContent",[n,o,t,...i])}insertObject(n,e,t,i,...o){const s=Ha(e,t);return this.fire("insertObject",[n,s,i,i,...o])}deleteContent(n,e){D2(this,n,e)}modifySelection(n,e){t5(this,n,e)}getSelectedContent(n){return Z2(this,n)}hasContent(n,e={}){const t=n instanceof y?n:y._createIn(n);if(t.isCollapsed)return!1;const{ignoreWhitespaces:i=!1,ignoreMarkers:o=!1}=e;if(!o){for(const s of this.markers.getMarkersIntersectingRange(t))if(s.affectsData)return!0}for(const s of t.getItems())if(this.schema.isContent(s))if(s.is("$textProxy"))if(i){if(s.data.search(/\S/)!==-1)return!0}else return!0;else return!0;return!1}canEditAt(n){const e=Ha(n);return this.fire("canEditAt",[e])}createPositionFromPath(n,e,t){return new C(n,e,t)}createPositionAt(n,e){return C._createAt(n,e)}createPositionAfter(n){return C._createAfter(n)}createPositionBefore(n){return C._createBefore(n)}createRange(n,e){return new y(n,e)}createRangeIn(n){return y._createIn(n)}createRangeOn(n){return y._createOn(n)}createSelection(...n){return new yt(...n)}createBatch(n){return new Nn(n)}createOperationFromJSON(n){return y2.fromJSON(n,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const n=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const e=this._pendingChanges[0].batch;this._currentWriter=new F2(this,e);const t=this._pendingChanges[0].callback(this._currentWriter);n.push(t),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return n}};function Ha(n,e){if(n)return n instanceof yt||n instanceof Kt?n:n instanceof Tn?e||e===0?new yt(n,e):n.is("rootElement")?new yt(n,"in"):new yt(n,"on"):new yt(n)}class ew extends ui{constructor(){super(...arguments),h(this,"domEventType","click")}onDomEvent(e){this.fire(e.type,e)}}class ua extends ui{constructor(){super(...arguments),h(this,"domEventType",["mousedown","mouseup","mouseover","mouseout"])}onDomEvent(e){this.fire(e.type,e)}}class c5 extends ui{constructor(){super(...arguments),h(this,"domEventType",["touchstart","touchend","touchmove"])}onDomEvent(e){this.fire(e.type,e)}}class Ht{constructor(e){h(this,"document"),this.document=e}createDocumentFragment(e){return new vn(this.document,e)}createElement(e,t,i){return new ai(this.document,e,t,i)}createText(e){return new Ge(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const i=e.parent;if(i){const o=i.getChildIndex(e);return this.removeChildren(o,1,i),this.insertChild(o,t,i),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){const i=new ai(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){Ut(e)&&i===void 0?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return V._createAt(e,t)}createPositionAfter(e){return V._createAfter(e)}createPositionBefore(e){return V._createBefore(e)}createRange(e,t){return new Q(e,t)}createRangeOn(e){return Q._createOn(e)}createRangeIn(e){return Q._createIn(e)}createSelection(...e){return new ki(...e)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const u5=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,h5=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,d5=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,m5=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,f5=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,g5=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,p5=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","activeborder","activecaption","appworkspace","background","buttonface","buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext","inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext","scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window","windowframe","windowtext","rebeccapurple","currentcolor","transparent"]);function tw(n){return n.startsWith("#")?u5.test(n):n.startsWith("rgb")?h5.test(n)||d5.test(n):n.startsWith("hsl")?m5.test(n)||f5.test(n):p5.has(n.toLowerCase())}const w5=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function b5(n){return w5.includes(n)}const _5=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function ha(n){return _5.test(n)}const v5=/^[+-]?[0-9]*([.][0-9]+)?%$/;function iw(n){return v5.test(n)}const y5=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function k5(n){return y5.includes(n)}const C5=["center","top","bottom","left","right"];function A5(n){return C5.includes(n)}const x5=["fixed","scroll","local"];function T5(n){return x5.includes(n)}const E5=/^url\(/;function S5(n){return E5.test(n)}function es(n=""){if(n==="")return{top:void 0,right:void 0,bottom:void 0,left:void 0};const e=tu(n),t=e[0],i=e[2]||t,o=e[1]||t,s=e[3]||o;return{top:t,bottom:i,right:o,left:s}}function ts(n){return e=>{const{top:t,right:i,bottom:o,left:s}=e,r=[];return[t,i,s,o].every(a=>!!a)?r.push([n,P5(e)]):(t&&r.push([n+"-top",t]),i&&r.push([n+"-right",i]),o&&r.push([n+"-bottom",o]),s&&r.push([n+"-left",s])),r}}function P5({top:n,right:e,bottom:t,left:i}){const o=[];return i!==e?o.push(n,e,t,i):t!==n?o.push(n,e,t):e!==n?o.push(n,e):o.push(n),o.join(" ")}function nw(n){return e=>({path:n,value:es(e)})}function tu(n){const e=n.trim().slice(0,1500).matchAll(g5);return Array.from(e).map(t=>t[0])}function iu(n){n.setNormalizer("background",I5()),n.setNormalizer("background-color",V5()),n.setReducer("background",R5()),n.setStyleRelation("background",["background-color"])}function I5(){return n=>{const e={},t=tu(n);for(const i of t)k5(i)?(e.repeat=e.repeat||[],e.repeat.push(i)):A5(i)?(e.position=e.position||[],e.position.push(i)):T5(i)?e.attachment=i:tw(i)?e.color=i:S5(i)&&(e.image=i);return{path:"background",value:e}}}function V5(){return n=>({path:"background.color",value:n})}function R5(){return n=>{const e=[];return e.push(["background-color",n.color]),e}}function ow(n){n.setNormalizer("border",O5()),n.setNormalizer("border-top",$s("top")),n.setNormalizer("border-right",$s("right")),n.setNormalizer("border-bottom",$s("bottom")),n.setNormalizer("border-left",$s("left")),n.setNormalizer("border-color",$a("color")),n.setNormalizer("border-width",$a("width")),n.setNormalizer("border-style",$a("style")),n.setNormalizer("border-top-color",Bt("color","top")),n.setNormalizer("border-top-style",Bt("style","top")),n.setNormalizer("border-top-width",Bt("width","top")),n.setNormalizer("border-right-color",Bt("color","right")),n.setNormalizer("border-right-style",Bt("style","right")),n.setNormalizer("border-right-width",Bt("width","right")),n.setNormalizer("border-bottom-color",Bt("color","bottom")),n.setNormalizer("border-bottom-style",Bt("style","bottom")),n.setNormalizer("border-bottom-width",Bt("width","bottom")),n.setNormalizer("border-left-color",Bt("color","left")),n.setNormalizer("border-left-style",Bt("style","left")),n.setNormalizer("border-left-width",Bt("width","left")),n.setExtractor("border-top",Ws("top")),n.setExtractor("border-right",Ws("right")),n.setExtractor("border-bottom",Ws("bottom")),n.setExtractor("border-left",Ws("left")),n.setExtractor("border-top-color","border.color.top"),n.setExtractor("border-right-color","border.color.right"),n.setExtractor("border-bottom-color","border.color.bottom"),n.setExtractor("border-left-color","border.color.left"),n.setExtractor("border-top-width","border.width.top"),n.setExtractor("border-right-width","border.width.right"),n.setExtractor("border-bottom-width","border.width.bottom"),n.setExtractor("border-left-width","border.width.left"),n.setExtractor("border-top-style","border.style.top"),n.setExtractor("border-right-style","border.style.right"),n.setExtractor("border-bottom-style","border.style.bottom"),n.setExtractor("border-left-style","border.style.left"),n.setReducer("border-color",ts("border-color")),n.setReducer("border-style",ts("border-style")),n.setReducer("border-width",ts("border-width")),n.setReducer("border-top",js("top")),n.setReducer("border-right",js("right")),n.setReducer("border-bottom",js("bottom")),n.setReducer("border-left",js("left")),n.setReducer("border",M5()),n.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),n.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),n.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),n.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),n.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),n.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),n.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),n.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function O5(){return n=>{const{color:e,style:t,width:i}=sw(n);return{path:"border",value:{color:es(e),style:es(t),width:es(i)}}}}function $s(n){return e=>{const{color:t,style:i,width:o}=sw(e),s={};return t!==void 0&&(s.color={[n]:t}),i!==void 0&&(s.style={[n]:i}),o!==void 0&&(s.width={[n]:o}),{path:"border",value:s}}}function $a(n){return e=>({path:"border",value:B5(e,n)})}function B5(n,e){return{[e]:es(n)}}function Bt(n,e){return t=>({path:"border",value:{[n]:{[e]:t}}})}function Ws(n){return(e,t)=>{if(t.border)return Uo(t.border,n)}}function Uo(n,e){const t={};return n.width&&n.width[e]&&(t.width=n.width[e]),n.style&&n.style[e]&&(t.style=n.style[e]),n.color&&n.color[e]&&(t.color=n.color[e]),t}function sw(n){const e={},t=tu(n);for(const i of t)ha(i)||/thin|medium|thick/.test(i)?e.width=i:b5(i)?e.style=i:e.color=i;return e}function M5(){return e=>{const t=Uo(e,"top"),i=Uo(e,"right"),o=Uo(e,"bottom"),s=Uo(e,"left"),r=[t,i,o,s],a={width:n(r,"width"),style:n(r,"style"),color:n(r,"color")},l=Zn(a,"all");return l.length?l:[...Object.entries(a).reduce((c,[u,d])=>(d&&(c.push([`border-${u}`,d]),r.forEach(m=>delete m[u])),c),[]),...Zn(t,"top"),...Zn(i,"right"),...Zn(o,"bottom"),...Zn(s,"left")]};function n(e,t){return e.map(i=>i[t]).reduce((i,o)=>i==o?i:null)}}function js(n){return e=>Zn(e,n)}function Zn(n,e){const t=[];if(n&&n.width&&t.push("width"),n&&n.style&&t.push("style"),n&&n.color&&t.push("color"),t.length==3){const i=t.map(o=>n[o]).join(" ");return[e=="all"?["border",i]:[`border-${e}`,i]]}return e=="all"?[]:t.map(i=>[`border-${e}-${i}`,n[i]])}function L5(n){n.setNormalizer("margin",nw("margin")),n.setNormalizer("margin-top",e=>({path:"margin.top",value:e})),n.setNormalizer("margin-right",e=>({path:"margin.right",value:e})),n.setNormalizer("margin-bottom",e=>({path:"margin.bottom",value:e})),n.setNormalizer("margin-left",e=>({path:"margin.left",value:e})),n.setReducer("margin",ts("margin")),n.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function F5(n){n.setNormalizer("padding",nw("padding")),n.setNormalizer("padding-top",e=>({path:"padding.top",value:e})),n.setNormalizer("padding-right",e=>({path:"padding.right",value:e})),n.setNormalizer("padding-bottom",e=>({path:"padding.bottom",value:e})),n.setNormalizer("padding-left",e=>({path:"padding.left",value:e})),n.setReducer("padding",ts("padding")),n.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class rw{constructor(e){if(h(this,"crashes",[]),h(this,"state","initializing"),h(this,"_crashNumberLimit"),h(this,"_now",Date.now),h(this,"_minimumNonErrorTimePeriod"),h(this,"_boundErrorHandler"),h(this,"_listeners"),this.crashes=[],this._crashNumberLimit=typeof e.crashNumberLimit=="number"?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod=typeof e.minimumNonErrorTimePeriod=="number"?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=t=>{const i="error"in t?t.error:t.reason;i instanceof Error&&this._handleError(i,t)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}destroy(){this._stopErrorHandling(),this._listeners={}}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){this._listeners[e]=this._listeners[e].filter(i=>i!==t)}_fire(e,...t){const i=this._listeners[e]||[];for(const o of i)o.apply(this,[null,...t])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const i=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:i}),i?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&e.context!==void 0&&e.context!==null&&this.state==="ready"&&this._isErrorComingFromThisItem(e)}_shouldRestart(){if(this.crashes.length<=this._crashNumberLimit)return!0;const e=this.crashes[this.crashes.length-1].date,t=this.crashes[this.crashes.length-1-this._crashNumberLimit].date;return(e-t)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Zl(n,e=new Set){const t=[n],i=new Set;let o=0;for(;t.length>o;){const s=t[o++];if(!(i.has(s)||!N5(s)||e.has(s)))if(i.add(s),Symbol.iterator in s)try{for(const r of s)t.push(r)}catch{}else for(const r in s)r!=="defaultValue"&&t.push(s[r])}return i}function N5(n){const e=Object.prototype.toString.call(n),t=typeof n;return!(t==="number"||t==="boolean"||t==="string"||t==="symbol"||t==="function"||e==="[object Date]"||e==="[object RegExp]"||e==="[object Module]"||n===void 0||n===null||n._watchdogExcluded||n instanceof EventTarget||n instanceof Event)}function aw(n,e,t=new Set){if(n===e&&D5(n))return!0;const i=Zl(n,t),o=Zl(e,t);for(const s of i)if(o.has(s))return!0;return!1}function D5(n){return typeof n=="object"&&n!==null}class lw extends rw{constructor(e,t={}){super(t),h(this,"_editor",null),h(this,"_lifecyclePromise",null),h(this,"_throttledSave"),h(this,"_data"),h(this,"_lastDocumentVersion"),h(this,"_elementOrData"),h(this,"_initUsingData",!0),h(this,"_editables",{}),h(this,"_config"),h(this,"_excludedProps"),this._throttledSave=co(this._save.bind(this),typeof t.saveInterval=="number"?t.saveInterval:5e3),e&&(this._creator=(i,o)=>e.create(i,o)),this._destructor=i=>i.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then(()=>(this.state="initializing",this._fire("stateChange"),this._destroy())).catch(e=>{console.error("An error happened during the editor destroying.",e)}).then(()=>{const e={},t=[],i=this._config.rootsAttributes||{},o={};for(const[r,a]of Object.entries(this._data.roots))a.isLoaded?(e[r]="",o[r]=i[r]||{}):t.push(r);const s={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:o,_watchdogInitialData:this._data};return delete s.initialData,s.extraPlugins.push(z5),this._initUsingData?this.create(e,s,s.context):xi(this._elementOrData)?this.create(this._elementOrData,s,s.context):this.create(this._editables,s,s.context)}).then(()=>{this._fire("restart")})}create(e=this._elementOrData,t=this._config,i){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>(super._startErrorHandling(),this._elementOrData=e,this._initUsingData=typeof e=="string"||Object.keys(e).length>0&&typeof Object.values(e)[0]=="string",this._config=this._cloneEditorConfiguration(t)||{},this._config.context=i,this._creator(e,this._config))).then(o=>{this._editor=o,o.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=o.model.document.version,this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this.state="ready",this._fire("stateChange")}).finally(()=>{this._lifecyclePromise=null}),this._lifecyclePromise}destroy(){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())).finally(()=>{this._lifecyclePromise=null}),this._lifecyclePromise}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling(),this._throttledSave.cancel();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)})}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(t){console.error(t,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(e){this._excludedProps=e}_getData(){const e=this._editor,t=e.model.document.roots.filter(a=>a.isAttached()&&a.rootName!="$graveyard"),{plugins:i}=e,o=i.has("CommentsRepository")&&i.get("CommentsRepository"),s=i.has("TrackChanges")&&i.get("TrackChanges"),r={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach(a=>{r.roots[a.rootName]={content:JSON.stringify(Array.from(a.getChildren())),attributes:JSON.stringify(Array.from(a.getAttributes())),isLoaded:a._isLoaded}});for(const a of e.model.markers)a._affectsData&&(r.markers[a.name]={rangeJSON:a.getRange().toJSON(),usingOperation:a._managedUsingOperations,affectsData:a._affectsData});return o&&(r.commentThreads=JSON.stringify(o.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),s&&(r.suggestions=JSON.stringify(s.getSuggestions({toJSON:!0,skipNotAttached:!0}))),r}_getEditables(){const e={};for(const t of this.editor.model.document.getRootNames()){const i=this.editor.ui.getEditableElement(t);i&&(e[t]=i)}return e}_isErrorComingFromThisItem(e){return aw(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return Xr(e,(t,i)=>{if(xi(t)||i==="context")return t})}}class z5{constructor(e){h(this,"editor"),h(this,"_data"),this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},t=>{this._restoreCollaborationData(),this._restoreEditorData(t)}),this.editor.data.fire("ready")},{priority:999})}_createNode(e,t){if("name"in t){const i=e.createElement(t.name,t.attributes);if(t.children)for(const o of t.children)i._appendChild(this._createNode(e,o));return i}else return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach(([i,{content:o,attributes:s}])=>{const r=JSON.parse(o),a=JSON.parse(s),l=t.model.document.getRoot(i);for(const[c,u]of a)e.setAttribute(c,u,l);for(const c of r){const u=this._createNode(e,c);e.insert(u,l,"end")}}),Object.entries(this._data.markers).forEach(([i,o])=>{const{document:s}=t.model,{rangeJSON:{start:r,end:a},...l}=o,c=s.getRoot(r.root),u=e.createPositionFromPath(c,r.path,r.stickiness),d=e.createPositionFromPath(c,a.path,a.stickiness),m=e.createRange(u,d);e.addMarker(i,{range:m,...l})})}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach(i=>{const o=this.editor.config.get("collaboration.channelId"),s=this.editor.plugins.get("CommentsRepository");s.hasCommentThread(i.threadId)&&s.getCommentThread(i.threadId).remove(),s.addCommentThread({channelId:o,...i})}),t.forEach(i=>{const o=this.editor.plugins.get("TrackChangesEditing");if(o.hasSuggestion(i.id)){const s=o.getSuggestion(i.id);s.attributes=i.attributes}else o.addSuggestionData(i)})}}const is=Symbol("MainQueueId");class H5 extends rw{constructor(e,t={}){super(t),h(this,"_watchdogs",new Map),h(this,"_watchdogConfig"),h(this,"_context",null),h(this,"_contextProps",new Set),h(this,"_actionQueues",new $5),h(this,"_contextConfig"),h(this,"_item"),this._watchdogConfig=t,this._creator=i=>e.create(i),this._destructor=i=>i.destroy(),this._actionQueues.onEmpty(()=>{this.state==="initializing"&&(this.state="ready",this._fire("stateChange"))})}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(is,()=>(this._contextConfig=e,this._create()))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=nd(e);return Promise.all(t.map(i=>this._actionQueues.enqueue(i.id,()=>{if(this.state==="destroyed")throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let o;if(this._watchdogs.has(i.id))throw new Error(`Item with the given id is already added: '${i.id}'.`);if(i.type==="editor")return o=new lw(null,this._watchdogConfig),o.setCreator(i.creator),o._setExcludedProperties(this._contextProps),i.destructor&&o.setDestructor(i.destructor),this._watchdogs.set(i.id,o),o.on("error",(s,{error:r,causesRestart:a})=>{this._fire("itemError",{itemId:i.id,error:r}),a&&this._actionQueues.enqueue(i.id,()=>new Promise(l=>{const c=()=>{o.off("restart",c),this._fire("itemRestart",{itemId:i.id}),l()};o.on("restart",c)}))}),o.create(i.sourceElementOrData,i.config,this._context);throw new Error(`Not supported item type: '${i.type}'.`)})))}remove(e){const t=nd(e);return Promise.all(t.map(i=>this._actionQueues.enqueue(i,()=>{const o=this._getWatchdog(i);return this._watchdogs.delete(i),o.destroy()})))}destroy(){return this._actionQueues.enqueue(is,()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))}_restart(){return this._actionQueues.enqueue(is,()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch(e=>{console.error("An error happened during destroying the context or items.",e)}).then(()=>this._create()).then(()=>this._fire("restart"))))}_create(){return Promise.resolve().then(()=>(this._startErrorHandling(),this._creator(this._contextConfig))).then(e=>(this._context=e,this._contextProps=Zl(this._context),Promise.all(Array.from(this._watchdogs.values()).map(t=>(t._setExcludedProperties(this._contextProps),t.create(void 0,void 0,this._context))))))}_destroy(){return Promise.resolve().then(()=>{this._stopErrorHandling();const e=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map(t=>t.destroy())).then(()=>this._destructor(e))})}_getWatchdog(e){const t=this._watchdogs.get(e);if(!t)throw new Error(`Item with the given id was not registered: ${e}.`);return t}_isErrorComingFromThisItem(e){for(const t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return aw(this._context,e.context)}}class $5{constructor(){h(this,"_onEmptyCallbacks",[]),h(this,"_queues",new Map),h(this,"_activeActions",0)}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===is;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const o=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(is),this._queues.get(e)])).then(t),s=o.catch(()=>{});return this._queues.set(e,s),o.finally(()=>{this._activeActions--,this._queues.get(e)===s&&this._activeActions===0&&this._onEmptyCallbacks.forEach(r=>r())})}}function nd(n){return Array.isArray(n)?n:[n]}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class w extends ue(){constructor(e){super(),h(this,"editor"),h(this,"_disableStack",new Set),this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on("set:isEnabled",od,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",od),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}function od(n){n.return=!1,n.stop()}class O extends ue(){constructor(e){super(),h(this,"editor"),h(this,"_isEnabledBasedOnSelection"),h(this,"_affectsData"),h(this,"_disableStack"),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.listenTo(e,"change:isReadOnly",()=>{this.refresh()}),this.on("set:isEnabled",t=>{if(!this.affectsData)return;const i=e.model.document.selection,o=i.getFirstPosition().root.rootName!="$graveyard"&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!o)&&(t.return=!1,t.stop())},{priority:"highest"}),this.on("execute",t=>{this.isEnabled||t.stop()},{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),this._disableStack.size==1&&(this.on("set:isEnabled",sd,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),this._disableStack.size==0&&(this.off("set:isEnabled",sd),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function sd(n){n.return=!1,n.stop()}class rd extends O{constructor(){super(...arguments),h(this,"_childCommandsDefinitions",[])}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){Fg(this._childCommandsDefinitions,{command:e,priority:t.priority||"normal"}),e.on("change:isEnabled",()=>this._checkEnabled()),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){const e=this._childCommandsDefinitions.find(({command:t})=>t.isEnabled);return e&&e.command}}class cw extends ge(){constructor(e,t=[],i=[]){super(),h(this,"_context"),h(this,"_plugins",new Map),h(this,"_availablePlugins"),h(this,"_contextPlugins"),this._context=e,this._availablePlugins=new Map;for(const o of t)o.pluginName&&this._availablePlugins.set(o.pluginName,o);this._contextPlugins=new Map;for(const[o,s]of i)this._contextPlugins.set(o,s),this._contextPlugins.set(s,o),o.pluginName&&this._availablePlugins.set(o.pluginName,o)}*[Symbol.iterator](){for(const e of this._plugins)typeof e[0]=="function"&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let i=e;throw typeof e=="function"&&(i=e.pluginName||e.name),new b("plugincollection-plugin-not-loaded",this._context,{plugin:i})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const o=this,s=this._context;f(e),p(e);const r=e.filter(T=>!d(T,t)),a=[...g(r)];X(a,i);const l=M(a);return G(l,"init").then(()=>G(l,"afterInit")).then(()=>l);function c(T){return typeof T=="function"}function u(T){return c(T)&&!!T.isContextPlugin}function d(T,F){return F.some(x=>x===T||m(T)===x||m(x)===T)}function m(T){return c(T)?T.pluginName||T.name:T}function f(T,F=new Set){T.forEach(x=>{c(x)&&(F.has(x)||(F.add(x),x.pluginName&&!o._availablePlugins.has(x.pluginName)&&o._availablePlugins.set(x.pluginName,x),x.requires&&f(x.requires,F)))})}function g(T,F=new Set){return T.map(x=>c(x)?x:o._availablePlugins.get(x)).reduce((x,q)=>F.has(q)?x:(F.add(q),q.requires&&(p(q.requires,q),g(q.requires,F).forEach(Ve=>x.add(Ve))),x.add(q)),new Set)}function p(T,F=null){T.map(x=>c(x)?x:o._availablePlugins.get(x)||x).forEach(x=>{_(x,F),v(x,F),E(x,F)})}function _(T,F){if(!c(T))throw F?new b("plugincollection-soft-required",s,{missingPlugin:T,requiredBy:m(F)}):new b("plugincollection-plugin-not-found",s,{plugin:T})}function v(T,F){if(u(F)&&!u(T))throw new b("plugincollection-context-required",s,{plugin:m(T),requiredBy:m(F)})}function E(T,F){if(F&&d(T,t))throw new b("plugincollection-required",s,{plugin:m(T),requiredBy:m(F)})}function M(T){return T.map(F=>{let x=o._contextPlugins.get(F);return x=x||new F(s),o._add(F,x),x})}function G(T,F){return T.reduce((x,q)=>!q[F]||o._contextPlugins.has(q)?x:x.then(q[F].bind(q)),Promise.resolve())}function X(T,F){for(const x of F){if(typeof x!="function")throw new b("plugincollection-replace-plugin-invalid-type",null,{pluginItem:x});const q=x.pluginName;if(!q)throw new b("plugincollection-replace-plugin-missing-name",null,{pluginItem:x});if(x.requires&&x.requires.length)throw new b("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:q});const Ve=o._availablePlugins.get(q);if(!Ve)throw new b("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:q});const pe=T.indexOf(Ve);if(pe===-1){if(o._contextPlugins.has(Ve))return;throw new b("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:q})}if(Ve.requires&&Ve.requires.length)throw new b("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:q});T.splice(pe,1,x),o._availablePlugins.set(q,x)}}}destroy(){const e=[];for(const[,t]of this)typeof t.destroy=="function"&&!this._contextPlugins.has(t)&&e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new b("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class Or{constructor(e){h(this,"config"),h(this,"plugins"),h(this,"locale"),h(this,"t"),h(this,"editors"),h(this,"_contextOwner",null);const{translations:t,...i}=e||{};this.config=new qg(i,this.constructor.defaultConfig);const o=this.constructor.builtinPlugins;this.config.define("plugins",o),this.plugins=new cw(this,o);const s=this.config.get("language")||{};this.locale=new lp({uiLanguage:typeof s=="string"?s:s.ui,contentLanguage:this.config.get("language.content"),translations:t}),this.t=this.locale.t,this.editors=new _e}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if(typeof i!="function")throw new b("context-initplugins-constructor-only",null,{Plugin:i});if(i.isContextPlugin!==!0)throw new b("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,e=>e.destroy())).then(()=>this.plugins.destroy())}_addEditor(e,t){if(this._contextOwner)throw new b("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise(t=>{const i=new this(e);t(i.initPlugins().then(()=>i))})}}h(Or,"defaultConfig"),h(Or,"builtinPlugins");class uw extends ue(){constructor(e){super(),h(this,"context"),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}class W5{constructor(){h(this,"_commands"),this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new b("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class j5 extends te{constructor(e){super(),h(this,"editor"),this.editor=e}set(e,t,i={}){if(typeof t=="string"){const o=t;t=(s,r)=>{this.editor.execute(o),r()}}super.set(e,t,i)}}const Wa="contentEditing",ad="common";class U5{constructor(e){h(this,"keystrokeInfos",new Map),h(this,"_editor"),this._editor=e;const t=e.config.get("menuBar.isVisible"),i=e.locale.t;this.addKeystrokeInfoCategory({id:Wa,label:i("Content editing keystrokes"),description:i("These keyboard shortcuts allow for quick access to content editing features.")});const o=[{label:i("Close contextual balloons, dropdowns, and dialogs"),keystroke:"Esc"},{label:i("Open the accessibility help dialog"),keystroke:"Alt+0"},{label:i("Move focus between form fields (inputs, buttons, etc.)"),keystroke:[["Tab"],["Shift+Tab"]]},{label:i("Move focus to the toolbar, navigate between toolbars"),keystroke:"Alt+F10",mayRequireFn:!0},{label:i("Navigate through the toolbar or menu bar"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]},{label:i("Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content."),keystroke:[["Enter"],["Space"]]}];t&&o.push({label:i("Move focus to the menu bar, navigate between menu bars"),keystroke:"Alt+F9",mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:"navigation",label:i("User interface and content navigation keystrokes"),description:i("Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface."),groups:[{id:"common",keystrokes:o}]})}addKeystrokeInfoCategory({id:e,label:t,description:i,groups:o}){this.keystrokeInfos.set(e,{id:e,label:t,description:i,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:e,id:ad}),o&&o.forEach(s=>{this.addKeystrokeInfoGroup({categoryId:e,...s})})}addKeystrokeInfoGroup({categoryId:e=Wa,id:t,label:i,keystrokes:o}){const s=this.keystrokeInfos.get(e);if(!s)throw new b("accessibility-unknown-keystroke-info-category",this._editor,{groupId:t,categoryId:e});s.groups.set(t,{id:t,label:i,keystrokes:o||[]})}addKeystrokeInfos({categoryId:e=Wa,groupId:t=ad,keystrokes:i}){if(!this.keystrokeInfos.has(e))throw new b("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:e,keystrokes:i});const o=this.keystrokeInfos.get(e);if(!o.groups.has(t))throw new b("accessibility-unknown-keystroke-info-group",this._editor,{groupId:t,categoryId:e,keystrokes:i});o.groups.get(t).keystrokes.push(...i)}}function q5(n){return{sessionId:Q5(),pageSessionId:Y5(),hostname:window.location.hostname,version:globalThis.CKEDITOR_VERSION,type:G5(n),plugins:K5(n.plugins),distribution:Z5(),env:J5(),integration:Object.create(null),menuBar:{isVisible:!!n.config.get("menuBar.isVisible")},language:{ui:n.locale.uiLanguage,content:n.locale.contentLanguage},toolbar:{main:ja(n.config.get("toolbar")),block:ja(n.config.get("blockToolbar")),balloon:ja(n.config.get("balloonToolbar"))}}}function G5(n){return Object.getPrototypeOf(n).constructor.editorName}function K5(n){return Array.from(n).filter(([e])=>!!e.pluginName).map(([e])=>{const{pluginName:t,isContextPlugin:i,isOfficialPlugin:o,isPremiumPlugin:s}=e;return{isContext:!!i,isOfficial:!!o,isPremium:!!s,name:t}})}function ja(n){if(!n)return;const e=Array.isArray(n)?{items:n}:n,t=o(e.items||[]);return{isMultiline:t.includes("-"),shouldNotGroupWhenFull:!!e.shouldNotGroupWhenFull,items:i(t)};function i(s){return s.filter(r=>r!=="|"&&r!=="-")}function o(s){return s.flatMap(r=>typeof r=="string"?[r]:o(r.items))}}function Z5(){return{channel:window[Symbol.for("cke distribution")]||"sh"}}function J5(){let n="unknown",e="unknown";return N.isMac?n="mac":N.isWindows?n="windows":N.isiOS?n="ios":N.isAndroid&&(n="android"),N.isGecko?e="gecko":N.isBlink?e="blink":N.isSafari&&(e="safari"),{os:n,browser:e}}function Q5(){return localStorage.getItem("__ckeditor-session-id")||localStorage.setItem("__ckeditor-session-id",ze()),localStorage.getItem("__ckeditor-session-id")}function Y5(){return I.window.CKEDITOR_PAGE_SESSION_ID=I.window.CKEDITOR_PAGE_SESSION_ID||ze(),I.window.CKEDITOR_PAGE_SESSION_ID}class pn extends ue(){constructor(e={}){if(super(),h(this,"accessibility"),h(this,"commands"),h(this,"config"),h(this,"conversion"),h(this,"data"),h(this,"editing"),h(this,"locale"),h(this,"model"),h(this,"plugins"),h(this,"keystrokes"),h(this,"t"),h(this,"_context"),h(this,"_readOnlyLocks"),"sanitizeHtml"in e)throw new b("editor-config-sanitizehtml-not-supported");const t=this.constructor,{translations:i,...o}=t.defaultConfig||{},{translations:s=i,...r}=e,a=e.language||o.language;this._context=e.context||new Or({language:a,translations:s}),this._context._addEditor(this,!e.context);const l=Array.from(t.builtinPlugins||[]);this.config=new qg(r,o),this.config.define("plugins",l),this.config.define(this._context._getEditorConfig()),u(this.config),this.plugins=new cw(this,l,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new W5,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.model=new l5,this.on("change:isReadOnly",()=>{this.model.document.isReadOnly=this.isReadOnly});const c=new Uv;this.data=new w2(this.model,c),this.editing=new Kk(this.model,c),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new _2([this.editing.downcastDispatcher,this.data.downcastDispatcher],this.data.upcastDispatcher),this.conversion.addAlias("dataDowncast",this.data.downcastDispatcher),this.conversion.addAlias("editingDowncast",this.editing.downcastDispatcher),this.keystrokes=new j5(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new U5(this),d(this);function u(m){let f=m.get("licenseKey");if(!f&&window.CKEDITOR_GLOBAL_LICENSE_KEY&&(f=window.CKEDITOR_GLOBAL_LICENSE_KEY,m.set("licenseKey",f)),!f)throw new b("license-key-missing")}function d(m){const f=m.config.get("licenseKey"),g=window[Symbol.for("cke distribution")]||"sh";function p(x){m.enableReadOnlyMode(Symbol("invalidLicense")),m._showLicenseError(x)}function _(x){const q=x.split(".");return q.length!=3?null:q[1]}function v(x){return["exp","jti","vc"].every(q=>q in x)}function E(x){return Object.getOwnPropertyNames(x).sort().filter(q=>q!="vc"&&x[q]!=null).map(q=>x[q])}function M(x){const{hostname:q}=new URL(window.location.href);if(x.includes(q))return!0;const Ve=q.split(".");return x.filter(pe=>pe.includes("*")).map(pe=>pe.split(".")).filter(pe=>pe.length<=Ve.length).map(pe=>Array(Ve.length-pe.length).fill(pe[0]==="*"?"*":"").concat(pe)).some(pe=>Ve.every((di,Bn)=>pe[Bn]===di||pe[Bn]==="*"))}function G(x){const q=x[0].toUpperCase()+x.slice(1),Ve=x==="evaluation"?"an":"a";console.info(`%cCKEditor 5 ${q} License`,"color: #ffffff; background: #743CCD; font-size: 14px; padding: 4px 8px; border-radius: 4px;"),console.warn(`⚠️ You are using ${Ve} ${x} license of CKEditor 5${x==="trial"?" which is for evaluation purposes only":""}. For production usage, please obtain a production license at https://portal.ckeditor.com/`)}if(f=="GPL"){g=="cloud"&&p("distributionChannel");return}const X=_(f);if(!X){p("invalid");return}const T=Wc(X);if(!T){p("invalid");return}if(!v(T)){p("invalid");return}if(T.distributionChannel&&!he(T.distributionChannel).includes(g)){p("distributionChannel");return}if(Sv(E(T))!=T.vc.toLowerCase()){p("invalid");return}if(new Date(T.exp*1e3)<H_){p("expired");return}const F=T.licensedHosts;if(F&&F.length>0&&!M(F)){p("domainLimit");return}if(["evaluation","trial"].includes(T.licenseType)&&T.exp*1e3<Date.now()){p("expired");return}if(["development","evaluation","trial"].includes(T.licenseType)){const{licenseType:x}=T;window.CKEDITOR_WARNING_SUPPRESSIONS=window.CKEDITOR_WARNING_SUPPRESSIONS||{},window.CKEDITOR_WARNING_SUPPRESSIONS[x]||(G(x),window.CKEDITOR_WARNING_SUPPRESSIONS[x]=!0)}if(["evaluation","trial"].includes(T.licenseType)){const x=T.licenseType,q=setTimeout(()=>{p(`${x}Limit`)},6e5);m.on("destroy",()=>{clearTimeout(q)})}T.usageEndpoint&&m.once("ready",()=>{const x={requestId:ze(),requestTime:Math.round(Date.now()/1e3),license:f,editor:X5(m)};m._sendUsageRequest(T.usageEndpoint,x).then(q=>{const{status:Ve,message:pe}=q;pe&&console.warn(pe),Ve!="ok"&&p("usageLimit")},()=>{D_("license-key-validation-endpoint-not-reachable",{url:T.usageEndpoint})})},{priority:"high"})}}static get editorName(){return"Editor"}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new b("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new b("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),this._readOnlyLocks.size===1&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if(typeof e!="string"&&typeof e!="symbol")throw new b("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),this._readOnlyLocks.size===0&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],o=e.get("extraPlugins")||[],s=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(o),i,s)}destroy(){let e=Promise.resolve();return this.state=="initializing"&&(e=new Promise(t=>this.once("ready",t))),e.then(()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()}).then(()=>this.plugins.destroy()).then(()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()}).then(()=>this._context._removeEditor(this))}execute(e,...t){try{return this.commands.execute(e,...t)}catch(i){/* istanbul ignore next -- @preserve */b.rethrowUnexpectedError(i,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}_showLicenseError(e,t){setTimeout(()=>{if(e=="invalid")throw new b("invalid-license-key");if(e=="expired")throw new b("license-key-expired");if(e=="domainLimit")throw new b("license-key-domain-limit");if(e=="featureNotAllowed")throw new b("license-key-plugin-not-allowed",null,{pluginName:t});if(e=="evaluationLimit")throw new b("license-key-evaluation-limit");if(e=="trialLimit")throw new b("license-key-trial-limit");if(e=="developmentLimit")throw new b("license-key-development-limit");if(e=="usageLimit")throw new b("license-key-usage-limit");if(e=="distributionChannel")throw new b("license-key-invalid-distribution-channel")},0),this._showLicenseError=()=>{}}async _sendUsageRequest(e,t){const i=new Headers({"Content-Type":"application/json"}),o=await fetch(new URL(e),{method:"POST",headers:i,body:JSON.stringify(t)});if(!o.ok)throw new Error(`HTTP Response: ${o.status}`);return o.json()}}h(pn,"defaultConfig"),h(pn,"builtinPlugins"),h(pn,"Context",Or),h(pn,"EditorWatchdog",lw),h(pn,"ContextWatchdog",H5);function X5(n){const e=q5(n);function t(i,o){if(Ki(e,i)!==void 0)throw new b("editor-usage-data-path-already-set",{path:i});Ig(e,i,o)}return n.fire("collectUsageData",{setUsageData:t}),e}function eC(n){if(!Tr(n.updateSourceElement))throw new b("attachtoform-missing-elementapi-interface",n);const e=n.sourceElement;if(tC(e)&&e.form){let t;const i=e.form,o=()=>n.updateSourceElement();Tr(i.submit)&&(t=i.submit,i.submit=()=>{o(),t.apply(i)}),i.addEventListener("submit",o),n.on("destroy",()=>{i.removeEventListener("submit",o),t&&(i.submit=t)})}}function tC(n){return!!n&&n.tagName.toLowerCase()==="textarea"}function Br(n){class e extends n{constructor(){super(...arguments),h(this,"sourceElement")}updateSourceElement(i){if(!this.sourceElement)throw new b("editor-missing-sourceelement",this);const o=this.config.get("updateSourceElementOnDestroy"),s=this.sourceElement instanceof HTMLTextAreaElement;if(!o&&!s){hh(this.sourceElement,"");return}const r=typeof i=="string"?i:this.data.get();hh(this.sourceElement,r)}}return e}Br.updateSourceElement=Br(Object).prototype.updateSourceElement;function hw(n,e){if(e.ckeditorInstance)throw new b("editor-source-element-already-used",n);e.ckeditorInstance=n,n.once("destroy",()=>{delete e.ckeditorInstance})}class ld extends uw{constructor(){super(...arguments),h(this,"_actions")}static get pluginName(){return"PendingActions"}static get isOfficialPlugin(){return!0}init(){this.set("hasAny",!1),this._actions=new _e({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if(typeof e!="string")throw new b("pendingactions-add-invalid-message",this);const t=new(ue());return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class iC extends ue(){constructor(){super(),h(this,"total"),h(this,"_reader"),h(this,"_data");const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=t=>{this.loaded=t.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise((i,o)=>{t.onload=()=>{const s=t.result;this._data=s,i(s)},t.onerror=()=>{o("error")},t.onabort=()=>{o("aborted")},this._reader.readAsDataURL(e)})}abort(){this._reader.abort()}}class At extends w{constructor(){super(...arguments),h(this,"loaders",new _e),h(this,"_loadersMap",new Map),h(this,"_pendingAction",null)}static get pluginName(){return"FileRepository"}static get isOfficialPlugin(){return!0}static get requires(){return[ld]}init(){this.loaders.on("change",()=>this._updatePendingAction()),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(e,t)=>t?e/t*100:0)}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return J("filerepository-no-upload-adapter"),null;const t=new cd(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then(i=>{this._loadersMap.set(i,t)}).catch(()=>{}),t.on("change:uploaded",()=>{let i=0;for(const o of this.loaders)i+=o.uploaded;this.uploaded=i}),t.on("change:uploadTotal",()=>{let i=0;for(const o of this.loaders)o.uploadTotal&&(i+=o.uploadTotal);this.uploadTotal=i}),t}destroyLoader(e){const t=e instanceof cd?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach((i,o)=>{i===t&&this._loadersMap.delete(o)})}_updatePendingAction(){const e=this.editor.plugins.get(ld);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=o=>`${t("Upload in progress")} ${parseInt(o)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}class cd extends ue(){constructor(e,t){super(),h(this,"id"),h(this,"_filePromiseWrapper"),h(this,"_adapter"),h(this,"_reader"),this.id=ze(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new iC,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(i,o)=>o?i/o*100:0),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then(e=>this._filePromiseWrapper?e:null):Promise.resolve(null)}get data(){return this._reader.data}read(){if(this.status!="idle")throw new b("filerepository-read-wrong-status",this);return this.status="reading",this.file.then(e=>this._reader.read(e)).then(e=>{if(this.status!=="reading")throw this.status;return this.status="idle",e}).catch(e=>{throw e==="aborted"?(this.status="aborted","aborted"):(this.status="error",this._reader.error?this._reader.error:e)})}upload(){if(this.status!="idle")throw new b("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then(()=>this._adapter.upload()).then(e=>(this.uploadResponse=e,this.status="idle",e)).catch(e=>{throw this.status==="aborted"?"aborted":(this.status="error",e)})}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?e=="reading"?this._reader.abort():e=="uploading"&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch(()=>{}),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise((i,o)=>{t.rejecter=o,t.isFulfilled=!1,e.then(s=>{t.isFulfilled=!0,i(s)}).catch(s=>{t.isFulfilled=!0,o(s)})}),t}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const ud="ckCsrfToken",hd=40,dd="abcdefghijklmnopqrstuvwxyz0123456789";function nC(){let n=oC(ud);return(!n||n.length!=hd)&&(n=rC(hd),sC(ud,n)),n}function oC(n){n=n.toLowerCase();const e=document.cookie.split(";");for(const t of e){const i=t.split("=");if(decodeURIComponent(i[0].trim().toLowerCase())===n)return decodeURIComponent(i[1])}return null}function sC(n,e){document.cookie=encodeURIComponent(n)+"="+encodeURIComponent(e)+";path=/"}function rC(n){let e="";const t=new Uint8Array(n);window.crypto.getRandomValues(t);for(let i=0;i<t.length;i++){const o=dd.charAt(t[i]%dd.length);e+=Math.random()>.5?o.toUpperCase():o}return e}class aC extends w{static get requires(){return[At]}static get pluginName(){return"CKFinderUploadAdapter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(At).createUploadAdapter=t=>new lC(t,e,this.editor.t))}}class lC{constructor(e,t,i){h(this,"loader"),h(this,"url"),h(this,"t"),h(this,"xhr"),this.loader=e,this.url=t,this.t=i}upload(){return this.loader.file.then(e=>new Promise((t,i)=>{this._initRequest(),this._initListeners(t,i,e),this._sendRequest(e)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,i){const o=this.xhr,s=this.loader,r=this.t,a=r("Cannot upload file:")+` ${i.name}.`;o.addEventListener("error",()=>t(a)),o.addEventListener("abort",()=>t()),o.addEventListener("load",()=>{const l=o.response;if(!l||!l.uploaded)return t(l&&l.error&&l.error.message?l.error.message:a);e({default:l.url})});/* istanbul ignore else -- @preserve */o.upload&&o.upload.addEventListener("progress",l=>{l.lengthComputable&&(s.uploadTotal=l.total,s.uploaded=l.loaded)})}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",nC()),this.xhr.send(t)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/var cC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m9.239 13.938-2.88-1.663a.75.75 0 0 1 .75-1.3L9 12.067V4.75a.75.75 0 1 1 1.5 0v7.318l1.89-1.093a.75.75 0 0 1 .75 1.3l-2.879 1.663a.752.752 0 0 1-.511.187.752.752 0 0 1-.511-.187zM4.25 17a.75.75 0 1 1 0-1.5h10.5a.75.75 0 0 1 0 1.5H4.25z"/></svg>',dw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm2.286 4c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h9.928a.75.75 0 1 0 0-1.5H5.036a.75.75 0 0 0-.75.75z"/></svg>',mw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75z"/></svg>',nu='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 8c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0 4c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm0-8c0 .414.336.75.75.75h9.929a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75z"/></svg>',uC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.75 11.875a.752.752 0 0 1 .508.184l2.883 1.666a.75.75 0 0 1-.659 1.344l-.091-.044-1.892-1.093.001 4.318a.75.75 0 1 1-1.5 0v-4.317l-1.89 1.092a.75.75 0 0 1-.75-1.3l2.879-1.663a.752.752 0 0 1 .51-.187zM15.25 9a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5h10.5zM9.75.375a.75.75 0 0 1 .75.75v4.318l1.89-1.093.092-.045a.75.75 0 0 1 .659 1.344l-2.883 1.667a.752.752 0 0 1-.508.184.752.752 0 0 1-.511-.187L6.359 5.65a.75.75 0 0 1 .75-1.299L9 5.442V1.125a.75.75 0 0 1 .75-.75z"/></svg>',fw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M18 3.75a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75zm0 8a.75.75 0 0 1-.75.75H2.75a.75.75 0 1 1 0-1.5h14.5a.75.75 0 0 1 .75.75zm0 4a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75zm0-8a.75.75 0 0 1-.75.75H7.321a.75.75 0 1 1 0-1.5h9.929a.75.75 0 0 1 .75.75z"/></svg>',hC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m10.261 7.062 2.88 1.663a.75.75 0 0 1-.75 1.3L10.5 8.933v7.317a.75.75 0 1 1-1.5 0V8.932l-1.89 1.093a.75.75 0 0 1-.75-1.3l2.879-1.663a.752.752 0 0 1 .511-.187.752.752 0 0 1 .511.187zM15.25 4a.75.75 0 1 1 0 1.5H4.75a.75.75 0 0 1 0-1.5h10.5z"/></svg>',gw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.187 17H5.773c-.637 0-1.092-.138-1.364-.415-.273-.277-.409-.718-.409-1.323V4.738c0-.617.14-1.062.419-1.332.279-.27.73-.406 1.354-.406h4.68c.69 0 1.288.041 1.793.124.506.083.96.242 1.36.478.341.197.644.447.906.75a3.262 3.262 0 0 1 .808 2.162c0 1.401-.722 2.426-2.167 3.075C15.05 10.175 16 11.315 16 13.01a3.756 3.756 0 0 1-2.296 3.504 6.1 6.1 0 0 1-1.517.377c-.571.073-1.238.11-2 .11zm-.217-6.217H7v4.087h3.069c1.977 0 2.965-.69 2.965-2.072 0-.707-.256-1.22-.768-1.537-.512-.319-1.277-.478-2.296-.478zM7 5.13v3.619h2.606c.729 0 1.292-.067 1.69-.2a1.6 1.6 0 0 0 .91-.765c.165-.267.247-.566.247-.897 0-.707-.26-1.176-.778-1.409-.519-.232-1.31-.348-2.375-.348H7z"/></svg>',dC='<svg viewBox="0 0 14 16" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M2 14.436V2a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v12.436a.5.5 0 0 1-.819.385l-3.862-3.2a.5.5 0 0 0-.638 0l-3.862 3.2A.5.5 0 0 1 2 14.436Z"/></svg>',mC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M5.68 3.417a.238.238 0 0 0-.24.236v12.66l3.793-3.102a1.215 1.215 0 0 1 1.534 0l3.793 3.103V3.654a.238.238 0 0 0-.24-.237H5.68ZM4 3.653C4 2.74 4.752 2 5.68 2h8.64c.928 0 1.68.74 1.68 1.653v13.164c0 1-1.185 1.547-1.967.908L10 14.426l-4.033 3.299c-.782.64-1.967.092-1.967-.908V3.653Z"/></svg>',fC='<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M4.4 2.24c-.11 0-.2.092-.2.207v11.077l3.16-2.714a.975.975 0 0 1 1.28 0l3.16 2.714V2.447a.203.203 0 0 0-.2-.207H4.4ZM3 2.447C3 1.647 3.627 1 4.4 1h7.2c.773 0 1.4.648 1.4 1.447v11.518c0 .875-.988 1.354-1.64.794L8 11.873 4.64 14.76c-.652.56-1.64.081-1.64-.794V2.447Z"/></svg>',gC='<svg viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M4.216 2.031a.503.503 0 0 0-.489.516v9.42l2.648-2.324a.938.938 0 0 1 1.25 0l2.648 2.324v-9.42a.503.503 0 0 0-.489-.516H4.216Zm-1.466.516C2.75 1.693 3.406 1 4.216 1h5.568c.81 0 1.466.693 1.466 1.547v9.42c0 .873-.965 1.351-1.602.793L7 10.436 4.352 12.76c-.637.558-1.602.08-1.602-.793v-9.42Z"/></svg>',ou='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0C1 4.784 1.777 4 2.75 4c.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75C1.784 7.5 1 6.723 1 5.75zm6 9c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0c0-.966.777-1.75 1.75-1.75.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75-.966 0-1.75-.777-1.75-1.75z"/></svg>',_o='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.591 10.177 4.243 4.242a1 1 0 0 1-1.415 1.415l-4.242-4.243-4.243 4.243a1 1 0 0 1-1.414-1.415l4.243-4.242L4.52 5.934A1 1 0 0 1 5.934 4.52l4.243 4.243 4.242-4.243a1 1 0 1 1 1.415 1.414l-4.243 4.243z"/></svg>',pw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 16h9a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2z"/><path d="M17 1a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14zm0 1.5H3a.5.5 0 0 0-.492.41L2.5 3v9a.5.5 0 0 0 .41.492L3 12.5h14a.5.5 0 0 0 .492-.41L17.5 12V3a.5.5 0 0 0-.41-.492L17 2.5z" fill-opacity=".6"/></svg>',Es='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.972 16.615a.997.997 0 0 1-.744-.292l-4.596-4.596a1 1 0 1 1 1.414-1.414l3.926 3.926 9.937-9.937a1 1 0 0 1 1.414 1.415L7.717 16.323a.997.997 0 0 1-.745.292z"/></svg>',md='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><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.174zm2.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.207zM16 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-2h14zM5.009 15l.003 1H3v-1h2.009zm2.188-2-1.471 1H5v-1h2.197zM10 11v.095L8.668 12H7v-1h3zm4-2v1H7V9h7zm0-2v1H7V7h7zm-4-2v1H5V5h5zM6 3v1H3V3h3z"/></svg>',pC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.5 5.7 5.2 3.9v1.3l-5.6 4c-.1.2-.3.2-.5.2-.3-.1-.6-.7-.6-1l.3-.4 4.7-3.5L11.5 7l-.2-.2c-.1-.3-.1-.6 0-.8.2-.2.5-.4.8-.4a.8.8 0 0 1 .4.1zm-5.2 0L2 9.6v1.3l5.6 4c.1.2.3.2.5.2.3-.1.7-.7.6-1 0-.1 0-.3-.2-.4l-5-3.5L8.2 7l.2-.2c.1-.3.1-.6 0-.8-.2-.2-.5-.4-.8-.4a.8.8 0 0 0-.3.1z"/></svg>',wC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><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 8.665 8.665 0 0 1-.372.008Zm-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.414ZM9.76 6.155a1.25 1.25 0 1 0 .647-2.415 1.25 1.25 0 0 0-.647 2.415Zm4.028 1.759a1.25 1.25 0 1 0 .647-2.415 1.25 1.25 0 0 0-.647 2.415Z"/></svg>',bC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" 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 0z"/><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>',_C='<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M4 0v1H1v3H0V.5A.5.5 0 0 1 .5 0H4zm8 0h3.5a.5.5 0 0 1 .5.5V4h-1V1h-3V0zM4 16H.5a.5.5 0 0 1-.5-.5V12h1v3h3v1zm8 0v-1h3v-3h1v3.5a.5.5 0 0 1-.5.5H12z"/><path fill-opacity=".256" d="M1 1h14v14H1z"/><g class="ck-icon__selected-indicator"><path d="M7 0h2v1H7V0zM0 7h1v2H0V7zm15 0h1v2h-1V7zm-8 8h2v1H7v-1z"/><path fill-opacity=".254" d="M1 1h14v14H1z"/></g></svg>',vC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5 3.25a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 3.25a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M5 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 10a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M5 16.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/><path d="M12 16.75a1.5 1.5 0 1 0 3 0 1.5 1.5 0 1 0-3 0"/></svg>',da='<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path d="M.941 4.523a.75.75 0 1 1 1.06-1.06l3.006 3.005 3.005-3.005a.75.75 0 1 1 1.06 1.06l-3.549 3.55a.75.75 0 0 1-1.168-.136L.941 4.523z"/></svg>',yC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M8.5 8.25a1.25 1.25 0 1 1-2.499.001A1.25 1.25 0 0 1 8.5 8.25Z"/><path clip-rule="evenodd" d="M14 8.25a1.25 1.25 0 1 1-2.499.001A1.25 1.25 0 0 1 14 8.25Z"/><path clip-rule="evenodd" d="M7.127 12.088a.75.75 0 1 0-1.254.824C6.88 14.444 8.423 15.25 10 15.25c1.578 0 3.12-.805 4.127-2.338a.75.75 0 0 0-1.254-.824C12.13 13.221 11.048 13.75 10 13.75c-1.047 0-2.13-.529-2.873-1.662Z"/><path d="M10 19a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm0-1.5a7.5 7.5 0 1 1 0-15 7.5 7.5 0 0 1 0 15Z"/></svg>',kC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m8.636 9.531-2.758 3.94a.5.5 0 0 0 .122.696l3.224 2.284h1.314l2.636-3.736L8.636 9.53zm.288 8.451L5.14 15.396a2 2 0 0 1-.491-2.786l6.673-9.53a2 2 0 0 1 2.785-.49l3.742 2.62a2 2 0 0 1 .491 2.785l-7.269 10.053-2.147-.066z"/><path d="M4 18h5.523v-1H4zm-2 0h1v-1H2z"/></svg>',fd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m12.87 13.786 1.532-1.286 3.857 4.596a1 1 0 1 1-1.532 1.286l-3.857-4.596z"/><path d="M16.004 8.5a6.5 6.5 0 0 1-9.216 5.905c-1.154-.53-.863-1.415-.663-1.615.194-.194.564-.592 1.635-.141a4.5 4.5 0 0 0 5.89-5.904l-.104-.227 1.332-1.331c.045-.046.196-.041.224.007a6.47 6.47 0 0 1 .902 3.306zm-3.4-5.715c.562.305.742 1.106.354 1.494-.388.388-.995.414-1.476.178a4.5 4.5 0 0 0-6.086 5.882l.114.236-1.348 1.349c-.038.037-.17.022-.198-.023a6.5 6.5 0 0 1 5.54-9.9 6.469 6.469 0 0 1 3.1.784z"/><path d="M4.001 11.93.948 8.877a.2.2 0 0 1 .141-.341h6.106a.2.2 0 0 1 .141.341L4.283 11.93a.2.2 0 0 1-.282 0zm11.083-6.789 3.053 3.053a.2.2 0 0 1-.14.342H11.89a.2.2 0 0 1-.14-.342l3.052-3.053a.2.2 0 0 1 .282 0z"/></svg>',CC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><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-2zm8.38 9.262H7.62L10 5.506l2.38 5.756zm.532 1.285L14.34 16h1.426L10.804 4H9.196L4.234 16H5.66l1.428-3.453h5.824z"/></svg>',AC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.4 10.3 10 4.5l-2.4 5.8h4.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 2z"/></svg>',gd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.03 3h6.149a.75.75 0 1 1 0 1.5h-5.514L11.03 3zm1.27 3h4.879a.75.75 0 1 1 0 1.5h-4.244L12.3 6zm1.27 3h3.609a.75.75 0 1 1 0 1.5h-2.973L13.57 9zm-2.754 2.5L8.038 4.785 5.261 11.5h5.555zm.62 1.5H4.641l-1.666 4.028H1.312l5.789-14h1.875l5.789 14h-1.663L11.436 13z"/></svg>',pd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.816 11.5 7.038 4.785 4.261 11.5h5.555zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663L10.436 13zm7.55 2.279.779-.779.707.707-2.265 2.265-2.193-2.265.707-.707.765.765V4.825c0-.042 0-.083.002-.123l-.77.77-.707-.707L17.207 2.5l2.265 2.265-.707.707-.782-.782c.002.043.003.089.003.135v10.454z"/></svg>',xC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M19 9v10h-2v-8h-2V9h4zM4 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1H10a1 1 0 0 1-1-1V11H4v4.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1H3a1 1 0 0 1 1 1v4.5z"/></svg>',TC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V11H3v4.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1H2a1 1 0 0 1 1 1v4.5zm16.076 8.343V18.5h-6.252c.067-.626.27-1.22.61-1.78.338-.561 1.006-1.305 2.005-2.232.804-.749 1.297-1.257 1.479-1.523.245-.368.368-.732.368-1.092 0-.398-.107-.703-.32-.917-.214-.214-.51-.32-.886-.32-.372 0-.669.111-.889.336-.22.224-.347.596-.38 1.117l-1.778-.178c.106-.982.438-1.686.997-2.114.558-.427 1.257-.64 2.095-.64.918 0 1.64.247 2.164.742.525.495.787 1.11.787 1.847 0 .419-.075.818-.225 1.197-.15.378-.388.775-.714 1.19-.216.275-.605.67-1.168 1.187-.563.516-.92.859-1.07 1.028a3.11 3.11 0 0 0-.365.495h3.542z"/></svg>',EC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V11H3v4.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1H2a1 1 0 0 1 1 1v4.5zm9.989 7.53 1.726-.209c.055.44.203.777.445 1.01.24.232.533.349.876.349.368 0 .678-.14.93-.42.251-.279.377-.655.377-1.13 0-.448-.12-.803-.362-1.066a1.153 1.153 0 0 0-.882-.393c-.228 0-.501.044-.819.133l.197-1.453c.482.012.85-.092 1.105-.315.253-.222.38-.517.38-.885 0-.313-.093-.563-.279-.75-.186-.185-.434-.278-.743-.278a1.07 1.07 0 0 0-.78.317c-.216.212-.347.52-.394.927l-1.644-.28c.114-.562.287-1.012.517-1.348.231-.337.553-.601.965-.794a3.24 3.24 0 0 1 1.387-.289c.876 0 1.579.28 2.108.838.436.457.653.973.653 1.549 0 .817-.446 1.468-1.339 1.955.533.114.96.37 1.28.768.319.398.478.878.478 1.441 0 .817-.298 1.513-.895 2.088-.596.576-1.339.864-2.228.864-.842 0-1.54-.243-2.094-.727-.555-.485-.876-1.118-.965-1.901z"/></svg>',SC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V11h-5v4.5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v4.5zm13.55 10v-1.873h-3.81v-1.561l4.037-5.91h1.498v5.904h1.156v1.567h-1.156V18.5H17.05zm0-3.44v-3.18l-2.14 3.18h2.14z"/></svg>',PC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V11h-5v4.5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v4.5zm9.578 7.607 1.777-.184c.05.402.201.72.45.955a1.223 1.223 0 0 0 1.81-.101c.258-.303.387-.759.387-1.368 0-.572-.128-1-.384-1.286-.256-.285-.59-.428-1-.428-.512 0-.971.226-1.377.679l-1.448-.21.915-4.843h4.716v1.67H15.56l-.28 1.58a2.697 2.697 0 0 1 1.219-.298 2.68 2.68 0 0 1 2.012.863c.55.576.825 1.323.825 2.241a3.36 3.36 0 0 1-.666 2.05c-.605.821-1.445 1.232-2.52 1.232-.86 0-1.56-.23-2.101-.692-.542-.461-.866-1.081-.971-1.86z"/></svg>',IC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.5 8.5h5V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v11.5a1 1 0 0 1-1 1h-.5a1 1 0 0 1-1-1V11h-5v4.5a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h.5a1 1 0 0 1 1 1v4.5zm15.595 2.973-1.726.19c-.043-.355-.153-.617-.33-.787-.178-.169-.409-.253-.692-.253-.377 0-.695.169-.956.507-.26.339-.424 1.043-.492 2.114.445-.525.997-.787 1.657-.787.745 0 1.383.284 1.914.85.531.568.797 1.3.797 2.197 0 .952-.28 1.716-.838 2.291-.559.576-1.276.864-2.152.864-.94 0-1.712-.365-2.317-1.095-.605-.73-.908-1.927-.908-3.59 0-1.705.316-2.935.946-3.688.63-.753 1.45-1.13 2.457-1.13.706 0 1.291.198 1.755.594.463.395.758.97.885 1.723zm-4.043 3.891c0 .58.133 1.028.4 1.343.266.315.57.473.914.473.33 0 .605-.13.825-.388.22-.258.33-.68.33-1.27 0-.604-.118-1.047-.355-1.329a1.115 1.115 0 0 0-.89-.422c-.342 0-.632.134-.869.403s-.355.666-.355 1.19z"/></svg>',VC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 9h16v2H2z"/></svg>',RC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><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.1l4.16-4.482ZM17.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 1h15.6Zm-5.655 6a2.128 2.128 0 0 1 .157-2.364A2.133 2.133 0 1 1 12.145 7Z"/></svg>',OC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.201 1C.538 1 0 1.47 0 2.1v14.363c0 .64.534 1.037 1.186 1.037h9.494a2.97 2.97 0 0 1-.414-.287 2.998 2.998 0 0 1-1.055-2.03 3.003 3.003 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.1H1.202Zm11.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.134 2.134 0 0 0-1.875-.978Z"/><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.784.784 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.79Z"/><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.784.784 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.79Z"/></svg>',BC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><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.822V4.5ZM14 5V2l3.3 3H14Zm-3.692 12.5c.062.105.133.206.213.303L11.52 19H8v-.876a2.243 2.243 0 0 0 1.82-.624h.488Zm7.518-.657a.75.75 0 0 0-1.152-.96L15.5 17.29V12H14v5.29l-1.174-1.408a.75.75 0 0 0-1.152.96l2.346 2.816a.95.95 0 0 0 1.46 0l2.346-2.815Zm-15.056-.38a.75.75 0 0 1-.096-1.056l2.346-2.815a.95.95 0 0 1 1.46 0l2.346 2.815a.75.75 0 1 1-1.152.96L6.5 14.96V20H5v-5.04l-1.174 1.408a.75.75 0 0 1-1.056.096Z"/></svg>',wd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5zM1.632 6.95 5.02 9.358a.4.4 0 0 1-.013.661l-3.39 2.207A.4.4 0 0 1 1 11.892V7.275a.4.4 0 0 1 .632-.326z"/></svg>',MC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m9.586 14.633.021.004c-.036.335.095.655.393.962.082.083.173.15.274.201h1.474a.6.6 0 1 1 0 1.2H5.304a.6.6 0 0 1 0-1.2h1.15c.474-.07.809-.182 1.005-.334.157-.122.291-.32.404-.597l2.416-9.55a1.053 1.053 0 0 0-.281-.823 1.12 1.12 0 0 0-.442-.296H8.15a.6.6 0 0 1 0-1.2h6.443a.6.6 0 1 1 0 1.2h-1.195c-.376.056-.65.155-.823.296-.215.175-.423.439-.623.79l-2.366 9.347z"/></svg>',LC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184z"/></svg>',FC='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M11 27a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0 1a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm0-10a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0 1a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm0-10a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0 1a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/></svg>',NC='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M5.714 15.11c.624 0 1.11-.22 1.46-.66.421-.533.632-1.408.632-2.627 0-1.222-.21-2.096-.629-2.624-.351-.445-.839-.668-1.463-.668-.624 0-1.11.22-1.459.66-.422.533-.633 1.406-.633 2.619 0 1.236.192 2.095.576 2.577.384.482.89.723 1.516.723zm0-1.024a.614.614 0 0 1-.398-.14c-.115-.094-.211-.283-.287-.565-.077-.283-.115-.802-.115-1.558s.043-1.294.128-1.613c.064-.246.155-.417.272-.512a.617.617 0 0 1 .4-.143.61.61 0 0 1 .398.143c.116.095.211.284.288.567.076.283.114.802.114 1.558s-.043 1.292-.128 1.608c-.064.246-.155.417-.272.512a.617.617 0 0 1-.4.143zm6.078.914V8.531H10.79c-.14.393-.4.736-.778 1.03-.378.295-.728.495-1.05.6v1.121a4.257 4.257 0 0 0 1.595-.936V15h1.235zm3.344 0v-1.235h-1.235V15h1.235zm-9.422 9.11c.624 0 1.11-.22 1.46-.66.421-.533.632-1.408.632-2.627 0-1.222-.21-2.096-.629-2.624-.351-.445-.839-.668-1.463-.668-.624 0-1.11.22-1.459.66-.422.533-.633 1.406-.633 2.619 0 1.236.192 2.095.576 2.577.384.482.89.723 1.516.723zm0-1.024a.614.614 0 0 1-.398-.14c-.115-.094-.211-.283-.287-.565-.077-.283-.115-.802-.115-1.558s.043-1.294.128-1.613c.064-.246.155-.417.272-.512a.617.617 0 0 1 .4-.143.61.61 0 0 1 .398.143c.116.095.211.284.288.567.076.283.114.802.114 1.558s-.043 1.292-.128 1.608c-.064.246-.155.417-.272.512a.617.617 0 0 1-.4.143zm7.088.914v-1.147H10.35c.065-.111.149-.226.253-.343.104-.117.35-.354.74-.712.39-.357.66-.631.81-.821.225-.288.39-.562.493-.824.104-.263.156-.539.156-.829 0-.51-.181-.936-.544-1.279-.364-.342-.863-.514-1.499-.514-.58 0-1.063.148-1.45.444-.387.296-.617.784-.69 1.463l1.23.124c.024-.36.112-.619.264-.774.152-.155.357-.233.615-.233.261 0 .465.074.613.222.148.148.222.36.222.635 0 .25-.085.501-.255.756-.126.185-.467.536-1.024 1.055-.691.641-1.154 1.156-1.388 1.544-.235.389-.375.8-.422 1.233h4.328zm2.334 0v-1.235h-1.235V24h1.235zM5.714 34.11c.624 0 1.11-.22 1.46-.66.421-.533.632-1.408.632-2.627 0-1.222-.21-2.096-.629-2.624-.351-.445-.839-.668-1.463-.668-.624 0-1.11.22-1.459.66-.422.533-.633 1.406-.633 2.619 0 1.236.192 2.095.576 2.577.384.482.89.723 1.516.723zm0-1.024a.614.614 0 0 1-.398-.14c-.115-.094-.211-.283-.287-.565-.077-.283-.115-.802-.115-1.558s.043-1.294.128-1.613c.064-.246.155-.417.272-.512a.617.617 0 0 1 .4-.143.61.61 0 0 1 .398.143c.116.095.211.284.288.567.076.283.114.802.114 1.558s-.043 1.292-.128 1.608c-.064.246-.155.417-.272.512a.617.617 0 0 1-.4.143zm4.992 1.024c.616 0 1.13-.2 1.543-.598.413-.398.62-.88.62-1.446 0-.39-.111-.722-.332-.997a1.5 1.5 0 0 0-.886-.532c.618-.337.927-.788.927-1.353 0-.399-.15-.756-.452-1.073-.366-.386-.853-.58-1.46-.58a2.25 2.25 0 0 0-.96.2 1.617 1.617 0 0 0-.667.55c-.16.232-.28.544-.359.933l1.139.194c.032-.282.123-.495.272-.642.15-.146.33-.22.54-.22.214 0 .386.065.515.194s.193.302.193.518c0 .255-.088.46-.264.613-.175.154-.43.227-.764.218l-.136 1.006c.22-.061.408-.092.566-.092.24 0 .444.09.611.272.167.182.25.428.25.739 0 .328-.086.589-.26.782a.833.833 0 0 1-.644.29.841.841 0 0 1-.607-.242c-.167-.16-.27-.394-.308-.698l-1.195.145c.062.542.284.98.668 1.316.384.335.867.503 1.45.503zm4.43-.11v-1.235h-1.235V34h1.235z"/></svg>',DC='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M10.29 15V8.531H9.286c-.14.393-.4.736-.778 1.03-.378.295-.728.495-1.05.6v1.121a4.257 4.257 0 0 0 1.595-.936V15h1.235zm3.343 0v-1.235h-1.235V15h1.235zM11.3 24v-1.147H8.848c.064-.111.148-.226.252-.343.104-.117.351-.354.74-.712.39-.357.66-.631.81-.821.225-.288.39-.562.494-.824.104-.263.156-.539.156-.829 0-.51-.182-.936-.545-1.279-.363-.342-.863-.514-1.499-.514-.58 0-1.063.148-1.45.444-.387.296-.617.784-.69 1.463l1.23.124c.024-.36.112-.619.264-.774.153-.155.358-.233.616-.233.26 0 .465.074.613.222.148.148.222.36.222.635 0 .25-.085.501-.255.756-.126.185-.468.536-1.024 1.055-.692.641-1.155 1.156-1.389 1.544-.234.389-.375.8-.422 1.233H11.3zm2.333 0v-1.235h-1.235V24h1.235zM9.204 34.11c.615 0 1.129-.2 1.542-.598.413-.398.62-.88.62-1.446 0-.39-.11-.722-.332-.997a1.5 1.5 0 0 0-.886-.532c.619-.337.928-.788.928-1.353 0-.399-.151-.756-.453-1.073-.366-.386-.852-.58-1.459-.58a2.25 2.25 0 0 0-.96.2 1.617 1.617 0 0 0-.668.55c-.16.232-.28.544-.358.933l1.138.194c.032-.282.123-.495.272-.642.15-.146.33-.22.54-.22.215 0 .386.065.515.194s.193.302.193.518c0 .255-.087.46-.263.613-.176.154-.43.227-.765.218l-.136 1.006c.22-.061.409-.092.567-.092.24 0 .444.09.61.272.168.182.251.428.251.739 0 .328-.087.589-.261.782a.833.833 0 0 1-.644.29.841.841 0 0 1-.607-.242c-.167-.16-.27-.394-.307-.698l-1.196.145c.062.542.285.98.668 1.316.384.335.868.503 1.45.503zm4.43-.11v-1.235h-1.236V34h1.235z"/></svg>',zC='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M11 27a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0-9a3 3 0 1 1 0 6 3 3 0 0 1 0-6zm0-9a3 3 0 1 1 0 6 3 3 0 0 1 0-6z"/></svg>',HC='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M9.62 14.105c.272 0 .528-.05.768-.153s.466-.257.677-.462c.009.024.023.072.044.145.047.161.086.283.119.365h1.221a2.649 2.649 0 0 1-.222-.626c-.04-.195-.059-.498-.059-.908l.013-1.441c0-.536-.055-.905-.165-1.105-.11-.201-.3-.367-.569-.497-.27-.13-.68-.195-1.23-.195-.607 0-1.064.108-1.371.325-.308.217-.525.55-.65 1.002l1.12.202c.076-.217.176-.369.299-.455.123-.086.294-.13.514-.13.325 0 .546.05.663.152.118.101.176.27.176.508v.123c-.222.093-.622.194-1.2.303-.427.082-.755.178-.982.288-.227.11-.403.268-.53.474a1.327 1.327 0 0 0-.188.706c0 .398.138.728.415.988.277.261.656.391 1.136.391zm.368-.87a.675.675 0 0 1-.492-.189.606.606 0 0 1-.193-.448c0-.176.08-.32.241-.435.106-.07.33-.142.673-.215a7.19 7.19 0 0 0 .751-.19v.247c0 .296-.016.496-.048.602a.773.773 0 0 1-.295.409 1.07 1.07 0 0 1-.637.22zm4.645.765v-1.235h-1.235V14h1.235zM10.2 25.105c.542 0 1.003-.215 1.382-.646.38-.43.57-1.044.57-1.84 0-.771-.187-1.362-.559-1.774a1.82 1.82 0 0 0-1.41-.617c-.522 0-.973.216-1.354.65v-2.32H7.594V25h1.147v-.686a1.9 1.9 0 0 0 .67.592c.26.133.523.2.79.2zm-.299-.975c-.354 0-.638-.164-.852-.492-.153-.232-.229-.59-.229-1.073 0-.468.098-.818.295-1.048a.93.93 0 0 1 .738-.345c.302 0 .55.118.743.354.193.236.29.62.29 1.154 0 .5-.096.868-.288 1.1-.192.233-.424.35-.697.35zm4.478.87v-1.235h-1.234V25h1.234zm-4.017 9.105c.6 0 1.08-.142 1.437-.426.357-.284.599-.704.725-1.261l-1.213-.207c-.061.326-.167.555-.316.688a.832.832 0 0 1-.576.2.916.916 0 0 1-.75-.343c-.185-.228-.278-.62-.278-1.173 0-.498.091-.853.274-1.066.183-.212.429-.318.736-.318.232 0 .42.061.565.184.145.123.238.306.28.55l1.216-.22c-.146-.501-.387-.874-.722-1.119-.336-.244-.788-.366-1.356-.366-.695 0-1.245.214-1.653.643-.407.43-.61 1.03-.61 1.8 0 .762.202 1.358.608 1.788.406.431.95.646 1.633.646zM14.633 34v-1.235h-1.235V34h1.235z"/></svg>',$C='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M11.88 8.7V7.558h-1.234V8.7h1.234zm0 5.3V9.333h-1.234V14h1.234zm2.5 0v-1.235h-1.234V14h1.235zm-4.75 4.7v-1.142H8.395V18.7H9.63zm0 5.3v-4.667H8.395V24H9.63zm2.5-5.3v-1.142h-1.234V18.7h1.235zm0 5.3v-4.667h-1.234V24h1.235zm2.501 0v-1.235h-1.235V24h1.235zM7.38 28.7v-1.142H6.145V28.7H7.38zm0 5.3v-4.667H6.145V34H7.38zm2.5-5.3v-1.142H8.646V28.7H9.88zm0 5.3v-4.667H8.646V34H9.88zm2.5-5.3v-1.142h-1.234V28.7h1.235zm0 5.3v-4.667h-1.234V34h1.235zm2.501 0v-1.235h-1.235V34h1.235z"/></svg>',WC='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M14 27v6H8v-6h6zm0-9v6H8v-6h6zm0-9v6H8V9h6z"/></svg>',jC='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="m7.88 15 .532-1.463h2.575L11.549 15h1.415l-2.58-6.442H9.01L6.5 15h1.38zm2.69-2.549H8.811l.87-2.39.887 2.39zM14.88 15v-1.235h-1.234V15h1.234zM9.352 25c.83-.006 1.352-.02 1.569-.044.346-.038.636-.14.872-.305.236-.166.422-.387.558-.664.137-.277.205-.562.205-.855 0-.372-.106-.695-.317-.97-.21-.276-.512-.471-.905-.585a1.51 1.51 0 0 0 .661-.567 1.5 1.5 0 0 0 .244-.83c0-.28-.066-.53-.197-.754a1.654 1.654 0 0 0-.495-.539 1.676 1.676 0 0 0-.672-.266c-.25-.042-.63-.063-1.14-.063H7.158V25h2.193zm.142-3.88H8.46v-1.49h.747c.612 0 .983.007 1.112.022.217.026.38.102.49.226.11.125.165.287.165.486a.68.68 0 0 1-.192.503.86.86 0 0 1-.525.23 11.47 11.47 0 0 1-.944.023h.18zm.17 2.795H8.46v-1.723h1.05c.592 0 .977.03 1.154.092.177.062.313.16.406.295a.84.84 0 0 1 .14.492c0 .228-.06.41-.181.547a.806.806 0 0 1-.473.257c-.126.026-.423.04-.892.04zM14.88 25v-1.235h-1.234V25h1.234zm-5.018 9.11c.691 0 1.262-.17 1.711-.512.45-.341.772-.864.965-1.567l-1.261-.4c-.109.472-.287.818-.536 1.037-.25.22-.547.33-.892.33-.47 0-.85-.173-1.143-.519-.293-.345-.44-.925-.44-1.74 0-.767.15-1.322.447-1.665.297-.343.684-.514 1.162-.514.346 0 .64.096.881.29.242.193.4.457.477.79l1.288-.307c-.147-.516-.367-.911-.66-1.187-.492-.465-1.132-.698-1.92-.698-.902 0-1.63.296-2.184.89-.554.593-.83 1.426-.83 2.498 0 1.014.275 1.813.825 2.397.551.585 1.254.877 2.11.877zM14.88 34v-1.235h-1.234V34h1.234z"/></svg>',UC='<svg viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg"><path d="M35 29a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17zm0-9a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1H18a1 1 0 0 1-1-1v-1a1 1 0 0 1 1-1h17z" fill-opacity=".163"/><path d="M11.916 15V8.558h-1.301V15h1.3zm2.465 0v-1.235h-1.235V15h1.235zM9.665 25v-6.442h-1.3V25h1.3zm2.5 0v-6.442h-1.3V25h1.3zm2.466 0v-1.235h-1.235V25h1.235zm-7.216 9v-6.442h-1.3V34h1.3zm2.5 0v-6.442h-1.3V34h1.3zm2.501 0v-6.442h-1.3V34h1.3zm2.465 0v-1.235h-1.235V34h1.235z"/></svg>',qC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.68 13.74h-.001l4.209 4.208a1 1 0 1 0 1.414-1.414l-4.267-4.268a6 6 0 1 0-1.355 1.474ZM13 9a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z"/></svg>',ww='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.537 14.813a.888.888 0 1 1-1.254-1.255L10.84 10 7.283 6.442a.888.888 0 1 1 1.254-1.255L12.74 9.39a.888.888 0 0 1-.16 1.382l-4.043 4.042z"/></svg>',su='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM3.5 3v5H2V3.7H1v-1h2.5V3zM.343 17.857l2.59-3.257H2.92a.6.6 0 1 0-1.04 0H.302a2 2 0 1 1 3.995 0h-.001c-.048.405-.16.734-.333.988-.175.254-.59.692-1.244 1.312H4.3v1h-4l.043-.043zM7 14.75a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z"/></svg>',Mr='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M15.003 7v5.5a1 1 0 0 1-1 1H5.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H6.5V12h6.997V7.5z"/></svg>',GC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M18 7v5.5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1zm-1.505.5H3.504V12h12.991V7.5z"/></svg>',ru='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm11.5 9H18v1.5h-4.5zm0-3H18v1.5h-4.5zm0-3H18v1.5h-4.5zM2 15h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',Lr='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2zm0-9h5v1.5H2zm0 3h5v1.5H2zm0 3h5v1.5H2z"/><path d="M18.003 7v5.5a1 1 0 0 1-1 1H8.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H9.5V12h6.997V7.5z"/></svg>',bw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm11.5 9H18v1.5h-4.5zM2 15h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',_w='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M12.003 7v5.5a1 1 0 0 1-1 1H2.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H3.5V12h6.997V7.5z"/></svg>',vw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path opacity=".5" d="M2 3h16v1.5H2zm0 12h16v1.5H2z"/><path d="M18.003 7v5.5a1 1 0 0 1-1 1H8.996a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h8.007a1 1 0 0 1 1 1zm-1.506.5H9.5V12h6.997V7.5z"/></svg>',KC='<svg xmlns="http://www.w3.org/2000/svg" xmlns:v="https://vecta.io/nano" 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-.95H.95zm.55 3.5v-2h2v2h-2zm0 9.3v2h2v-2h-2zm15-11.3v2h2v-2h-2z"/><path d="M8.139 20.004v-2.388l7.045-7.048 2.391 2.391-7.046 7.046h-2.39zm11.421-9.101a.64.64 0 0 1-.138.206l-1.165 1.168-2.391-2.391 1.167-1.163a.63.63 0 0 1 .206-.138.635.635 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.243z"/></svg>',ZC='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.5 17v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zm2 0v1h-1v-1h1zM1 15.5v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm-19-2v1H0v-1h1zm19 0v1h-1v-1h1zm0-2v1h-1v-1h1zm-19 0v1H0v-1h1zM14.5 2v1h-1V2h1zm2 0v1h-1V2h1zm2 0v1h-1V2h1zm-8 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm-2 0v1h-1V2h1zm8 0v1h-1V2h1zm-10 0v1h-1V2h1z"/><path d="M18.095 2H1.905C.853 2 0 2.895 0 4v12c0 1.105.853 2 1.905 2h16.19C19.147 18 20 17.105 20 16V4c0-1.105-.853-2-1.905-2zm0 1.5c.263 0 .476.224.476.5v12c0 .276-.213.5-.476.5H1.905a.489.489 0 0 1-.476-.5V4c0-.276.213-.5.476-.5h16.19z"/></svg>',JC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 16.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1ZM1 15v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 13v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 11v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 9v1H0V9h1Zm19 0v1h-1V9h1ZM1 7v1H0V7h1Zm19 0v1h-1V7h1ZM1 5v1H0V5h1Zm19 0v1h-1V5h1Zm0-2v1h-1V3h1ZM1 3v1H0V3h1Zm13.5-1.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm-8 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm8 0v1h-1v-1h1Zm-10 0v1h-1v-1h1Z"/><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-2ZM13 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 7h11Z"/></svg>',QC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 16.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1ZM1 15v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 13v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 11v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 9v1H0V9h1Zm19 0v1h-1V9h1ZM1 7v1H0V7h1Zm19 0v1h-1V7h1ZM1 5v1H0V5h1Zm19 0v1h-1V5h1Zm0-2v1h-1V3h1ZM1 3v1H0V3h1Zm13.5-1.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm-8 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm8 0v1h-1v-1h1Zm-10 0v1h-1v-1h1Z"/><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-2ZM10 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 9h8Z"/></svg>',YC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 16.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1ZM1 15v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 13v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 11v1H0v-1h1Zm19 0v1h-1v-1h1ZM1 9v1H0V9h1Zm19 0v1h-1V9h1ZM1 7v1H0V7h1Zm19 0v1h-1V7h1ZM1 5v1H0V5h1Zm19 0v1h-1V5h1Zm0-2v1h-1V3h1ZM1 3v1H0V3h1Zm13.5-1.5v1h-1v-1h1Zm2 0v1h-1v-1h1Zm2 0v1h-1v-1h1Zm-8 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm-2 0v1h-1v-1h1Zm8 0v1h-1v-1h1Zm-10 0v1h-1v-1h1Z"/><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-2ZM7 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 11h5Z"/></svg>',bd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 3.75c0 .414.336.75.75.75h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 0 0-.75.75zm5 6c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zM2.75 16.5h14.5a.75.75 0 1 0 0-1.5H2.75a.75.75 0 1 0 0 1.5zm1.618-9.55L.98 9.358a.4.4 0 0 0 .013.661l3.39 2.207A.4.4 0 0 0 5 11.892V7.275a.4.4 0 0 0-.632-.326z"/></svg>',XC='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.598.687h1.5v5h-1.5zm14.5 0h1.5v5h-1.5z"/><path d="M19.598 4.187v1.5h-16v-1.5zm-16 14.569h1.5v-5h-1.5zm14.5 0h1.5v-5h-1.5z"/><path d="M19.598 15.256v-1.5h-16v1.5zM5.081 9h6v2h-6zm8 0h6v2h-6zm-9.483 1L0 12.5v-5z"/></svg>',yw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.5 5.5H7v5h3.5a2.5 2.5 0 1 0 0-5zM5 3h6.5v.025a5 5 0 0 1 0 9.95V13H7v4a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z"/></svg>',kw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m7.3 17.37-.061.088a1.518 1.518 0 0 1-.934.535l-4.178.663-.806-4.153a1.495 1.495 0 0 1 .187-1.058l.056-.086L8.77 2.639c.958-1.351 2.803-1.076 4.296-.03 1.497 1.047 2.387 2.693 1.433 4.055L7.3 17.37zM9.14 4.728l-5.545 8.346 3.277 2.294 5.544-8.346L9.14 4.728zM6.07 16.512l-3.276-2.295.53 2.73 2.746-.435zM9.994 3.506 13.271 5.8c.316-.452-.16-1.333-1.065-1.966-.905-.634-1.895-.78-2.212-.328zM8 18.5 9.375 17H19v1.5H8z"/></svg>',eA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.999 2H15a1 1 0 0 1 0 2h-1.004v13a1 1 0 1 1-2 0V4H8.999v13a1 1 0 1 1-2 0v-7A4 4 0 0 1 3 6a4 4 0 0 1 3.999-4z"/></svg>',tA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a1 1 0 0 0-1 1v6H3a1 1 0 1 0 0 2h6v6a1 1 0 1 0 2 0v-6h6a1 1 0 1 0 0-2h-6V3a1 1 0 0 0-1-1Z"/></svg>',li='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.463 5.187a.888.888 0 1 1 1.254 1.255L9.16 10l3.557 3.557a.888.888 0 1 1-1.254 1.255L7.26 10.61a.888.888 0 0 1 .16-1.382l4.043-4.042z"/></svg>',iA=`<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>
`,nA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 10.423a6.5 6.5 0 0 1 6.056-6.408l.038.67C6.448 5.423 5.354 7.663 5.22 10H9c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003v-4.574zm8 0a6.5 6.5 0 0 1 6.056-6.408l.038.67c-2.646.739-3.74 2.979-3.873 5.315H17c.552 0 .5.432.5.986v4.511c0 .554-.448.503-1 .503h-5c-.552 0-.5-.449-.5-1.003v-4.574z"/></svg>',_d='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m14.958 9.367-2.189 1.837a.75.75 0 0 0 .965 1.149l3.788-3.18a.747.747 0 0 0 .21-.284.75.75 0 0 0-.17-.945L13.77 4.762a.75.75 0 1 0-.964 1.15l2.331 1.955H6.22A.75.75 0 0 0 6 7.9a4 4 0 1 0 1.477 7.718l-.344-1.489A2.5 2.5 0 1 1 6.039 9.4l-.008-.032h8.927z"/></svg>',oA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.69 14.915c.053.052.173.083.36.093a.366.366 0 0 1 .345.485l-.003.01a.738.738 0 0 1-.697.497h-2.67a.374.374 0 0 1-.353-.496l.013-.038a.681.681 0 0 1 .644-.458c.197-.012.325-.043.386-.093a.28.28 0 0 0 .072-.11L9.592 4.5H6.269c-.359-.017-.609.013-.75.09-.142.078-.289.265-.442.563-.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-.486c.001-.284-.054-.464-.167-.54-.112-.076-.367-.106-.766-.091h-3.28l-2.68 10.257c-.006.074.007.127.038.158zM3 17h8a.5.5 0 1 1 0 1H3a.5.5 0 1 1 0-1zm11.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.414-1.414 1.414z"/></svg>',sA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5.2 7h9.2c.6 0 1 .4 1 1v9.9c0 .5-.4 1-1 1H5.2a1 1 0 0 1-1-1V8c0-.6.4-1 1-1Zm1 1.5c-.3 0-.5.2-.5.5v8c0 .3.2.5.5.5h.5c.2 0 .5-.2.5-.5V9c0-.3-.3-.5-.5-.5h-.5Zm3.2 0c-.2 0-.5.2-.5.5v8c0 .3.3.5.5.5h.5c.3 0 .5-.2.5-.5V9c0-.3-.2-.5-.5-.5h-.5Zm3.5 0c-.2 0-.5.2-.5.5v8c0 .3.3.5.5.5h.5c.3 0 .5-.2.5-.5V9c0-.3-.2-.5-.5-.5h-.5Zm-1.4-7.1H8.3L6.5 3.6H3.8c-.5 0-.7.3-.7.8s.2.7.7.7h12c.6 0 .9-.2.9-.7 0-.5-.3-.8-1-.8h-2.4l-1.8-2.2Z"/></svg>',rA='<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>',aA='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M.75 15.5a.75.75 0 0 1 .75.75V18l.008.09A.5.5 0 0 0 2 18.5h1.75a.75.75 0 1 1 0 1.5H1.5l-.144-.007a1.5 1.5 0 0 1-1.35-1.349L0 18.5v-2.25a.75.75 0 0 1 .75-.75zm18.5 0a.75.75 0 0 1 .75.75v2.25l-.007.144a1.5 1.5 0 0 1-1.349 1.35L18.5 20h-2.25a.75.75 0 1 1 0-1.5H18a.5.5 0 0 0 .492-.41L18.5 18v-1.75a.75.75 0 0 1 .75-.75zm-10.45 3c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2h1.6zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2v-1.1c0-.11.09-.2.2-.2h1.6zm.45-5.5a.75.75 0 1 1 0 1.5h-8.5a.75.75 0 1 1 0-1.5h8.5zM1.3 11c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2h1.1zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2v-1.6c0-.11.09-.2.2-.2h1.1zm-4.55-2a.75.75 0 1 1 0 1.5H4.75a.75.75 0 1 1 0-1.5h10.5zM1.3 7c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2H.2a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2h1.1zm18.5 0c.11 0 .2.09.2.2v1.6a.2.2 0 0 1-.2.2h-1.1a.2.2 0 0 1-.2-.2V7.2c0-.11.09-.2.2-.2h1.1zm-4.55-2a.75.75 0 1 1 0 1.5h-2.5a.75.75 0 1 1 0-1.5h2.5zm-5 0a.75.75 0 1 1 0 1.5h-5.5a.75.75 0 0 1 0-1.5h5.5zm-6.5-5a.75.75 0 0 1 0 1.5H2a.5.5 0 0 0-.492.41L1.5 2v1.75a.75.75 0 0 1-1.5 0V1.5l.007-.144A1.5 1.5 0 0 1 1.356.006L1.5 0h2.25zM18.5 0l.144.007a1.5 1.5 0 0 1 1.35 1.349L20 1.5v2.25a.75.75 0 1 1-1.5 0V2l-.008-.09A.5.5 0 0 0 18 1.5h-1.75a.75.75 0 1 1 0-1.5h2.25zM8.8 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2H7.2a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2h1.6zm4 0c.11 0 .2.09.2.2v1.1a.2.2 0 0 1-.2.2h-1.6a.2.2 0 0 1-.2-.2V.2c0-.11.09-.2.2-.2h1.6z"/></svg>',lA=`<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>
`,cA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2.5a7.47 7.47 0 0 1 4.231 1.31 7.268 7.268 0 0 1 2.703 3.454 7.128 7.128 0 0 1 .199 4.353c-.39 1.436-1.475 2.72-2.633 3.677h2.013c0-.226.092-.443.254-.603a.876.876 0 0 1 1.229 0c.163.16.254.377.254.603v.853c0 .209-.078.41-.22.567a.873.873 0 0 1-.547.28l-.101.006h-4.695a.517.517 0 0 1-.516-.518v-1.265c0-.21.128-.398.317-.489a5.601 5.601 0 0 0 2.492-2.371 5.459 5.459 0 0 0 .552-3.693 5.53 5.53 0 0 0-1.955-3.2A5.71 5.71 0 0 0 10 4.206 5.708 5.708 0 0 0 6.419 5.46 5.527 5.527 0 0 0 4.46 8.663a5.457 5.457 0 0 0 .554 3.695 5.6 5.6 0 0 0 2.497 2.37.55.55 0 0 1 .317.49v1.264c0 .286-.23.518-.516.518H2.618a.877.877 0 0 1-.614-.25.845.845 0 0 1-.254-.603v-.853c0-.226.091-.443.254-.603a.876.876 0 0 1 1.228 0c.163.16.255.377.255.603h1.925c-1.158-.958-2.155-2.241-2.545-3.678a7.128 7.128 0 0 1 .199-4.352 7.268 7.268 0 0 1 2.703-3.455A7.475 7.475 0 0 1 10 2.5z"/></svg>',uA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><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-.6zM6.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>',hA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m7.03 10.349 3.818-3.819a.8.8 0 1 1 1.132 1.132L8.16 11.48l3.819 3.818a.8.8 0 1 1-1.132 1.132L7.03 12.61l-3.818 3.82a.8.8 0 1 1-1.132-1.132L5.9 11.48 2.08 7.662A.8.8 0 1 1 3.212 6.53l3.818 3.82zm8.147 7.829h2.549c.254 0 .447.05.58.152a.49.49 0 0 1 .201.413.54.54 0 0 1-.159.393c-.105.108-.266.162-.48.162h-3.594c-.245 0-.435-.066-.572-.197a.621.621 0 0 1-.205-.463c0-.114.044-.265.132-.453a1.62 1.62 0 0 1 .288-.444c.433-.436.824-.81 1.172-1.122.348-.312.597-.517.747-.615.267-.183.49-.368.667-.553.177-.185.312-.375.405-.57.093-.194.139-.384.139-.57a1.008 1.008 0 0 0-.554-.917 1.197 1.197 0 0 0-.56-.133c-.426 0-.761.182-1.005.546a2.332 2.332 0 0 0-.164.39 1.609 1.609 0 0 1-.258.488c-.096.114-.237.17-.423.17a.558.558 0 0 1-.405-.156.568.568 0 0 1-.161-.427c0-.218.05-.446.151-.683.101-.238.252-.453.452-.646s.454-.349.762-.467a2.998 2.998 0 0 1 1.081-.178c.498 0 .923.076 1.274.228a1.916 1.916 0 0 1 1.004 1.032 1.984 1.984 0 0 1-.156 1.794c-.2.32-.405.572-.613.754-.208.182-.558.468-1.048.857-.49.39-.826.691-1.008.906a2.703 2.703 0 0 0-.24.309z"/></svg>',dA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M15.677 8.678h2.549c.254 0 .447.05.58.152a.49.49 0 0 1 .201.413.54.54 0 0 1-.159.393c-.105.108-.266.162-.48.162h-3.594c-.245 0-.435-.066-.572-.197a.621.621 0 0 1-.205-.463c0-.114.044-.265.132-.453a1.62 1.62 0 0 1 .288-.444c.433-.436.824-.81 1.172-1.122.348-.312.597-.517.747-.615.267-.183.49-.368.667-.553.177-.185.312-.375.405-.57.093-.194.139-.384.139-.57a1.008 1.008 0 0 0-.554-.917 1.197 1.197 0 0 0-.56-.133c-.426 0-.761.182-1.005.546a2.332 2.332 0 0 0-.164.39 1.609 1.609 0 0 1-.258.488c-.096.114-.237.17-.423.17a.558.558 0 0 1-.405-.156.568.568 0 0 1-.161-.427c0-.218.05-.446.151-.683.101-.238.252-.453.452-.646s.454-.349.762-.467a2.998 2.998 0 0 1 1.081-.178c.498 0 .923.076 1.274.228a1.916 1.916 0 0 1 1.004 1.032 1.984 1.984 0 0 1-.156 1.794c-.2.32-.405.572-.613.754-.208.182-.558.468-1.048.857-.49.39-.826.691-1.008.906a2.703 2.703 0 0 0-.24.309zM7.03 10.349l3.818-3.819a.8.8 0 1 1 1.132 1.132L8.16 11.48l3.819 3.818a.8.8 0 1 1-1.132 1.132L7.03 12.61l-3.818 3.82a.8.8 0 1 1-1.132-1.132L5.9 11.48 2.08 7.662A.8.8 0 1 1 3.212 6.53l3.818 3.82z"/></svg>',mA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><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 13v5h3.105zM2 12h5V8H2v4zm10-4H8v4h4V8zM2 2v5h5V2H2zm0 16h5v-5H2v5zM13 7h5V2h-5v5zM8 2v5h4V2H8z" 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-.43L15.5 11.5zM13 6a1 1 0 0 1 1 1v3.172a2.047 2.047 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.976 1.976 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm-1 2H8v4h4V8z"/></svg>',fA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M18 7v1H2V7h16zm0 5v1H2v-1h16z" opacity=".6"/><path d="M14 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1zm-2 1H8v4h4V2zm0 6H8v4h4V8zm0 6H8v4h4v-4z"/></svg>',gA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>',pA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 2v5h4V2h1v5h5v1h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5H7v-5H2v-1h5V8H2V7h5V2h1zm4 6H8v4h4V8z" 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-.43L15.5 11.5zM17 1a2 2 0 0 1 2 2v9.475l-.85-.124-.857-1.736a2.048 2.048 0 0 0-.292-.44L17 3H3v14h7.808l.402.392L10.935 19H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h14z"/></svg>',wA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v16h-1V2z" opacity=".6"/><path d="M1 6h18a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1 2v4h4V8H2zm6 0v4h4V8H8zm6 0v4h4V8h-4z"/></svg>',vd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 5.5v3h4v-3H3Zm0 4v3h4v-3H3Zm0 4v3h4v-3H3Zm5 3h4v-3H8v3Zm5 0h4v-3h-4v3Zm4-4v-3h-4v3h4Zm0-4v-3h-4v3h4Zm1.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.5v13.5Zm-6.5-4v-3H8v3h4Zm0-4v-3H8v3h4Z"/></svg>',bA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3.035 1C2.446 1 2 1.54 2 2.098V10.5h1.5v-8h13v8H18V2.098C18 1.539 17.48 1 16.9 1H3.035Zm10.453 2.61a1.885 1.885 0 0 0-1.442.736 1.89 1.89 0 0 0 1.011 2.976 1.903 1.903 0 0 0 2.253-1.114 1.887 1.887 0 0 0-1.822-2.598ZM7.463 8.163a.611.611 0 0 0-.432.154L5.071 10.5h5.119L7.88 8.348a.628.628 0 0 0-.417-.185Zm6.236 1.059a.62.62 0 0 0-.42.164L12.07 10.5h2.969l-.92-1.113a.618.618 0 0 0-.42-.165ZM.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.908.908 0 0 0-.912-.912H.91ZM3.668 13h1.947l2.135 5.7H5.898l-.28-.946H3.601l-.278.945H1.516L3.668 13Zm4.947 0h1.801v4.3h2.7v1.4h-4.5V13h-.001Zm4.5 0h5.4v1.4h-1.798v4.3h-1.701v-4.3h-1.9V13h-.001Zm-8.517 1.457-.614 2.059h1.262l-.648-2.059Z"/></svg>',_A='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.816 11.5 7.038 4.785 4.261 11.5h5.555Zm.62 1.5H3.641l-1.666 4.028H.312l5.789-14h1.875l5.789 14h-1.663L10.436 13Z"/><path d="m12.09 17-.534-1.292.848-1.971.545 1.319L12.113 17h-.023Zm1.142-5.187.545 1.319L15.5 9.13l1.858 4.316h-3.45l.398.965h3.467L18.887 17H20l-3.873-9h-1.254l-1.641 3.813Z"/></svg>',au='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="9.5" cy="4.5" r="1.5"/><circle cx="9.5" cy="10.5" r="1.5"/><circle cx="9.5" cy="16.5" r="1.5"/></svg>',vA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m2.315 14.705 2.224-2.24a.689.689 0 0 1 .963 0 .664.664 0 0 1 0 .949L2.865 16.07a.682.682 0 0 1-.112.089.647.647 0 0 1-.852-.051L.688 14.886a.635.635 0 0 1 0-.903.647.647 0 0 1 .91 0l.717.722zm5.185.045a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75zM2.329 5.745l2.21-2.226a.689.689 0 0 1 .963 0 .664.664 0 0 1 0 .95L2.865 7.125a.685.685 0 0 1-.496.196.644.644 0 0 1-.468-.187L.688 5.912a.635.635 0 0 1 0-.903.647.647 0 0 1 .91 0l.73.736zM7.5 5.75A.75.75 0 0 1 8.25 5h9.5a.75.75 0 1 1 0 1.5h-9.5a.75.75 0 0 1-.75-.75z"/></svg>',yA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><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.8 1.9 0 3.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-4z"/></svg>',yd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m5.042 9.367 2.189 1.837a.75.75 0 0 1-.965 1.149l-3.788-3.18a.747.747 0 0 1-.21-.284.75.75 0 0 1 .17-.945L6.23 4.762a.75.75 0 1 1 .964 1.15L4.863 7.866h8.917A.75.75 0 0 1 14 7.9a4 4 0 1 1-1.477 7.718l.344-1.489a2.5 2.5 0 1 0 1.094-4.73l.008-.032H5.042z"/></svg>',kA='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184zm4.919 10.562-1.414 1.414a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.061-1.06l1.414 1.414 1.414-1.415a.75.75 0 0 1 1.061 1.061l-1.414 1.414 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414z"/></svg>';function lu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var kd,Cd;function Cw(){return Cd||(Cd=1,kd={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),kd}var CA=Cw();const Ad=lu(CA);var xd={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Td(n){var e,t=[],i=1,o;if(typeof n=="string")if(Ad[n])t=Ad[n].slice(),o="rgb";else if(n==="transparent")i=0,o="rgb",t=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(n)){var s=n.slice(1),r=s.length,a=r<=4;i=1,a?(t=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],r===4&&(i=parseInt(s[3]+s[3],16)/255)):(t=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],r===8&&(i=parseInt(s[6]+s[7],16)/255)),t[0]||(t[0]=0),t[1]||(t[1]=0),t[2]||(t[2]=0),o="rgb"}else if(e=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(n)){var l=e[1],c=l==="rgb",s=l.replace(/a$/,"");o=s;var r=s==="cmyk"?4:s==="gray"?1:3;t=e[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(m,f){if(/%$/.test(m))return f===r?parseFloat(m)/100:s==="rgb"?parseFloat(m)*255/100:parseFloat(m);if(s[f]==="h"){if(/deg$/.test(m))return parseFloat(m);if(xd[m]!==void 0)return xd[m]}return parseFloat(m)}),l===s&&t.push(1),i=c||t[r]===void 0?1:t[r],t=t.slice(0,r)}else n.length>10&&/[0-9](?:\s|\/)/.test(n)&&(t=n.match(/([0-9]+)/g).map(function(u){return parseFloat(u)}),o=n.match(/([a-z])/ig).join("").toLowerCase());else isNaN(n)?Array.isArray(n)||n.length?(t=[n[0],n[1],n[2]],o="rgb",i=n.length===4?n[3]:1):n instanceof Object&&(n.r!=null||n.red!=null||n.R!=null?(o="rgb",t=[n.r||n.red||n.R||0,n.g||n.green||n.G||0,n.b||n.blue||n.B||0]):(o="hsl",t=[n.h||n.hue||n.H||0,n.s||n.saturation||n.S||0,n.l||n.lightness||n.L||n.b||n.brightness]),i=n.a||n.alpha||n.opacity||1,n.opacity!=null&&(i/=100)):(o="rgb",t=[n>>>16,(n&65280)>>>8,n&255]);return{space:o,values:t,alpha:i}}var Ua,Ed;function Aw(){if(Ed)return Ua;Ed=1;const n=Cw(),e={};for(const o of Object.keys(n))e[n[o]]=o;const t={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};Ua=t;for(const o of Object.keys(t)){if(!("channels"in t[o]))throw new Error("missing channels property: "+o);if(!("labels"in t[o]))throw new Error("missing channel labels property: "+o);if(t[o].labels.length!==t[o].channels)throw new Error("channel and label counts mismatch: "+o);const{channels:s,labels:r}=t[o];delete t[o].channels,delete t[o].labels,Object.defineProperty(t[o],"channels",{value:s}),Object.defineProperty(t[o],"labels",{value:r})}t.rgb.hsl=function(o){const s=o[0]/255,r=o[1]/255,a=o[2]/255,l=Math.min(s,r,a),c=Math.max(s,r,a),u=c-l;let d,m;c===l?d=0:s===c?d=(r-a)/u:r===c?d=2+(a-s)/u:a===c&&(d=4+(s-r)/u),d=Math.min(d*60,360),d<0&&(d+=360);const f=(l+c)/2;return c===l?m=0:f<=.5?m=u/(c+l):m=u/(2-c-l),[d,m*100,f*100]},t.rgb.hsv=function(o){let s,r,a,l,c;const u=o[0]/255,d=o[1]/255,m=o[2]/255,f=Math.max(u,d,m),g=f-Math.min(u,d,m),p=function(_){return(f-_)/6/g+1/2};return g===0?(l=0,c=0):(c=g/f,s=p(u),r=p(d),a=p(m),u===f?l=a-r:d===f?l=1/3+s-a:m===f&&(l=2/3+r-s),l<0?l+=1:l>1&&(l-=1)),[l*360,c*100,f*100]},t.rgb.hwb=function(o){const s=o[0],r=o[1];let a=o[2];const l=t.rgb.hsl(o)[0],c=1/255*Math.min(s,Math.min(r,a));return a=1-1/255*Math.max(s,Math.max(r,a)),[l,c*100,a*100]},t.rgb.cmyk=function(o){const s=o[0]/255,r=o[1]/255,a=o[2]/255,l=Math.min(1-s,1-r,1-a),c=(1-s-l)/(1-l)||0,u=(1-r-l)/(1-l)||0,d=(1-a-l)/(1-l)||0;return[c*100,u*100,d*100,l*100]};function i(o,s){return(o[0]-s[0])**2+(o[1]-s[1])**2+(o[2]-s[2])**2}return t.rgb.keyword=function(o){const s=e[o];if(s)return s;let r=1/0,a;for(const l of Object.keys(n)){const c=n[l],u=i(o,c);u<r&&(r=u,a=l)}return a},t.keyword.rgb=function(o){return n[o]},t.rgb.xyz=function(o){let s=o[0]/255,r=o[1]/255,a=o[2]/255;s=s>.04045?((s+.055)/1.055)**2.4:s/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92,a=a>.04045?((a+.055)/1.055)**2.4:a/12.92;const l=s*.4124+r*.3576+a*.1805,c=s*.2126+r*.7152+a*.0722,u=s*.0193+r*.1192+a*.9505;return[l*100,c*100,u*100]},t.rgb.lab=function(o){const s=t.rgb.xyz(o);let r=s[0],a=s[1],l=s[2];r/=95.047,a/=100,l/=108.883,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116,l=l>.008856?l**(1/3):7.787*l+16/116;const c=116*a-16,u=500*(r-a),d=200*(a-l);return[c,u,d]},t.hsl.rgb=function(o){const s=o[0]/360,r=o[1]/100,a=o[2]/100;let l,c,u;if(r===0)return u=a*255,[u,u,u];a<.5?l=a*(1+r):l=a+r-a*r;const d=2*a-l,m=[0,0,0];for(let f=0;f<3;f++)c=s+1/3*-(f-1),c<0&&c++,c>1&&c--,6*c<1?u=d+(l-d)*6*c:2*c<1?u=l:3*c<2?u=d+(l-d)*(2/3-c)*6:u=d,m[f]=u*255;return m},t.hsl.hsv=function(o){const s=o[0];let r=o[1]/100,a=o[2]/100,l=r;const c=Math.max(a,.01);a*=2,r*=a<=1?a:2-a,l*=c<=1?c:2-c;const u=(a+r)/2,d=a===0?2*l/(c+l):2*r/(a+r);return[s,d*100,u*100]},t.hsv.rgb=function(o){const s=o[0]/60,r=o[1]/100;let a=o[2]/100;const l=Math.floor(s)%6,c=s-Math.floor(s),u=255*a*(1-r),d=255*a*(1-r*c),m=255*a*(1-r*(1-c));switch(a*=255,l){case 0:return[a,m,u];case 1:return[d,a,u];case 2:return[u,a,m];case 3:return[u,d,a];case 4:return[m,u,a];case 5:return[a,u,d]}},t.hsv.hsl=function(o){const s=o[0],r=o[1]/100,a=o[2]/100,l=Math.max(a,.01);let c,u;u=(2-r)*a;const d=(2-r)*l;return c=r*l,c/=d<=1?d:2-d,c=c||0,u/=2,[s,c*100,u*100]},t.hwb.rgb=function(o){const s=o[0]/360;let r=o[1]/100,a=o[2]/100;const l=r+a;let c;l>1&&(r/=l,a/=l);const u=Math.floor(6*s),d=1-a;c=6*s-u,(u&1)!==0&&(c=1-c);const m=r+c*(d-r);let f,g,p;switch(u){default:case 6:case 0:f=d,g=m,p=r;break;case 1:f=m,g=d,p=r;break;case 2:f=r,g=d,p=m;break;case 3:f=r,g=m,p=d;break;case 4:f=m,g=r,p=d;break;case 5:f=d,g=r,p=m;break}return[f*255,g*255,p*255]},t.cmyk.rgb=function(o){const s=o[0]/100,r=o[1]/100,a=o[2]/100,l=o[3]/100,c=1-Math.min(1,s*(1-l)+l),u=1-Math.min(1,r*(1-l)+l),d=1-Math.min(1,a*(1-l)+l);return[c*255,u*255,d*255]},t.xyz.rgb=function(o){const s=o[0]/100,r=o[1]/100,a=o[2]/100;let l,c,u;return l=s*3.2406+r*-1.5372+a*-.4986,c=s*-.9689+r*1.8758+a*.0415,u=s*.0557+r*-.204+a*1.057,l=l>.0031308?1.055*l**(1/2.4)-.055:l*12.92,c=c>.0031308?1.055*c**(1/2.4)-.055:c*12.92,u=u>.0031308?1.055*u**(1/2.4)-.055:u*12.92,l=Math.min(Math.max(0,l),1),c=Math.min(Math.max(0,c),1),u=Math.min(Math.max(0,u),1),[l*255,c*255,u*255]},t.xyz.lab=function(o){let s=o[0],r=o[1],a=o[2];s/=95.047,r/=100,a/=108.883,s=s>.008856?s**(1/3):7.787*s+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,a=a>.008856?a**(1/3):7.787*a+16/116;const l=116*r-16,c=500*(s-r),u=200*(r-a);return[l,c,u]},t.lab.xyz=function(o){const s=o[0],r=o[1],a=o[2];let l,c,u;c=(s+16)/116,l=r/500+c,u=c-a/200;const d=c**3,m=l**3,f=u**3;return c=d>.008856?d:(c-16/116)/7.787,l=m>.008856?m:(l-16/116)/7.787,u=f>.008856?f:(u-16/116)/7.787,l*=95.047,c*=100,u*=108.883,[l,c,u]},t.lab.lch=function(o){const s=o[0],r=o[1],a=o[2];let l;l=Math.atan2(a,r)*360/2/Math.PI,l<0&&(l+=360);const c=Math.sqrt(r*r+a*a);return[s,c,l]},t.lch.lab=function(o){const s=o[0],r=o[1],a=o[2]/360*2*Math.PI,l=r*Math.cos(a),c=r*Math.sin(a);return[s,l,c]},t.rgb.ansi16=function(o,s=null){const[r,a,l]=o;let c=s===null?t.rgb.hsv(o)[2]:s;if(c=Math.round(c/50),c===0)return 30;let u=30+(Math.round(l/255)<<2|Math.round(a/255)<<1|Math.round(r/255));return c===2&&(u+=60),u},t.hsv.ansi16=function(o){return t.rgb.ansi16(t.hsv.rgb(o),o[2])},t.rgb.ansi256=function(o){const s=o[0],r=o[1],a=o[2];return s===r&&r===a?s<8?16:s>248?231:Math.round((s-8)/247*24)+232:16+36*Math.round(s/255*5)+6*Math.round(r/255*5)+Math.round(a/255*5)},t.ansi16.rgb=function(o){let s=o%10;if(s===0||s===7)return o>50&&(s+=3.5),s=s/10.5*255,[s,s,s];const r=(~~(o>50)+1)*.5,a=(s&1)*r*255,l=(s>>1&1)*r*255,c=(s>>2&1)*r*255;return[a,l,c]},t.ansi256.rgb=function(o){if(o>=232){const c=(o-232)*10+8;return[c,c,c]}o-=16;let s;const r=Math.floor(o/36)/5*255,a=Math.floor((s=o%36)/6)/5*255,l=s%6/5*255;return[r,a,l]},t.rgb.hex=function(o){const s=(((Math.round(o[0])&255)<<16)+((Math.round(o[1])&255)<<8)+(Math.round(o[2])&255)).toString(16).toUpperCase();return"000000".substring(s.length)+s},t.hex.rgb=function(o){const s=o.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!s)return[0,0,0];let r=s[0];s[0].length===3&&(r=r.split("").map(d=>d+d).join(""));const a=parseInt(r,16),l=a>>16&255,c=a>>8&255,u=a&255;return[l,c,u]},t.rgb.hcg=function(o){const s=o[0]/255,r=o[1]/255,a=o[2]/255,l=Math.max(Math.max(s,r),a),c=Math.min(Math.min(s,r),a),u=l-c;let d,m;return u<1?d=c/(1-u):d=0,u<=0?m=0:l===s?m=(r-a)/u%6:l===r?m=2+(a-s)/u:m=4+(s-r)/u,m/=6,m%=1,[m*360,u*100,d*100]},t.hsl.hcg=function(o){const s=o[1]/100,r=o[2]/100,a=r<.5?2*s*r:2*s*(1-r);let l=0;return a<1&&(l=(r-.5*a)/(1-a)),[o[0],a*100,l*100]},t.hsv.hcg=function(o){const s=o[1]/100,r=o[2]/100,a=s*r;let l=0;return a<1&&(l=(r-a)/(1-a)),[o[0],a*100,l*100]},t.hcg.rgb=function(o){const s=o[0]/360,r=o[1]/100,a=o[2]/100;if(r===0)return[a*255,a*255,a*255];const l=[0,0,0],c=s%1*6,u=c%1,d=1-u;let m=0;switch(Math.floor(c)){case 0:l[0]=1,l[1]=u,l[2]=0;break;case 1:l[0]=d,l[1]=1,l[2]=0;break;case 2:l[0]=0,l[1]=1,l[2]=u;break;case 3:l[0]=0,l[1]=d,l[2]=1;break;case 4:l[0]=u,l[1]=0,l[2]=1;break;default:l[0]=1,l[1]=0,l[2]=d}return m=(1-r)*a,[(r*l[0]+m)*255,(r*l[1]+m)*255,(r*l[2]+m)*255]},t.hcg.hsv=function(o){const s=o[1]/100,r=o[2]/100,a=s+r*(1-s);let l=0;return a>0&&(l=s/a),[o[0],l*100,a*100]},t.hcg.hsl=function(o){const s=o[1]/100,r=o[2]/100*(1-s)+.5*s;let a=0;return r>0&&r<.5?a=s/(2*r):r>=.5&&r<1&&(a=s/(2*(1-r))),[o[0],a*100,r*100]},t.hcg.hwb=function(o){const s=o[1]/100,r=o[2]/100,a=s+r*(1-s);return[o[0],(a-s)*100,(1-a)*100]},t.hwb.hcg=function(o){const s=o[1]/100,r=1-o[2]/100,a=r-s;let l=0;return a<1&&(l=(r-a)/(1-a)),[o[0],a*100,l*100]},t.apple.rgb=function(o){return[o[0]/65535*255,o[1]/65535*255,o[2]/65535*255]},t.rgb.apple=function(o){return[o[0]/255*65535,o[1]/255*65535,o[2]/255*65535]},t.gray.rgb=function(o){return[o[0]/100*255,o[0]/100*255,o[0]/100*255]},t.gray.hsl=function(o){return[0,0,o[0]]},t.gray.hsv=t.gray.hsl,t.gray.hwb=function(o){return[0,100,o[0]]},t.gray.cmyk=function(o){return[0,0,0,o[0]]},t.gray.lab=function(o){return[o[0],0,0]},t.gray.hex=function(o){const s=Math.round(o[0]/100*255)&255,r=((s<<16)+(s<<8)+s).toString(16).toUpperCase();return"000000".substring(r.length)+r},t.rgb.gray=function(o){return[(o[0]+o[1]+o[2])/3/255*100]},Ua}var qa,Sd;function AA(){if(Sd)return qa;Sd=1;const n=Aw();function e(){const s={},r=Object.keys(n);for(let a=r.length,l=0;l<a;l++)s[r[l]]={distance:-1,parent:null};return s}function t(s){const r=e(),a=[s];for(r[s].distance=0;a.length;){const l=a.pop(),c=Object.keys(n[l]);for(let u=c.length,d=0;d<u;d++){const m=c[d],f=r[m];f.distance===-1&&(f.distance=r[l].distance+1,f.parent=l,a.unshift(m))}}return r}function i(s,r){return function(a){return r(s(a))}}function o(s,r){const a=[r[s].parent,s];let l=n[r[s].parent][s],c=r[s].parent;for(;r[c].parent;)a.unshift(r[c].parent),l=i(n[r[c].parent][c],l),c=r[c].parent;return l.conversion=a,l}return qa=function(s){const r=t(s),a={},l=Object.keys(r);for(let c=l.length,u=0;u<c;u++){const d=l[u];r[d].parent!==null&&(a[d]=o(d,r))}return a},qa}var Ga,Pd;function xA(){if(Pd)return Ga;Pd=1;const n=Aw(),e=AA(),t={},i=Object.keys(n);function o(r){const a=function(...l){const c=l[0];return c==null?c:(c.length>1&&(l=c),r(l))};return"conversion"in r&&(a.conversion=r.conversion),a}function s(r){const a=function(...l){const c=l[0];if(c==null)return c;c.length>1&&(l=c);const u=r(l);if(typeof u=="object")for(let d=u.length,m=0;m<d;m++)u[m]=Math.round(u[m]);return u};return"conversion"in r&&(a.conversion=r.conversion),a}return i.forEach(r=>{t[r]={},Object.defineProperty(t[r],"channels",{value:n[r].channels}),Object.defineProperty(t[r],"labels",{value:n[r].labels});const a=e(r);Object.keys(a).forEach(l=>{const c=a[l];t[r][l]=s(c),t[r][l].raw=o(c)})}),Ga=t,Ga}var xw=xA();const TA=lu(xw),Tw=U0({__proto__:null,default:TA},[xw]),gs=(n,e=0,t=1)=>n>t?t:n<e?e:n,qe=(n,e=0,t=Math.pow(10,e))=>Math.round(t*n)/t,EA=n=>RA(Jl(n)),Jl=n=>(n[0]==="#"&&(n=n.substring(1)),n.length<6?{r:parseInt(n[0]+n[0],16),g:parseInt(n[1]+n[1],16),b:parseInt(n[2]+n[2],16),a:n.length===4?qe(parseInt(n[3]+n[3],16)/255,2):1}:{r:parseInt(n.substring(0,2),16),g:parseInt(n.substring(2,4),16),b:parseInt(n.substring(4,6),16),a:n.length===8?qe(parseInt(n.substring(6,8),16)/255,2):1}),SA=n=>VA(IA(n)),PA=({h:n,s:e,v:t,a:i})=>{const o=(200-e)*t/100;return{h:qe(n),s:qe(o>0&&o<200?e*t/100/(o<=100?o:200-o)*100:0),l:qe(o/2),a:qe(i,2)}},Ql=n=>{const{h:e,s:t,l:i}=PA(n);return`hsl(${e}, ${t}%, ${i}%)`},IA=({h:n,s:e,v:t,a:i})=>{n=n/360*6,e=e/100,t=t/100;const o=Math.floor(n),s=t*(1-e),r=t*(1-(n-o)*e),a=t*(1-(1-n+o)*e),l=o%6;return{r:qe([t,r,s,s,a,t][l]*255),g:qe([a,t,t,r,s,s][l]*255),b:qe([s,s,a,t,t,r][l]*255),a:qe(i,2)}},Us=n=>{const e=n.toString(16);return e.length<2?"0"+e:e},VA=({r:n,g:e,b:t,a:i})=>{const o=i<1?Us(qe(i*255)):"";return"#"+Us(n)+Us(e)+Us(t)+o},RA=({r:n,g:e,b:t,a:i})=>{const o=Math.max(n,e,t),s=o-Math.min(n,e,t),r=s?o===n?(e-t)/s:o===e?2+(t-n)/s:4+(n-e)/s:0;return{h:qe(60*(r<0?r+6:r)),s:qe(o?s/o*100:0),v:qe(o/255*100),a:i}},Ew=(n,e)=>{if(n===e)return!0;for(const t in n)if(n[t]!==e[t])return!1;return!0},OA=(n,e)=>n.toLowerCase()===e.toLowerCase()?!0:Ew(Jl(n),Jl(e)),Id={},Sw=n=>{let e=Id[n];return e||(e=document.createElement("template"),e.innerHTML=n,Id[n]=e),e},cu=(n,e,t)=>{n.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:t}))};let ro=!1;const Yl=n=>"touches"in n,BA=n=>ro&&!Yl(n)?!1:(ro||(ro=Yl(n)),!0),Vd=(n,e)=>{const t=Yl(e)?e.touches[0]:e,i=n.el.getBoundingClientRect();cu(n.el,"move",n.getMove({x:gs((t.pageX-(i.left+window.pageXOffset))/i.width),y:gs((t.pageY-(i.top+window.pageYOffset))/i.height)}))},MA=(n,e)=>{const t=e.keyCode;t>40||n.xy&&t<37||t<33||(e.preventDefault(),cu(n.el,"move",n.getMove({x:t===39?.01:t===37?-.01:t===34?.05:t===33?-.05:t===35?1:t===36?-1:0,y:t===40?.01:t===38?-.01:0},!0)))};class Pw{constructor(e,t,i,o){const s=Sw(`<div role="slider" tabindex="0" part="${t}" ${i}><div part="${t}-pointer"></div></div>`);e.appendChild(s.content.cloneNode(!0));const r=e.querySelector(`[part=${t}]`);r.addEventListener("mousedown",this),r.addEventListener("touchstart",this),r.addEventListener("keydown",this),this.el=r,this.xy=o,this.nodes=[r.firstChild,r]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(ro?"touchmove":"mousemove",this),t(ro?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!BA(e)||!ro&&e.button!=0)return;this.el.focus(),Vd(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),Vd(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":MA(this,e);break}}style(e){e.forEach((t,i)=>{for(const o in t)this.nodes[i].style.setProperty(o,t[o])})}}class LA extends Pw{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:`${e/360*100}%`,color:Ql({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${qe(e)}`)}getMove(e,t){return{h:t?gs(this.h+e.x*360,0,360):360*e.x}}}class FA extends Pw{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:`${100-e.v}%`,left:`${e.s}%`,color:Ql(e)},{"background-color":Ql({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${qe(e.s)}%, Brightness ${qe(e.v)}%`)}getMove(e,t){return{s:t?gs(this.hsva.s+e.x*100,0,100):e.x*100,v:t?gs(this.hsva.v-e.y*100,0,100):Math.round(100-e.y*100)}}}const NA=':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',DA="[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}",zA="[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}",qs=Symbol("same"),Ka=Symbol("color"),Rd=Symbol("hsva"),Za=Symbol("update"),Od=Symbol("parts"),Bd=Symbol("css"),Md=Symbol("sliders");class HA extends HTMLElement{static get observedAttributes(){return["color"]}get[Bd](){return[NA,DA,zA]}get[Md](){return[FA,LA]}get color(){return this[Ka]}set color(e){if(!this[qs](e)){const t=this.colorModel.toHsva(e);this[Za](t),this[Ka]=e}}constructor(){super();const e=Sw(`<style>${this[Bd].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[Od]=this[Md].map(i=>new i(t))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,i){const o=this.colorModel.fromAttr(i);this[qs](o)||(this.color=o)}handleEvent(e){const t=this[Rd],i={...t,...e.detail};this[Za](i);let o;!Ew(i,t)&&!this[qs](o=this.colorModel.fromHsva(i))&&(this[Ka]=o,cu(this,"color-changed",{value:o}))}[qs](e){return this.color&&this.colorModel.equal(e,this.color)}[Za](e){this[Rd]=e,this[Od].forEach(t=>t.update(e))}}const $A={defaultColor:"#000",toHsva:EA,fromHsva:({h:n,s:e,v:t})=>SA({h:n,s:e,v:t,a:1}),equal:OA,fromAttr:n=>n};class WA extends HA{get colorModel(){return $A}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ie extends _e{constructor(e=[]){super(e,{idProperty:"viewUid"}),h(this,"_parentElement"),this.on("add",(t,i,o)=>{this._renderViewIntoCollectionParent(i,o)}),this.on("remove",(t,i)=>{i.element&&this._parentElement&&i.element.remove()}),this._parentElement=null}destroy(){this.map(e=>e.destroy())}setParent(e){this._parentElement=e;for(const t of this)this._renderViewIntoCollectionParent(t)}delegate(...e){if(!e.length||!jA(e))throw new b("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const o of e)i.delegate(o).to(t);this.on("add",(i,o)=>{for(const s of e)o.delegate(s).to(t)}),this.on("remove",(i,o)=>{for(const s of e)o.stopDelegating(s,t)})}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}remove(e){return super.remove(e)}}function jA(n){return n.every(e=>typeof e=="string")}const UA="http://www.w3.org/1999/xhtml";class qt extends ge(){constructor(e){super(),h(this,"ns"),h(this,"tag"),h(this,"text"),h(this,"attributes"),h(this,"children"),h(this,"eventListeners"),h(this,"_isRendered"),h(this,"_revertData"),Object.assign(this,Fd(Ld(e))),this._isRendered=!1,this._revertData=null}render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData=zd(),this._renderNode({node:e,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new b("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){function*e(t){if(t.children)for(const i of t.children)Fr(i)?yield i:uu(i)&&(yield*e(i))}yield*e(this)}static bind(e,t){return{to(i,o){return new qA({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:o})},if(i,o,s){return new Iw({observable:e,emitter:t,attribute:i,valueIfTrue:o,callback:s})}}}static extend(e,t){if(e._isRendered)throw new b("template-extend-render",[this,e]);Bw(e,Fd(Ld(t)))}_renderNode(e){let t;if(e.node?t=this.tag&&this.text:t=this.tag?this.text:!this.text,t)throw new b("ui-template-wrong-syntax",this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return t||(t=e.node=document.createElementNS(this.ns||UA,this.tag)),this._renderAttributes(e),this._renderElementChildren(e),this._setUpListeners(e),t}_renderText(e){let t=e.node;return t?e.revertData.text=t.textContent:t=e.node=document.createTextNode(""),ur(this.text)?this._bindToObservable({schema:this.text,updater:KA(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,i=e.revertData;for(const o in this.attributes){const s=t.getAttribute(o),r=this.attributes[o];i&&(i.attributes[o]=s);const a=Dd(r)?r[0].ns:null;if(ur(r)){const l=Dd(r)?r[0].value:r;i&&Hd(o)&&l.unshift(s),this._bindToObservable({schema:l,updater:ZA(t,o,a),data:e})}else if(o=="style"&&typeof r[0]!="string")this._renderStyleAttribute(r[0],e);else{i&&s&&Hd(o)&&r.unshift(s);const l=r.map(c=>c&&(c.value||c)).reduce((c,u)=>c.concat(u),[]).reduce(Ow,"");uo(l)||t.setAttributeNS(a,o,l)}}}_renderStyleAttribute(e,t){const i=t.node;for(const o in e){const s=e[o];ur(s)?this._bindToObservable({schema:[s],updater:JA(i,o),data:t}):i.style[o]=s}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,o=e.isApplying;let s=0;for(const r of this.children)if(hu(r)){if(!o){r.setParent(t);for(const a of r)i.appendChild(a.element)}}else if(Fr(r))o||(r.isRendered||r.render(),i.appendChild(r.element));else if(Zi(r))i.appendChild(r);else if(o){const a=e.revertData,l=zd();a.children.push(l),r._renderNode({intoFragment:!1,node:i.childNodes[s++],isApplying:!0,revertData:l})}else i.appendChild(r.render());e.intoFragment&&t.appendChild(i)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const i=this.eventListeners[t].map(o=>{const[s,r]=t.split("@");return o.activateDomEventListener(s,r,e)});e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const o=i.revertData;Vw(e,t,i);const s=e.filter(r=>!uo(r)).filter(r=>r.observable).map(r=>r.activateAttributeListener(e,t,i));o&&o.bindings.push(s)}_revertTemplateFromNode(e,t){for(const o of t.bindings)for(const s of o)s();if(t.text){e.textContent=t.text;return}const i=e;for(const o in t.attributes){const s=t.attributes[o];s===null?i.removeAttribute(o):i.setAttribute(o,s)}for(let o=0;o<t.children.length;++o)this._revertTemplateFromNode(i.childNodes[o],t.children[o])}}class Ss{constructor(e){h(this,"attribute"),h(this,"observable"),h(this,"emitter"),h(this,"callback"),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 o=()=>Vw(e,t,i);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,o),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,o)}}}class qA extends Ss{constructor(e){super(e),h(this,"eventNameOrFunction"),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,i){const o=(s,r)=>{(!t||r.target.matches(t))&&(typeof this.eventNameOrFunction=="function"?this.eventNameOrFunction(r):this.observable.fire(this.eventNameOrFunction,r))};return this.emitter.listenTo(i.node,e,o),()=>{this.emitter.stopListening(i.node,e,o)}}}class Iw extends Ss{constructor(e){super(e),h(this,"valueIfTrue"),this.valueIfTrue=e.valueIfTrue}getValue(e){const t=super.getValue(e);return uo(t)?!1:this.valueIfTrue||!0}}function ur(n){return n?(n.value&&(n=n.value),Array.isArray(n)?n.some(ur):n instanceof Ss):!1}function GA(n,e){return n.map(t=>t instanceof Ss?t.getValue(e):t)}function Vw(n,e,{node:t}){const i=GA(n,t);let o;n.length==1&&n[0]instanceof Iw?o=i[0]:o=i.reduce(Ow,""),uo(o)?e.remove():e.set(o)}function KA(n){return{set(e){n.textContent=e},remove(){n.textContent=""}}}function ZA(n,e,t){return{set(i){n.setAttributeNS(t,e,i)},remove(){n.removeAttributeNS(t,e)}}}function JA(n,e){return{set(t){n.style[e]=t},remove(){n.style[e]=null}}}function Ld(n){return Xr(n,e=>{if(e&&(e instanceof Ss||uu(e)||Fr(e)||hu(e)))return e})}function Fd(n){if(typeof n=="string"?n=XA(n):n.text&&ex(n),n.on&&(n.eventListeners=YA(n.on),delete n.on),!n.text){n.attributes&&QA(n.attributes);const e=[];if(n.children)if(hu(n.children))e.push(n.children);else for(const t of n.children)uu(t)||Fr(t)||Zi(t)?e.push(t):e.push(new qt(t));n.children=e}return n}function QA(n){for(const e in n)n[e].value&&(n[e].value=he(n[e].value)),Rw(n,e)}function YA(n){for(const e in n)Rw(n,e);return n}function XA(n){return{text:[n]}}function ex(n){n.text=he(n.text)}function Rw(n,e){n[e]=he(n[e])}function Ow(n,e){return uo(e)?n:uo(n)?e:`${n} ${e}`}function Nd(n,e){for(const t in e)n[t]?n[t].push(...e[t]):n[t]=e[t]}function Bw(n,e){if(e.attributes&&(n.attributes||(n.attributes={}),Nd(n.attributes,e.attributes)),e.eventListeners&&(n.eventListeners||(n.eventListeners={}),Nd(n.eventListeners,e.eventListeners)),e.text&&n.text.push(...e.text),e.children&&e.children.length){if(n.children.length!=e.children.length)throw new b("ui-template-extend-children-mismatch",n);let t=0;for(const i of e.children)Bw(n.children[t++],i)}}function uo(n){return!n&&n!==0}function Fr(n){return n instanceof A}function uu(n){return n instanceof qt}function hu(n){return n instanceof Ie}function Dd(n){return Et(n[0])&&n[0].ns}function zd(){return{children:[],bindings:[],attributes:{}}}function Hd(n){return n=="class"||n=="style"}class A extends st(ue()){constructor(e){super(),h(this,"element"),h(this,"isRendered"),h(this,"locale"),h(this,"t"),h(this,"template"),h(this,"_viewCollections"),h(this,"_unboundChildren"),h(this,"_bindTemplate"),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new _e,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",(t,i)=>{i.locale=e,i.t=e&&e.t}),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=qt.bind(this,this)}createCollection(e){const t=new Ie(e);return this._viewCollections.add(t),t}registerChild(e){Pt(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){Pt(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new qt(e)}extendTemplate(e){qt.extend(this.template,e)}render(){if(this.isRendered)throw new b("ui-view-render-already-rendered",this);this.template&&(this.element=this.template.render(),this.registerChild(this.template.getViews())),this.isRendered=!0}destroy(){this.stopListening(),this._viewCollections.map(e=>e.destroy()),this.template&&this.template._revertData&&this.template.revert(this.element)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function $t({emitter:n,activator:e,callback:t,contextElements:i,listenerOptions:o}){n.listenTo(document,"mousedown",(s,r)=>{if(!e())return;const a=typeof r.composedPath=="function"?r.composedPath():[],l=typeof i=="function"?i():i;for(const c of l)if(c.contains(r.target)||a.includes(c))return;t()},o)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ho(n){class e extends n{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...i){super(...i),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ri({view:n}){n.listenTo(n.element,"submit",(e,t)=>{t.preventDefault(),n.fire("submit")},{useCapture:!0})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function vo({keystrokeHandler:n,focusTracker:e,gridItems:t,numberOfColumns:i,uiLanguageDirection:o}){const s=typeof i=="number"?()=>i:i;n.set("arrowright",r((c,u)=>o==="rtl"?l(c,u.length):a(c,u.length))),n.set("arrowleft",r((c,u)=>o==="rtl"?a(c,u.length):l(c,u.length))),n.set("arrowup",r((c,u)=>{let d=c-s();return d<0&&(d=c+s()*Math.floor(u.length/s()),d>u.length-1&&(d-=s())),d})),n.set("arrowdown",r((c,u)=>{let d=c+s();return d>u.length-1&&(d=c%s()),d}));function r(c){return u=>{const d=t.find(g=>g.element===e.focusedElement),m=t.getIndex(d),f=c(m,t);t.get(f).focus(),u.stopPropagation(),u.preventDefault()}}function a(c,u){return c===u-1?0:c+1}function l(c,u){return c===0?u-1:c-1}}const Mw=class Lw extends A{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.set("isVisible",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon",e.if("isVisible","ck-hidden",t=>!t),"ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox"),"aria-hidden":!0}})}render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",()=>{this._updateXMLContent(),this._colorFillPaths()}),this.on("change:fillColor",()=>{this._colorFillPaths()})}_updateXMLContent(){if(this.content){const e=new DOMParser().parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg");if(!e)throw new b("ui-iconview-invalid-svg",this);const t=e.getAttribute("viewBox");t&&(this.viewBox=t);for(const{name:i,value:o}of Array.from(e.attributes))Lw.presentationalAttributeNames.includes(i)&&this.element.setAttribute(i,o);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;e.childNodes.length>0;)this.element.appendChild(e.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach(e=>{e.style.fill=this.fillColor})}};h(Mw,"presentationalAttributeNames",["alignment-baseline","baseline-shift","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-rendering","cursor","direction","display","dominant-baseline","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-overflow","text-rendering","transform","unicode-bidi","vector-effect","visibility","white-space","word-spacing","writing-mode"]);let hi=Mw;class Fw extends A{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:e.to("style"),id:e.to("id")},children:[{text:e.to("text")}]})}}class P extends A{constructor(e,t=new Fw){super(e),h(this,"children"),h(this,"labelView"),h(this,"iconView"),h(this,"keystrokeView"),h(this,"_focusDelayed",null);const i=this.bindTemplate,o=ze();this.set("_ariaPressed",!1),this.set("_ariaChecked",!1),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${o}`),this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke",void 0),this.set("label",void 0),this.set("role",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.labelView=this._setupLabelView(t),this.iconView=new hi,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.iconView.bind("content").to(this,"icon"),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const s={tag:"button",attributes:{class:["ck","ck-button",i.to("class"),i.if("isEnabled","ck-disabled",r=>!r),i.if("isVisible","ck-hidden",r=>!r),i.to("isOn",r=>r?"ck-on":"ck-off"),i.if("withText","ck-button_with-text"),i.if("withKeystroke","ck-button_with-keystroke")],role:i.to("role"),type:i.to("type",r=>r||"button"),tabindex:i.to("tabindex"),"aria-checked":i.to("_ariaChecked"),"aria-pressed":i.to("_ariaPressed"),"aria-label":i.to("ariaLabel"),"aria-labelledby":i.to("ariaLabelledBy"),"aria-disabled":i.if("isEnabled",!0,r=>!r),"data-cke-tooltip-text":i.to("_tooltipString"),"data-cke-tooltip-position":i.to("tooltipPosition")},children:this.children,on:{click:i.to(r=>{this.isEnabled?this.fire("execute"):r.preventDefault()})}};this.bind("_ariaPressed").to(this,"isOn",this,"isToggleable",this,"role",(r,a,l)=>!a||$d(l)?!1:String(!!r)),this.bind("_ariaChecked").to(this,"isOn",this,"isToggleable",this,"role",(r,a,l)=>!a||!$d(l)?!1:String(!!r)),N.isSafari&&(this._focusDelayed||(this._focusDelayed=$c(()=>this.focus(),0)),s.on.mousedown=i.to(()=>{this._focusDelayed()}),s.on.mouseup=i.to(()=>{this._focusDelayed.cancel()})),this.setTemplate(s)}render(){super.render(),this.icon&&this.children.add(this.iconView),this.on("change:icon",(e,t,i,o)=>{i&&!o?this.children.add(this.iconView,0):!i&&o&&this.children.remove(this.iconView)}),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}destroy(){this._focusDelayed&&this._focusDelayed.cancel(),super.destroy()}_setupLabelView(e){return e.bind("text","style","id").to(this,"label","labelStyle","ariaLabelledBy"),e}_createKeystrokeView(){const e=new A;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",t=>ph(t))}]}),e}_getTooltipString(e,t,i){return e?typeof e=="string"?e:(i&&(i=ph(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}function $d(n){switch(n){case"radio":case"checkbox":case"option":case"switch":case"menuitemcheckbox":case"menuitemradio":return!0;default:return!1}}class Jt extends A{constructor(e,t={}){super(e),h(this,"children"),h(this,"iconView");const i=this.bindTemplate;this.set("label",t.label||""),this.set("class",t.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",i.to("class")]},children:this.children}),t.icon&&(this.iconView=new hi,this.iconView.content=t.icon,this.children.add(this.iconView));const o=new A(e);o.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"],role:"presentation"},children:[{text:i.to("label")}]}),this.children.add(o)}}class Ae extends ge(){constructor(e){if(super(),h(this,"focusables"),h(this,"focusTracker"),h(this,"keystrokeHandler"),h(this,"actions"),this.focusables=e.focusables,this.focusTracker=e.focusTracker,this.keystrokeHandler=e.keystrokeHandler,this.actions=e.actions,e.actions&&e.keystrokeHandler)for(const t in e.actions){let i=e.actions[t];typeof i=="string"&&(i=[i]);for(const o of i)e.keystrokeHandler.set(o,(s,r)=>{this[t](),r()},e.keystrokeHandlerOptions)}this.on("forwardCycle",()=>this.focusFirst(),{priority:"low"}),this.on("backwardCycle",()=>this.focusLast(),{priority:"low"})}get first(){return this.focusables.find(Ja)||null}get last(){return this.focusables.filter(Ja).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-1)}get current(){let e=null;return this.focusTracker.focusedElement===null?null:(this.focusables.find((t,i)=>{const o=t.element===this.focusTracker.focusedElement;return o&&(e=i),o}),e)}focusFirst(){this._focus(this.first,1)}focusLast(){this._focus(this.last,-1)}focusNext(){const e=this.next;if(e&&this.focusables.getIndex(e)===this.current){this.fire("forwardCycle");return}e===this.first?this.fire("forwardCycle"):this._focus(e,1)}focusPrevious(){const e=this.previous;if(e&&this.focusables.getIndex(e)===this.current){this.fire("backwardCycle");return}e===this.last?this.fire("backwardCycle"):this._focus(e,-1)}chain(e){const t=()=>this.current===null?null:this.focusables.get(this.current);this.listenTo(e,"forwardCycle",i=>{const o=t();this.focusNext(),o!==t()&&i.stop()},{priority:"low"}),this.listenTo(e,"backwardCycle",i=>{const o=t();this.focusPrevious(),o!==t()&&i.stop()},{priority:"low"})}unchain(e){this.stopListening(e)}_focus(e,t){e&&this.focusTracker.focusedElement!==e.element&&e.focus(t)}_getDomFocusableItem(e){const t=this.focusables.length;if(!t)return null;const i=this.current;if(i===null)return this[e===1?"first":"last"];let o=this.focusables.get(i),s=(i+t+e)%t;do{const r=this.focusables.get(s);if(Ja(r)){o=r;break}s=(s+t+e)%t}while(s!==i);return o}}function Ja(n){return yo(n)&&Gt(n.element)}function yo(n){return"focus"in n&&typeof n.focus=="function"}function Nw(n){return yo(n)&&"focusCycler"in n&&n.focusCycler instanceof Ae}function tx(n){class e extends n{constructor(...i){super(...i),h(this,"_onDragBound",this._onDrag.bind(this)),h(this,"_onDragEndBound",this._onDragEnd.bind(this)),h(this,"_lastDraggingCoordinates",{x:0,y:0}),this.on("render",()=>{this._attachListeners()}),this.set("isDragging",!1)}_attachListeners(){this.listenTo(this.element,"mousedown",this._onDragStart.bind(this)),this.listenTo(this.element,"touchstart",this._onDragStart.bind(this))}_attachDragListeners(){this.listenTo(I.document,"mouseup",this._onDragEndBound),this.listenTo(I.document,"touchend",this._onDragEndBound),this.listenTo(I.document,"mousemove",this._onDragBound),this.listenTo(I.document,"touchmove",this._onDragBound)}_detachDragListeners(){this.stopListening(I.document,"mouseup",this._onDragEndBound),this.stopListening(I.document,"touchend",this._onDragEndBound),this.stopListening(I.document,"mousemove",this._onDragBound),this.stopListening(I.document,"touchmove",this._onDragBound)}_onDragStart(i,o){if(!this._isHandleElementPressed(o))return;this._attachDragListeners();let s=0,r=0;o instanceof MouseEvent?(s=o.clientX,r=o.clientY):(s=o.touches[0].clientX,r=o.touches[0].clientY),this._lastDraggingCoordinates={x:s,y:r},this.isDragging=!0}_onDrag(i,o){if(!this.isDragging){this._detachDragListeners();return}let s=0,r=0;o instanceof MouseEvent?(s=o.clientX,r=o.clientY):(s=o.touches[0].clientX,r=o.touches[0].clientY),o.preventDefault(),this.fire("drag",{deltaX:Math.round(s-this._lastDraggingCoordinates.x),deltaY:Math.round(r-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:s,y:r}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(i){return this.dragHandleElement?this.dragHandleElement===i.target||i.target instanceof HTMLElement&&this.dragHandleElement.contains(i.target):!1}}return e}class ix extends A{constructor(e){super(e),h(this,"children"),h(this,"keystrokes"),h(this,"focusCycler"),h(this,"_focusTracker"),h(this,"_focusables"),this.children=this.createCollection(),this.keystrokes=new te,this._focusTracker=new ee,this._focusables=new Ie,this.focusCycler=new Ae({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__actions"]},children:this.children})}render(){super.render(),this.keystrokes.listenTo(this.element)}setButtons(e){for(const t of e){const i=new P(this.locale);let o;i.on("execute",()=>t.onExecute()),t.onCreate&&t.onCreate(i);for(o in t)o!="onExecute"&&o!="onCreate"&&i.set(o,t[o]);this.children.add(i)}this._updateFocusCyclableItems()}focus(e){e===-1?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}}class nx extends A{constructor(e){super(e),h(this,"children"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__content"]},children:this.children})}reset(){for(;this.children.length;)this.children.remove(0)}}const vt={SCREEN_CENTER:"screen-center",EDITOR_CENTER:"editor-center",EDITOR_TOP_SIDE:"editor-top-side",EDITOR_TOP_CENTER:"editor-top-center",EDITOR_BOTTOM_CENTER:"editor-bottom-center",EDITOR_ABOVE_CENTER:"editor-above-center",EDITOR_BELOW_CENTER:"editor-below-center"},Wd=Vi("px"),Dw=class zw extends tx(A){constructor(e,{getCurrentDomRoot:t,getViewportOffset:i,keystrokeHandlerOptions:o}){super(e),h(this,"parts"),h(this,"headerView"),h(this,"closeButtonView"),h(this,"actionsView"),h(this,"contentView"),h(this,"keystrokes"),h(this,"focusTracker"),h(this,"wasMoved",!1),h(this,"_getCurrentDomRoot"),h(this,"_getViewportOffset"),h(this,"_focusables"),h(this,"_focusCycler");const s=this.bindTemplate,r=e.t;this.set("className",""),this.set("ariaLabel",r("Editor dialog")),this.set("isModal",!1),this.set("position",vt.SCREEN_CENTER),this.set("_isVisible",!1),this.set("_isTransparent",!1),this.set("_top",0),this.set("_left",0),this._getCurrentDomRoot=t,this._getViewportOffset=i,this.decorate("moveTo"),this.parts=this.createCollection(),this.keystrokes=new te,this.focusTracker=new ee,this._focusables=new Ie,this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"},keystrokeHandlerOptions:o}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog-overlay",s.if("isModal","ck-dialog-overlay__transparent",a=>!a),s.if("_isVisible","ck-hidden",a=>!a)],tabindex:"-1"},children:[{tag:"div",attributes:{tabindex:"-1",class:["ck","ck-dialog",s.if("isModal","ck-dialog_modal"),s.to("className")],role:"dialog","aria-label":s.to("ariaLabel"),style:{top:s.to("_top",a=>Wd(a)),left:s.to("_left",a=>Wd(a)),visibility:s.if("_isTransparent","hidden")}},children:this.parts}]})}render(){super.render(),this.keystrokes.set("Esc",(e,t)=>{e.defaultPrevented||(this.fire("close",{source:"escKeyPress"}),t())}),this.on("drag",(e,{deltaX:t,deltaY:i})=>{this.wasMoved=!0,this.moveBy(t,i)}),this.listenTo(I.window,"resize",()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.listenTo(I.document,"scroll",()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()}),this.on("change:_isVisible",(e,t,i)=>{i&&(this._isTransparent=!0,setTimeout(()=>{this.updatePosition(),this._isTransparent=!1,this.focus()},10))}),this.keystrokes.listenTo(this.element)}get dragHandleElement(){return this.headerView&&!this.isModal?this.headerView.element:null}setupParts({icon:e,title:t,hasCloseButton:i=!0,content:o,actionButtons:s}){t&&(this.headerView=new Jt(this.locale,{icon:e}),i&&(this.closeButtonView=this._createCloseButton(),this.headerView.children.add(this.closeButtonView)),this.headerView.label=t,this.ariaLabel=t,this.parts.add(this.headerView,0)),o&&(o instanceof A&&(o=[o]),this.contentView=new nx(this.locale),this.contentView.children.addMany(o),this.parts.add(this.contentView)),s&&(this.actionsView=new ix(this.locale),this.actionsView.setButtons(s),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(e,t){const i=this._getViewportRect(),o=this._getDialogRect();e+o.width>i.right&&(e=i.right-o.width),e<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=this.position,i;this._getCurrentDomRoot()?i=this._getVisibleDomRootRect(e):t=vt.SCREEN_CENTER;const o=zw.defaultOffset,s=this._getDialogRect();switch(t){case vt.EDITOR_TOP_SIDE:{if(i){const r=this.locale.contentLanguageDirection==="ltr"?i.right-s.width-o:i.left+o;this.moveTo(r,i.top+o)}else this._moveOffScreen();break}case vt.EDITOR_CENTER:{i?this.moveTo(Math.round(i.left+i.width/2-s.width/2),Math.round(i.top+i.height/2-s.height/2)):this._moveOffScreen();break}case vt.SCREEN_CENTER:{this.moveTo(Math.round((e.width-s.width)/2),Math.round((e.height-s.height)/2));break}case vt.EDITOR_TOP_CENTER:{i?this.moveTo(Math.round(i.left+i.width/2-s.width/2),i.top+o):this._moveOffScreen();break}case vt.EDITOR_BOTTOM_CENTER:{i?this.moveTo(Math.round(i.left+i.width/2-s.width/2),i.bottom-s.height-o):this._moveOffScreen();break}case vt.EDITOR_ABOVE_CENTER:{i?this.moveTo(Math.round(i.left+i.width/2-s.width/2),i.top-s.height-o):this._moveOffScreen();break}case vt.EDITOR_BELOW_CENTER:{i?this.moveTo(Math.round(i.left+i.width/2-s.width/2),i.bottom+o):this._moveOffScreen();break}}}_getVisibleDomRootRect(e){let t=new z(this._getCurrentDomRoot()).getVisible();if(t){if(t=e.getIntersection(t),!t)return null}else return null;return t}_getDialogRect(){return new z(this.element.firstElementChild)}_getViewportRect(){const e=new z(I.window);if(this.isModal)return e;const t={top:0,bottom:0,left:0,right:0,...this._getViewportOffset()};return e.top+=t.top,e.height-=t.top,e.bottom-=t.bottom,e.height-=t.bottom,e.left+=t.left,e.right-=t.right,e.width-=t.left+t.right,e}_updateFocusCyclableItems(){const e=[];if(this.contentView)for(const t of this.contentView.children)yo(t)&&e.push(t);this.actionsView&&e.push(this.actionsView),this.closeButtonView&&e.push(this.closeButtonView),e.forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element),Nw(t)&&this._focusCycler.chain(t.focusCycler)})}_createCloseButton(){const e=new P(this.locale),t=this.locale.t;return e.set({label:t("Close"),tooltip:!0,icon:_o}),e.on("execute",()=>this.fire("close",{source:"closeButton"})),e}};h(Dw,"defaultOffset",15);let ox=Dw;const Hw=class wi extends w{constructor(e){super(e),h(this,"view"),h(this,"_onHide");const t=e.t;this._initShowHideListeners(),this._initFocusToggler(),this._initMultiRootIntegration(),this.set({id:null,isOpen:!1}),e.accessibility.addKeystrokeInfos({categoryId:"navigation",keystrokes:[{label:t("Move focus in and out of an active dialog window"),keystroke:"Ctrl+F6",mayRequireFn:!0}]})}static get pluginName(){return"Dialog"}static get isOfficialPlugin(){return!0}destroy(){super.destroy(),wi._visibleDialogPlugin===this&&this._unlockBodyScroll()}_initShowHideListeners(){this.on("show",(e,t)=>{this._show(t)}),this.on("show",(e,t)=>{t.onShow&&t.onShow(this)},{priority:"low"}),this.on("hide",()=>{wi._visibleDialogPlugin&&wi._visibleDialogPlugin._hide()}),this.on("hide",()=>{this._onHide&&(this._onHide(this),this._onHide=void 0)},{priority:"low"})}_initFocusToggler(){const e=this.editor;e.keystrokes.set("Ctrl+F6",(t,i)=>{!this.isOpen||this.view.isModal||(this.view.focusTracker.isFocused?e.editing.view.focus():this.view.focus(),i())})}_initMultiRootIntegration(){const e=this.editor.model;e.document.on("change:data",()=>{if(!this.view)return;const t=e.document.differ.getChangedRoots();for(const i of t)i.state&&this.view.updatePosition()})}show(e){this.hide(),this.fire(`show:${e.id}`,e)}_show({id:e,icon:t,title:i,hasCloseButton:o=!0,content:s,actionButtons:r,className:a,isModal:l,position:c,onHide:u,keystrokeHandlerOptions:d}){const m=this.editor;this.view=new ox(m.locale,{getCurrentDomRoot:()=>m.editing.view.getDomRoot(m.model.document.selection.anchor.root.rootName),getViewportOffset:()=>m.ui.viewportOffset,keystrokeHandlerOptions:d});const f=this.view;f.on("close",()=>{this.hide()}),m.ui.view.body.add(f),m.keystrokes.listenTo(f.element),c||(c=l?vt.SCREEN_CENTER:vt.EDITOR_CENTER),l&&this._lockBodyScroll(),f.set({position:c,_isVisible:!0,className:a,isModal:l}),f.setupParts({icon:t,title:i,hasCloseButton:o,content:s,actionButtons:r}),this.id=e,u&&(this._onHide=u),this.isOpen=!0,wi._visibleDialogPlugin=this}hide(){wi._visibleDialogPlugin&&wi._visibleDialogPlugin.fire(`hide:${wi._visibleDialogPlugin.id}`)}_hide(){if(!this.view)return;const e=this.editor,t=this.view;t.isModal&&this._unlockBodyScroll(),t.contentView&&t.contentView.reset(),e.ui.view.body.remove(t),e.ui.focusTracker.remove(t.element),e.keystrokes.stopListening(t.element),t.destroy(),e.editing.view.focus(),this.id=null,this.isOpen=!1,wi._visibleDialogPlugin=null}_lockBodyScroll(){document.documentElement.classList.add("ck-dialog-scroll-locked")}_unlockBodyScroll(){document.documentElement.classList.remove("ck-dialog-scroll-locked")}};h(Hw,"_visibleDialogPlugin");let du=Hw;class ko extends P{constructor(e,t=new Fw){super(e,t),h(this,"_checkIconHolderView",new sx),this.set({hasCheckSpace:!1,_hasCheck:this.isToggleable});const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-list-item-button",i.if("isToggleable","ck-list-item-button_toggleable")]}}),this.bind("_hasCheck").to(this,"hasCheckSpace",this,"isToggleable",(o,s)=>o||s)}render(){super.render(),this._hasCheck&&this.children.add(this._checkIconHolderView,0),this._watchCheckIconHolderMount()}_watchCheckIconHolderMount(){this._checkIconHolderView.bind("isOn").to(this,"isOn",e=>this.isToggleable&&e),this.on("change:_hasCheck",(e,t,i)=>{const{children:o,_checkIconHolderView:s}=this;i?o.add(s,0):o.remove(s)})}}class sx extends A{constructor(){super(),h(this,"children"),h(this,"_checkIconView",this._createCheckIconView());const e=this.bindTemplate;this.children=this.createCollection(),this.set("isOn",!1),this.setTemplate({tag:"span",children:this.children,attributes:{class:["ck","ck-list-item-button__check-holder",e.to("isOn",t=>t?"ck-on":"ck-off")]}})}render(){super.render(),this.isOn&&this.children.add(this._checkIconView,0),this._watchCheckIconMount()}_watchCheckIconMount(){this.on("change:isOn",(e,t,i)=>{const{children:o,_checkIconView:s}=this;i&&!o.has(s)?o.add(s):!i&&o.has(s)&&o.remove(s)})}_createCheckIconView(){const e=new hi;return e.content=Es,e.extendTemplate({attributes:{class:"ck-list-item-button__check-icon"}}),e}}class ve extends ko{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}class xt extends A{constructor(e){super(e),h(this,"id"),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${ze()}`;const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}const $w=class ei extends Ie{constructor(e,t=[]){super(t),h(this,"locale"),h(this,"_bodyCollectionContainer"),this.locale=e}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new qt({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection,role:"application"},children:this}).render(),(!ei._bodyWrapper||!ei._bodyWrapper.isConnected)&&(ei._bodyWrapper=Ll(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(ei._bodyWrapper)),ei._bodyWrapper.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove(),ei._bodyWrapper&&!ei._bodyWrapper.childElementCount&&(ei._bodyWrapper.remove(),delete ei._bodyWrapper)}};h($w,"_bodyWrapper");let rx=$w;class Ji extends P{constructor(e){super(e),h(this,"toggleSwitchView"),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new A;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}class jd extends Ww(P){}class ax extends Ww(ko){}function Ww(n){class e extends n{constructor(...i){super(...i),h(this,"buttonView"),h(this,"_fileInputView"),this.buttonView=this,this._fileInputView=new lx(this.locale),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.on("execute",()=>{this._fileInputView.open()}),this.extendTemplate({attributes:{class:"ck-file-dialog-button"}})}render(){super.render(),this.children.add(this._fileInputView)}}return e}class lx extends A{constructor(e){super(e),this.set("acceptedType",void 0),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to(()=>{var i,o;(o=(i=this.element)==null?void 0:i.files)!=null&&o.length&&this.fire("done",this.element.files),this.element.value=""})}})}open(){this.element.click()}}class mu extends A{constructor(e,t){super(e),h(this,"buttonView"),h(this,"children");const i=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid",void 0),t&&this.children.addMany(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",i.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:i.if("isCollapsed","hidden"),"aria-labelledby":i.to("_collapsibleAriaLabelUid")},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}focus(){this.buttonView.focus()}_createButtonView(){const e=new P(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:da}),e.extendTemplate({attributes:{"aria-expanded":t.to("isOn",i=>String(i))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",i=>!i),e.on("execute",()=>{this.isCollapsed=!this.isCollapsed}),e}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ps(n,e){const t=n.t,i={Black:t("Black"),"Dim grey":t("Dim grey"),Grey:t("Grey"),"Light grey":t("Light grey"),White:t("White"),Red:t("Red"),Orange:t("Orange"),Yellow:t("Yellow"),"Light green":t("Light green"),Green:t("Green"),Aquamarine:t("Aquamarine"),Turquoise:t("Turquoise"),"Light blue":t("Light blue"),Blue:t("Blue"),Purple:t("Purple")};return e.map(o=>{const s=i[o.label];return s&&s!=o.label&&(o.label=s),o})}function ws(n){return n.map(cx).filter(e=>!!e)}function cx(n){return typeof n=="string"?{model:n,label:n,hasBorder:!1,view:{name:"span",styles:{color:n}}}:{model:n.color,label:n.label||n.color,hasBorder:n.hasBorder===void 0?!1:n.hasBorder,view:{name:"span",styles:{color:`${n.color}`}}}}class jw extends P{constructor(e){super(e);const t=this.bindTemplate;this.set("color",void 0),this.set("hasBorder",!1),this.icon=bC,this.extendTemplate({attributes:{style:{backgroundColor:t.to("color",i=>N.isMediaForcedColors?null:i)},class:["ck","ck-color-grid__tile",t.if("hasBorder","ck-color-selector__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}class Ud extends A{constructor(e,t){super(e),h(this,"columns"),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes");const i=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t?.columns||5;const o={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this.items.on("add",(s,r)=>{r.isOn=r.color===this.selectedColor}),i.forEach(s=>{const r=new jw;r.set({color:s.color,label:s.label,tooltip:!0,hasBorder:s.options.hasBorder}),r.on("execute",()=>{this.fire("execute",{value:s.color,hasBorder:s.options.hasBorder,label:s.label})}),this.items.add(r)}),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:o}}),this.on("change:selectedColor",(s,r,a)=>{for(const l of this.items)l.isOn=l.color===a})}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){var e;super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",(t,i)=>{this.focusTracker.add(i.element)}),this.items.on("remove",(t,i)=>{this.focusTracker.remove(i.element)}),this.keystrokes.listenTo(this.element),vo({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:(e=this.locale)==null?void 0:e.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Uw(n,e){if(!n)return"";const t=qw(n);if(!t)return"";if(t.space===e)return n;if(!mx(t))return"";const i=Tw[t.space][e];if(!i)return"";const o=i(t.space==="hex"?t.hexValue:t.values);return dx(o,e)}function ux(n){if(!n)return"";const e=qw(n);return e?e.space==="hex"?e.hexValue:Uw(n,"hex"):"#000"}function hx(n,e){customElements.get(n)===void 0&&customElements.define(n,e)}function dx(n,e){switch(e){case"hex":return`#${n}`;case"rgb":return`rgb(${n[0]}, ${n[1]}, ${n[2]})`;case"hsl":return`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`;case"hwb":return`hwb(${n[0]}, ${n[1]}, ${n[2]})`;case"lab":return`lab(${n[0]}% ${n[1]} ${n[2]})`;case"lch":return`lch(${n[0]}% ${n[1]} ${n[2]})`;default:return""}}function qw(n){if(n.startsWith("#")){const t=Td(n);return{space:"hex",values:t.values,hexValue:n,alpha:t.alpha}}const e=Td(n);return e.space?e:null}function mx(n){return Object.keys(Tw).includes(n.space)}class Te extends A{constructor(e,t){super(e),h(this,"fieldView"),h(this,"labelView"),h(this,"statusView"),h(this,"fieldWrapperChildren");const i=`ck-labeled-field-view-${ze()}`,o=`ck-labeled-field-view-status-${ze()}`;this.fieldView=t(this,i,o),this.set("label",void 0),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class",void 0),this.set("placeholder",void 0),this.labelView=this._createLabelView(i),this.statusView=this._createStatusView(o),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",(r,a)=>r||a);const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",s.to("class"),s.if("isEnabled","ck-disabled",r=>!r),s.if("isEmpty","ck-labeled-field-view_empty"),s.if("isFocused","ck-labeled-field-view_focused"),s.if("placeholder","ck-labeled-field-view_placeholder"),s.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:this.fieldWrapperChildren},this.statusView]})}_createLabelView(e){const t=new xt(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new A(this.locale),i=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",i.if("errorText","ck-labeled-field-view__status_error"),i.if("_statusText","ck-hidden",o=>!o)],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}focus(e){this.fieldView.focus(e)}}class Gw extends A{constructor(e){super(e),h(this,"focusTracker"),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("tabIndex",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.set("ariaLabel",void 0),this.focusTracker=new ee,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),tabindex:t.to("tabIndex"),readonly:t.to("isReadOnly"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById"),"aria-label":t.to("ariaLabel")},on:{input:t.to((...i)=>{this.fire("input",...i),this._updateIsEmpty()}),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",(e,t,i)=>{this._setDomElementValue(i),this._updateIsEmpty()})}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}reset(){this.value=this.element.value="",this._updateIsEmpty()}_updateIsEmpty(){this.isEmpty=fx(this.element)}_setDomElementValue(e){this.element.value=!e&&e!==0?"":e}}function fx(n){return!n.value}class Kw extends Gw{constructor(e){super(e),this.set("inputMode","text");const t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to("inputMode")}})}}class Zw extends Kw{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class gx extends Kw{constructor(e,{min:t,max:i,step:o}={}){super(e);const s=this.bindTemplate;this.set("min",t),this.set("max",i),this.set("step",o),this.extendTemplate({attributes:{type:"number",class:["ck-input-number"],min:s.to("min"),max:s.to("max"),step:s.to("step")}})}}class px extends Gw{constructor(e){super(e),h(this,"_resizeObserver"),h(this,"_isUpdateAutoGrowHeightPending",!1);const t=Vi("px");this.set("minRows",2),this.set("maxRows",5),this.set("_height",null),this.set("resize","none"),this._resizeObserver=null,this.on("change:minRows",this._validateMinMaxRows.bind(this)),this.on("change:maxRows",this._validateMinMaxRows.bind(this));const i=this.bindTemplate;this.template.tag="textarea",this.extendTemplate({attributes:{class:["ck-textarea"],style:{height:i.to("_height",o=>o?t(o):null),resize:i.to("resize")},rows:i.to("minRows")}})}render(){super.render();let e=!1;this.on("input",()=>{this._updateAutoGrowHeight(!0),this.fire("update")}),this.on("change:value",()=>{I.window.requestAnimationFrame(()=>{if(!Gt(this.element)){this._isUpdateAutoGrowHeightPending=!0;return}this._updateAutoGrowHeight(),this.fire("update")})}),this._resizeObserver=new bo(this.element,t=>{const i=!!t.contentRect.width&&!!t.contentRect.height;!e&&i&&this._isUpdateAutoGrowHeightPending&&I.window.requestAnimationFrame(()=>{this._updateAutoGrowHeight(),this.fire("update")}),e=i})}destroy(){this._resizeObserver&&this._resizeObserver.destroy()}reset(){super.reset(),this._updateAutoGrowHeight(),this.fire("update")}_updateAutoGrowHeight(e){const t=this.element;if(!t.offsetParent){this._isUpdateAutoGrowHeightPending=!0;return}this._isUpdateAutoGrowHeightPending=!1;const i=qd(t,"1"),o=qd(t,t.value),s=i.ownerDocument.defaultView.getComputedStyle(i),r=parseFloat(s.paddingTop)+parseFloat(s.paddingBottom),a=Dc(i),l=parseFloat(s.lineHeight),c=a.top+a.bottom,u=new z(i).height,d=Math.round((o.scrollHeight-r)/l),m=this.maxRows*l+r+c,f=d===1?u:this.minRows*l+r+c;this._height=Math.min(Math.max(Math.max(d,this.minRows)*l+r+c,f),m),e&&(t.scrollTop=t.scrollHeight),i.remove(),o.remove()}_validateMinMaxRows(){if(this.minRows>this.maxRows)throw new b("ui-textarea-view-min-rows-greater-than-max-rows",{textareaView:this,minRows:this.minRows,maxRows:this.maxRows})}}function qd(n,e){const t=n.cloneNode();return t.style.position="absolute",t.style.top="-99999px",t.style.left="-99999px",t.style.height="auto",t.style.overflow="hidden",t.style.width=n.ownerDocument.defaultView.getComputedStyle(n).width,t.tabIndex=-1,t.rows=1,t.value=e,n.parentNode.insertBefore(t,n),t}class wx extends A{constructor(e){super(e),h(this,"children");const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-dropdown__panel",t.to("position",i=>`ck-dropdown__panel_${i}`),t.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:t.to(i=>{i.target.tagName.toLocaleLowerCase()!=="input"&&i.preventDefault()})}})}focus(){if(this.children.length){const e=this.children.first;typeof e.focus=="function"?e.focus():J("ui-dropdown-panel-focus-child-missing-focus",{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){const e=this.children.last;typeof e.focusLast=="function"?e.focusLast():e.focus()}}}const Xl=class ec extends A{constructor(e,t,i){super(e),h(this,"buttonView"),h(this,"panelView"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"listView"),h(this,"toolbarView"),h(this,"menuView");const o=this.bindTemplate;this.buttonView=t,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new te,this.focusTracker=new ee,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",o.to("class"),o.if("isEnabled","ck-disabled",s=>!s)],id:o.to("id"),"aria-describedby":o.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":o.to("isOpen")}})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.listenTo(this.buttonView,"open",()=>{this.isOpen=!this.isOpen}),this.on("change:isOpen",(t,i,o)=>{if(o)if(this.panelPosition==="auto"){const s=ec._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=s?s.name:this._defaultPanelPositionName}else this.panelView.position=this.panelPosition}),this.keystrokes.listenTo(this.element);const e=(t,i)=>{this.isOpen&&(this.isOpen=!1,i())};this.keystrokes.set("arrowdown",(t,i)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,i())}),this.keystrokes.set("arrowright",(t,i)=>{this.isOpen&&i()}),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:i,southWest:o,northEast:s,northWest:r,southMiddleEast:a,southMiddleWest:l,northMiddleEast:c,northMiddleWest:u}=ec.defaultPanelPositions;return this.locale.uiLanguageDirection!=="rtl"?[i,o,a,l,e,s,r,c,u,t]:[o,i,l,a,e,r,s,u,c,t]}get _defaultPanelPositionName(){return this.locale.uiLanguageDirection==="rtl"?"sw":"se"}};h(Xl,"defaultPanelPositions",{south:(n,e)=>({top:n.bottom,left:n.left-(e.width-n.width)/2,name:"s"}),southEast:n=>({top:n.bottom,left:n.left,name:"se"}),southWest:(n,e)=>({top:n.bottom,left:n.left-e.width+n.width,name:"sw"}),southMiddleEast:(n,e)=>({top:n.bottom,left:n.left-(e.width-n.width)/4,name:"sme"}),southMiddleWest:(n,e)=>({top:n.bottom,left:n.left-(e.width-n.width)*3/4,name:"smw"}),north:(n,e)=>({top:n.top-e.height,left:n.left-(e.width-n.width)/2,name:"n"}),northEast:(n,e)=>({top:n.top-e.height,left:n.left,name:"ne"}),northWest:(n,e)=>({top:n.top-e.height,left:n.left-e.width+n.width,name:"nw"}),northMiddleEast:(n,e)=>({top:n.top-e.height,left:n.left-(e.width-n.width)/4,name:"nme"}),northMiddleWest:(n,e)=>({top:n.top-e.height,left:n.left-(e.width-n.width)*3/4,name:"nmw"})}),h(Xl,"_getOptimalPosition",zc);let Jw=Xl;class fu extends P{constructor(e){super(e),h(this,"arrowView"),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",t=>String(t))}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new hi;return e.content=da,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class Nt extends A{constructor(e){super(e),h(this,"children");const t=this.bindTemplate;this.set("isVisible",!0),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item",t.if("isVisible","ck-hidden",i=>!i)],role:"presentation"},children:this.children})}focus(){this.children.first&&this.children.first.focus()}}class ma extends A{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class hr extends A{constructor(e,t=new xt){super(e),h(this,"labelView"),h(this,"items"),h(this,"children");const i=this.bindTemplate,o=new En(e);this.set({label:"",isVisible:!0}),this.labelView=t,this.labelView.bind("text").to(this,"label"),this.children=this.createCollection(),this.children.addMany([this.labelView,o]),o.set({role:"group",ariaLabelledBy:t.id}),o.focusTracker.destroy(),o.keystrokes.destroy(),this.items=o.items,this.setTemplate({tag:"li",attributes:{role:"presentation",class:["ck","ck-list__group",i.if("isVisible","ck-hidden",s=>!s)]},children:this.children})}focus(){if(this.items){const e=this.items.find(t=>!(t instanceof ma));e&&e.focus()}}}class En extends A{constructor(e){super(e),h(this,"focusables"),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"_focusCycler"),h(this,"_listItemGroupToChangeListeners",new WeakMap);const t=this.bindTemplate;this.focusables=new Ie,this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this._focusCycler=new Ae({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",void 0),this.set("role",void 0),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"],role:t.to("role"),"aria-label":t.to("ariaLabel"),"aria-labelledby":t.to("ariaLabelledBy")},children:this.items})}render(){super.render();for(const e of this.items)e instanceof hr?this._registerFocusableItemsGroup(e):e instanceof Nt&&this._registerFocusableListItem(e);this.items.on("change",(e,t)=>{for(const i of t.removed)i instanceof hr?this._deregisterFocusableItemsGroup(i):i instanceof Nt&&this._deregisterFocusableListItem(i);for(const i of Array.from(t.added).reverse())i instanceof hr?this._registerFocusableItemsGroup(i,t.index):this._registerFocusableListItem(i,t.index)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_registerFocusableListItem(e,t){this.focusTracker.add(e.element),this.focusables.add(e,t)}_deregisterFocusableListItem(e){this.focusTracker.remove(e.element),this.focusables.remove(e)}_getOnGroupItemsChangeCallback(e){return(t,i)=>{for(const o of i.removed)this._deregisterFocusableListItem(o);for(const o of Array.from(i.added).reverse())this._registerFocusableListItem(o,this.items.getIndex(e)+i.index)}}_registerFocusableItemsGroup(e,t){Array.from(e.items).forEach((o,s)=>{const r=typeof t<"u"?t+s:void 0;this._registerFocusableListItem(o,r)});const i=this._getOnGroupItemsChangeCallback(e);this._listItemGroupToChangeListeners.set(e,i),e.items.on("change",i)}_deregisterFocusableItemsGroup(e){for(const t of e.items)this._deregisterFocusableListItem(t);e.items.off("change",this._listItemGroupToChangeListeners.get(e)),this._listItemGroupToChangeListeners.delete(e)}}const Gd=Vi("px"),bx={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}},dn=class Jn extends A{constructor(e){super(e),h(this,"content"),h(this,"_pinWhenIsVisibleCallback"),h(this,"_resizeObserver");const t=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class",void 0),this._pinWhenIsVisibleCallback=null,this._resizeObserver=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",i=>`ck-balloon-panel_${i}`),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Gd),left:t.to("left",Gd)}},children:this.content})}destroy(){this.hide(),super.destroy()}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){const t=dr(e.target);if(t&&!Gt(t))return!1;this.show();const i=Jn.defaultPositions,o=Object.assign({},{element:this.element,positions:[i.southArrowNorth,i.southArrowNorthMiddleWest,i.southArrowNorthMiddleEast,i.southArrowNorthWest,i.southArrowNorthEast,i.northArrowSouth,i.northArrowSouthMiddleWest,i.northArrowSouthMiddleEast,i.northArrowSouthWest,i.northArrowSouthEast,i.viewportStickyNorth],limiter:I.document.body,fitInViewport:!0},e),s=Jn._getOptimalPosition(o)||bx,r=parseInt(s.left),a=parseInt(s.top),l=s.name,c=s.config||{},{withArrow:u=!0}=c;return this.top=a,this.left=r,this.position=l,this.withArrow=u,!0}pin(e){this.unpin(),this._startPinning(e)&&(this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback))}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(e){if(!this.attachTo(e))return!1;let t=dr(e.target);const i=e.limiter?dr(e.limiter):I.document.body;if(this.listenTo(I.document,"scroll",(o,s)=>{const r=s.target,a=t&&r.contains(t),l=i&&r.contains(i);(a||l||!t||!i)&&this.attachTo(e)},{useCapture:!0}),this.listenTo(I.window,"resize",()=>{this.attachTo(e)}),!this._resizeObserver&&(t&&xe(t)&&(t=t.parentElement),t)){const o=()=>{Gt(t)||this.unpin()};this._resizeObserver=new bo(t,o)}return!0}_stopPinning(){this.stopListening(I.document,"scroll"),this.stopListening(I.window,"resize"),this._resizeObserver&&(this._resizeObserver.destroy(),this._resizeObserver=null)}static generatePositions(e={}){const{sideOffset:t=Jn.arrowSideOffset,heightOffset:i=Jn.arrowHeightOffset,stickyVerticalOffset:o=Jn.stickyVerticalOffset,config:s}=e;return{northWestArrowSouthWest:(l,c)=>({top:r(l,c),left:l.left-t,name:"arrow_sw",...s&&{config:s}}),northWestArrowSouthMiddleWest:(l,c)=>({top:r(l,c),left:l.left-c.width*.25-t,name:"arrow_smw",...s&&{config:s}}),northWestArrowSouth:(l,c)=>({top:r(l,c),left:l.left-c.width/2,name:"arrow_s",...s&&{config:s}}),northWestArrowSouthMiddleEast:(l,c)=>({top:r(l,c),left:l.left-c.width*.75+t,name:"arrow_sme",...s&&{config:s}}),northWestArrowSouthEast:(l,c)=>({top:r(l,c),left:l.left-c.width+t,name:"arrow_se",...s&&{config:s}}),northArrowSouthWest:(l,c)=>({top:r(l,c),left:l.left+l.width/2-t,name:"arrow_sw",...s&&{config:s}}),northArrowSouthMiddleWest:(l,c)=>({top:r(l,c),left:l.left+l.width/2-c.width*.25-t,name:"arrow_smw",...s&&{config:s}}),northArrowSouth:(l,c)=>({top:r(l,c),left:l.left+l.width/2-c.width/2,name:"arrow_s",...s&&{config:s}}),northArrowSouthMiddleEast:(l,c)=>({top:r(l,c),left:l.left+l.width/2-c.width*.75+t,name:"arrow_sme",...s&&{config:s}}),northArrowSouthEast:(l,c)=>({top:r(l,c),left:l.left+l.width/2-c.width+t,name:"arrow_se",...s&&{config:s}}),northEastArrowSouthWest:(l,c)=>({top:r(l,c),left:l.right-t,name:"arrow_sw",...s&&{config:s}}),northEastArrowSouthMiddleWest:(l,c)=>({top:r(l,c),left:l.right-c.width*.25-t,name:"arrow_smw",...s&&{config:s}}),northEastArrowSouth:(l,c)=>({top:r(l,c),left:l.right-c.width/2,name:"arrow_s",...s&&{config:s}}),northEastArrowSouthMiddleEast:(l,c)=>({top:r(l,c),left:l.right-c.width*.75+t,name:"arrow_sme",...s&&{config:s}}),northEastArrowSouthEast:(l,c)=>({top:r(l,c),left:l.right-c.width+t,name:"arrow_se",...s&&{config:s}}),southWestArrowNorthWest:l=>({top:a(l),left:l.left-t,name:"arrow_nw",...s&&{config:s}}),southWestArrowNorthMiddleWest:(l,c)=>({top:a(l),left:l.left-c.width*.25-t,name:"arrow_nmw",...s&&{config:s}}),southWestArrowNorth:(l,c)=>({top:a(l),left:l.left-c.width/2,name:"arrow_n",...s&&{config:s}}),southWestArrowNorthMiddleEast:(l,c)=>({top:a(l),left:l.left-c.width*.75+t,name:"arrow_nme",...s&&{config:s}}),southWestArrowNorthEast:(l,c)=>({top:a(l),left:l.left-c.width+t,name:"arrow_ne",...s&&{config:s}}),southArrowNorthWest:l=>({top:a(l),left:l.left+l.width/2-t,name:"arrow_nw",...s&&{config:s}}),southArrowNorthMiddleWest:(l,c)=>({top:a(l),left:l.left+l.width/2-c.width*.25-t,name:"arrow_nmw",...s&&{config:s}}),southArrowNorth:(l,c)=>({top:a(l),left:l.left+l.width/2-c.width/2,name:"arrow_n",...s&&{config:s}}),southArrowNorthMiddleEast:(l,c)=>({top:a(l),left:l.left+l.width/2-c.width*.75+t,name:"arrow_nme",...s&&{config:s}}),southArrowNorthEast:(l,c)=>({top:a(l),left:l.left+l.width/2-c.width+t,name:"arrow_ne",...s&&{config:s}}),southEastArrowNorthWest:l=>({top:a(l),left:l.right-t,name:"arrow_nw",...s&&{config:s}}),southEastArrowNorthMiddleWest:(l,c)=>({top:a(l),left:l.right-c.width*.25-t,name:"arrow_nmw",...s&&{config:s}}),southEastArrowNorth:(l,c)=>({top:a(l),left:l.right-c.width/2,name:"arrow_n",...s&&{config:s}}),southEastArrowNorthMiddleEast:(l,c)=>({top:a(l),left:l.right-c.width*.75+t,name:"arrow_nme",...s&&{config:s}}),southEastArrowNorthEast:(l,c)=>({top:a(l),left:l.right-c.width+t,name:"arrow_ne",...s&&{config:s}}),westArrowEast:(l,c)=>({top:l.top+l.height/2-c.height/2,left:l.left-c.width-i,name:"arrow_e",...s&&{config:s}}),eastArrowWest:(l,c)=>({top:l.top+l.height/2-c.height/2,left:l.right+i,name:"arrow_w",...s&&{config:s}}),viewportStickyNorth:(l,c,u)=>{const d=new z(I.document.body).getIntersection(u.getVisible());if(!d)return null;const m=d.getVisible();return!l.getIntersection(m)||!(m.top-l.top-o<c.height&&m.bottom-l.bottom<c.height)?null:{top:m.top+o,left:l.left+l.width/2-c.width/2,name:"arrowless",config:{withArrow:!1,...s}}}};function r(l,c){return l.top-c.height-i}function a(l){return l.bottom+i}}};h(dn,"arrowSideOffset",25),h(dn,"arrowHeightOffset",10),h(dn,"stickyVerticalOffset",20),h(dn,"_getOptimalPosition",zc),h(dn,"defaultPositions",dn.generatePositions());let Ne=dn;function dr(n){return xi(n)?n:ia(n)?n.commonAncestorContainer:typeof n=="function"?dr(n()):null}class Qw extends A{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class _x extends A{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function vx(n){return n.bindTemplate.to(e=>{e.target===n.element&&e.preventDefault()})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function gu(n){if(Array.isArray(n))return{items:n,removeItems:[]};const e={items:[],removeItems:[]};return n?{...e,...n}:e}const tc={alignLeft:nu,bold:gw,importExport:BC,paragraph:yw,plus:tA,text:_A,threeVerticalDots:au,pilcrow:eA,dragIndicator:vC};class Ei extends A{constructor(e,t){super(e),h(this,"options"),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"itemsView"),h(this,"children"),h(this,"focusables"),h(this,"_focusCycler"),h(this,"_behavior");const i=this.bindTemplate,o=this.t;this.options=t||{},this.set("ariaLabel",o("Editor toolbar")),this.set("maxWidth","auto"),this.set("role","toolbar"),this.set("isGrouping",!!this.options.shouldGroupWhenFull),this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this.set("class",void 0),this.set("isCompact",!1),this.set("isVertical",!1),this.itemsView=new yx(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const s=e.uiLanguageDirection==="rtl";this._focusCycler=new Ae({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[s?"arrowright":"arrowleft","arrowup"],focusNext:[s?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact"),i.if("isGrouping","ck-toolbar_grouping"),i.if("isVertical","ck-toolbar_vertical")];this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:i.to("role"),"aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:vx(this)}}),this._behavior=this.options.shouldGroupWhenFull?new Zd(this):new Kd(this)}render(){super.render(),this.focusTracker.add(this.element);for(const e of this.items)this.focusTracker.add(e);this.items.on("add",(e,t)=>{this.focusTracker.add(t)}),this.items.on("remove",(e,t)=>{this.focusTracker.remove(t)}),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(e,t,i){this.items.addMany(this._buildItemsFromConfig(e,t,i))}switchBehavior(e){this._behavior.type!==e&&(this._behavior.destroy(),this.itemsView.children.clear(),this.focusables.clear(),e==="dynamic"?(this._behavior=new Zd(this),this._behavior.render(this),this._behavior.refreshItems()):(this._behavior=new Kd(this),this._behavior.render(this)))}_buildItemsFromConfig(e,t,i){const o=gu(e),s=i||o.removeItems;return this._cleanItemsConfiguration(o.items,t,s).map(r=>Et(r)?this._createNestedToolbarDropdown(r,t,s):r==="|"?new Qw:r==="-"?new _x:t.create(r)).filter(r=>!!r)}_cleanItemsConfiguration(e,t,i){const o=e.filter((s,r,a)=>s==="|"?!0:i.indexOf(s)!==-1?!1:s==="-"?this.options.shouldGroupWhenFull?(J("toolbarview-line-break-ignored-when-grouping-items",a),!1):!0:!Et(s)&&!t.has(s)?(J("toolbarview-item-unavailable",{item:s}),!1):!0);return this._cleanSeparatorsAndLineBreaks(o)}_cleanSeparatorsAndLineBreaks(e){const t=r=>r!=="-"&&r!=="|",i=e.length,o=e.findIndex(t);if(o===-1)return[];const s=i-e.slice().reverse().findIndex(t);return e.slice(o,s).filter((r,a,l)=>t(r)?!0:!(a>0&&l[a-1]===r))}_createNestedToolbarDropdown(e,t,i){let{label:o,icon:s,items:r,tooltip:a=!0,withText:l=!1}=e;if(r=this._cleanItemsConfiguration(r,t,i),!r.length)return null;const c=this.locale,u=Ee(c);return o||J("toolbarview-nested-toolbar-dropdown-missing-label",e),u.class="ck-toolbar__nested-toolbar-dropdown",u.buttonView.set({label:o,tooltip:a,withText:!!l}),s!==!1?u.buttonView.icon=tc[s]||s||au:u.buttonView.withText=!0,fa(u,()=>u.toolbarView._buildItemsFromConfig(r,t,i)),u}}class yx extends A{constructor(e){super(e),h(this,"children"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Kd{constructor(e){h(this,"type","static"),e.isGrouping=!1,e.itemsView.children.bindTo(e.items).using(t=>t),e.focusables.bindTo(e.items).using(t=>yo(t)?t:null)}render(){}destroy(){}}class Zd{constructor(e){h(this,"type","dynamic"),h(this,"view"),h(this,"viewChildren"),h(this,"viewFocusables"),h(this,"viewItemsView"),h(this,"viewFocusTracker"),h(this,"viewLocale"),h(this,"ungroupedItems"),h(this,"groupedItems"),h(this,"groupedItemsDropdown"),h(this,"resizeObserver",null),h(this,"cachedPadding",null),h(this,"shouldUpdateGroupingOnNextResize",!1),h(this,"viewElement"),this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.view.isGrouping=!0,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),e.itemsView.children.bindTo(this.ungroupedItems).using(t=>t),this.ungroupedItems.on("change",this._updateFocusCyclableItems.bind(this)),e.children.on("change",this._updateFocusCyclableItems.bind(this)),e.items.on("change",(t,i)=>{const o=i.index,s=Array.from(i.added);for(const r of i.removed)o>=this.ungroupedItems.length?this.groupedItems.remove(r):this.ungroupedItems.remove(r);for(let r=o;r<o+s.length;r++){const a=s[r-o];r>this.ungroupedItems.length?this.groupedItems.add(a,r-this.ungroupedItems.length):this.ungroupedItems.add(a,r)}this._updateGrouping()})}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.viewChildren.length>1&&(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last)),this.resizeObserver.destroy()}refreshItems(){const e=this.view;if(e.items.length){for(let t=0;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(!Gt(this.viewElement)){this.shouldUpdateGroupingOnNextResize=!0;return}const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,t=this.viewLocale.uiLanguageDirection,i=new z(e.lastChild),o=new z(e);if(!this.cachedPadding){const s=I.window.getComputedStyle(e),r=t==="ltr"?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(s[r])}return t==="ltr"?i.right>o.right-this.cachedPadding:i.left<o.left+this.cachedPadding}_enableGroupingOnResize(){let e;this.resizeObserver=new bo(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 Qw),this.viewChildren.add(this.groupedItemsDropdown),this.viewFocusTracker.add(this.groupedItemsDropdown.element)),this.groupedItems.add(this.ungroupedItems.remove(this.ungroupedItems.last),0)}_ungroupFirstItem(){this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first)),this.groupedItems.length||(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last),this.viewFocusTracker.remove(this.groupedItemsDropdown.element))}_createGroupedItemsDropdown(){const e=this.viewLocale,t=e.t,i=Ee(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition=e.uiLanguageDirection==="ltr"?"sw":"se",fa(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:e.uiLanguageDirection==="rtl"?"se":"sw",icon:au}),i}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map(e=>{yo(e)&&this.viewFocusables.add(e)}),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class Xi extends A{constructor(e,t){super(e),h(this,"children"),h(this,"actionView"),h(this,"arrowView"),h(this,"keystrokes"),h(this,"focusTracker");const i=this.bindTemplate;this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke",void 0),this.set("withKeystroke",!1),this.set("label",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(t),this.arrowView=this._createArrowView(),this.keystrokes=new te,this.focusTracker=new ee,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",i.to("class"),i.if("isVisible","ck-hidden",o=>!o),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",(e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())}),this.keystrokes.set("arrowleft",(e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(e){const t=e||new P;return e||t.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),t.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),t.delegate("execute").to(this),t}_createArrowView(){const e=new P,t=e.bindTemplate;return e.icon=da,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",i=>String(i))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}}function Ee(n,e=fu){const t=typeof e=="function"?new e(n):e,i=new wx(n),o=new Jw(n,t,i);return t.bind("isEnabled").to(o),t instanceof Xi?t.arrowView.bind("isOn").to(o,"isOpen"):t.bind("isOn").to(o,"isOpen"),kx(o),o}function fa(n,e,t={}){n.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),n.isOpen?Jd(n,e,t):n.once("change:isOpen",()=>Jd(n,e,t),{priority:"highest"}),t.enableActiveItemFocusOnDropdownOpen&&ga(n,()=>n.toolbarView.items.find(i=>i.isOn))}function Jd(n,e,t){const i=n.locale,o=i.t,s=n.toolbarView=new Ei(i),r=typeof e=="function"?e():e;s.ariaLabel=t.ariaLabel||o("Dropdown toolbar"),t.maxWidth&&(s.maxWidth=t.maxWidth),t.class&&(s.class=t.class),t.isCompact&&(s.isCompact=t.isCompact),t.isVertical&&(s.isVertical=!0),r instanceof Ie?s.items.bindTo(r).using(a=>a):s.items.addMany(r),n.panelView.children.add(s),n.focusTracker.add(s),s.items.delegate("execute").to(n)}function wt(n,e,t={}){n.isOpen?Qd(n,e,t):n.once("change:isOpen",()=>Qd(n,e,t),{priority:"highest"}),ga(n,()=>n.listView.items.find(i=>i instanceof Nt?i.children.first.isOn:!1))}function Qd(n,e,t){const i=n.locale,o=n.listView=new En(i),s=typeof e=="function"?e():e;o.ariaLabel=t.ariaLabel,o.role=t.role,Xw(n,o.items,s,i),n.panelView.children.add(o),o.items.delegate("execute").to(n)}function ga(n,e){n.on("change:isOpen",()=>{if(!n.isOpen)return;const t=e();t&&(typeof t.focus=="function"?t.focus():J("ui-dropdown-focus-child-on-open-child-missing-focus",{view:t}))},{priority:kt.low-10})}function kx(n){Cx(n),Ax(n),xx(n),Tx(n),Ex(n),Sx(n)}function Cx(n){$t({emitter:n,activator:()=>n.isRendered&&n.isOpen,callback:()=>{n.isOpen=!1},contextElements:()=>[n.element,...Yw(n.focusTracker).filter(e=>!n.element.contains(e))]})}function Yw(n){return[...n.elements,...n.externalViews.flatMap(e=>Yw(e.focusTracker))]}function Ax(n){n.on("execute",e=>{e.source instanceof Ji||(n.isOpen=!1)})}function xx(n){n.focusTracker.on("change:isFocused",(e,t,i)=>{i||!n.isOpen||(n.isOpen=!1)})}function Tx(n){n.keystrokes.set("arrowdown",(e,t)=>{n.isOpen&&(n.panelView.focus(),t())}),n.keystrokes.set("arrowup",(e,t)=>{n.isOpen&&(n.panelView.focusLast(),t())})}function Ex(n){n.on("change:isOpen",(e,t,i)=>{i||n.focusTracker.elements.some(o=>o.contains(I.document.activeElement))&&n.buttonView.focus()})}function Sx(n){n.on("change:isOpen",(e,t,i)=>{i&&n.panelView.focus()},{priority:"low"})}function Xw(n,e,t,i){Px(e),e.bindTo(t).using(o=>{if(o.type==="separator")return new ma(i);if(o.type==="group"){const s=new hr(i);return s.set({label:o.label}),Xw(n,s.items,o.items,i),s.items.delegate("execute").to(n),s}else if(o.type==="button"||o.type==="switchbutton"){const s=o.model.role==="menuitemcheckbox"||o.model.role==="menuitemradio",r=new Nt(i);let a;return o.type==="button"?(a=new ko(i),a.set({isToggleable:s})):a=new Ji(i),a.bind(...Object.keys(o.model)).to(o.model),a.delegate("execute").to(r),r.children.add(a),r}return null})}function Px(n){let e=0;const t=s=>!(s instanceof Nt)||!(s.children.first instanceof ko)?null:s.children.first,i=s=>{const r=t(s);return!r||!r.isToggleable?null:r},o=s=>{for(const r of n){const a=t(r);a&&(a.hasCheckSpace=s)}};n.on("change",(s,r)=>{const a=e>0;for(const c of r.removed)i(c)&&e--;for(const c of r.added){const u=t(c);u&&(u.isToggleable&&e++,u.hasCheckSpace=e>0)}const l=e>0;a!==l&&o(l)})}const nt=(n,e,t)=>{const i=new Zw(n.locale);return i.set({id:e,ariaDescribedById:t}),i.bind("isReadOnly").to(n,"isEnabled",o=>!o),i.bind("hasError").to(n,"errorText",o=>!!o),i.on("input",()=>{n.errorText=null}),n.bind("isEmpty","isFocused","placeholder").to(i),i},eb=(n,e,t)=>{const i=new gx(n.locale);return i.set({id:e,ariaDescribedById:t,inputMode:"numeric"}),i.bind("isReadOnly").to(n,"isEnabled",o=>!o),i.bind("hasError").to(n,"errorText",o=>!!o),i.on("input",()=>{n.errorText=null}),n.bind("isEmpty","isFocused","placeholder").to(i),i},Ix=(n,e,t)=>{const i=new px(n.locale);return i.set({id:e,ariaDescribedById:t}),i.bind("isReadOnly").to(n,"isEnabled",o=>!o),i.bind("hasError").to(n,"errorText",o=>!!o),i.on("input",()=>{n.errorText=null}),n.bind("isEmpty","isFocused","placeholder").to(i),i},pu=(n,e,t)=>{const i=Ee(n.locale);return i.set({id:e,ariaDescribedById:t}),i.bind("isEnabled").to(n),i},Vx=150;class Rx extends A{constructor(e,t={}){super(e),h(this,"hexInputRow"),h(this,"_debounceColorPickerEvent"),h(this,"_config"),this.set({color:"",_hexColor:""}),this.hexInputRow=this._createInputRow();const i=this.createCollection();t.hideInput||i.add(this.hexInputRow),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker"],tabindex:-1},children:i}),this._config=t,this._debounceColorPickerEvent=St(o=>{this.set("color",o),this.fire("colorSelected",{color:this.color})},Vx,{leading:!0}),this.on("set:color",(o,s,r)=>{o.return=Uw(r,this._config.format||"hsl")}),this.on("change:color",()=>{this._hexColor=Qa(this.color)}),this.on("change:_hexColor",()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Qa(this.color)!=Qa(this._hexColor)&&(this.color=this._hexColor)})}render(){if(super.render(),hx("hex-color-picker",WA),this.picker=I.document.createElement("hex-color-picker"),this.picker.setAttribute("class","hex-color-picker"),this.picker.setAttribute("tabindex","-1"),this._createSlidersView(),this.element){this.hexInputRow.element?this.element.insertBefore(this.picker,this.hexInputRow.element):this.element.appendChild(this.picker);const e=document.createElement("style");e.textContent='[role="slider"]:focus [part$="pointer"] {border: 1px solid #fff;outline: 1px solid var(--ck-color-focus-border);box-shadow: 0 0 0 2px #fff;}',this.picker.shadowRoot.appendChild(e)}this.picker.addEventListener("color-changed",e=>{const t=e.detail.value;this._debounceColorPickerEvent(t)})}focus(){/* istanbul ignore next -- @preserve */!this._config.hideInput&&(N.isGecko||N.isiOS||N.isSafari||N.isBlink)&&this.hexInputRow.children.get(1).focus(),this.slidersView.first.focus()}_createSlidersView(){const e=[...this.picker.shadowRoot.children].filter(t=>t.getAttribute("role")==="slider").map(t=>new Ox(t));this.slidersView=this.createCollection(),e.forEach(t=>{this.slidersView.add(t)})}_createInputRow(){const e=this._createColorInput();return new Mx(this.locale,e)}_createColorInput(){const e=new Te(this.locale,nt),{t}=this.locale;return e.set({label:t("HEX"),class:"color-picker-hex-input"}),e.fieldView.bind("value").to(this,"_hexColor",i=>e.isFocused?e.fieldView.value:i.startsWith("#")?i.substring(1):i),e.fieldView.on("input",()=>{const i=e.fieldView.element.value;if(i){const o=tb(i);o&&this._debounceColorPickerEvent(o)}}),e}isValid(){const{t:e}=this.locale;return this._config.hideInput?!0:(this.resetValidationStatus(),this.hexInputRow.getParsedColor()?!0:(this.hexInputRow.inputView.errorText=e('Please enter a valid color (e.g. "ff0000").'),!1))}resetValidationStatus(){this.hexInputRow.inputView.errorText=null}}function Qa(n){let e=ux(n);return e||(e="#000"),e.length===4&&(e="#"+[e[1],e[1],e[2],e[2],e[3],e[3]].join("")),e.toLowerCase()}class Ox extends A{constructor(e){super(),this.element=e}focus(){this.element.focus()}}class Bx extends A{constructor(e){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class Mx extends A{constructor(e,t){super(e),h(this,"children"),h(this,"inputView"),this.inputView=t,this.children=this.createCollection([new Bx,this.inputView]),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}getParsedColor(){return tb(this.inputView.fieldView.element.value)}}function tb(n){if(!n)return null;const e=n.trim().replace(/^#/,"");return![3,4,6,8].includes(e.length)||!/^(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})$/.test(e)?null:`#${e}`}class Lx extends ue(_e){constructor(e){super(e),this.set("isEmpty",!0),this.on("change",()=>{this.set("isEmpty",this.length===0)})}add(e,t){return this.find(i=>i.color===e.color)?this:super.add(e,t)}hasColor(e){return!!this.find(t=>t.color===e)}}class Fx extends A{constructor(e,{colors:t,columns:i,removeButtonLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerLabel:a,focusTracker:l,focusables:c}){super(e),h(this,"items"),h(this,"colorDefinitions"),h(this,"focusTracker"),h(this,"columns"),h(this,"documentColors"),h(this,"documentColorsCount"),h(this,"staticColorsGrid"),h(this,"documentColorsGrid"),h(this,"colorPickerButtonView"),h(this,"removeColorButtonView"),h(this,"_focusables"),h(this,"_documentColorsLabel"),h(this,"_removeButtonLabel"),h(this,"_colorPickerLabel");const u=this.bindTemplate;this.set("isVisible",!0),this.focusTracker=l,this.items=this.createCollection(),this.colorDefinitions=t,this.columns=i,this.documentColors=new Lx,this.documentColorsCount=r,this._focusables=c,this._removeButtonLabel=o,this._colorPickerLabel=a,this._documentColorsLabel=s,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-fragment",u.if("isVisible","ck-hidden",d=>!d)]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}updateDocumentColors(e,t){const i=e.document,o=this.documentColorsCount;this.documentColors.clear();for(const s of i.getRoots()){const r=e.createRangeIn(s);for(const a of r.getItems())if(a.is("$textProxy")&&a.hasAttribute(t)&&(this._addColorToDocumentColors(a.getAttribute(t)),this.documentColors.length>=o))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,i=this.selectedColor;t.selectedColor=i,e&&(e.selectedColor=i)}render(){if(super.render(),this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount){const e=qt.bind(this.documentColors,this.documentColors),t=new A(this.locale);t.setTemplate({tag:"span",attributes:{class:["ck","ck-color-grid__label",e.if("isEmpty","ck-hidden")]},children:[{text:this._documentColorsLabel}]}),this.items.add(t),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}this._createColorPickerButton(),this._addColorSelectorElementsToFocusTracker()}focus(){this.removeColorButtonView.focus()}destroy(){super.destroy()}addColorPickerButton(){this.colorPickerButtonView&&(this.items.add(this.colorPickerButtonView),this.focusTracker.add(this.colorPickerButtonView.element),this._focusables.add(this.colorPickerButtonView))}_addColorSelectorElementsToFocusTracker(){this.focusTracker.add(this.removeColorButtonView.element),this._focusables.add(this.removeColorButtonView),this.staticColorsGrid&&(this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid)),this.documentColorsGrid&&(this.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid))}_createColorPickerButton(){this.colorPickerButtonView=new P,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:wC,class:"ck-color-selector__color-picker"}),this.colorPickerButtonView.on("execute",()=>{this.fire("colorPicker:show")})}_createRemoveColorButton(){const e=new P;return e.set({withText:!0,icon:kC,label:this._removeButtonLabel}),e.class="ck-color-selector__remove-color",e.on("execute",()=>{this.fire("execute",{value:null,source:"removeColorButton"})}),e.render(),e}_createStaticColorsGrid(){const e=new Ud(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.on("execute",(t,i)=>{this.fire("execute",{value:i.value,source:"staticColorsGrid"})}),e}_createDocumentColorsGrid(){const e=qt.bind(this.documentColors,this.documentColors),t=new Ud(this.locale,{columns:this.columns});return t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using(i=>{var o;const s=new jw;return s.set({color:i.color,hasBorder:(o=i.options)==null?void 0:o.hasBorder}),i.label&&s.set({label:i.label,tooltip:!0}),s.on("execute",()=>{this.fire("execute",{value:i.color,source:"documentColorsGrid"})}),s}),this.documentColors.on("change:isEmpty",(i,o,s)=>{s&&(t.selectedColor=null)}),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find(i=>i.color===e);t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}}class Nx extends A{constructor(e,{focusTracker:t,focusables:i,keystrokes:o,colorPickerViewConfig:s}){super(e),h(this,"items"),h(this,"colorPickerView"),h(this,"saveButtonView"),h(this,"cancelButtonView"),h(this,"actionBarView"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"_focusables"),h(this,"_colorPickerViewConfig"),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=o,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=i,this._colorPickerViewConfig=s;const r=this.bindTemplate,{saveButtonView:a,cancelButtonView:l}=this._createActionButtons();this.saveButtonView=a,this.cancelButtonView=l,this.actionBarView=this._createActionBarView({saveButtonView:a,cancelButtonView:l}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-fragment",r.if("isVisible","ck-hidden",c=>!c)]},children:this.items})}render(){super.render();const e=new Rx(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=e,this.colorPickerView.render(),this.selectedColor&&(e.color=this.selectedColor),this.listenTo(this,"change:selectedColor",(t,i,o)=>{e.color=o}),this.items.add(this.colorPickerView),this.items.add(this.actionBarView),this._addColorPickersElementsToFocusTracker(),this._stopPropagationOnArrowsKeys(),this._executeOnEnterPress(),this._executeUponColorChange()}destroy(){super.destroy()}focus(){this.colorPickerView.focus()}resetValidationStatus(){this.colorPickerView.resetValidationStatus()}_executeOnEnterPress(){this.keystrokes.set("enter",e=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&this.colorPickerView.isValid()&&(this.fire("execute",{value:this.selectedColor}),e.stopPropagation(),e.preventDefault())})}_stopPropagationOnArrowsKeys(){const e=t=>t.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}_addColorPickersElementsToFocusTracker(){for(const t of this.colorPickerView.slidersView)this.focusTracker.add(t.element),this._focusables.add(t);const e=this.colorPickerView.hexInputRow.children.get(1);e.element&&(this.focusTracker.add(e.element),this._focusables.add(e)),this.focusTracker.add(this.saveButtonView.element),this._focusables.add(this.saveButtonView),this.focusTracker.add(this.cancelButtonView.element),this._focusables.add(this.cancelButtonView)}_createActionBarView({saveButtonView:e,cancelButtonView:t}){const i=new A,o=this.createCollection();return o.add(e),o.add(t),i.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector_action-bar"]},children:o}),i}_createActionButtons(){const e=this.locale,t=e.t,i=new P(e),o=new P(e);return i.set({icon:Es,class:"ck-button-save",type:"button",withText:!1,label:t("Accept")}),o.set({icon:_o,class:"ck-button-cancel",type:"button",withText:!1,label:t("Cancel")}),i.on("execute",()=>{this.colorPickerView.isValid()&&this.fire("execute",{source:"colorPickerSaveButton",value:this.selectedColor})}),o.on("execute",()=>{this.fire("colorPicker:cancel")}),{saveButtonView:i,cancelButtonView:o}}_executeUponColorChange(){this.colorPickerView.on("colorSelected",(e,t)=>{this.fire("execute",{value:t.color,source:"colorPicker"}),this.set("selectedColor",t.color)})}}class wu extends A{constructor(e,{colors:t,columns:i,removeButtonLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerLabel:a,colorPickerViewConfig:l}){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"items"),h(this,"colorGridsFragmentView"),h(this,"colorPickerFragmentView"),h(this,"_focusCycler"),h(this,"_focusables"),h(this,"_colorPickerViewConfig"),this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this._focusables=new Ie,this._colorPickerViewConfig=l,this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsFragmentView=new Fx(e,{colors:t,columns:i,removeButtonLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerLabel:a,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new Nx(e,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerViewConfig:l}),this.set("_isColorGridsFragmentVisible",!0),this.set("_isColorPickerFragmentVisible",!1),this.set("selectedColor",void 0),this.colorGridsFragmentView.bind("isVisible").to(this,"_isColorGridsFragmentVisible"),this.colorPickerFragmentView.bind("isVisible").to(this,"_isColorPickerFragmentVisible"),this.on("change:selectedColor",(c,u,d)=>{this.colorGridsFragmentView.set("selectedColor",d),this.colorPickerFragmentView.set("selectedColor",d)}),this.colorGridsFragmentView.on("change:selectedColor",(c,u,d)=>{this.set("selectedColor",d)}),this.colorPickerFragmentView.on("change:selectedColor",(c,u,d)=>{this.set("selectedColor",d)}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector"]},children:this.items})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendUI(){this._appendColorGridsFragment(),this._colorPickerViewConfig&&this._appendColorPickerFragment()}showColorPickerFragment(){!this.colorPickerFragmentView.colorPickerView||this._isColorPickerFragmentVisible||(this._isColorPickerFragmentVisible=!0,this.colorPickerFragmentView.focus(),this.colorPickerFragmentView.resetValidationStatus(),this._isColorGridsFragmentVisible=!1)}showColorGridsFragment(){this._isColorGridsFragmentVisible||(this._isColorGridsFragmentVisible=!0,this.colorGridsFragmentView.focus(),this._isColorPickerFragmentVisible=!1)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}updateDocumentColors(e,t){this.colorGridsFragmentView.updateDocumentColors(e,t)}updateSelectedColors(){this.colorGridsFragmentView.updateSelectedColors()}_appendColorGridsFragment(){this.items.length||(this.items.add(this.colorGridsFragmentView),this.colorGridsFragmentView.delegate("execute").to(this),this.colorGridsFragmentView.delegate("colorPicker:show").to(this))}_appendColorPickerFragment(){this.items.length!==2&&(this.items.add(this.colorPickerFragmentView),this.colorGridsFragmentView.colorPickerButtonView&&this.colorGridsFragmentView.colorPickerButtonView.on("execute",()=>{this.showColorPickerFragment()}),this.colorGridsFragmentView.addColorPickerButton(),this.colorPickerFragmentView.delegate("execute").to(this),this.colorPickerFragmentView.delegate("colorPicker:cancel").to(this))}}class Dx{constructor(e){h(this,"editor"),h(this,"_components",new Map),this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(Ya(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new b("componentfactory-item-missing",this,{name:e});return this._components.get(Ya(e)).callback(this.editor.locale)}has(e){return this._components.has(Ya(e))}}function Ya(n){return String(n).toLowerCase()}const Yd="ck-tooltip",mr=class at extends st(){constructor(e){if(super(),h(this,"tooltipTextView"),h(this,"balloonPanelView"),h(this,"_currentElementWithTooltip",null),h(this,"_currentTooltipPosition",null),h(this,"_mutationObserver",null),h(this,"_pinTooltipDebounced"),h(this,"_unpinTooltipDebounced"),h(this,"_watchdogExcluded"),at._editors.add(e),at._instance)return at._instance;at._instance=this,this.tooltipTextView=new A(e.locale),this.tooltipTextView.set("text",""),this.tooltipTextView.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:this.tooltipTextView.bindTemplate.to("text")}]}),this.balloonPanelView=new Ne(e.locale),this.balloonPanelView.class=Yd,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=Hx(()=>{this._updateTooltipPosition()}),this._pinTooltipDebounced=St(this._pinTooltip,600),this._unpinTooltipDebounced=St(this._unpinTooltip,400),this.listenTo(I.document,"keydown",this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(I.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(I.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(I.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(I.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(I.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;at._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),at._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),at._instance=null)}static getPositioningFunctions(e){const t=at.defaultBalloonPositions;return{s:[t.southArrowNorth,t.southArrowNorthEast,t.southArrowNorthWest],n:[t.northArrowSouth],e:[t.eastArrowWest],w:[t.westArrowEast],sw:[t.southArrowNorthEast],se:[t.southArrowNorthWest]}[e]}_onKeyDown(e,t){t.key==="Escape"&&this._currentElementWithTooltip&&(this._unpinTooltip(),t.stopPropagation())}_onEnterOrFocus(e,{target:t}){const i=Xa(t);if(!i){e.name==="focus"&&this._unpinTooltip();return}if(i===this._currentElementWithTooltip){this._unpinTooltipDebounced.cancel();return}this._unpinTooltip(),e.name==="focus"&&!i.matches(":hover")||i.matches("[data-cke-tooltip-instant]")?this._pinTooltip(i,el(i)):this._pinTooltipDebounced(i,el(i))}_onLeaveOrBlur(e,{target:t,relatedTarget:i}){if(e.name==="mouseleave"){if(!xi(t))return;const o=this.balloonPanelView.element,s=o&&(o===i||o.contains(i)),r=!s&&t===o;if(s){this._unpinTooltipDebounced.cancel();return}if(!r&&this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const a=Xa(t),l=Xa(i);(r||a&&a!==l)&&(this._pinTooltipDebounced.cancel(),this._currentElementWithTooltip&&this._currentElementWithTooltip.matches("[data-cke-tooltip-instant]")||a&&a.matches("[data-cke-tooltip-instant]")?this._unpinTooltip():this._unpinTooltipDebounced())}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._pinTooltipDebounced.cancel(),this._unpinTooltipDebounced()}}_onScroll(e,{target:t}){this._currentElementWithTooltip&&(t.contains(this.balloonPanelView.element)&&t.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(e,{text:t,position:i,cssClass:o}){this._unpinTooltip();const s=ae(at._editors.values()).ui.view.body;s.has(this.balloonPanelView)||s.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.class=[Yd,o].filter(r=>r).join(" "),this.balloonPanelView.pin({target:e,positions:at.getPositioningFunctions(i)}),this._mutationObserver.attach(e);for(const r of at._editors)this.listenTo(r.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=i}_unpinTooltip(){this._unpinTooltipDebounced.cancel(),this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of at._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this.tooltipTextView.text="",this._mutationObserver.detach()}_updateTooltipPosition(){if(!this._currentElementWithTooltip)return;const e=el(this._currentElementWithTooltip);if(!Gt(this._currentElementWithTooltip)||!e.text){this._unpinTooltip();return}this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:at.getPositioningFunctions(e.position)})}};h(mr,"defaultBalloonPositions",Ne.generatePositions({heightOffset:5,sideOffset:13})),h(mr,"_editors",new Set),h(mr,"_instance",null);let zx=mr;function Xa(n){return xi(n)?n.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function el(n){return{text:n.dataset.ckeTooltipText,position:n.dataset.ckeTooltipPosition||"s",cssClass:n.dataset.ckeTooltipClass||""}}function Hx(n){const e=new MutationObserver(()=>{n()});return{attach(t){e.observe(t,{attributes:!0,attributeFilter:["data-cke-tooltip-text","data-cke-tooltip-position"]})},detach(){e.disconnect()}}}const $x=50,Wx=350;class ib extends st(){constructor(e,t={}){super(),h(this,"editor"),h(this,"_balloonView",null),h(this,"_showBalloonThrottled",co(()=>this._showBalloon(),50,{leading:!0})),h(this,"_lastFocusedEditableElement",null),h(this,"_balloonClass"),this.editor=e,this._balloonClass=t.balloonClass,e.on("ready",()=>this._handleEditorReady())}destroy(){const e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const e=this.editor;this._isEnabled()&&e.ui.view&&(e.ui.focusTracker.on("change:isFocused",(t,i,o)=>{this._updateLastFocusedEditableElement(),o?this._showBalloon():this._hideBalloon()}),e.ui.focusTracker.on("change:focusedElement",(t,i,o)=>{this._updateLastFocusedEditableElement(),o&&this._showBalloon()}),e.ui.on("update",()=>{this._showBalloonThrottled()}))}_getNormalizedConfig(){return{side:this.editor.locale.contentLanguageDirection==="ltr"?"right":"left",position:"border",verticalOffset:0,horizontalOffset:5}}_showBalloon(){const e=this._getBalloonAttachOptions();e&&(this._balloonView||(this._balloonView=this._createBalloonView()),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_createBalloonView(){const e=this.editor,t=new Ne,i=this._createBadgeContent();return t.content.add(i),this._balloonClass&&(t.class=this._balloonClass),e.ui.view.body.add(t),t}_getBalloonAttachOptions(){if(!this._lastFocusedEditableElement)return null;const e=this._getNormalizedConfig(),t=e.side==="right"?jx(this._lastFocusedEditableElement,e):Ux(this._lastFocusedEditableElement,e);return{target:this._lastFocusedEditableElement,positions:[t]}}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,i=e.ui.focusTracker.focusedElement;if(!t||!i){this._lastFocusedEditableElement=null;return}const o=Array.from(e.ui.getEditableElementsNames()).map(s=>e.ui.getEditableElement(s));o.includes(i)?this._lastFocusedEditableElement=i:this._lastFocusedEditableElement=o[0]}}function jx(n,e){return nb(n,e,(t,i)=>t.left+t.width-i.width-e.horizontalOffset)}function Ux(n,e){return nb(n,e,t=>t.left+e.horizontalOffset)}function nb(n,e,t){return(i,o)=>{const s=new z(n);if(s.width<Wx||s.height<$x)return null;let r;e.position==="inside"?r=s.bottom-o.height:r=s.bottom-o.height/2,r-=e.verticalOffset;const a=t(s,o),l=i.clone().moveTo(a,r).getIntersection(o.clone().moveTo(a,r)).getVisible();return!l||l.getArea()<o.getArea()?null:{top:r,left:a,name:`position_${e.position}-side_${e.side}`,config:{withArrow:!1}}}}const qx="Powered by";class Gx extends ib{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(t=="GPL")return!0;const i=Wc(t.split(".")[1]);return i?!i.whiteLabel:!0}_createBadgeContent(){return new Kx(this.editor.locale,this._getNormalizedConfig().label)}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{},i=t.position||e.position,o=i==="inside"?5:e.verticalOffset;return{position:i,side:t.side||e.side,label:t.label===void 0?qx:t.label,verticalOffset:t.verticalOffset!==void 0?t.verticalOffset:o,horizontalOffset:t.horizontalOffset!==void 0?t.horizontalOffset:e.horizontalOffset,forceVisible:!!t.forceVisible}}}class Kx extends A{constructor(e,t){super(e);const i=new hi,o=this.bindTemplate;i.set({content:iA,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:o.to(s=>s.preventDefault())}}]})}}class Zx extends ib{constructor(e){super(e,{balloonClass:"ck-evaluation-badge-balloon"}),h(this,"licenseTypeMessage",{evaluation:"For evaluation purposes only",trial:"For evaluation purposes only",development:"For development purposes only"})}_isEnabled(){const e=this.editor.config.get("licenseKey"),t=Xd(e);return!!(t&&this.licenseTypeMessage[t])}_createBadgeContent(){const e=this.editor.config.get("licenseKey"),t=Xd(e);return new Jx(this.editor.locale,this.licenseTypeMessage[t])}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{},i=t.position||e.position,o=t.side||e.side;return{position:i,side:o==="left"?"right":"left",verticalOffset:e.verticalOffset,horizontalOffset:e.horizontalOffset}}}class Jx extends A{constructor(e,t){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-evaluation-badge"],"aria-hidden":!0},children:[{tag:"span",attributes:{class:["ck","ck-evaluation-badge__label"]},children:[t]}]})}}function Xd(n){if(n=="GPL")return"GPL";const e=Wc(n.split(".")[1]);return e?e.licenseType||"production":null}const em={POLITE:"polite",ASSERTIVE:"assertive"};class Qx{constructor(e){h(this,"editor"),h(this,"view"),this.editor=e,e.once("ready",()=>{for(const t of Object.values(em))this.announce("",t)})}announce(e,t=em.POLITE){const i=this.editor;if(!i.ui.view)return;this.view||(this.view=new Yx(i.locale),i.ui.view.body.add(this.view));const{politeness:o,isUnsafeHTML:s}=typeof t=="string"?{politeness:t}:t;let r=this.view.regionViews.find(a=>a.politeness===o);r||(r=new Xx(i,o),this.view.regionViews.add(r)),r.announce({announcement:e,isUnsafeHTML:s})}}class Yx extends A{constructor(e){super(e),h(this,"regionViews"),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class Xx extends A{constructor(e,t){super(e.locale),h(this,"politeness"),h(this,"_domConverter"),h(this,"_pruneAnnouncementsInterval"),this.setTemplate({tag:"div",attributes:{"aria-live":t,"aria-relevant":"additions"},children:[{tag:"ul",attributes:{class:["ck","ck-aria-live-region-list"]}}]}),e.on("destroy",()=>{this._pruneAnnouncementsInterval!==null&&(clearInterval(this._pruneAnnouncementsInterval),this._pruneAnnouncementsInterval=null)}),this.politeness=t,this._domConverter=e.data.htmlProcessor.domConverter,this._pruneAnnouncementsInterval=setInterval(()=>{this.element&&this._listElement.firstChild&&this._listElement.firstChild.remove()},5e3)}announce({announcement:e,isUnsafeHTML:t}){if(!e.trim().length)return;const i=document.createElement("li");t?this._domConverter.setContentOf(i,e):i.innerText=e,this._listElement.appendChild(i)}get _listElement(){return this.element.querySelector("ul")}}class Oi extends Nt{constructor(e,t){super(e);const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item"]},on:{mouseenter:i.to("mouseenter")}}),this.delegate("mouseenter").to(t)}}const Gs=5,Dn={toggleMenusAndFocusItemsOnHover(n){n.on("menu:mouseenter",e=>{if(!(!n.isFocusBorderEnabled&&!n.isOpen)){if(n.isOpen)for(const t of n.menus){const i=e.path[0],o=i instanceof Oi&&i.children.first===t;t.isOpen=(e.path.includes(t)||o)&&t.isEnabled}e.source.focus()}})},focusCycleMenusOnArrows(n){const e=n.locale.uiLanguageDirection==="rtl";n.on("menu:arrowright",i=>{t(i.source,e?-1:1)}),n.on("menu:arrowleft",i=>{t(i.source,e?1:-1)});function t(i,o){const s=n.children.getIndex(i),r=i.isOpen,a=n.children.length,l=n.children.get((s+a+o)%a);i.isOpen=!1,r&&(l.isOpen=!0),l.buttonView.focus()}},closeMenusWhenTheBarCloses(n){n.on("change:isOpen",()=>{n.isOpen||n.menus.forEach(e=>{e.isOpen=!1})})},closeMenuWhenAnotherOnTheSameLevelOpens(n){n.on("menu:change:isOpen",(e,t,i)=>{i&&n.menus.filter(o=>e.source.parentMenuView===o.parentMenuView&&e.source!==o&&o.isOpen).forEach(o=>{o.isOpen=!1})})},closeOnClickOutside(n){$t({emitter:n,activator:()=>n.isOpen,callback:()=>n.close(),contextElements:()=>n.children.map(e=>e.element)})},enableFocusHighlightOnInteraction(n){let e=!1;n.on("change:isOpen",(t,i,o)=>{o||(e||(n.isFocusBorderEnabled=!1),e=!1)}),n.listenTo(n.element,"keydown",()=>{e=!0},{useCapture:!0}),n.listenTo(n.element,"keyup",()=>{e=!1},{useCapture:!0}),n.listenTo(n.element,"focus",()=>{e&&(n.isFocusBorderEnabled=!0)},{useCapture:!0})}},Fi={openAndFocusPanelOnArrowDownKey(n){n.keystrokes.set("arrowdown",(e,t)=>{n.isEnabled&&n.focusTracker.focusedElement===n.buttonView.element&&(n.isOpen||(n.isOpen=!0),n.panelView.focus(),t())})},openOnArrowRightKey(n){const e=n.locale.uiLanguageDirection==="rtl"?"arrowleft":"arrowright";n.keystrokes.set(e,(t,i)=>{n.focusTracker.focusedElement!==n.buttonView.element||!n.isEnabled||(n.isOpen||(n.isOpen=!0),n.panelView.focus(),i())})},openOnButtonClick(n){n.buttonView.on("execute",()=>{n.isOpen=!0})},toggleOnButtonClick(n){n.buttonView.on("execute",()=>{n.isOpen=!n.isOpen})},openAndFocusOnEnterKeyPress(n){n.keystrokes.set("enter",(e,t)=>{n.focusTracker.focusedElement===n.buttonView.element&&(n.isOpen=!0,n.panelView.focus(),t())})},closeOnArrowLeftKey(n){const e=n.locale.uiLanguageDirection==="rtl"?"arrowright":"arrowleft";n.keystrokes.set(e,(t,i)=>{n.isOpen&&(n.isOpen=!1,n.focus(),i())})},closeOnEscKey(n){n.keystrokes.set("esc",(e,t)=>{n.isOpen&&(n.isOpen=!1,n.focus(),t())})},closeOnParentClose(n){n.parentMenuView.on("change:isOpen",(e,t,i)=>{!i&&e.source===n.parentMenuView&&(n.isOpen=!1)})}},eT={southEast:n=>({top:n.bottom,left:n.left,name:"se"}),southWest:(n,e)=>({top:n.bottom,left:n.left-e.width+n.width,name:"sw"}),northEast:(n,e)=>({top:n.top-e.height,left:n.left,name:"ne"}),northWest:(n,e)=>({top:n.top-e.height,left:n.left-e.width+n.width,name:"nw"}),eastSouth:n=>({top:n.top,left:n.right-Gs,name:"es"}),eastNorth:(n,e)=>({top:n.top-e.height,left:n.right-Gs,name:"en"}),westSouth:(n,e)=>({top:n.top,left:n.left-e.width+Gs,name:"ws"}),westNorth:(n,e)=>({top:n.top-e.height,left:n.left-e.width+Gs,name:"wn"})},tT=[{menuId:"file",label:"File",groups:[{groupId:"export",items:["menuBar:exportPdf","menuBar:exportWord"]},{groupId:"import",items:["menuBar:importWord"]},{groupId:"revisionHistory",items:["menuBar:revisionHistory"]}]},{menuId:"edit",label:"Edit",groups:[{groupId:"undo",items:["menuBar:undo","menuBar:redo"]},{groupId:"selectAll",items:["menuBar:selectAll"]},{groupId:"findAndReplace",items:["menuBar:findAndReplace"]}]},{menuId:"view",label:"View",groups:[{groupId:"sourceEditingEnhanced",items:["menuBar:sourceEditingEnhanced"]},{groupId:"sourceEditing",items:["menuBar:sourceEditing"]},{groupId:"showBlocks",items:["menuBar:showBlocks"]},{groupId:"previewMergeFields",items:["menuBar:previewMergeFields"]},{groupId:"fullscreen",items:["menuBar:fullscreen"]},{groupId:"restrictedEditing",items:["menuBar:restrictedEditing"]}]},{menuId:"insert",label:"Insert",groups:[{groupId:"insertMainWidgets",items:["menuBar:insertImage","menuBar:ckbox","menuBar:ckfinder","menuBar:insertTable","menuBar:insertTableLayout"]},{groupId:"insertInline",items:["menuBar:link","menuBar:bookmark","menuBar:comment","menuBar:insertMergeField","menuBar:emoji"]},{groupId:"insertMinorWidgets",items:["menuBar:mediaEmbed","menuBar:insertTemplate","menuBar:specialCharacters","menuBar:blockQuote","menuBar:codeBlock","menuBar:htmlEmbed"]},{groupId:"insertStructureWidgets",items:["menuBar:horizontalLine","menuBar:pageBreak","menuBar:tableOfContents"]},{groupId:"restrictedEditingException",items:["menuBar:restrictedEditingException"]}]},{menuId:"format",label:"Format",groups:[{groupId:"textAndFont",items:[{menuId:"text",label:"Text",groups:[{groupId:"basicStyles",items:["menuBar:bold","menuBar:italic","menuBar:underline","menuBar:strikethrough","menuBar:superscript","menuBar:subscript","menuBar:code"]},{groupId:"textPartLanguage",items:["menuBar:textPartLanguage"]}]},{menuId:"font",label:"Font",groups:[{groupId:"fontProperties",items:["menuBar:fontSize","menuBar:fontFamily"]},{groupId:"fontColors",items:["menuBar:fontColor","menuBar:fontBackgroundColor"]},{groupId:"highlight",items:["menuBar:highlight"]}]},"menuBar:heading"]},{groupId:"list",items:["menuBar:bulletedList","menuBar:numberedList","menuBar:multiLevelList","menuBar:todoList"]},{groupId:"indent",items:["menuBar:alignment","menuBar:indent","menuBar:outdent"]},{groupId:"caseChange",items:["menuBar:caseChange"]},{groupId:"removeFormat",items:["menuBar:removeFormat"]}]},{menuId:"tools",label:"Tools",groups:[{groupId:"aiTools",items:["menuBar:aiAssistant","menuBar:aiCommands"]},{groupId:"tools",items:["menuBar:trackChanges","menuBar:commentsArchive"]}]},{menuId:"help",label:"Help",groups:[{groupId:"help",items:["menuBar:accessibilityHelp"]}]}];function iT(n){let e;return!("items"in n)||!n.items?e={items:mt(tT),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0,...n}:e={items:n.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1,...n},e}function nT({normalizedConfig:n,locale:e,componentFactory:t,extraItems:i}){const o=mt(n);return tm(n,o,i),oT(n,o),tm(n,o,o.addItems),sT(n,o,t),ob(n,o),rT(o,e),o}function oT(n,e){const t=e.removeItems,i=[];e.items=e.items.filter(({menuId:o})=>t.includes(o)?(i.push(o),!1):!0),Co(e.items,o=>{o.groups=o.groups.filter(({groupId:s})=>t.includes(s)?(i.push(s),!1):!0);for(const s of o.groups)s.items=s.items.filter(r=>{const a=sb(r);return t.includes(a)?(i.push(a),!1):!0})});for(const o of t)i.includes(o)||J("menu-bar-item-could-not-be-removed",{menuBarConfig:n,itemName:o})}function tm(n,e,t){const i=[];if(t.length!=0){for(const o of t){const s=cT(o.position),r=uT(o.position);if(aT(o))if(!r)s==="start"?(e.items.unshift(o.menu),i.push(o)):s==="end"&&(e.items.push(o.menu),i.push(o));else{const a=e.items.findIndex(l=>l.menuId===r);a!=-1?s==="before"?(e.items.splice(a,0,o.menu),i.push(o)):s==="after"&&(e.items.splice(a+1,0,o.menu),i.push(o)):im(e,o.menu,r,s)&&i.push(o)}else lT(o)?Co(e.items,a=>{if(a.menuId===r)s==="start"?(a.groups.unshift(o.group),i.push(o)):s==="end"&&(a.groups.push(o.group),i.push(o));else{const l=a.groups.findIndex(c=>c.groupId===r);l!==-1&&(s==="before"?(a.groups.splice(l,0,o.group),i.push(o)):s==="after"&&(a.groups.splice(l+1,0,o.group),i.push(o)))}}):im(e,o.item,r,s)&&i.push(o)}for(const o of t)i.includes(o)||J("menu-bar-item-could-not-be-added",{menuBarConfig:n,addedItemConfig:o})}}function im(n,e,t,i){let o=!1;return Co(n.items,s=>{for(const{groupId:r,items:a}of s.groups){if(o)return;if(r===t)i==="start"?(a.unshift(e),o=!0):i==="end"&&(a.push(e),o=!0);else{const l=a.findIndex(c=>sb(c)===t);l!==-1&&(i==="before"?(a.splice(l,0,e),o=!0):i==="after"&&(a.splice(l+1,0,e),o=!0))}}}),o}function sT(n,e,t){Co(e.items,i=>{for(const o of i.groups)o.items=o.items.filter(s=>{const r=typeof s=="string"&&!t.has(s);return r&&!e.isUsingDefaultConfig&&J("menu-bar-item-unavailable",{menuBarConfig:n,parentMenuConfig:mt(i),componentName:s}),!r})})}function ob(n,e){const t=e.isUsingDefaultConfig;let i=!1;if(e.items=e.items.filter(o=>o.groups.length?!0:(tl(n,o,t),!1)),!e.items.length){tl(n,n,t);return}Co(e.items,o=>{o.groups=o.groups.filter(s=>s.items.length?!0:(i=!0,!1));for(const s of o.groups)s.items=s.items.filter(r=>rb(r)&&!r.groups.length?(tl(n,r,t),i=!0,!1):!0)}),i&&ob(n,e)}function tl(n,e,t){t||J("menu-bar-menu-empty",{menuBarConfig:n,emptyMenuConfig:e})}function rT(n,e){const t=e.t,i={File:t({string:"File",id:"MENU_BAR_MENU_FILE"}),Edit:t({string:"Edit",id:"MENU_BAR_MENU_EDIT"}),View:t({string:"View",id:"MENU_BAR_MENU_VIEW"}),Insert:t({string:"Insert",id:"MENU_BAR_MENU_INSERT"}),Format:t({string:"Format",id:"MENU_BAR_MENU_FORMAT"}),Tools:t({string:"Tools",id:"MENU_BAR_MENU_TOOLS"}),Help:t({string:"Help",id:"MENU_BAR_MENU_HELP"}),Text:t({string:"Text",id:"MENU_BAR_MENU_TEXT"}),Font:t({string:"Font",id:"MENU_BAR_MENU_FONT"})};Co(n.items,o=>{o.label in i&&(o.label=i[o.label])})}function Co(n,e){if(Array.isArray(n))for(const i of n)t(i);function t(i){e(i);for(const o of i.groups)for(const s of o.items)rb(s)&&t(s)}}function aT(n){return typeof n=="object"&&"menu"in n}function lT(n){return typeof n=="object"&&"group"in n}function cT(n){return n.startsWith("start")?"start":n.startsWith("end")?"end":n.startsWith("after")?"after":"before"}function uT(n){const e=n.match(/^[^:]+:(.+)/);return e?e[1]:null}function sb(n){return typeof n=="string"?n:n.menuId}function rb(n){return typeof n=="object"&&"menuId"in n}class ab extends ue(){constructor(e){super(),h(this,"editor"),h(this,"componentFactory"),h(this,"focusTracker"),h(this,"tooltipManager"),h(this,"poweredBy"),h(this,"evaluationBadge"),h(this,"ariaLiveAnnouncer"),h(this,"isReady",!1),h(this,"_editableElementsMap",new Map),h(this,"_focusableToolbarDefinitions",[]),h(this,"_extraMenuBarElements",[]),h(this,"_lastFocusedForeignElement",null),h(this,"_domEmitter");const t=e.editing.view;this.editor=e,this.componentFactory=new Dx(e),this.focusTracker=new ee,this.tooltipManager=new zx(e),this.poweredBy=new Gx(e),this.evaluationBadge=new Zx(e),this.ariaLiveAnnouncer=new Qx(e),this._initViewportOffset(this._readViewportOffsetFromConfig()),this.once("ready",()=>{this._bindBodyCollectionWithFocusTracker(),this.isReady=!0}),this.listenTo(t.document,"layoutChanged",this.update.bind(this)),this.listenTo(t,"scrollToTheSelection",this._handleScrollToTheSelection.bind(this)),this._initFocusTracking(),this._initVisualViewportSupport()}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy(),this.evaluationBadge.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[],this._domEmitter&&this._domEmitter.stopListening()}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor),this.focusTracker.add(t);const i=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?i():this.once("ready",i)}removeEditableElement(e){const t=this._editableElementsMap.get(e);t&&(this._editableElementsMap.delete(e),this.editor.keystrokes.stopListening(t),this.focusTracker.remove(t),t.ckeditorInstance=null)}getEditableElement(e="main"){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}addToolbar(e,t={}){e.isRendered?(this.focusTracker.add(e),this.editor.keystrokes.listenTo(e.element)):e.once("render",()=>{this.focusTracker.add(e),this.editor.keystrokes.listenTo(e.element)}),this._focusableToolbarDefinitions.push({toolbarView:e,options:t})}extendMenuBar(e){this._extraMenuBarElements.push(e)}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}initMenuBar(e){const t=e.element;this.focusTracker.add(t),this.editor.keystrokes.listenTo(t);const i=iT(this.editor.config.get("menuBar")||{});e.fillFromConfig(i,this.componentFactory,this._extraMenuBarElements),this.editor.keystrokes.set("Esc",(o,s)=>{t.contains(this.editor.ui.focusTracker.focusedElement)&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):this.editor.editing.view.focus(),s())}),this.editor.keystrokes.set("Alt+F9",(o,s)=>{t.contains(this.editor.ui.focusTracker.focusedElement)||(this._saveLastFocusedForeignElement(),e.isFocusBorderEnabled=!0,e.focus(),s())})}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const i=e.config.get("toolbar.viewportTopOffset");return i?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:i}):{top:0}}_initFocusTracking(){const e=this.editor;let t;e.keystrokes.set("Alt+F10",(i,o)=>{this._saveLastFocusedForeignElement();const s=this._getCurrentFocusedToolbarDefinition();(!s||!t)&&(t=this._getFocusableCandidateToolbarDefinitions());for(let r=0;r<t.length;r++){const a=t.shift();if(t.push(a),a!==s&&this._focusFocusableCandidateToolbar(a)){s&&s.options.afterBlur&&s.options.afterBlur();break}}o()}),e.keystrokes.set("Esc",(i,o)=>{const s=this._getCurrentFocusedToolbarDefinition();s&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):e.editing.view.focus(),s.options.afterBlur&&s.options.afterBlur(),o())})}_saveLastFocusedForeignElement(){const e=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(e)&&!Array.from(this.editor.editing.view.domRoots.values()).includes(e)&&(this._lastFocusedForeignElement=e)}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:i,options:o}=t;(Gt(i.element)||o.beforeFocus)&&e.push(t)}return e.sort((t,i)=>nm(t)-nm(i)),e}_getCurrentFocusedToolbarDefinition(){for(const e of this._focusableToolbarDefinitions)if(e.toolbarView.element&&e.toolbarView.element.contains(this.focusTracker.focusedElement))return e;return null}_focusFocusableCandidateToolbar(e){const{toolbarView:t,options:{beforeFocus:i}}=e;return i&&i(),Gt(t.element)?(t.focus(),!0):!1}_handleScrollToTheSelection(e,t){const i={top:0,bottom:0,left:0,right:0,...this.viewportOffset};t.viewportOffset.top+=i.top,t.viewportOffset.bottom+=i.bottom,t.viewportOffset.left+=i.left,t.viewportOffset.right+=i.right}_bindBodyCollectionWithFocusTracker(){const e=this.view.body;for(const t of e)this.focusTracker.add(t.element);e.on("add",(t,i)=>{this.focusTracker.add(i.element)}),e.on("remove",(t,i)=>{this.focusTracker.remove(i.element)})}_initViewportOffset(e){this.on("set:viewportOffset",(t,i,o)=>{const s=this._getVisualViewportTopOffset(o);o.visualTop!==s&&(t.return={...o,visualTop:s})}),this.set("viewportOffset",e)}_initVisualViewportSupport(){if(!I.window.visualViewport)return;const e=()=>{const t=this._getVisualViewportTopOffset(this.viewportOffset);this.viewportOffset.visualTop!==t&&(this.viewportOffset={...this.viewportOffset,visualTop:t})};this._domEmitter=new(st()),this._domEmitter.listenTo(I.window.visualViewport,"scroll",e),this._domEmitter.listenTo(I.window.visualViewport,"resize",e)}_getVisualViewportTopOffset(e){const t=av().top,i=e.top||0;return t>i?0:i-t}}function nm(n){const{toolbarView:e,options:t}=n;let i=10;return Gt(e.element)&&i--,t.isContextual&&(i-=2),i}class lb extends A{constructor(e){super(e),h(this,"body"),h(this,"menuBarView"),h(this,"toolbar"),this.body=new rx(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class hT extends A{constructor(e,t,i){super(e),h(this,"name",null),h(this,"_editingView"),h(this,"_editableElement"),h(this,"_hasExternalElement"),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.set("isFocused",!1),this._editableElement=i,this._hasExternalElement=!!this._editableElement,this._editingView=t}render(){super.render(),this._hasExternalElement?this.template.apply(this.element=this._editableElement):this._editableElement=this.element,this.on("change:isFocused",()=>this._updateIsFocusedClasses()),this._updateIsFocusedClasses()}destroy(){this._hasExternalElement&&this.template.revert(this._editableElement),super.destroy()}get hasExternalElement(){return this._hasExternalElement}_updateIsFocusedClasses(){const e=this._editingView;e.isRenderingInProgress?i(this):t(this);function t(o){e.change(s=>{const r=e.document.getRoot(o.name);s.addClass(o.isFocused?"ck-focused":"ck-blurred",r),s.removeClass(o.isFocused?"ck-blurred":"ck-focused",r)})}function i(o){e.once("change:isRenderingInProgress",(s,r,a)=>{a?i(o):t(o)})}}}class cb extends hT{constructor(e,t,i,o={}){super(e,t,i),h(this,"_options"),this._options=o,this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const e=this._editingView;e.change(t=>{const i=e.document.getRoot(this.name);t.setAttribute("aria-label",this.getEditableAriaLabel(),i)})}getEditableAriaLabel(){const e=this.locale.t,t=this._options.label,i=this._editableElement,o=this.name;if(typeof t=="string")return t;if(typeof t=="object")return t[o];if(typeof t=="function")return t(this);if(i){const s=i.getAttribute("aria-label");if(s)return s}return e("Rich Text Editor. Editing area: %0",o)}}class $e extends A{constructor(e,t={}){super(e),h(this,"children");const i=this.bindTemplate;this.set("class",["ck","ck-form__row",...he(t.class||[])]),this.children=this.createCollection(),t.children&&t.children.forEach(o=>this.children.add(o)),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:i.to("class",o=>o.join(" ")),role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}class Nr extends uw{static get pluginName(){return"Notification"}static get isOfficialPlugin(){return!0}init(){this.on("show:warning",(e,t)=>{window.alert(t.message)},{priority:"lowest"})}showSuccess(e,t={}){this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t=e.namespace?`show:${e.type}:${e.namespace}`:`show:${e.type}`;this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}class et extends ue(){constructor(e,t){super(),t&&Rg(this,t),e&&this.set(e)}}const Ks=Vi("px");class Ue extends w{constructor(e){super(e),h(this,"positionLimiter"),h(this,"visibleStack"),h(this,"_viewToStack",new Map),h(this,"_idToStack",new Map),h(this,"_view",null),h(this,"_rotatorView",null),h(this,"_fakePanelsView",null),this.positionLimiter=()=>{const t=this.editor.editing.view,i=t.document.selection.editableElement;return i?t.domConverter.mapViewToDom(i.root):null},this.decorate("getPositionOptions"),this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}static get pluginName(){return"ContextualBalloon"}static get isOfficialPlugin(){return!0}destroy(){super.destroy(),this._view&&this._view.destroy(),this._rotatorView&&this._rotatorView.destroy(),this._fakePanelsView&&this._fakePanelsView.destroy()}get view(){return this._view||this._createPanelView(),this._view}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this._view||this._createPanelView(),this.hasView(e.view))throw new b("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t)){this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,(!this._visibleStack||e.singleViewMode)&&this.showStack(t);return}const i=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),i.set(e.view,e),this._viewToStack.set(e.view,i),i===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new b("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(t.size===1?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),t.size===1?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition()}getPositionOptions(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&(e.limiter||(e=Object.assign({},e,{limiter:this.positionLimiter})),e=Object.assign({},e,{viewportOffsetConfig:{...this.editor.ui.viewportOffset,top:this.editor.ui.viewportOffset.visualTop}})),e}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new b("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new Ne(this.editor.locale),this.editor.ui.view.body.add(this._view),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(e){return Array.from(this._idToStack.entries()).find(t=>t[1]===e)[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new dT(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",(i,o)=>!o&&i>1),e.on("change:isNavigationVisible",()=>this.updatePosition(),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",(i,o)=>{if(o<2)return"";const s=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[s,o])}),e.buttonNextView.on("execute",()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()}),e.buttonPrevView.on("execute",()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()}),e}_createFakePanelsView(){const e=new mT(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",(t,i)=>!i&&t>=2?Math.min(t-1,2):0),e.listenTo(this.view,"change:top",()=>e.updatePosition()),e.listenTo(this.view,"change:left",()=>e.updatePosition()),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:i=!0,singleViewMode:o=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition(),o&&(this._singleViewMode=!0)}}class dT extends A{constructor(e){super(e),h(this,"focusTracker"),h(this,"buttonPrevView"),h(this,"buttonNextView"),h(this,"content");const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new ee,this.buttonPrevView=this._createButtonView(t("Previous"),li),this.buttonNextView=this._createButtonView(t("Next"),ww),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",i.to("isNavigationVisible",o=>o?"":"ck-hidden")]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:i.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const i=new P(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class mT extends A{constructor(e,t){super(e),h(this,"content"),h(this,"_balloonPanelView");const i=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",i.to("numberOfPanels",o=>o?"":"ck-hidden")],style:{top:i.to("top",Ks),left:i.to("left",Ks),width:i.to("width",Ks),height:i.to("height",Ks)}},children:this.content}),this.on("change:numberOfPanels",(o,s,r,a)=>{r>a?this._addPanels(r-a):this._removePanels(a-r),this.updatePosition()})}_addPanels(e){for(;e--;){const t=new A;t.setTemplate({tag:"div"}),this.content.add(t),this.registerChild(t)}}_removePanels(e){for(;e--;){const t=this.content.last;this.content.remove(t),this.deregisterChild(t),t.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:i,height:o}=new z(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:o})}}}class fT extends Te{constructor(e,t){const i=e.t,o=Object.assign({},{showResetButton:!0,showIcon:!0,creator:nt},t);super(e,o.creator),h(this,"iconView"),h(this,"resetButtonView"),h(this,"_viewConfig"),this.label=t.label,this._viewConfig=o,this._viewConfig.showIcon&&(this.iconView=new hi,this.iconView.content=qC,this.fieldWrapperChildren.add(this.iconView,0),this.extendTemplate({attributes:{class:"ck-search__query_with-icon"}})),this._viewConfig.showResetButton&&(this.resetButtonView=new P(e),this.resetButtonView.set({label:i("Clear"),icon:_o,class:"ck-search__reset",isVisible:!1,tooltip:!0}),this.resetButtonView.on("execute",()=>{this.reset(),this.focus(),this.fire("reset")}),this.resetButtonView.bind("isVisible").to(this.fieldView,"isEmpty",s=>!s),this.fieldWrapperChildren.add(this.resetButtonView),this.extendTemplate({attributes:{class:"ck-search__query_with-reset"}}))}reset(){this.fieldView.reset(),this._viewConfig.showResetButton&&(this.resetButtonView.isVisible=!1)}}class ub extends A{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,primaryText:"",secondaryText:""}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__info",e.if("isVisible","ck-hidden",t=>!t)],tabindex:-1},children:[{tag:"span",children:[{text:[e.to("primaryText")]}]},{tag:"span",children:[{text:[e.to("secondaryText")]}]}]})}focus(){this.element.focus()}}class gT extends A{constructor(e){super(e),h(this,"focusTracker"),h(this,"children"),h(this,"_focusCycler"),this.children=this.createCollection(),this.focusTracker=new ee,this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__results"],tabindex:-1},children:this.children}),this._focusCycler=new Ae({focusables:this.children,focusTracker:this.focusTracker})}render(){super.render();for(const e of this.children)this.focusTracker.add(e.element)}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}class pT extends A{constructor(e,t){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"resultsView"),h(this,"filteredView"),h(this,"infoView"),h(this,"queryView"),h(this,"focusCycler"),h(this,"_config"),this._config=t,this.filteredView=t.filteredView,this.queryView=this._createSearchTextQueryView(),this.focusTracker=new ee,this.keystrokes=new te,this.resultsView=new gT(e),this.children=this.createCollection(),this.focusableChildren=this.createCollection([this.queryView,this.resultsView]),this.set("isEnabled",!0),this.set("resultsCount",0),this.set("totalItemsCount",0),t.infoView&&t.infoView.instance?this.infoView=t.infoView.instance:(this.infoView=new ub,this._enableDefaultInfoViewBehavior(),this.on("render",()=>{this.search("")})),this.resultsView.children.addMany([this.infoView,this.filteredView]),this.focusCycler=new Ae({focusables:this.focusableChildren,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.on("search",(i,{resultsCount:o,totalItemsCount:s})=>{this.resultsCount=o,this.totalItemsCount=s}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search",t.class||null],tabindex:"-1"},children:this.children})}render(){super.render(),this.children.addMany([this.queryView,this.resultsView]);const e=t=>t.stopPropagation();for(const t of this.focusableChildren)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}focus(){this.queryView.focus()}reset(){this.queryView.reset(),this.search(""),this.filteredView.element.scrollTo(0,0)}search(e){const t=e?new RegExp(ta(e),"ig"):null,i=this.filteredView.filter(t);this.fire("search",{query:e,...i})}_createSearchTextQueryView(){const e=new fT(this.locale,this._config.queryView);return this.listenTo(e.fieldView,"input",()=>{this.search(e.fieldView.element.value)}),e.on("reset",()=>this.reset()),e.bind("isEnabled").to(this),e}_enableDefaultInfoViewBehavior(){const e=this.locale.t,t=this.infoView;this.on("search",(o,s)=>{if(s.resultsCount)t.set({isVisible:!1});else{const r=this._config.infoView&&this._config.infoView.text;let a,l;s.totalItemsCount?r!=null&&r.notFound?(a=r.notFound.primary,l=r.notFound.secondary):(a=e("No results found"),l=""):r!=null&&r.noSearchableItems?(a=r.noSearchableItems.primary,l=r.noSearchableItems.secondary):(a=e("No searchable items"),l=""),t.set({primaryText:i(a,s),secondaryText:i(l,s),isVisible:!0})}});function i(o,{query:s,resultsCount:r,totalItemsCount:a}){return typeof o=="function"?o(s,r,a):o}}}const wT=Vi("px");class bT extends w{constructor(e){super(e),h(this,"toolbarView"),h(this,"focusTracker"),h(this,"_balloonConfig"),h(this,"_resizeObserver",null),h(this,"_balloon"),h(this,"_fireSelectionChangeDebounced"),this._balloonConfig=gu(e.config.get("balloonToolbar")),this.toolbarView=this._createToolbarView(),this.focusTracker=new ee,this._trackFocusableEditableElements(),this.focusTracker.add(this.toolbarView),e.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this.show(!0),afterBlur:()=>this.hide(),isContextual:!0}),this._balloon=e.plugins.get(Ue),this._fireSelectionChangeDebounced=St(()=>this.fire("_selectionChangeDebounced"),200),this.decorate("show")}static get pluginName(){return"BalloonToolbar"}static get isOfficialPlugin(){return!0}static get requires(){return[Ue]}init(){const e=this.editor,t=e.model.document.selection;this.listenTo(this.focusTracker,"change:isFocused",(i,o,s)=>{const r=this._balloon.visibleView===this.toolbarView;!s&&r?this.hide():s&&this.show()}),this.listenTo(t,"change:range",(i,o)=>{(o.directChange||t.isCollapsed)&&this.hide(),this._fireSelectionChangeDebounced()}),this.listenTo(this,"_selectionChangeDebounced",()=>{this.editor.editing.view.document.isFocused&&this.show()}),this._balloonConfig.shouldNotGroupWhenFull||this.listenTo(e,"ready",()=>{const i=e.ui.view.editable.element;this._resizeObserver=new bo(i,o=>{this.toolbarView.maxWidth=wT(o.contentRect.width*.9)})}),this.listenTo(this.toolbarView,"groupedItemsUpdate",()=>{this._updatePosition()}),e.ui.once("ready",()=>{this.toolbarView.fillFromConfig(this._balloonConfig,this.editor.ui.componentFactory)})}_createToolbarView(){const e=this.editor.locale.t,t=!this._balloonConfig.shouldNotGroupWhenFull,i=new Ei(this.editor.locale,{shouldGroupWhenFull:t,isFloating:!0});return i.ariaLabel=e("Editor contextual toolbar"),i.render(),i}show(e=!1){const t=this.editor,i=t.model.document.selection,o=t.model.schema;this._balloon.hasView(this.toolbarView)||i.isCollapsed&&!e||_T(i,o)||Array.from(this.toolbarView.items).every(s=>s.isEnabled!==void 0&&!s.isEnabled)||(this.listenTo(this.editor.ui,"update",()=>{this._updatePosition()}),this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"}))}hide(){this._balloon.hasView(this.toolbarView)&&(this.stopListening(this.editor.ui,"update"),this._balloon.remove(this.toolbarView))}_trackFocusableEditableElements(){const{editor:e,focusTracker:t}=this,{editing:i}=e;i.view.addObserver(class extends Zt{observe(o){t.add(o)}stopObserving(o){t.remove(o)}})}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document,i=t.selection,o=t.selection.isBackward;return{target:()=>{const s=o?i.getFirstRange():i.getLastRange(),r=z.getDomRangeRects(e.domConverter.viewRangeToDom(s));return o?r[0]:(r.length>1&&r[r.length-1].width===0&&r.pop(),r[r.length-1])},positions:this._getBalloonPositions(o)}}_updatePosition(){this._balloon.updatePosition(this._getBalloonPositionData())}destroy(){super.destroy(),this.stopListening(),this._fireSelectionChangeDebounced.cancel(),this.toolbarView.destroy(),this.focusTracker.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_getBalloonPositions(e){const t=N.isSafari&&N.isiOS?Ne.generatePositions({heightOffset:Math.max(Ne.arrowHeightOffset,Math.round(20/I.window.visualViewport.scale))}):Ne.defaultPositions;return e?[t.northWestArrowSouth,t.northWestArrowSouthWest,t.northWestArrowSouthEast,t.northWestArrowSouthMiddleEast,t.northWestArrowSouthMiddleWest,t.southWestArrowNorth,t.southWestArrowNorthWest,t.southWestArrowNorthEast,t.southWestArrowNorthMiddleWest,t.southWestArrowNorthMiddleEast]:[t.southEastArrowNorth,t.southEastArrowNorthEast,t.southEastArrowNorthWest,t.southEastArrowNorthMiddleEast,t.southEastArrowNorthMiddleWest,t.northEastArrowSouth,t.northEastArrowSouthEast,t.northEastArrowSouthWest,t.northEastArrowSouthMiddleEast,t.northEastArrowSouthMiddleWest]}}function _T(n,e){return n.rangeCount===1?!1:[...n.getRanges()].every(t=>{const i=t.getContainedElement();return i&&e.isSelectable(i)})}const om=Vi("px");class vT extends P{constructor(e){super(e);const t=this.bindTemplate;this.isVisible=!1,this.isToggleable=!0,this.set("top",0),this.set("left",0),this.extendTemplate({attributes:{class:"ck-block-toolbar-button",style:{top:t.to("top",i=>om(i)),left:t.to("left",i=>om(i))}}})}}const Ro=Vi("px");class yT extends w{constructor(e){super(e),h(this,"toolbarView"),h(this,"panelView"),h(this,"buttonView"),h(this,"_resizeObserver",null),h(this,"_blockToolbarConfig"),this._blockToolbarConfig=gu(this.editor.config.get("blockToolbar")),this.toolbarView=this._createToolbarView(),this.panelView=this._createPanelView(),this.buttonView=this._createButtonView(),$t({emitter:this.panelView,contextElements:[this.panelView.element,this.buttonView.element],activator:()=>this.panelView.isVisible,callback:()=>this._hidePanel()})}static get pluginName(){return"BlockToolbar"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=t("Click to edit block"),o=t("Drag to move"),s=t("Edit block"),r=e.plugins.has("DragDropBlockToolbar"),a=r?`${i}
${o}`:s;this.buttonView.label=a,r&&(this.buttonView.element.dataset.ckeTooltipClass="ck-tooltip_multi-line"),this.listenTo(e.model.document.selection,"change:range",(l,c)=>{c.directChange&&this._hidePanel()}),this.listenTo(e.ui,"update",()=>this._updateButton()),this.listenTo(e,"change:isReadOnly",()=>this._updateButton(),{priority:"low"}),this.listenTo(e.ui.focusTracker,"change:isFocused",()=>this._updateButton()),this.listenTo(this.buttonView,"change:isVisible",(l,c,u)=>{u?this.buttonView.listenTo(window,"resize",()=>this._updateButton()):(this.buttonView.stopListening(window,"resize"),this._hidePanel())}),this._repositionButtonOnScroll(),e.ui.addToolbar(this.toolbarView,{beforeFocus:()=>this._showPanel(),afterBlur:()=>this._hidePanel()}),e.ui.once("ready",()=>{this.toolbarView.fillFromConfig(this._blockToolbarConfig,this.editor.ui.componentFactory);for(const l of this.toolbarView.items)l.on("execute",()=>this._hidePanel(!0),{priority:"high"})})}destroy(){super.destroy(),this.panelView.destroy(),this.buttonView.destroy(),this.toolbarView.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_createToolbarView(){const e=this.editor.locale.t,t=!this._blockToolbarConfig.shouldNotGroupWhenFull,i=new Ei(this.editor.locale,{shouldGroupWhenFull:t,isFloating:!0});return i.ariaLabel=e("Editor block content toolbar"),i}_createPanelView(){const e=this.editor,t=new Ne(e.locale);return t.content.add(this.toolbarView),t.class="ck-toolbar-container",e.ui.view.body.add(t),this.toolbarView.keystrokes.set("Esc",(i,o)=>{this._hidePanel(!0),o()}),t}_createButtonView(){const e=this.editor,t=e.t,i=new vT(e.locale),o=this._blockToolbarConfig.icon,s=tc[o]||o||tc.dragIndicator;return i.set({label:t("Edit block"),icon:s,withText:!1}),i.bind("isOn").to(this.panelView,"isVisible"),i.bind("tooltip").to(this.panelView,"isVisible",r=>!r),this.listenTo(i,"execute",()=>{this.panelView.isVisible?this._hidePanel(!0):this._showPanel()}),this.listenTo(i,"change:isEnabled",(r,a,l)=>{!l&&this.panelView.isVisible&&this._hidePanel(!1)}),e.ui.view.body.add(i),i}_updateButton(){const e=this.editor,t=e.model,i=e.editing.view;if(!e.ui.focusTracker.isFocused){this._hideButton();return}if(!e.model.canEditAt(e.model.document.selection)){this._hideButton();return}const o=Array.from(t.document.selection.getSelectedBlocks())[0];if(!o||Array.from(this.toolbarView.items).every(r=>!r.isEnabled)){this._hideButton();return}const s=i.domConverter.mapViewToDom(e.editing.mapper.toViewElement(o));this.buttonView.isVisible=!0,this._setupToolbarResize(),this._attachButtonToElement(s),this.panelView.isVisible&&this._showPanel()}_hideButton(){this.buttonView.isVisible=!1}_showPanel(){if(!this.buttonView.isVisible)return;const e=this.panelView.isVisible;this.panelView.show();const t=this._getSelectedEditableElement();this.toolbarView.maxWidth=this._getToolbarMaxWidth(t),this.panelView.pin({target:this.buttonView.element,limiter:t}),e||this.toolbarView.items.get(0).focus()}_getSelectedEditableElement(){const e=this.editor.model.document.selection.getFirstRange().root.rootName;return this.editor.ui.getEditableElement(e)}_hidePanel(e){this.panelView.isVisible=!1,e&&this.editor.editing.view.focus()}_repositionButtonOnScroll(){const{buttonView:e}=this;let t=!1;const i=(o,s)=>{if(t)return;const r=this._getSelectedEditableElement();s.target!==I.document&&!Zg(r).includes(s.target)||(t=!0,I.window.requestAnimationFrame(()=>{this._updateButton(),t=!1}))};e.on("change:isVisible",(o,s,r)=>{r?e.listenTo(I.document,"scroll",i,{useCapture:!0,usePassive:!0}):e.stopListening(I.document,"scroll",i)})}_attachButtonToElement(e){const t=this.buttonView.element,i=this._getSelectedEditableElement(),o=window.getComputedStyle(e),s=new z(i),r=parseInt(o.paddingTop,10),a=parseInt(o.lineHeight,10)||parseInt(o.fontSize,10)*1.2,l=new z(t),c=new z(e);let u;this.editor.locale.uiLanguageDirection==="ltr"?u=s.left-l.width:u=s.right;const d=c.top+r+(a-l.height)/2;l.moveTo(u,d);const m=l.toAbsoluteRect();this.buttonView.top=m.top,this.buttonView.left=m.left,this._clipButtonToViewport(this.buttonView,i)}_clipButtonToViewport(e,t){const i=new z(e.element),o=new z(t).getVisible(),s=(...a)=>{e.element.style.clipPath=a.length?`polygon(${a.join(",")})`:""},r=a=>{e.isEnabled=!a,e.element.style.pointerEvents=a?"none":""};if(o&&o.bottom<i.bottom){const a=Math.min(i.height,i.bottom-o.bottom);r(a>=i.height),s("0 0","100% 0",`100% calc(100% - ${Ro(a)})`,`0 calc(100% - ${Ro(a)}`)}else if(o&&o.top>i.top){const a=Math.min(i.height,o.top-i.top);r(a>=i.height),s(`0 ${Ro(a)}`,`100% ${Ro(a)}`,"100% 100%","0 100%")}else r(!1),s()}_setupToolbarResize(){const e=this._getSelectedEditableElement();this._blockToolbarConfig.shouldNotGroupWhenFull||(this._resizeObserver&&this._resizeObserver.element!==e&&(this._resizeObserver.destroy(),this._resizeObserver=null),this._resizeObserver||(this._resizeObserver=new bo(e,()=>{this.toolbarView.maxWidth=this._getToolbarMaxWidth(e)})))}_getToolbarMaxWidth(e){const t=new z(e),i=new z(this.buttonView.element),o=this.editor.locale.uiLanguageDirection==="rtl"?i.left-t.right+i.width:t.left-i.left;return Ro(t.width+o)}}class kT extends ko{constructor(e){super(e),h(this,"arrowView");const t=this.bindTemplate;this.set({withText:!0,role:"menuitem"}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__button"],"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",i=>String(i)),"data-cke-tooltip-disabled":t.to("isOn")},on:{mouseenter:t.to("mouseenter")}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new hi;return e.content=da,e.extendTemplate({attributes:{class:"ck-menu-bar__menu__button__arrow"}}),e}}class CT extends A{constructor(e){super(e),h(this,"children");const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-menu-bar__menu__panel",t.to("position",i=>`ck-menu-bar__menu__panel_position_${i}`),t.if("isVisible","ck-hidden",i=>!i)],tabindex:"-1"},children:this.children,on:{selectstart:t.to(i=>{i.target.tagName.toLocaleLowerCase()!=="input"&&i.preventDefault()})}})}focus(e=1){this.children.length&&(e===1?this.children.first.focus():this.children.last.focus())}}const hb=class db extends A{constructor(e){super(e),h(this,"buttonView"),h(this,"panelView"),h(this,"focusTracker"),h(this,"keystrokes");const t=this.bindTemplate;this.buttonView=new kT(e),this.buttonView.delegate("mouseenter").to(this),this.buttonView.bind("isOn","isEnabled").to(this,"isOpen","isEnabled"),this.panelView=new CT(e),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new te,this.focusTracker=new ee,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("panelPosition","w"),this.set("class",void 0),this.set("parentMenuView",null),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar__menu",t.to("class"),t.if("isEnabled","ck-disabled",i=>!i),t.if("parentMenuView","ck-menu-bar__menu_top-level",i=>!i)]},children:[this.buttonView,this.panelView]})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.keystrokes.listenTo(this.element),Fi.closeOnEscKey(this),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(Fi.openOnButtonClick(this),Fi.openOnArrowRightKey(this),Fi.closeOnArrowLeftKey(this),Fi.openAndFocusOnEnterKeyPress(this),Fi.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),Fi.openAndFocusPanelOnArrowDownKey(this),Fi.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set("arrowright",(e,t)=>{this.fire("arrowright"),t()}),this.keystrokes.set("arrowleft",(e,t)=>{this.fire("arrowleft"),t()})}_repositionPanelOnOpen(){this.on("change:isOpen",(e,t,i)=>{if(!i)return;const o=db._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=o?o.name:this._defaultMenuPositionName})}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:e,southWest:t,northEast:i,northWest:o,westSouth:s,eastSouth:r,westNorth:a,eastNorth:l}=eT;return this.locale.uiLanguageDirection==="ltr"?this.parentMenuView?[r,l,s,a]:[e,t,i,o]:this.parentMenuView?[s,a,r,l]:[t,e,o,i]}get _defaultMenuPositionName(){return this.locale.uiLanguageDirection==="ltr"?this.parentMenuView?"es":"se":this.parentMenuView?"ws":"sw"}};h(hb,"_getOptimalPosition",zc);let Tt=hb;class Si extends En{constructor(e){super(e),this.role="menu",this.items.on("change",this._setItemsCheckSpace.bind(this))}_setItemsCheckSpace(){const e=Array.from(this.items).some(t=>{const i=sm(t);return i&&i.isToggleable});this.items.forEach(t=>{const i=sm(t);i&&(i.hasCheckSpace=e)})}}function sm(n){return n instanceof Nt?n.children.map(e=>AT(e)?e.buttonView:e).find(e=>e instanceof ko):null}function AT(n){return typeof n=="object"&&"buttonView"in n&&n.buttonView instanceof P}class mb extends ax{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}const rm=["mouseenter","arrowleft","arrowright","change:isOpen"];class fb extends A{constructor(e){super(e),h(this,"children"),h(this,"menus",[]);const t=e.t,i=this.bindTemplate;this.set({isOpen:!1,isFocusBorderEnabled:!1}),this._setupIsOpenUpdater(),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar",i.if("isFocusBorderEnabled","ck-menu-bar_focus-border-enabled")],"aria-label":t("Editor menu bar"),role:"menubar"},children:this.children})}fillFromConfig(e,t,i=[]){const o=this.locale,s=nT({normalizedConfig:e,locale:o,componentFactory:t,extraItems:i}).items.map(r=>this._createMenu({componentFactory:t,menuDefinition:r}));this.children.addMany(s)}render(){super.render(),Dn.toggleMenusAndFocusItemsOnHover(this),Dn.closeMenusWhenTheBarCloses(this),Dn.closeMenuWhenAnotherOnTheSameLevelOpens(this),Dn.focusCycleMenusOnArrows(this),Dn.closeOnClickOutside(this),Dn.enableFocusHighlightOnInteraction(this)}focus(){this.children.first&&this.children.first.focus()}close(){for(const e of this.children)e.isOpen=!1}disable(){for(const e of this.children)e.isEnabled=!1}enable(){for(const e of this.children)e.isEnabled=!0}registerMenu(e,t=null){t?(e.delegate(...rm).to(t),e.parentMenuView=t):e.delegate(...rm).to(this,i=>"menu:"+i),e._attachBehaviors(),this.menus.push(e)}_createMenu({componentFactory:e,menuDefinition:t,parentMenuView:i}){const o=this.locale,s=new Tt(o);return this.registerMenu(s,i),s.buttonView.set({label:t.label}),s.once("change:isOpen",()=>{const r=new Si(o);r.ariaLabel=t.label,s.panelView.children.add(r),r.items.addMany(this._createMenuItems({menuDefinition:t,parentMenuView:s,componentFactory:e}))}),s}_createMenuItems({menuDefinition:e,parentMenuView:t,componentFactory:i}){const o=this.locale,s=[];for(const r of e.groups){for(const a of r.items){const l=new Oi(o,t);if(Et(a))l.children.add(this._createMenu({componentFactory:i,menuDefinition:a,parentMenuView:t}));else{const c=this._createMenuItemContentFromFactory({componentName:a,componentFactory:i,parentMenuView:t});if(!c)continue;l.children.add(c)}s.push(l)}r!==e.groups[e.groups.length-1]&&s.push(new ma(o))}return s}_createMenuItemContentFromFactory({componentName:e,parentMenuView:t,componentFactory:i}){const o=i.create(e);return o instanceof Tt||o instanceof ve||o instanceof mb?(this._registerMenuTree(o,t),o.on("execute",()=>{this.close()}),o):(J("menu-bar-component-unsupported",{componentName:e,componentView:o}),null)}_registerMenuTree(e,t){if(!(e instanceof Tt)){e.delegate("mouseenter").to(t);return}this.registerMenu(e,t);const i=e.panelView.children.filter(s=>s instanceof Si)[0];if(!i){e.delegate("mouseenter").to(t);return}const o=i.items.filter(s=>s instanceof Nt);for(const s of o)this._registerMenuTree(s.children.get(0),e)}_setupIsOpenUpdater(){let e;this.on("menu:change:isOpen",(t,i,o)=>{clearTimeout(e),o?this.isOpen=!0:e=setTimeout(()=>{this.isOpen=Array.from(this.children).some(s=>s.isOpen)},0)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const bu=["left","right","center","justify"];function gb(n){return bu.includes(n)}function pb(n,e){return e.contentLanguageDirection=="rtl"?n==="right":n==="left"}function wb(n){const e=n.map(i=>{let o;return typeof i=="string"?o={name:i}:o=i,o}).filter(i=>{const o=bu.includes(i.name);return o||J("alignment-config-name-not-recognized",{option:i}),o}),t=e.filter(i=>!!i.className).length;if(t&&t<e.length)throw new b("alignment-config-classnames-are-missing",{configuredOptions:n});return e.forEach((i,o,s)=>{const r=s.slice(o+1);if(r.some(a=>a.name==i.name))throw new b("alignment-config-name-already-defined",{option:i,configuredOptions:n});if(i.className&&r.some(a=>a.className==i.className))throw new b("alignment-config-classname-already-defined",{option:i,configuredOptions:n})}),e}const _u="alignment";class xT extends O{refresh(){const e=this.editor.locale,t=ae(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=!!t&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value=e.contentLanguageDirection==="rtl"?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,o=t.model,s=o.document,r=e.value;o.change(a=>{const l=Array.from(s.selection.getSelectedBlocks()).filter(u=>this._canBeAligned(u)),c=l[0].getAttribute("alignment");pb(r,i)||c===r||!r?TT(l,a):ET(l,a,r)})}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,_u)}}function TT(n,e){for(const t of n)e.removeAttribute(_u,t)}function ET(n,e,t){for(const i of n)e.setAttribute(_u,t,i)}class ST extends w{static get pluginName(){return"AlignmentEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("alignment",{options:bu.map(t=>({name:t}))})}init(){const e=this.editor,t=e.locale,i=e.model.schema,o=wb(e.config.get("alignment.options")).filter(l=>gb(l.name)&&!pb(l.name,t)),s=o.some(l=>!!l.className);i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),s?e.conversion.attributeToAttribute(RT(o)):e.conversion.for("downcast").attributeToAttribute(PT(o));const r=IT(o);for(const l of r)e.conversion.for("upcast").attributeToAttribute(l);const a=VT(o);for(const l of a)e.conversion.for("upcast").attributeToAttribute(l);e.commands.add("alignment",new xT(e))}}function PT(n){const e={};for(const{name:t}of n)e[t]={key:"style",value:{"text-align":t}};return{model:{key:"alignment",values:n.map(t=>t.name)},view:e}}function IT(n){const e=[];for(const{name:t}of n)e.push({view:{key:"style",value:{"text-align":t}},model:{key:"alignment",value:t}});return e}function VT(n){const e=[];for(const{name:t}of n)e.push({view:{key:"align",value:t},model:{key:"alignment",value:t}});return e}function RT(n){const e={};for(const t of n)e[t.name]={key:"class",value:t.className};return{model:{key:"alignment",values:n.map(t=>t.name)},view:e}}const Oo=new Map([["left",nu],["right",fw],["center",dw],["justify",mw]]);class OT extends w{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=wb(e.config.get("alignment.options"));t.map(i=>i.name).filter(gb).forEach(i=>this._addButton(i)),this._addToolbarDropdown(t),this._addMenuBarMenu(t)}_addButton(e){this.editor.ui.componentFactory.add(`alignment:${e}`,t=>this._createButton(t,e))}_createButton(e,t,i={}){const o=this.editor,s=o.commands.get("alignment"),r=new P(e);return r.set({label:this.localizedOptionTitles[t],icon:Oo.get(t),tooltip:!0,isToggleable:!0,...i}),r.bind("isEnabled").to(s),r.bind("isOn").to(s,"value",a=>a===t),this.listenTo(r,"execute",()=>{o.execute("alignment",{value:t}),o.editing.view.focus()}),r}_addToolbarDropdown(e){const t=this.editor;t.ui.componentFactory.add("alignment",i=>{const o=Ee(i),s=i.uiLanguageDirection==="rtl"?"w":"e",r=i.t;fa(o,()=>e.map(c=>this._createButton(i,c.name,{tooltipPosition:s})),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:r("Text alignment toolbar")}),o.buttonView.set({label:r("Text alignment"),tooltip:!0}),o.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const a=i.contentLanguageDirection==="rtl"?Oo.get("right"):Oo.get("left"),l=t.commands.get("alignment");return o.buttonView.bind("icon").to(l,"value",c=>Oo.get(c)||a),o.bind("isEnabled").to(l,"isEnabled"),this.listenTo(o,"execute",()=>{t.editing.view.focus()}),o})}_addMenuBarMenu(e){const t=this.editor;t.ui.componentFactory.add("menuBar:alignment",i=>{const o=t.commands.get("alignment"),s=i.t,r=new Tt(i),a=new Si(i);r.bind("isEnabled").to(o),a.set({ariaLabel:s("Text alignment"),role:"menu"}),r.buttonView.set({label:s("Text alignment")});for(const l of e){const c=new Oi(i,r),u=new ve(i);u.delegate("execute").to(r),u.set({label:this.localizedOptionTitles[l.name],icon:Oo.get(l.name),role:"menuitemcheckbox",isToggleable:!0}),u.on("execute",()=>{t.execute("alignment",{value:l.name}),t.editing.view.focus()}),u.bind("isOn").to(o,"value",d=>d===l.name),u.bind("isEnabled").to(o,"isEnabled"),c.children.add(u),a.items.add(c)}return r.panelView.children.add(a),r})}}class BT extends w{static get requires(){return[ST,OT]}static get pluginName(){return"Alignment"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bb{constructor(e,t=20){h(this,"model"),h(this,"limit"),h(this,"_isLocked"),h(this,"_size"),h(this,"_batch",null),h(this,"_changeCallback"),h(this,"_selectionChangeCallback"),this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(i,o)=>{o.isLocal&&o.isUndoable&&o!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}get size(){return this._size}input(e){this._size+=e,this._size>=this.limit&&this._reset(!0)}get isLocked(){return this._isLocked}lock(){this._isLocked=!0}unlock(){this._isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e=!1){(!this.isLocked||e)&&(this._batch=null,this._size=0)}}class MT extends O{constructor(e,t){super(e),h(this,"_buffer"),this._buffer=new bb(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,i=t.document,o=e.text||"",s=o.length;let r=i.selection;if(e.selection?r=e.selection:e.range&&(r=t.createSelection(e.range)),!t.canEditAt(r))return;const a=e.resultRange;t.enqueueChange(this._buffer.batch,l=>{this._buffer.lock();const c=Array.from(i.selection.getAttributes());t.deleteContent(r),o&&t.insertContent(l.createText(o,c),r),a?l.setSelection(a):r.is("documentSelection")||l.setSelection(r),this._buffer.unlock(),this._buffer.input(s)})}}const _b=["insertText","insertReplacementText"],LT=[..._b,"insertCompositionText"];class FT extends Zt{constructor(e){super(e),h(this,"focusObserver"),this.focusObserver=e.getObserver(Vr);const t=N.isAndroid?LT:_b,i=e.document;i.on("beforeinput",(o,s)=>{if(!this.isEnabled)return;const{data:r,targetRanges:a,inputType:l,domEvent:c,isComposing:u}=s;if(!t.includes(l))return;this.focusObserver.flush();const d=new Ti(i,"insertText");i.fire(d,new kn(e,c,{text:r,selection:e.createSelection(a),isComposing:u})),d.stop.called&&o.stop()}),N.isAndroid||i.on("compositionend",(o,{data:s,domEvent:r})=>{this.isEnabled&&s&&i.fire("insertText",new kn(e,r,{text:s,isComposing:!0}))},{priority:"low"})}observe(){}stopObserving(){}}class vb extends w{constructor(){super(...arguments),h(this,"_typingQueue")}static get pluginName(){return"Input"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=e.editing.view,o=e.editing.mapper,s=t.document.selection;this._typingQueue=new NT(e),i.addObserver(FT);const r=new MT(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",r),e.commands.add("input",r),this.listenTo(i.document,"beforeinput",()=>{this._typingQueue.flush("next beforeinput")},{priority:"high"}),this.listenTo(i.document,"insertText",(a,l)=>{const{text:c,selection:u}=l;if(i.document.selection.isFake&&u&&i.document.selection.isSimilar(u)&&l.preventDefault(),!r.isEnabled){l.preventDefault();return}let d;u?d=Array.from(u.getRanges()).map(g=>o.toModelRange(g)):d=Array.from(s.getRanges());let m=c;if(N.isAndroid){const g=Array.from(d[0].getItems()).reduce((p,_)=>p+(_.is("$textProxy")?_.data:""),"");if(g&&(g.length<=m.length?m.startsWith(g)&&(m=m.substring(g.length),d[0].start=d[0].start.getShiftedBy(g.length)):g.startsWith(m)&&(d[0].start=d[0].start.getShiftedBy(m.length),m="")),m.length==0&&d[0].isCollapsed)return}const f={text:m,selection:t.createSelection(d)};this._typingQueue.push(f,!!l.isComposing),l.domEvent.defaultPrevented&&this._typingQueue.flush("beforeinput default prevented")}),N.isAndroid?this.listenTo(i.document,"keydown",(a,l)=>{s.isCollapsed||l.keyCode!=229||!i.document.isComposing||am(t,r)}):this.listenTo(i.document,"compositionstart",()=>{s.isCollapsed||am(t,r)},{priority:"high"}),this.listenTo(i.document,"mutations",(a,{mutations:l})=>{if(this._typingQueue.hasAffectedElements())for(const{node:c}of l){const u=zT(c,o),d=o.toModelElement(u);if(this._typingQueue.isElementAffected(d)){this._typingQueue.flush("mutations");return}}}),this.listenTo(i.document,"compositionend",()=>{this._typingQueue.flush("before composition end")},{priority:"high"}),this.listenTo(i.document,"compositionend",()=>{this._typingQueue.flush("after composition end");const a=[];if(this._typingQueue.hasAffectedElements())for(const l of this._typingQueue.flushAffectedElements()){const c=o.toViewElement(l);c&&a.push({type:"children",node:c})}(a.length||!N.isAndroid)&&i.document.fire("mutations",{mutations:a})},{priority:"lowest"})}destroy(){super.destroy(),this._typingQueue.destroy()}}class NT{constructor(e){h(this,"editor"),h(this,"flushDebounced",St(()=>this.flush("timeout"),50)),h(this,"_queue",[]),h(this,"_isComposing",!1),h(this,"_affectedElements",new Set),this.editor=e}destroy(){for(this.flushDebounced.cancel(),this._affectedElements.clear();this._queue.length;)this.shift()}get length(){return this._queue.length}push(e,t){const i={text:e.text};if(e.selection){i.selectionRanges=[];for(const o of e.selection.getRanges())i.selectionRanges.push(ht.fromRange(o)),this._affectedElements.add(o.start.parent)}this._queue.push(i),this._isComposing||(this._isComposing=t),this.flushDebounced()}shift(){const e=this._queue.shift(),t={text:e.text};if(e.selectionRanges){const i=e.selectionRanges.map(o=>DT(o)).filter(o=>!!o);i.length&&(t.selection=this.editor.model.createSelection(i))}return t}flush(e){const t=this.editor,i=t.model,o=t.editing.view;if(this.flushDebounced.cancel(),!this._queue.length)return;const s=t.commands.get("insertText").buffer;i.enqueueChange(s.batch,()=>{for(s.lock();this._queue.length;){const r=this.shift();t.execute("insertText",r)}s.unlock(),this._isComposing||this._affectedElements.clear(),this._isComposing=!1}),o.scrollToTheSelection()}isElementAffected(e){return this._affectedElements.has(e)}hasAffectedElements(){return this._affectedElements.size>0}flushAffectedElements(){const e=Array.from(this._affectedElements);return this._affectedElements.clear(),e}}function am(n,e){if(!e.isEnabled)return;const t=e.buffer;t.lock(),n.enqueueChange(t.batch,()=>{n.deleteContent(n.document.selection)}),t.unlock()}function DT(n){const e=n.toRange();return n.detach(),e.root.rootName=="$graveyard"?null:e}function zT(n,e){let t=n.is("$text")?n.parent:n;for(;!e.toModelElement(t);)t=t.parent;return t}class lm extends O{constructor(e,t){super(e),h(this,"direction"),h(this,"_buffer"),this.direction=t,this._buffer=new bb(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,i=t.document;t.enqueueChange(this._buffer.batch,o=>{this._buffer.lock();const s=o.createSelection(e.selection||i.selection);if(!t.canEditAt(s))return;const r=e.sequence||1,a=s.isCollapsed;if(s.isCollapsed&&t.modifySelection(s,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(r)){this._replaceEntireContentWithParagraph(o);return}if(this._shouldReplaceFirstBlockWithParagraph(s,r)){this.editor.execute("paragraph",{selection:s});return}if(s.isCollapsed)return;let l=0;s.getFirstRange().getMinimalFlatRanges().forEach(c=>{l+=Ml(c.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))}),t.deleteContent(s,{doNotResetEntireContent:a,direction:this.direction}),this._buffer.input(l),o.setSelection(s),this._buffer.unlock()})}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,o=t.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(o))||!t.schema.checkChild(o,"paragraph"))return!1;const s=o.getChild(0);return!(s&&s.is("element","paragraph"))}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,o=t.schema.getLimitElement(i),s=e.createElement("paragraph");e.remove(e.createRangeIn(o)),e.insert(s,o),e.setSelection(s,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||this.direction!="backward"||!e.isCollapsed)return!1;const o=e.getFirstPosition(),s=i.schema.getLimitElement(o),r=s.getChild(0);return!(o.parent!=r||!e.containsEntireContent(r)||!i.schema.checkChild(s,"paragraph")||r.name=="paragraph")}}const HT="character",cm="word",$T="codePoint",$i="selection",Qn="backward",qo="forward",yb={deleteContent:{unit:$i,direction:Qn},deleteContentBackward:{unit:$T,direction:Qn},deleteWordBackward:{unit:cm,direction:Qn},deleteHardLineBackward:{unit:$i,direction:Qn},deleteSoftLineBackward:{unit:$i,direction:Qn},deleteContentForward:{unit:HT,direction:qo},deleteWordForward:{unit:cm,direction:qo},deleteHardLineForward:{unit:$i,direction:qo},deleteSoftLineForward:{unit:$i,direction:qo}};class WT extends Zt{constructor(e){super(e);const t=e.document;let i=0;t.on("keydown",()=>{i++}),t.on("keyup",()=>{i=0}),t.on("beforeinput",(o,s)=>{if(!this.isEnabled)return;const{targetRanges:r,domEvent:a,inputType:l}=s,c=yb[l];if(!c)return;const u={direction:c.direction,unit:c.unit,sequence:i};u.unit==$i&&(u.selectionToRemove=e.createSelection(r[0])),l==="deleteContentBackward"&&(N.isAndroid&&(u.sequence=1),UT(r)&&(u.unit=$i,u.selectionToRemove=e.createSelection(r)));const d=new xn(t,"delete",r[0]);t.fire(d,new kn(e,a,u)),d.stop.called&&o.stop()}),N.isBlink&&jT(this)}observe(){}stopObserving(){}}function jT(n){const e=n.view,t=e.document;let i=null,o=!1;t.on("keydown",(a,{keyCode:l})=>{i=l,o=!1}),t.on("keyup",(a,{keyCode:l,domEvent:c})=>{const u=t.selection,d=n.isEnabled&&l==i&&s(l)&&!u.isCollapsed&&!o;if(i=null,d){const m=u.getFirstRange(),f=new xn(t,"delete",m),g={unit:$i,direction:r(l),selectionToRemove:u};t.fire(f,new kn(e,c,g))}}),t.on("beforeinput",(a,{inputType:l})=>{const c=yb[l];s(i)&&c&&c.direction==r(i)&&(o=!0)},{priority:"high"}),t.on("beforeinput",(a,{inputType:l,data:c})=>{i==Z.delete&&l=="insertText"&&c==""&&a.stop()},{priority:"high"});function s(a){return a==Z.backspace||a==Z.delete}function r(a){return a==Z.backspace?Qn:qo}}function UT(n){if(n.length!=1||n[0].isCollapsed)return!1;const e=n[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let t=0;for(const{nextPosition:i,item:o}of e){if(i.parent.is("$text")){const s=i.parent.data,r=i.offset;if(jc(s,r)||Uc(s,r)||cp(s,r))continue;t++}else(o.is("containerElement")||o.is("emptyElement"))&&t++;if(t>1)return!0}return!1}class en extends w{constructor(){super(...arguments),h(this,"_undoOnBackspace")}static get pluginName(){return"Delete"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,o=e.model.document;t.addObserver(WT),this._undoOnBackspace=!1;const s=new lm(e,"forward");e.commands.add("deleteForward",s),e.commands.add("forwardDelete",s),e.commands.add("delete",new lm(e,"backward")),this.listenTo(i,"delete",(r,a)=>{i.isComposing||a.preventDefault();const{direction:l,sequence:c,selectionToRemove:u,unit:d}=a,m=l==="forward"?"deleteForward":"delete",f={sequence:c};if(d=="selection"){const g=Array.from(u.getRanges()).map(p=>e.editing.mapper.toModelRange(p));f.selection=e.model.createSelection(g)}else f.unit=d;e.execute(m,f),t.scrollToTheSelection()},{priority:"low"}),this.listenTo(i,"keydown",(r,a)=>{if(i.isComposing||a.keyCode!=Z.backspace||!o.selection.isCollapsed)return;const l=e.model.schema.getLimitElement(o.selection),c=e.model.createPositionAt(l,0);if(c.isTouching(o.selection.getFirstPosition())){a.preventDefault();const u=e.model.schema.getNearestSelectionRange(c,"forward");if(!u)return;const d=t.createSelection(e.editing.mapper.toViewRange(u)),m=d.getFirstRange(),f=new xn(document,"delete",m),g={unit:"selection",direction:"backward",selectionToRemove:d};i.fire(f,new kn(t,a.domEvent,g))}}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(i,"delete",(r,a)=>{this._undoOnBackspace&&a.direction=="backward"&&a.sequence==1&&a.unit=="codePoint"&&(this._undoOnBackspace=!1,e.execute("undo"),a.preventDefault(),r.stop())},{context:"$capture"}),this.listenTo(o,"change",()=>{this._undoOnBackspace=!1}))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class pa extends w{static get requires(){return[vb,en]}static get pluginName(){return"Typing"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function kb(n,e){let t=n.start;return{text:Array.from(n.getWalker({ignoreElementEnd:!1})).reduce((i,{item:o})=>o.is("$text")||o.is("$textProxy")?i+o.data:(t=e.createPositionAfter(o),""),""),range:e.createRange(t,n.end)}}class vu extends ue(){constructor(e,t){super(),h(this,"model"),h(this,"testCallback"),h(this,"_hasMatch"),this.model=e,this.testCallback=t,this._hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))}),this._startListening()}get hasMatch(){return this._hasMatch}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",(t,{directChange:i})=>{if(i){if(!e.selection.isCollapsed){this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1);return}this._evaluateTextBeforeSelection("selection")}}),this.listenTo(e,"change:data",(t,i)=>{i.isUndo||!i.isLocal||this._evaluateTextBeforeSelection("data",{batch:i})})}_evaluateTextBeforeSelection(e,t={}){const i=this.model,o=i.document.selection,s=i.createRange(i.createPositionAt(o.focus.parent,0),o.focus),{text:r,range:a}=kb(s,i),l=this.testCallback(r);if(!l&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!l,l){const c=Object.assign(t,{text:r,range:a});typeof l=="object"&&Object.assign(c,l),this.fire(`matched:${e}`,c)}}}class Dr extends w{constructor(e){super(e),h(this,"attributes"),h(this,"_overrideUid"),h(this,"_isNextGravityRestorationSkipped",!1),this.attributes=new Set,this._overrideUid=null}static get pluginName(){return"TwoStepCaretMovement"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=e.editing.view,o=e.locale,s=t.document.selection;this.listenTo(i.document,"arrowKey",(r,a)=>{if(!s.isCollapsed||a.shiftKey||a.altKey||a.ctrlKey)return;const l=a.keyCode==Z.arrowright,c=a.keyCode==Z.arrowleft;if(!l&&!c)return;const u=o.contentLanguageDirection;let d=!1;u==="ltr"&&l||u==="rtl"&&c?d=this._handleForwardMovement(a):d=this._handleBackwardMovement(a),d===!0&&r.stop()},{context:"$text",priority:"highest"}),this.listenTo(s,"change:range",(r,a)=>{if(this._isNextGravityRestorationSkipped){this._isNextGravityRestorationSkipped=!1;return}this._isGravityOverridden&&(!a.directChange&&Mt(s.getFirstPosition(),this.attributes)||this._restoreGravity())}),this._enableClickingAfterNode(),this._enableInsertContentSelectionAttributesFixer(),this._handleDeleteContentAfterNode()}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model,o=i.document.selection,s=o.getFirstPosition();return this._isGravityOverridden||s.isAtStart&&gi(o,t)?!1:Mt(s,t)?(e&&Mo(e),gi(o,t)&&Mt(s,t,!0)?Bo(i,t):this._overrideGravity(),!0):!1}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,o=i.document.selection,s=o.getFirstPosition();return this._isGravityOverridden?(e&&Mo(e),this._restoreGravity(),Mt(s,t,!0)?Bo(i,t):Zs(i,t,s),!0):s.isAtStart?gi(o,t)?(e&&Mo(e),Zs(i,t,s),!0):!1:!gi(o,t)&&Mt(s,t,!0)?(e&&Mo(e),Zs(i,t,s),!0):um(s,t)?s.isAtEnd&&!gi(o,t)&&Mt(s,t)?(e&&Mo(e),Zs(i,t,s),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):!1}_enableClickingAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,o=e.editing.view.document;e.editing.view.addObserver(ua),e.editing.view.addObserver(c5);let s=!1,r=!1;this.listenTo(o,"touchstart",()=>{r=!1,s=!0}),this.listenTo(o,"mousedown",()=>{r=!0}),this.listenTo(o,"selectionChange",()=>{const a=this.attributes;if(!r&&!s||(r=!1,s=!1,!i.isCollapsed)||!gi(i,a))return;const l=i.getFirstPosition();Mt(l,a)&&(l.isAtStart||Mt(l,a,!0)?Bo(t,a):this._isGravityOverridden||this._overrideGravity())})}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection,i=this.attributes;this.listenTo(e,"insertContent",()=>{const o=t.getFirstPosition();gi(t,i)&&Mt(o,i)&&Bo(e,i)},{priority:"low"})}_handleDeleteContentAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,o=e.editing.view;let s=!1,r=!1;this.listenTo(o.document,"delete",(a,l)=>{s=l.direction==="backward"},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{if(!s)return;const a=i.getFirstPosition();r=gi(i,this.attributes)&&!um(a,this.attributes)},{priority:"high"}),this.listenTo(t,"deleteContent",()=>{s&&(s=!1,!r&&e.model.enqueueChange(()=>{const a=i.getFirstPosition();gi(i,this.attributes)&&Mt(a,this.attributes)&&(a.isAtStart||Mt(a,this.attributes,!0)?Bo(t,this.attributes):this._isGravityOverridden||this._overrideGravity())}))},{priority:"low"})}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change(e=>e.overrideSelectionGravity())}_restoreGravity(){this.editor.model.change(e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null})}}function gi(n,e){for(const t of e)if(n.hasAttribute(t))return!0;return!1}function Zs(n,e,t){const i=t.nodeBefore;n.change(o=>{if(i){const s=[],r=n.schema.isObject(i)&&n.schema.isInline(i);for(const[a,l]of i.getAttributes())n.schema.checkAttribute("$text",a)&&(!r||n.schema.getAttributeProperties(a).copyFromObject!==!1)&&s.push([a,l]);o.setSelectionAttribute(s)}else o.removeSelectionAttribute(e)})}function Bo(n,e){n.change(t=>{t.removeSelectionAttribute(e)})}function Mo(n){n.preventDefault()}function um(n,e){const t=n.getShiftedBy(-1);return Mt(t,e)}function Mt(n,e,t=!1){const{nodeBefore:i,nodeAfter:o}=n;for(const s of e){const r=i?i.getAttribute(s):void 0,a=o?o.getAttribute(s):void 0;if(!(t&&(r===void 0||a===void 0))&&a!==r)return!0}return!1}const hm={copyright:{from:"(c)",to:"©"},registeredTrademark:{from:"(r)",to:"®"},trademark:{from:"(tm)",to:"™"},oneHalf:{from:/(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i,to:[null,"½",null]},oneThird:{from:/(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i,to:[null,"⅓",null]},twoThirds:{from:/(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i,to:[null,"⅔",null]},oneForth:{from:/(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i,to:[null,"¼",null]},threeQuarters:{from:/(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i,to:[null,"¾",null]},lessThanOrEqual:{from:"<=",to:"≤"},greaterThanOrEqual:{from:">=",to:"≥"},notEqual:{from:"!=",to:"≠"},arrowLeft:{from:"<-",to:"←"},arrowRight:{from:"->",to:"→"},horizontalEllipsis:{from:"...",to:"…"},enDash:{from:/(^| )(--)( )$/,to:[null,"–",null]},emDash:{from:/(^| )(---)( )$/,to:[null,"—",null]},quotesPrimary:{from:zn('"'),to:[null,"“",null,"”"]},quotesSecondary:{from:zn("'"),to:[null,"‘",null,"’"]},quotesPrimaryEnGb:{from:zn("'"),to:[null,"‘",null,"’"]},quotesSecondaryEnGb:{from:zn('"'),to:[null,"“",null,"”"]},quotesPrimaryPl:{from:zn('"'),to:[null,"„",null,"”"]},quotesSecondaryPl:{from:zn("'"),to:[null,"‚",null,"’"]}},dm={symbols:["copyright","registeredTrademark","trademark"],mathematical:["oneHalf","oneThird","twoThirds","oneForth","threeQuarters","lessThanOrEqual","greaterThanOrEqual","notEqual","arrowLeft","arrowRight"],typography:["horizontalEllipsis","enDash","emDash"],quotes:["quotesPrimary","quotesSecondary"]},qT=["symbols","mathematical","typography","quotes"];class GT extends w{static get requires(){return["Delete","Input"]}static get pluginName(){return"TextTransformation"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("typing",{transformations:{include:qT}})}init(){const e=this.editor.model.document.selection;e.on("change:range",()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}),this._enableTransformationWatchers()}_enableTransformationWatchers(){const e=this.editor,t=e.model,i=e.plugins.get("Delete"),o=QT(e.config.get("typing.transformations")),s=a=>{for(const l of o)if(l.from.test(a))return{normalizedTransformation:l}},r=new vu(e.model,s);r.on("matched:data",(a,l)=>{if(!l.batch.isTyping)return;const{from:c,to:u}=l.normalizedTransformation,d=c.exec(l.text),m=u(d.slice(1)),f=l.range;let g=d.index;t.enqueueChange(p=>{for(let _=1;_<d.length;_++){const v=d[_],E=m[_-1];if(E==null){g+=v.length;continue}const M=f.start.getShiftedBy(g),G=t.createRange(M,M.getShiftedBy(v.length)),X=JT(M);t.insertContent(p.createText(E,X),G),g+=E.length}t.enqueueChange(()=>{i.requestUndoOnBackspace()})})}),r.bind("isEnabled").to(this)}}function KT(n){return typeof n=="string"?new RegExp(`(${ta(n)})$`):n}function ZT(n){return typeof n=="string"?()=>[n]:n instanceof Array?()=>n:n}function JT(n){return(n.textNode?n.textNode:n.nodeAfter).getAttributes()}function zn(n){return new RegExp(`(^|\\s)(${n})([^${n}]*)(${n})$`)}function QT(n){const e=n.extra||[],t=n.remove||[],i=s=>!t.includes(s),o=n.include.concat(e).filter(i);return YT(o).filter(i).map(s=>typeof s=="string"&&hm[s]?hm[s]:s).filter(s=>typeof s=="object").map(s=>({from:KT(s.from),to:ZT(s.to)}))}function YT(n){const e=new Set;for(const t of n)if(typeof t=="string"&&dm[t])for(const i of dm[t])e.add(i);else e.add(t);return Array.from(e)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ps(n,e,t,i){return i.createRange(ic(n,e,t,!0,i),ic(n,e,t,!1,i))}function ic(n,e,t,i,o){let s=n.textNode||(i?n.nodeBefore:n.nodeAfter),r=null;for(;s&&s.getAttribute(e)==t;)r=s,s=i?s.previousSibling:s.nextSibling;return r?o.createPositionAt(r,i?"before":"after"):n}function Cb(n,e,t,i){const o=n.editing.view,s=new Set;o.document.registerPostFixer(r=>{const a=n.model.document.selection;let l=!1;if(a.hasAttribute(e)){const c=Ps(a.getFirstPosition(),e,a.getAttribute(e),n.model),u=n.editing.mapper.toViewRange(c);for(const d of u.getItems())d.is("element",t)&&!d.hasClass(i)&&(r.addClass(i,d),s.add(d),l=!0)}return l}),n.conversion.for("editingDowncast").add(r=>{r.on("insert",a,{priority:"highest"}),r.on("remove",a,{priority:"highest"}),r.on("attribute",a,{priority:"highest"}),r.on("selection",a,{priority:"highest"});function a(){o.change(l=>{for(const c of s.values())l.removeClass(i,c),s.delete(c)})}})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Wt(n,e,t,i){let o,s=null;typeof i=="function"?o=i:(s=n.commands.get(i),o=()=>{n.execute(i)}),n.model.document.on("change:data",(r,a)=>{if(s&&!s.isEnabled||!e.isEnabled)return;const l=ae(n.model.document.selection.getRanges());if(!l.isCollapsed||a.isUndo||!a.isLocal)return;const c=Array.from(n.model.document.differ.getChanges()),u=c[0];if(c.length!=1||u.type!=="insert"||u.name!="$text"||u.length!=1)return;const d=u.position.parent;if(d.is("element","codeBlock")||d.is("element","listItem")&&typeof i!="function"&&!["numberedList","bulletedList","todoList"].includes(i)||s&&s.value===!0)return;const m=d.getChild(0),f=n.model.createRangeOn(m);if(!f.containsRange(l)&&!l.end.isEqual(f.end))return;const g=t.exec(m.data.substr(0,l.end.offset));g&&n.model.enqueueChange(p=>{const _=p.createPositionAt(d,0),v=p.createPositionAt(d,g[0].length),E=new ht(_,v);if(o({match:g})!==!1){p.remove(E);const M=n.model.document.selection.getFirstRange(),G=p.createRangeIn(d);d.isEmpty&&!G.isEqual(M)&&!G.containsRange(M,!0)&&p.remove(d)}E.detach(),n.model.enqueueChange(()=>{n.plugins.get("Delete").requestUndoOnBackspace()})})})}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function mn(n,e,t,i){let o,s;t instanceof RegExp?o=t:s=t,s=s||(r=>{let a;const l=[],c=[];for(;(a=o.exec(r))!==null&&!(a&&a.length<4);){let{index:u,"1":d,"2":m,"3":f}=a;const g=d+m+f;u+=a[0].length-g.length;const p=[u,u+d.length],_=[u+d.length+m.length,u+d.length+m.length+f.length];l.push(p),l.push(_),c.push([u+d.length,u+d.length+m.length])}return{remove:l,format:c}}),n.model.document.on("change:data",(r,a)=>{if(a.isUndo||!a.isLocal||!e.isEnabled)return;const l=n.model,c=l.document.selection;if(!c.isCollapsed)return;const u=Array.from(l.document.differ.getChanges()),d=u[0];if(u.length!=1||d.type!=="insert"||d.name!="$text"||d.length!=1)return;const m=c.focus,f=m.parent,{text:g,range:p}=XT(l.createRange(l.createPositionAt(f,0),m),l),_=s(g),v=mm(p.start,_.format,l),E=mm(p.start,_.remove,l);v.length&&E.length&&l.enqueueChange(M=>{if(i(M,v)!==!1){for(const G of E.reverse())M.remove(G);l.enqueueChange(()=>{n.plugins.get("Delete").requestUndoOnBackspace()})}})})}function mm(n,e,t){return e.filter(i=>i[0]!==void 0&&i[1]!==void 0).map(i=>t.createRange(n.getShiftedBy(i[0]),n.getShiftedBy(i[1])))}function XT(n,e){let t=n.start;return{text:Array.from(n.getItems()).reduce((i,o)=>!(o.is("$text")||o.is("$textProxy"))||o.getAttribute("code")?(t=e.createPositionAfter(o),""):i+o.data,""),range:e.createRange(t,n.end)}}class yu extends w{static get requires(){return[en]}static get pluginName(){return"Autoformat"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=this.editor.t;this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats(),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Revert autoformatting action"),keystroke:"Backspace"}]})}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&Wt(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&Wt(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&Wt(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&Wt(this.editor,this,/^\[\s?x\s?\]\s$/,()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")})}_addBasicStylesAutoformats(){const e=this.editor.commands;if(e.get("bold")){const t=Js(this.editor,"bold");mn(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,t),mn(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,t)}if(e.get("italic")){const t=Js(this.editor,"italic");mn(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,t),mn(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,t)}if(e.get("code")){const t=Js(this.editor,"code");mn(this.editor,this,/(`)([^`]+)(`)$/g,t)}if(e.get("strikethrough")){const t=Js(this.editor,"strikethrough");mn(this.editor,this,/(~~)([^~]+)(~~)$/g,t)}}_addHeadingAutoformats(){const e=this.editor.commands.get("heading");e&&e.modelElements.filter(t=>t.match(/^heading[1-6]$/)).forEach(t=>{const i=t[7],o=new RegExp(`^(#{${i}})\\s$`);Wt(this.editor,this,o,()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&Wt(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&Wt(e,this,/^```$/,()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})})}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&Wt(this.editor,this,/^---$/,"horizontalLine")}}function Js(n,e){return(t,i)=>{if(!n.commands.get(e).isEnabled)return!1;const o=n.model.schema.getValidRanges(i,e);for(const s of o)t.setAttribute(e,!0,s);t.removeSelectionAttribute(e)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class tn extends O{constructor(e,t){super(e),h(this,"attributeKey"),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,o=e.forceValue===void 0?!this.value:e.forceValue;t.change(s=>{if(i.isCollapsed)o?s.setSelectionAttribute(this.attributeKey,!0):s.removeSelectionAttribute(this.attributeKey);else{const r=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const a of r)o?s.setAttribute(this.attributeKey,o,a):s.removeAttribute(this.attributeKey,a)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const o of i.getRanges())for(const s of o.getItems())if(t.checkAttribute(s,this.attributeKey))return s.hasAttribute(this.attributeKey);return!1}}const Hn="bold";class eE extends w{static get pluginName(){return"BoldEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Hn}),e.model.schema.setAttributeProperties(Hn,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Hn,view:"strong",upcastAlso:["b",i=>{const o=i.getStyle("font-weight");return o&&(o=="bold"||Number(o)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(Hn,new tn(e,Hn)),e.keystrokes.set("CTRL+B",Hn),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Bold text"),keystroke:"CTRL+B"}]})}}function Sn({editor:n,commandName:e,plugin:t,icon:i,label:o,keystroke:s}){return r=>{const a=n.commands.get(e),l=new r(n.locale);return l.set({label:o,icon:i,keystroke:s,isToggleable:!0}),l.bind("isEnabled").to(a,"isEnabled"),l.bind("isOn").to(a,"value"),l instanceof ve?l.set({role:"menuitemcheckbox"}):l.set({tooltip:!0}),t.listenTo(l,"execute",()=>{n.execute(e),n.editing.view.focus()}),l}}const il="bold";class tE extends w{static get pluginName(){return"BoldUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:il,plugin:this,icon:gw,label:t("Bold"),keystroke:"CTRL+B"});e.ui.componentFactory.add(il,()=>i(P)),e.ui.componentFactory.add("menuBar:"+il,()=>i(ve))}}class iE extends w{static get requires(){return[eE,tE]}static get pluginName(){return"Bold"}static get isOfficialPlugin(){return!0}}const ln="code",nE="ck-code_selected";class oE extends w{static get pluginName(){return"CodeEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Dr]}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:ln}),e.model.schema.setAttributeProperties(ln,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:ln,view:"code"}),e.commands.add(ln,new tn(e,ln)),e.plugins.get(Dr).registerAttribute(ln),Cb(e,ln,"code",nE),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Move out of an inline code style"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}}const nl="code";class sE extends w{static get pluginName(){return"CodeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:nl,plugin:this,icon:pC,label:t("Code")});e.ui.componentFactory.add(nl,()=>i(P)),e.ui.componentFactory.add("menuBar:"+nl,()=>i(ve))}}class rE extends w{static get requires(){return[oE,sE]}static get pluginName(){return"Code"}static get isOfficialPlugin(){return!0}}const $n="italic";class aE extends w{static get pluginName(){return"ItalicEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:$n}),e.model.schema.setAttributeProperties($n,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:$n,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add($n,new tn(e,$n)),e.keystrokes.set("CTRL+I",$n),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Italic text"),keystroke:"CTRL+I"}]})}}const ol="italic";class lE extends w{static get pluginName(){return"ItalicUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:ol,plugin:this,icon:MC,keystroke:"CTRL+I",label:t("Italic")});e.ui.componentFactory.add(ol,()=>i(P)),e.ui.componentFactory.add("menuBar:"+ol,()=>i(ve))}}class cE extends w{static get requires(){return[aE,lE]}static get pluginName(){return"Italic"}static get isOfficialPlugin(){return!0}}const Lo="strikethrough";class uE extends w{static get pluginName(){return"StrikethroughEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Lo}),e.model.schema.setAttributeProperties(Lo,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Lo,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(Lo,new tn(e,Lo)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Strikethrough text"),keystroke:"CTRL+SHIFT+X"}]})}}const sl="strikethrough";class hE extends w{static get pluginName(){return"StrikethroughUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:sl,plugin:this,icon:uA,keystroke:"CTRL+SHIFT+X",label:t("Strikethrough")});e.ui.componentFactory.add(sl,()=>i(P)),e.ui.componentFactory.add("menuBar:"+sl,()=>i(ve))}}class dE extends w{static get requires(){return[uE,hE]}static get pluginName(){return"Strikethrough"}static get isOfficialPlugin(){return!0}}const Fo="subscript";class mE extends w{static get pluginName(){return"SubscriptEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Fo}),e.model.schema.setAttributeProperties(Fo,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Fo,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),e.commands.add(Fo,new tn(e,Fo))}}const rl="subscript";class fE extends w{static get pluginName(){return"SubscriptUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:rl,plugin:this,icon:hA,label:t("Subscript")});e.ui.componentFactory.add(rl,()=>i(P)),e.ui.componentFactory.add("menuBar:"+rl,()=>i(ve))}}class gE extends w{static get requires(){return[mE,fE]}static get pluginName(){return"Subscript"}static get isOfficialPlugin(){return!0}}const No="superscript";class pE extends w{static get pluginName(){return"SuperscriptEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:No}),e.model.schema.setAttributeProperties(No,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:No,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),e.commands.add(No,new tn(e,No))}}const al="superscript";class wE extends w{static get pluginName(){return"SuperscriptUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:al,plugin:this,icon:dA,label:t("Superscript")});e.ui.componentFactory.add(al,()=>i(P)),e.ui.componentFactory.add("menuBar:"+al,()=>i(ve))}}class bE extends w{static get requires(){return[pE,wE]}static get pluginName(){return"Superscript"}static get isOfficialPlugin(){return!0}}const Do="underline";class _E extends w{static get pluginName(){return"UnderlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Do}),e.model.schema.setAttributeProperties(Do,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Do,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(Do,new tn(e,Do)),e.keystrokes.set("CTRL+U","underline"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Underline text"),keystroke:"CTRL+U"}]})}}const ll="underline";class vE extends w{static get pluginName(){return"UnderlineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=Sn({editor:e,commandName:ll,plugin:this,icon:yA,label:t("Underline"),keystroke:"CTRL+U"});e.ui.componentFactory.add(ll,()=>i(P)),e.ui.componentFactory.add("menuBar:"+ll,()=>i(ve))}}class yE extends w{static get requires(){return[_E,vE]}static get pluginName(){return"Underline"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function*Ab(n,e){for(const t of e)t&&n.getAttributeProperties(t[0]).copyOnEnter&&(yield t)}class kE extends O{execute(){this.editor.model.change(e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})})}enterBlock(e){const t=this.editor.model,i=t.document.selection,o=t.schema,s=i.isCollapsed,r=i.getFirstRange(),a=r.start.parent,l=r.end.parent;if(o.isLimit(a)||o.isLimit(l))return!s&&a==l&&t.deleteContent(i),!1;if(s){const c=Ab(e.model.schema,i.getAttributes());return fm(e,r.start),e.setSelectionAttribute(c),!0}else{const c=!(r.start.isAtStart&&r.end.isAtEnd),u=a==l;if(t.deleteContent(i,{leaveUnmerged:c}),c){if(u)return fm(e,i.focus),!0;e.setSelection(l,0)}}return!1}}function fm(n,e){n.split(e),n.setSelection(e.parent.nextSibling,0)}const CE={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class xb extends Zt{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",(o,s)=>{i=s.shiftKey}),t.on("beforeinput",(o,s)=>{if(!this.isEnabled)return;let r=s.inputType;N.isSafari&&i&&r=="insertParagraph"&&(r="insertLineBreak");const a=s.domEvent,l=CE[r];if(!l)return;const c=new xn(t,"enter",s.targetRanges[0]);t.fire(c,new kn(e,a,{isSoft:l.isSoft})),c.stop.called&&o.stop()})}observe(){}stopObserving(){}}class Ao extends w{static get pluginName(){return"Enter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,o=this.editor.t;t.addObserver(xb),e.commands.add("enter",new kE(e)),this.listenTo(i,"enter",(s,r)=>{i.isComposing||r.preventDefault(),!r.isSoft&&(e.execute("enter"),t.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class AE extends O{execute(){const e=this.editor.model,t=e.document;e.change(i=>{TE(e,i,t.selection),this.fire("afterExecute",{writer:i})})}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=xE(e.schema,t.selection)}}function xE(n,e){if(e.rangeCount>1)return!1;const t=e.anchor;if(!t||!n.checkChild(t,"softBreak"))return!1;const i=e.getFirstRange(),o=i.start.parent,s=i.end.parent;return!((nc(o,n)||nc(s,n))&&o!==s)}function TE(n,e,t){const i=t.isCollapsed,o=t.getFirstRange(),s=o.start.parent,r=o.end.parent,a=s==r;if(i){const l=Ab(n.schema,t.getAttributes());gm(n,e,o.end),e.removeSelectionAttribute(t.getAttributeKeys()),e.setSelectionAttribute(l)}else{const l=!(o.start.isAtStart&&o.end.isAtEnd);n.deleteContent(t,{leaveUnmerged:l}),a?gm(n,e,t.focus):l&&e.setSelection(r,0)}}function gm(n,e,t){const i=e.createElement("softBreak");n.insertContent(i,t),e.setSelection(i,"after")}function nc(n,e){return n.is("rootElement")?!1:e.isLimit(n)||nc(n.parent,e)}class Tb extends w{static get pluginName(){return"ShiftEnter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.conversion,o=e.editing.view,s=o.document,r=this.editor.t;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(a,{writer:l})=>l.createEmptyElement("br")}),o.addObserver(xb),e.commands.add("shiftEnter",new AE(e)),this.listenTo(s,"enter",(a,l)=>{s.isComposing||l.preventDefault(),l.isSoft&&(e.execute("shiftEnter"),o.scrollToTheSelection())},{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:r("Insert a soft break (a <code>&lt;br&gt;</code> element)"),keystroke:"Shift+Enter"}]})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class EE extends O{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,o=t.document.selection,s=Array.from(o.getSelectedBlocks()),r=e.forceValue===void 0?!this.value:e.forceValue;t.change(a=>{if(!r)this._removeQuote(a,s.filter(Qs));else{const l=s.filter(c=>Qs(c)||wm(i,c));this._applyQuote(a,l)}})}_getValue(){const e=this.editor.model.document.selection,t=ae(e.getSelectedBlocks());return!!(t&&Qs(t))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=ae(e.getSelectedBlocks());return i?wm(t,i):!1}_removeQuote(e,t){pm(e,t).reverse().forEach(i=>{if(i.start.isAtStart&&i.end.isAtEnd){e.unwrap(i.start.parent);return}if(i.start.isAtStart){const s=e.createPositionBefore(i.start.parent);e.move(i,s);return}i.end.isAtEnd||e.split(i.end);const o=e.createPositionAfter(i.end.parent);e.move(i,o)})}_applyQuote(e,t){const i=[];pm(e,t).reverse().forEach(o=>{let s=Qs(o.start);s||(s=e.createElement("blockQuote"),e.wrap(o,s)),i.push(s)}),i.reverse().reduce((o,s)=>o.nextSibling==s?(e.merge(e.createPositionAfter(o)),o):s)}}function Qs(n){return n.parent.name=="blockQuote"?n.parent:null}function pm(n,e){let t,i=0;const o=[];for(;i<e.length;){const s=e[i],r=e[i+1];t||(t=n.createPositionBefore(s)),(!r||s.nextSibling!=r)&&(o.push(n.createRange(t,n.createPositionAfter(s))),t=null),i++}return o}function wm(n,e){const t=n.checkChild(e.parent,"blockQuote"),i=n.checkChild(["$root","blockQuote"],e);return t&&i}class SE extends w{static get pluginName(){return"BlockQuoteEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Ao,en]}init(){const e=this.editor,t=e.model.schema;e.commands.add("blockQuote",new EE(e)),t.register("blockQuote",{inheritAllFrom:"$container"}),e.conversion.elementToElement({model:"blockQuote",view:"blockquote"}),e.model.document.registerPostFixer(r=>{const a=e.model.document.differ.getChanges();for(const l of a)if(l.type=="insert"){const c=l.position.nodeAfter;if(!c)continue;if(c.is("element","blockQuote")&&c.isEmpty)return r.remove(c),!0;if(c.is("element","blockQuote")&&!t.checkChild(l.position,c))return r.unwrap(c),!0;if(c.is("element")){const u=r.createRangeIn(c);for(const d of u.getItems())if(d.is("element","blockQuote")&&!t.checkChild(r.createPositionBefore(d),d))return r.unwrap(d),!0}}else if(l.type=="remove"){const c=l.position.parent;if(c.is("element","blockQuote")&&c.isEmpty)return r.remove(c),!0}return!1});const i=this.editor.editing.view.document,o=e.model.document.selection,s=e.commands.get("blockQuote");this.listenTo(i,"enter",(r,a)=>{!o.isCollapsed||!s.value||o.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"blockquote"}),this.listenTo(i,"delete",(r,a)=>{if(a.direction!="backward"||!o.isCollapsed||!s.value)return;const l=o.getLastPosition().parent;l.isEmpty&&!l.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"blockquote"})}}class PE extends w{static get pluginName(){return"BlockQuoteUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("blockQuote",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:blockQuote",()=>{const t=this._createButton(ve);return t.set({role:"menuitemcheckbox"}),t})}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("blockQuote"),s=new e(t.locale),r=i.t;return s.set({label:r("Block quote"),icon:nA,isToggleable:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value"),this.listenTo(s,"execute",()=>{t.execute("blockQuote"),t.editing.view.focus()}),s}}class IE extends w{static get requires(){return[SE,PE]}static get pluginName(){return"BlockQuote"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class VE extends ge(){constructor(){super(...arguments),h(this,"_stack",[])}add(e,t){const i=this._stack,o=i[0];this._insertDescriptor(e);const s=i[0];o!==s&&!cl(o,s)&&this.fire("change:top",{oldDescriptor:o,newDescriptor:s,writer:t})}remove(e,t){const i=this._stack,o=i[0];this._removeDescriptor(e);const s=i[0];o!==s&&!cl(o,s)&&this.fire("change:top",{oldDescriptor:o,newDescriptor:s,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex(s=>s.id===e.id);if(cl(e,t[i]))return;i>-1&&t.splice(i,1);let o=0;for(;t[o]&&RE(t[o],e);)o++;t.splice(o,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex(o=>o.id===e);i>-1&&t.splice(i,1)}}function cl(n,e){return n&&e&&n.priority==e.priority&&zr(n.classes)==zr(e.classes)}function RE(n,e){return n.priority>e.priority?!0:n.priority<e.priority?!1:zr(n.classes)>zr(e.classes)}function zr(n){return Array.isArray(n)?n.sort().join(","):n}const OE="ck-widget",bm="ck-widget_selected";function Se(n){return n.is("element")?!!n.getCustomProperty("widget"):!1}function gt(n,e,t={}){if(!n.is("containerElement"))throw new b("widget-to-widget-wrong-element-type",null,{element:n});return e.setAttribute("contenteditable","false",n),e.addClass(OE,n),e.setCustomProperty("widget",!0,n),n.getFillerOffset=NE,e.setCustomProperty("widgetLabel",[],n),t.label&&LE(n,t.label),t.hasSelectionHandle&&DE(n,e),Eb(n,e),n}function BE(n,e,t){if(e.classes&&t.addClass(he(e.classes),n),e.attributes)for(const i in e.attributes)t.setAttribute(i,e.attributes[i],n)}function ME(n,e,t){if(e.classes&&t.removeClass(he(e.classes),n),e.attributes)for(const i in e.attributes)t.removeAttribute(i,n)}function Eb(n,e,t=BE,i=ME){const o=new VE;o.on("change:top",(a,l)=>{l.oldDescriptor&&i(n,l.oldDescriptor,l.writer),l.newDescriptor&&t(n,l.newDescriptor,l.writer)});const s=(a,l,c)=>o.add(l,c),r=(a,l,c)=>o.remove(l,c);e.setCustomProperty("addHighlight",s,n),e.setCustomProperty("removeHighlight",r,n)}function LE(n,e){n.getCustomProperty("widgetLabel").push(e)}function FE(n){return n.getCustomProperty("widgetLabel").reduce((e,t)=>typeof t=="function"?e?e+". "+t():t():e?e+". "+t:t,"")}function wa(n,e,t={}){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],n),t.withAriaRole!==!1&&e.setAttribute("role","textbox",n),e.setAttribute("tabindex","-1",n),t.label&&e.setAttribute("aria-label",t.label,n),e.setAttribute("contenteditable",n.isReadOnly?"false":"true",n),n.on("change:isReadOnly",(i,o,s)=>{e.setAttribute("contenteditable",s?"false":"true",n)}),n.on("change:isFocused",(i,o,s)=>{s?e.addClass("ck-editor__nested-editable_focused",n):e.removeClass("ck-editor__nested-editable_focused",n)}),Eb(n,e),n}function ku(n,e){const t=n.getSelectedElement();if(t){const i=zi(n);if(i)return e.createRange(e.createPositionAt(t,i))}return e.schema.findOptimalInsertionRange(n)}function Cu(n,e){return(t,i)=>{const{mapper:o,viewPosition:s}=i,r=o.findMappedViewAncestor(s);if(!e(r))return;const a=o.toModelElement(r);i.modelPosition=n.createPositionAt(a,s.isAtStart?"before":"after")}}function NE(){return null}function DE(n,e){const t=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},function(i){const o=this.toDomElement(i),s=new hi;return s.set("content",_C),s.render(),o.appendChild(s.element),o});e.insert(e.createPositionAt(n,0),t),e.addClass(["ck-widget_with-selection-handle"],n)}function Au(n){const e=a=>{const{width:l,paddingLeft:c,paddingRight:u}=a.ownerDocument.defaultView.getComputedStyle(a);return parseFloat(l)-(parseFloat(c)||0)-(parseFloat(u)||0)},t=n.parentElement;if(!t)return 0;let i=e(t);const o=5;let s=0,r=t;for(;isNaN(i);){if(r=r.parentElement,++s>o)return 0;i=e(r)}return i}function zE(n,e=new z(n)){const t=Au(n);return t?e.width/t*100:0}const bi="widget-type-around";function cn(n,e,t){return!!n&&Se(n)&&!t.isInline(e)}function HE(n){return n.closest(".ck-widget__type-around__button")}function $E(n){return n.classList.contains("ck-widget__type-around__button_before")?"before":"after"}function WE(n,e){const t=n.closest(".ck-widget");return e.mapDomToView(t)}function zi(n){return n.getAttribute(bi)}const Sb=["before","after"],jE=new DOMParser().parseFromString(rA,"image/svg+xml").firstChild,_m="ck-widget__type-around_disabled";class UE extends w{constructor(){super(...arguments),h(this,"_currentFakeCaretModelElement",null)}static get pluginName(){return"WidgetTypeAround"}static get isOfficialPlugin(){return!0}static get requires(){return[Ao,en]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",(i,o,s)=>{t.change(r=>{for(const a of t.document.roots)s?r.removeClass(_m,a):r.addClass(_m,a)}),s||e.model.change(r=>{r.removeSelectionAttribute(bi)})}),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const i=this.editor,o=i.editing.view,s=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:s}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(e,t,i,o){this.listenTo(e,t,(...s)=>{this.isEnabled&&i(...s)},o)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=zi(e);if(!t)return!1;const i=e.getSelectedElement();return this._insertParagraph(i,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,o={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",(s,r,a)=>{const l=a.mapper.toViewElement(r.item);l&&cn(l,r.item,t)&&(qE(a.writer,o,l),l.getCustomProperty("widgetLabel").push(()=>this.isEnabled?i("Press Enter to type after or press Shift + Enter to type before the widget"):""))},{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,i=t.document.selection,o=t.schema,s=e.editing.view;this._listenToIfEnabled(s.document,"arrowKey",(a,l)=>{this._handleArrowKeyPress(a,l)},{context:[Se,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",(a,l)=>{l.directChange&&e.model.change(c=>{c.removeSelectionAttribute(bi)})}),this._listenToIfEnabled(t.document,"change:data",()=>{const a=i.getSelectedElement();if(a){const l=e.editing.mapper.toViewElement(a);if(cn(l,a,o))return}e.model.change(l=>{l.removeSelectionAttribute(bi)})}),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",(a,l,c)=>{const u=c.writer;if(this._currentFakeCaretModelElement){const g=c.mapper.toViewElement(this._currentFakeCaretModelElement);g&&(u.removeClass(Sb.map(r),g),this._currentFakeCaretModelElement=null)}const d=l.selection.getSelectedElement();if(!d)return;const m=c.mapper.toViewElement(d);if(!cn(m,d,o))return;const f=zi(l.selection);f&&(u.addClass(r(f),m),this._currentFakeCaretModelElement=d)}),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",(a,l,c)=>{c||e.model.change(u=>{u.removeSelectionAttribute(bi)})});function r(a){return`ck-widget_type-around_show-fake-caret_${a}`}}_handleArrowKeyPress(e,t){const i=this.editor,o=i.model,s=o.document.selection,r=o.schema,a=i.editing.view,l=t.keyCode,c=pv(l,i.locale.contentLanguageDirection),u=a.document.selection.getSelectedElement(),d=i.editing.mapper.toModelElement(u);let m;cn(u,d,r)?m=this._handleArrowKeyPressOnSelectedWidget(c):s.isCollapsed?m=this._handleArrowKeyPressWhenSelectionNextToAWidget(c):t.shiftKey||(m=this._handleArrowKeyPressWhenNonCollapsedSelection(c)),m&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=t.document.selection,o=zi(i);return t.change(s=>{if(o){if(o!==(e?"after":"before"))return s.removeSelectionAttribute(bi),!0}else return s.setSelectionAttribute(bi,e?"after":"before"),!0;return!1})}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,o=i.schema,s=t.plugins.get("Widget"),r=s._getObjectElementNextToSelection(e),a=t.editing.mapper.toViewElement(r);return cn(a,r,o)?(i.change(l=>{s._setSelectionOverElement(r),l.setSelectionAttribute(bi,e?"before":"after")}),!0):!1}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,o=i.schema,s=t.editing.mapper,r=i.document.selection,a=e?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter,l=s.toViewElement(a);return cn(l,a,o)?(i.change(c=>{c.setSelection(a,"on"),c.setSelectionAttribute(bi,e?"after":"before")}),!0):!1}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",(i,o)=>{const s=HE(o.domTarget);if(!s)return;const r=$E(s),a=WE(s,t.domConverter),l=e.editing.mapper.toModelElement(a);this._insertParagraph(l,r),o.preventDefault(),i.stop()})}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",(o,s)=>{if(o.eventPhase!="atTarget")return;const r=t.getSelectedElement(),a=e.editing.mapper.toViewElement(r),l=e.model.schema;let c;this._insertParagraphAccordingToFakeCaretPosition()?c=!0:cn(a,r,l)&&(this._insertParagraph(r,s.isSoft?"before":"after"),c=!0),c&&(s.preventDefault(),o.stop())},{context:Se})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",(t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)},{priority:"high"}),N.isAndroid?this._listenToIfEnabled(e,"keydown",(t,i)=>{i.keyCode==229&&this._insertParagraphAccordingToFakeCaretPosition()}):this._listenToIfEnabled(e,"compositionstart",()=>{this._insertParagraphAccordingToFakeCaretPosition()},{priority:"highest"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,o=i.schema;this._listenToIfEnabled(t.document,"delete",(s,r)=>{if(s.eventPhase!="atTarget")return;const a=zi(i.document.selection);if(!a)return;const l=r.direction,c=i.document.selection.getSelectedElement(),u=a==="before",d=l=="forward";if(u===d)e.execute("delete",{selection:i.createSelection(c,"on")});else{const m=o.getNearestSelectionRange(i.createPositionAt(c,a),l);if(m)if(!m.isCollapsed)i.change(f=>{f.setSelection(m),e.execute(d?"deleteForward":"delete")});else{const f=i.createSelection(m.start);if(i.modifySelection(f,{direction:l}),!f.focus.isEqual(m.start))i.change(g=>{g.setSelection(m),e.execute(d?"deleteForward":"delete")});else{const g=ZE(o,m.start.parent);i.deleteContent(i.createSelection(g,"on"),{doNotAutoparagraph:!0})}}}r.preventDefault(),s.stop()},{context:Se})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",(o,[s,r])=>{if(r&&!r.is("documentSelection"))return;const a=zi(i);if(a)return o.stop(),t.change(l=>{const c=i.getSelectedElement(),u=t.createPositionAt(c,a),d=l.createSelection(u),m=t.insertContent(s,d);return l.setSelection(d),m})},{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",(i,o)=>{const[,s,r={}]=o;if(s&&!s.is("documentSelection"))return;const a=zi(t);a&&(r.findOptimalPosition=a,o[3]=r)},{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",(i,[o])=>{o&&!o.is("documentSelection")||zi(t)&&i.stop()},{priority:"high"})}}function qE(n,e,t){const i=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},function(o){const s=this.toDomElement(o);return GE(s,e),KE(s),s});n.insert(n.createPositionAt(t,"end"),i)}function GE(n,e){for(const t of Sb){const i=new qt({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${t}`],title:e[t],"aria-hidden":"true"},children:[n.ownerDocument.importNode(jE,!0)]});n.appendChild(i.render())}}function KE(n){const e=new qt({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});n.appendChild(e.render())}function ZE(n,e){let t=e;for(const i of e.getAncestors({parentFirst:!0})){if(i.childCount>1||n.isLimit(i))break;t=i}return t}function JE(n){const e=n.model;return(t,i)=>{const o=i.keyCode==Z.arrowup,s=i.keyCode==Z.arrowdown,r=i.shiftKey,a=e.document.selection;if(!o&&!s)return;const l=s;if(r&&XE(a,l))return;const c=QE(n,a,l);if(c){if(c.isCollapsed&&(a.isCollapsed||r))return;(c.isCollapsed||YE(n,c,l))&&(e.change(u=>{const d=l?c.end:c.start;if(r){const m=e.createSelection(a.anchor);m.setFocus(d),u.setSelection(m)}else u.setSelection(d)}),t.stop(),i.preventDefault(),i.stopPropagation())}}}function QE(n,e,t){const i=n.model;if(t){const o=e.isCollapsed?e.focus:e.getLastPosition(),s=vm(i,o,"forward");if(!s)return null;const r=i.createRange(o,s),a=ym(i.schema,r,"backward");return a?i.createRange(o,a):null}else{const o=e.isCollapsed?e.focus:e.getFirstPosition(),s=vm(i,o,"backward");if(!s)return null;const r=i.createRange(s,o),a=ym(i.schema,r,"forward");return a?i.createRange(a,o):null}}function vm(n,e,t){const i=n.schema,o=n.createRangeIn(e.root),s=t=="forward"?"elementStart":"elementEnd";for(const{previousPosition:r,item:a,type:l}of o.getWalker({startPosition:e,direction:t})){if(i.isLimit(a)&&!i.isInline(a))return r;if(l==s&&i.isBlock(a))return null}return null}function ym(n,e,t){const i=t=="backward"?e.end:e.start;if(n.checkChild(i,"$text"))return i;for(const{nextPosition:o}of e.getWalker({direction:t}))if(n.checkChild(o,"$text"))return o;return null}function YE(n,e,t){const i=n.model,o=n.view.domConverter;if(t){const c=i.createSelection(e.start);i.modifySelection(c),!c.focus.isAtEnd&&!e.start.isEqual(c.focus)&&(e=i.createRange(c.focus,e.end))}const s=n.mapper.toViewRange(e),r=o.viewRangeToDom(s),a=z.getDomRangeRects(r);let l;for(const c of a){if(l===void 0){l=Math.round(c.bottom);continue}if(Math.round(c.top)>=l)return!1;l=Math.max(l,Math.round(c.bottom))}return!0}function XE(n,e){return!n.isCollapsed&&n.isBackward==e}class Vt extends w{constructor(){super(...arguments),h(this,"_previouslySelected",new Set)}static get pluginName(){return"Widget"}static get isOfficialPlugin(){return!0}static get requires(){return[UE,en]}init(){const e=this.editor,t=e.editing.view,i=t.document,o=e.t;this.editor.editing.downcastDispatcher.on("selection",(s,r,a)=>{const l=a.writer,c=r.selection;if(c.isCollapsed)return;const u=c.getSelectedElement();if(!u)return;const d=e.editing.mapper.toViewElement(u);Se(d)&&a.consumable.consume(c,"selection")&&l.setSelection(l.createRangeOn(d),{fake:!0,label:FE(d)})}),this.editor.editing.downcastDispatcher.on("selection",(s,r,a)=>{this._clearPreviouslySelectedWidgets(a.writer);const l=a.writer,c=l.document.selection;let u=null;for(const d of c.getRanges())for(const m of d){const f=m.item;Se(f)&&!i3(f,u)&&(l.addClass(bm,f),this._previouslySelected.add(f),u=f)}},{priority:"low"}),t.addObserver(ua),this.listenTo(i,"mousedown",(...s)=>this._onMousedown(...s)),this.listenTo(i,"arrowKey",(...s)=>{this._handleSelectionChangeOnArrowKeyPress(...s)},{context:[Se,"$text"]}),this.listenTo(i,"arrowKey",(...s)=>{this._preventDefaultOnArrowKeyPress(...s)},{context:"$root"}),this.listenTo(i,"arrowKey",JE(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",(s,r)=>{this._handleDelete(r.direction=="forward")&&(r.preventDefault(),s.stop())},{context:"$root"}),this.listenTo(i,"tab",(s,r)=>{s.eventPhase=="atTarget"&&(r.shiftKey||this._selectFirstNestedEditable()&&(r.preventDefault(),s.stop()))},{context:Se,priority:"low"}),this.listenTo(i,"tab",(s,r)=>{r.shiftKey&&this._selectAncestorWidget()&&(r.preventDefault(),s.stop())},{priority:"low"}),this.listenTo(i,"keydown",(s,r)=>{r.keystroke==Z.esc&&this._selectAncestorWidget()&&(r.preventDefault(),s.stop())},{priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:o("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:o("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:o("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:o("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:o("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:o("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=this.editor,o=i.editing.view,s=o.document;let r=t.target;if(!r)return;if(t.domEvent.detail>=3){this._selectBlockContent(r)&&t.preventDefault();return}if(!Se(r)){const l=e3(r);if(!l)return;if(Se(l))r=l;else{const c=t3(o,t);if(c&&Se(c))r=c;else return}}N.isAndroid&&t.preventDefault(),s.isFocused||o.focus();const a=i.editing.mapper.toModelElement(r);this._setSelectionOverElement(a)}_selectBlockContent(e){const t=this.editor,i=t.model,o=t.editing.mapper,s=i.schema,r=o.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),a=n3(o.toModelElement(r),i.schema);return a?(i.change(l=>{const c=s.isLimit(a)?null:o3(l.createPositionAfter(a),s),u=l.createPositionAt(a,0),d=c?l.createPositionAt(c,0):l.createPositionAt(a,"end");l.setSelection(l.createRange(u,d))}),!0):!1}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,o=this.editor.model,s=o.schema,r=o.document.selection,a=r.getSelectedElement(),l=oa(i,this.editor.locale.contentLanguageDirection),c=l=="down"||l=="right",u=l=="up"||l=="down";if(a&&s.isObject(a)){const m=c?r.getLastPosition():r.getFirstPosition(),f=s.getNearestSelectionRange(m,c?"forward":"backward");f&&(o.change(g=>{g.setSelection(f)}),t.preventDefault(),e.stop());return}if(!r.isCollapsed&&!t.shiftKey){const m=r.getFirstPosition(),f=r.getLastPosition(),g=m.nodeAfter,p=f.nodeBefore;(g&&s.isObject(g)||p&&s.isObject(p))&&(o.change(_=>{_.setSelection(c?f:m)}),t.preventDefault(),e.stop());return}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(c);if(d&&s.isObject(d)){if(s.isInline(d)&&u)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,o=i.schema,s=i.document.selection.getSelectedElement();s&&o.isObject(s)&&(t.preventDefault(),e.stop())}_handleDelete(e){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t)||!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);if(i)return this.editor.model.change(o=>{let s=t.anchor.parent;for(;s.isEmpty;){const r=s;s=r.parent,o.remove(r)}this._setSelectionOverElement(i)}),!0}_setSelectionOverElement(e){this.editor.model.change(t=>{t.setSelection(t.createRangeOn(e))})}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,o=t.document.selection,s=t.createSelection(o);if(t.modifySelection(s,{direction:e?"forward":"backward"}),s.isEqual(o))return null;const r=e?s.focus.nodeBefore:s.focus.nodeAfter;return r&&i.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(bm,t);this._previouslySelected.clear()}_selectFirstNestedEditable(){const e=this.editor,t=this.editor.editing.view.document;for(const i of t.selection.getFirstRange().getItems())if(i.is("editableElement")){const o=e.editing.mapper.toModelElement(i);/* istanbul ignore next -- @preserve */if(!o)continue;const s=e.model.createPositionAt(o,0),r=e.model.schema.getNearestSelectionRange(s,"forward");return e.model.change(a=>{a.setSelection(r)}),!0}return!1}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,i=e.editing.view.document.selection.getFirstPosition().parent,o=(i.is("$text")?i.parent:i).findAncestor(Se);if(!o)return!1;const s=t.toModelElement(o);/* istanbul ignore next -- @preserve */return s?(e.model.change(r=>{r.setSelection(s,"on")}),!0):!1}}function e3(n){let e=n;for(;e;){if(e.is("editableElement")||Se(e))return e;e=e.parent}return null}function t3(n,e){const t=Qg(e.domEvent);let i=null;if(t?i=n.domConverter.domRangeToView(t):i=n.createRange(n.createPositionAt(e.target,0)),!i)return null;const o=i.start;if(!o.parent)return null;let s=o.parent;return o.parent.is("editableElement")&&(o.isAtEnd&&o.nodeBefore?s=o.nodeBefore:o.isAtStart&&o.nodeAfter&&(s=o.nodeAfter)),s.is("$text")?s.parent:s}function i3(n,e){return e?Array.from(n.getAncestors()).includes(e):!1}function n3(n,e){for(const t of n.getAncestors({includeSelf:!0,parentFirst:!0})){if(e.checkChild(t,"$text"))return t;if(e.isLimit(t)&&!e.isObject(t))break}return null}function o3(n,e){const t=new yi({startPosition:n});for(const{item:i}of t){if(e.isLimit(i)||!i.is("element"))return null;if(e.checkChild(i,"$text"))return i}return null}class ci extends w{constructor(){super(...arguments),h(this,"_toolbarDefinitions",new Map),h(this,"_balloon")}static get requires(){return[Ue]}static get pluginName(){return"WidgetToolbarRepository"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",i=>{s3(e.editing.view.document.selection)&&i.stop()},{priority:"high"})}this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",()=>{this._updateToolbarsVisibility()}),this.listenTo(e.ui,"update",()=>{this._updateToolbarsVisibility()}),this.listenTo(e.ui.focusTracker,"change:isFocused",()=>{this._updateToolbarsVisibility()},{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:i,getRelatedElement:o,balloonClassName:s="ck-toolbar-container",positions:r}){if(!i.length){J("widget-toolbar-no-items",{toolbarId:e});return}const a=this.editor,l=a.t,c=new Ei(a.locale);if(c.ariaLabel=t||l("Widget toolbar"),this._toolbarDefinitions.has(e))throw new b("widget-toolbar-duplicated",this,{toolbarId:e});const u={view:c,getRelatedElement:o,balloonClassName:s,itemsConfig:i,positions:r,initialized:!1};a.ui.addToolbar(c,{isContextual:!0,beforeFocus:()=>{const d=o(a.editing.view.document.selection);d&&this._showToolbar(u,d)},afterBlur:()=>{this._hideToolbar(u)}}),this._toolbarDefinitions.set(e,u)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const o of this._toolbarDefinitions.values()){const s=o.getRelatedElement(this.editor.editing.view.document.selection);if(!this.isEnabled||!s)this._isToolbarInBalloon(o)&&this._hideToolbar(o);else if(!this.editor.ui.focusTracker.isFocused)this._isToolbarVisible(o)&&this._hideToolbar(o);else{const r=s.getAncestors().length;r>e&&(e=r,t=s,i=o)}}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?km(this.editor,t,e.positions):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:Pb(this.editor,t,e.positions),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const i of this._toolbarDefinitions.values())if(this._isToolbarVisible(i)){const o=i.getRelatedElement(this.editor.editing.view.document.selection);km(this.editor,o,e.positions)}}))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function km(n,e,t){const i=n.plugins.get("ContextualBalloon"),o=Pb(n,e,t);i.updatePosition(o)}function Pb(n,e,t){const i=n.editing.view,o=Ne.defaultPositions;return{target:i.domConverter.mapViewToDom(e),positions:t||[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}function s3(n){const e=n.getSelectedElement();return!!(e&&Se(e))}class r3 extends ue(){constructor(e){super(),h(this,"_referenceCoordinates"),h(this,"_options"),h(this,"_originalWidth"),h(this,"_originalHeight"),h(this,"_originalWidthPercents"),h(this,"_aspectRatio"),this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(e,t,i){const o=new z(t);this.activeHandlePosition=c3(e),this._referenceCoordinates=a3(t,u3(this.activeHandlePosition)),this._originalWidth=o.width,this._originalHeight=o.height,this._aspectRatio=o.width/o.height;const s=i.style.width;s&&s.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(s):this._originalWidthPercents=zE(i,o)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function a3(n,e){const t=new z(n),i=e.split("-"),o={x:i[1]=="right"?t.right:t.left,y:i[0]=="bottom"?t.bottom:t.top};return o.x+=n.ownerDocument.defaultView.scrollX,o.y+=n.ownerDocument.defaultView.scrollY,o}function l3(n){return`ck-widget__resizer__handle-${n}`}function c3(n){const e=["top-left","top-right","bottom-right","bottom-left"];for(const t of e)if(n.classList.contains(l3(t)))return t}function u3(n){const e=n.split("-"),t={top:"bottom",bottom:"top",left:"right",right:"left"};return`${t[e[0]]}-${t[e[1]]}`}class h3 extends A{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",t=>t?`ck-orientation-${t}`:"")],style:{display:e.if("_isVisible","none",t=>!t)}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",(i,o)=>i!==null&&o!==null),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",(i,o,s)=>e.unit==="px"?`${i}×${o}`:`${s}%`),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",(i,o,s)=>o<50||s<50?"above-center":i)}_dismiss(){this.unbind(),this._isVisible=!1}}class Cm extends ue(){constructor(e){super(),h(this,"_state"),h(this,"_sizeView"),h(this,"_options"),h(this,"_viewResizerWrapper",null),h(this,"_initialViewWidth"),this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",(t,i)=>t&&i),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",t=>{!this.state.proposedWidth&&!this.state.proposedWidthPercents&&(this._cleanup(),t.stop())},{priority:"high"})}get state(){return this._state}show(){this._options.editor.editing.view.change(e=>{e.removeClass("ck-hidden",this._viewResizerWrapper)})}hide(){this._options.editor.editing.view.change(e=>{e.addClass("ck-hidden",this._viewResizerWrapper)})}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change(i=>{const o=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},function(s){const r=this.toDomElement(s);return e._appendHandles(r),e._appendSizeUI(r),r});i.insert(i.createPositionAt(t,"end"),o),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=o,this.isVisible||this.hide()}),this.on("change:isVisible",()=>{this.isVisible?(this.show(),this.redraw()):this.hide()})}begin(e){this._state=new r3(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change(l=>{const c=this._options.unit||"%",u=(c==="%"?t.widthPercents:t.width)+c;l.setStyle("width",u,this._options.viewElement)});const i=this._getHandleHost(),o=new z(i),s=Math.round(o.width),r=Math.round(o.height),a=new z(i);t.width=Math.round(a.width),t.height=Math.round(a.height),this.redraw(o),this.state.update({...t,handleHostWidth:s,handleHostHeight:r})}commit(){const e=this._options.unit||"%",t=(e==="%"?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change(()=>{this._cleanup(),this._options.onCommit(t)})}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!f3(t))return;const i=t.parentElement,o=this._getHandleHost(),s=this._viewResizerWrapper,r=[s.getStyle("width"),s.getStyle("height"),s.getStyle("left"),s.getStyle("top")];let a;if(i.isSameNode(o)){const l=e||new z(o);a=[l.width+"px",l.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];Xe(r,a)!=="same"&&this._options.editor.editing.view.change(l=>{l.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},s)})}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss(),this._options.editor.editing.view.change(e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(e){const t=this.state,i=m3(e),o=this._options.isCentered?this._options.isCentered(this):!0,s={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(s.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(s.x*=2);let r=Math.abs(t.originalWidth+s.x),a=Math.abs(t.originalHeight+s.y);return(r/t.aspectRatio>a?"width":"height")=="width"?a=r/t.aspectRatio:r=a*t.aspectRatio,{width:Math.round(r),height:Math.round(a),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*r*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)e.appendChild(new qt({tag:"div",attributes:{class:`ck-widget__resizer__handle ${d3(i)}`}}).render())}_appendSizeUI(e){this._sizeView=new h3,this._sizeView.render(),e.appendChild(this._sizeView.element)}}function d3(n){return`ck-widget__resizer__handle-${n}`}function m3(n){return{x:n.pageX,y:n.pageY}}function f3(n){return n&&n.ownerDocument&&n.ownerDocument.contains(n)}class ul extends w{constructor(){super(...arguments),h(this,"_resizers",new Map),h(this,"_observer"),h(this,"_redrawSelectedResizerThrottled")}static get pluginName(){return"WidgetResize"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.editing,t=I.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(ua),this._observer=new(st()),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=co(()=>this.redrawSelectedResizer(),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",()=>{for(const[o,s]of this._resizers)o.isAttached()||(this._resizers.delete(o),s.destroy())},{priority:"lowest"}),this._observer.listenTo(I.window,"resize",this._redrawSelectedResizerThrottled);const i=this.editor.editing.view.document.selection;i.on("change",()=>{const o=i.getSelectedElement(),s=this.getResizerByViewElement(o)||null;s?this.select(s):this.deselect()})}redrawSelectedResizer(){this.selectedResizer&&this.selectedResizer.isVisible&&this.selectedResizer.redraw()}destroy(){super.destroy(),this._observer.stopListening();for(const e of this._resizers.values())e.destroy();this._redrawSelectedResizerThrottled.cancel()}select(e){this.deselect(),this.selectedResizer=e,this.selectedResizer.isSelected=!0}deselect(){this.selectedResizer&&(this.selectedResizer.isSelected=!1),this.selectedResizer=null}attachTo(e){const t=new Cm(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const s=i.get("WidgetToolbarRepository");t.on("begin",()=>{s.forceDisabled("resize")},{priority:"lowest"}),t.on("cancel",()=>{s.clearForceDisabled("resize")},{priority:"highest"}),t.on("commit",()=>{s.clearForceDisabled("resize")},{priority:"highest"})}this._resizers.set(e.viewElement,t);const o=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(o)==t&&this.select(t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const i=t.domTarget;Cm.isResizeHandle(i)&&(this._activeResizer=this._getResizerByHandle(i)||null,this._activeResizer&&(this._activeResizer.begin(i),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class g3 extends A{constructor(e,t){super(e),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"idInputView"),h(this,"backButtonView"),h(this,"saveButtonView"),h(this,"children"),h(this,"_validators"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.idInputView=this._createIdInput(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new $e(e,{children:[this.idInputView,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this.keystrokes.set("Esc",(i,o)=>{this.fire("cancel"),o()}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-bookmark-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),[this.backButtonView,this.idInputView,this.saveButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.idInputView.focus()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.idInputView.errorText=t,!1}return!0}resetFormStatus(){this.idInputView.errorText=null}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new P(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Bookmark")});return t.children.add(this.backButtonView,0),t}_createIdInput(){const e=this.locale.t,t=new Te(this.locale,nt);return t.label=e("Bookmark name"),t.infoText=e("Enter the bookmark name without spaces."),t.class="ck-labeled-field-view_full-width",t}get id(){const{element:e}=this.idInputView.fieldView;return e?e.value.trim():null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ib(n){return!(!n||typeof n!="string"||/\s/.test(n))}class p3 extends O{refresh(){const e=this.editor.model.document.selection,t=this._getPositionToInsertBookmark(e);this.isEnabled=!!t}execute(e){if(!e)return;const{bookmarkId:t}=e;if(!Ib(t)){J("insert-bookmark-command-executed-with-invalid-name");return}const i=this.editor,o=i.model,s=o.document.selection;o.change(r=>{let a=this._getPositionToInsertBookmark(s);if(!o.schema.checkChild(a,"bookmark")){const c=i.execute("insertParagraph",{position:a});if(!c)return;a=c}const l=r.createElement("bookmark",{...Object.fromEntries(s.getAttributes()),bookmarkId:t});o.insertObject(l,a,null,{setSelection:"on"})})}_getPositionToInsertBookmark(e){const t=this.editor.model,i=t.schema,o=e.getFirstRange(),s=o.start;if(hl(s,i))return s;for(const{previousPosition:r,item:a}of o){if(a.is("element")&&i.checkChild(a,"$text")&&hl(a,i))return t.createPositionAt(a,0);if(hl(r,i))return r}return null}}function hl(n,e){return e.checkChild(n,"bookmark")?!0:e.checkChild(n,"paragraph")?e.checkChild("paragraph","bookmark"):!1}class w3 extends O{refresh(){const e=this.editor.model.document.selection,t=Am(e);this.isEnabled=!!t,this.value=t?t.getAttribute("bookmarkId"):void 0}execute(e){if(!e)return;const{bookmarkId:t}=e;if(!Ib(t)){J("update-bookmark-command-executed-with-invalid-name");return}const i=this.editor.model,o=i.document.selection,s=Am(o);s&&i.change(r=>{r.setAttribute("bookmarkId",t,s)})}}function Am(n){const e=n.getSelectedElement();return e&&e.is("element","bookmark")?e:null}class ns extends w{constructor(e){super(e),h(this,"_bookmarkElements",new Map),e.config.define("bookmark",{toolbar:["bookmarkPreview","|","editBookmark","removeBookmark"]})}static get pluginName(){return"BookmarkEditing"}static get isOfficialPlugin(){return!0}init(){const{editor:e}=this;this._defineSchema(),this._defineConverters(),e.commands.add("insertBookmark",new p3(e)),e.commands.add("updateBookmark",new w3(e)),this.listenTo(e.model.document,"change:data",()=>{this._trackBookmarkElements()})}getElementForBookmarkId(e){for(const[t,i]of this._bookmarkElements)if(i==e)return t;return null}getAllBookmarkNames(){return new Set(this._bookmarkElements.values())}_defineSchema(){this.editor.model.schema.register("bookmark",{inheritAllFrom:"$inlineObject",allowAttributes:"bookmarkId",disallowAttributes:["linkHref","htmlA"]})}_defineConverters(){const{editor:e}=this,{conversion:t,t:i}=e;e.data.htmlProcessor.domConverter.registerInlineObjectMatcher(o=>oc(o)),e.editing.view.domConverter.registerInlineObjectMatcher(o=>oc(o,!1)),t.for("dataDowncast").elementToElement({model:{name:"bookmark",attributes:["bookmarkId"]},view:(o,{writer:s})=>s.createEmptyElement("a",{id:o.getAttribute("bookmarkId")})}),t.for("editingDowncast").elementToElement({model:{name:"bookmark",attributes:["bookmarkId"]},view:(o,{writer:s})=>{const r=o.getAttribute("bookmarkId"),a=s.createContainerElement("a",{id:r,class:"ck-bookmark"},[this._createBookmarkUIElement(s)]);return s.setCustomProperty("bookmark",!0,a),this._bookmarkElements.set(o,r),gt(a,s,{label:()=>`${r} ${i("bookmark widget")}`})}}),t.for("upcast").add(o=>o.on("element:a",b3(e)))}_createBookmarkUIElement(e){return e.createUIElement("span",{class:"ck-bookmark__icon"},function(t){const i=this.toDomElement(t),o=new hi;return o.set({content:dC,isColorInherited:!1}),o.render(),i.appendChild(o.element),i})}_trackBookmarkElements(){this._bookmarkElements.forEach((e,t)=>{t.root.rootName==="$graveyard"&&this._bookmarkElements.delete(t)})}}function oc(n,e=!0){if(n.name!=="a"||e&&!n.isEmpty)return null;const t=n.hasAttribute("id"),i=n.hasAttribute("name"),o=n.hasAttribute("href");return t&&!o?{name:!0,attributes:["id"]}:i&&!o?{name:!0,attributes:["name"]}:null}function b3(n){return(e,t,i)=>{const o=t.viewItem,s=oc(o,!1);if(!s||!i.consumable.test(o,s)||!_3(n)&&!o.isEmpty)return;const r=i.writer,a=o.getAttribute("id"),l=o.getAttribute("name"),c=a||l,u=r.createElement("bookmark",{bookmarkId:c});if(!i.safeInsert(u,t.modelCursor))return;i.consumable.consume(o,s),a===l&&i.consumable.consume(o,{attributes:["name"]}),i.updateConversionResult(u,t);const{modelCursor:d,modelRange:m}=i.convertChildren(o,t.modelCursor);t.modelCursor=d,t.modelRange=r.createRange(t.modelRange.start,m.end)}}function _3(n){const e=n.config.get("bookmark.enableNonEmptyAnchorConversion");return e!==void 0?e:!0}const Yt="bookmark-ui";class v3 extends w{constructor(){super(...arguments),h(this,"formView",null),h(this,"_balloon")}static get requires(){return[ns,Ue,ci]}static get pluginName(){return"BookmarkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;this._balloon=e.plugins.get(Ue),e.plugins.has("LinkUI")&&this._registerLinkProvider(),this._registerComponents(),e.conversion.for("editingDowncast").markerToHighlight({model:Yt,view:{classes:["ck-fake-bookmark-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Yt,view:(t,{writer:i})=>{if(!t.markerRange.isCollapsed)return null;const o=i.createUIElement("span");return i.addClass(["ck-fake-bookmark-selection","ck-fake-bookmark-selection_collapsed"],o),o}})}afterInit(){const e=this.editor,t=e.locale.t,i=this.editor.plugins.get(ci),o=Ne.defaultPositions;i.register("bookmark",{ariaLabel:t("Bookmark toolbar"),items:e.config.get("bookmark.toolbar"),getRelatedElement:k3,balloonClassName:"ck-bookmark-balloon ck-toolbar-container",positions:[o.southArrowNorth,o.southArrowNorthMiddleWest,o.southArrowNorthMiddleEast,o.southArrowNorthWest,o.southArrowNorthEast,o.northArrowSouth,o.northArrowSouthMiddleWest,o.northArrowSouthMiddleEast,o.northArrowSouthWest,o.northArrowSouthEast,o.viewportStickyNorth]})}destroy(){super.destroy(),this.formView&&this.formView.destroy()}_createViews(){this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createFormView(){const e=this.editor,t=e.locale,i=t.t,o=e.commands.get("insertBookmark"),s=e.commands.get("updateBookmark"),r=[o,s],a=new(ho(g3))(t,y3(e));return a.idInputView.fieldView.bind("value").to(s,"value"),a.saveButtonView.bind("label").to(s,"value",l=>i(l?"Save":"Insert")),a.idInputView.bind("isEnabled").toMany(r,"isEnabled",(...l)=>l.some(c=>c)),a.saveButtonView.bind("isEnabled").toMany(r,"isEnabled",(...l)=>l.some(c=>c)),this.listenTo(a,"cancel",()=>{this._hideFormView()}),this.listenTo(a,"submit",()=>{if(a.isValid()){const l=a.id;this._getSelectedBookmarkElement()?e.execute("updateBookmark",{bookmarkId:l}):e.execute("insertBookmark",{bookmarkId:l}),this._hideFormView()}}),this.listenTo(a.idInputView,"change:errorText",()=>{e.ui.update()}),a}_registerLinkProvider(){const e=this.editor.locale.t,t=this.editor.plugins.get("LinkUI"),i=this.editor.plugins.get(ns),o=()=>Array.from(i.getAllBookmarkNames()).sort((r,a)=>r.localeCompare(a)).map(r=>({id:r,href:`#${r}`,label:r,icon:fC})),s=r=>{const a=[...i.getAllBookmarkNames()].find(l=>`#${l}`===r);return a?{href:r,label:a,icon:gC,tooltip:e("Scroll to bookmark")}:null};t.registerLinksListProvider({label:e("Bookmarks"),emptyListPlaceholder:e("No bookmarks available."),navigate:({href:r})=>this._scrollToBookmark(r),getListItems:o,getItem:s})}_scrollToBookmark(e){const t=this.editor.plugins.get(ns).getElementForBookmarkId(e.slice(1));return t?(this.editor.model.change(i=>{i.setSelection(t,"on")}),this.editor.editing.view.scrollToTheSelection({alignToTop:!0,forceScroll:!0}),!0):!1}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("bookmark",()=>{const t=this._createBookmarkButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:bookmark",()=>this._createBookmarkButton(ve)),e.ui.componentFactory.add("bookmarkPreview",t=>{const i=e.commands.get("updateBookmark"),o=new xt(t);return o.extendTemplate({attributes:{class:["ck-bookmark-toolbar__preview"]}}),o.bind("text").to(i,"value"),o}),e.ui.componentFactory.add("editBookmark",t=>{const i=e.commands.get("updateBookmark"),o=new P(t),s=t.t;return o.set({label:s("Edit bookmark"),icon:kw,tooltip:!0}),o.bind("isEnabled").to(i),this.listenTo(o,"execute",()=>{this._showFormView()}),o}),e.ui.componentFactory.add("removeBookmark",t=>{const i=e.commands.get("delete"),o=new P(t),s=t.t;return o.set({label:s("Remove bookmark"),icon:sA,tooltip:!0}),o.bind("isEnabled").to(i),this.listenTo(o,"execute",()=>{e.execute("delete"),e.editing.view.focus()}),o})}_createBookmarkButton(e){const t=this.editor,i=t.locale,o=new e(i),s=t.commands.get("insertBookmark"),r=t.commands.get("updateBookmark"),a=i.t;return o.set({label:a("Bookmark"),icon:mC}),this.listenTo(o,"execute",()=>{t.editing.view.scrollToTheSelection(),this._showFormView()}),o.bind("isEnabled").toMany([s,r],"isEnabled",(...l)=>l.some(c=>c)),o.bind("isOn").to(r,"value",l=>!!l),o}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Esc",(e,t)=>{this._isFormVisible&&(this._hideFormView(),t())}),$t({emitter:this.formView,activator:()=>this._isFormInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideFormView(!1)}})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("updateBookmark");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.formView.backButtonView.isVisible=e.isEnabled,this.formView.idInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.idInputView.fieldView.select(),this.formView.enableCssTransitions()}_removeFormView(e=!0){this.formView.saveButtonView.focus(),this.formView.idInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection()}_showFormView(){this.formView||this._createViews(),this._getSelectedBookmarkElement()||this._showFakeVisualSelection(),this._addFormView(),this._balloon.showStack("main"),this._startUpdatingUI()}_hideFormView(e=!0){if(!this._isFormInPanel)return;const t=this.editor;this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e&&t.editing.view.focus(),this._removeFormView(e),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedBookmarkElement(),o=r();const s=()=>{const a=this._getSelectedBookmarkElement(),l=r();i&&!a||!i&&l!==o?this._hideFormView():this._isFormVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=a,o=l};function r(){return t.selection.focus.getAncestors().reverse().find(a=>a.is("element"))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model;let i;const o=this._getSelectedBookmarkElement();if(t.markers.has(Yt)){const s=Array.from(this.editor.editing.mapper.markerNameToElements(Yt)),r=e.createRange(e.createPositionBefore(s[0]),e.createPositionAfter(s[s.length-1]));i=e.domConverter.viewRangeToDom(r)}else o&&(i=()=>{const s=this.editor.editing.mapper,r=e.domConverter,a=s.toViewElement(o);return r.mapViewToDom(a)});if(i)return{target:i}}_getSelectedBookmarkElement(){const e=this.editor.model.document.selection.getSelectedElement();return e&&e.is("element","bookmark")?e:null}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(Yt))t.updateMarker(Yt,{range:i});else if(i.start.isAtEnd){const o=i.start.getLastMatchingPosition(({item:s})=>!e.schema.isContent(s),{boundaries:i});t.addMarker(Yt,{usingOperation:!1,affectsData:!1,range:t.createRange(o,i.end)})}else t.addMarker(Yt,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Yt)&&e.change(t=>{t.removeMarker(Yt)})}}function y3(n){const{t:e}=n,t=n.plugins.get(ns);return[i=>{if(!i.id)return e("Bookmark must not be empty.")},i=>{if(i.id&&/\s/.test(i.id))return e("Bookmark name cannot contain space characters.")},i=>{const o=n.model.document.selection.getSelectedElement(),s=t.getElementForBookmarkId(i.id);if(o!==s&&s)return e("Bookmark name already exists.")}]}function k3(n){const e=n.getSelectedElement();return!e||!Se(e)||!e.getCustomProperty("bookmark")?null:e}class C3 extends w{static get pluginName(){return"Bookmark"}static get requires(){return[ns,v3,Vt]}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bs extends ui{constructor(e){super(e),h(this,"domEventType",["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"]);const t=this.document;this.listenTo(t,"paste",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",i("dragging"),{priority:"low"});function i(o){return(s,r)=>{r.preventDefault();const a=r.dropRange?[r.dropRange]:null,l=new Ti(t,o);t.fire(l,{dataTransfer:r.dataTransfer,method:s.name,targetRanges:a,target:r.target,domEvent:r.domEvent}),l.stop.called&&r.stopPropagation()}}}onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,i=e.type=="drop"||e.type=="paste",o={dataTransfer:new kp(t,{cacheFiles:i})};if(e.type=="drop"||e.type=="dragover"){const s=Qg(e);o.dropRange=s&&this.view.domConverter.domRangeToView(s)}this.fire(e.type,e,o)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function A3(n){return n=n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r?\n\r?\n/g,"</p><p>").replace(/\r?\n/g,"<br>").replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;").replace(/^\s/,"&nbsp;").replace(/\s$/,"&nbsp;").replace(/\s\s/g," &nbsp;"),(n.includes("</p><p>")||n.includes("<br>"))&&(n=`<p>${n}</p>`),n}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function x3(n){return n.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>t.length==1?" ":t).replace(/<!--[\s\S]*?-->/g,"")}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const xm=["figcaption","li"],Tm=["ol","ul"];function Vb(n,e){if(e.is("$text")||e.is("$textProxy"))return e.data;if(e.is("element","img")&&e.hasAttribute("alt"))return e.getAttribute("alt");if(e.is("element","br"))return`
`;let t="",i=null;for(const o of e.getChildren())t+=T3(o,i)+Vb(n,o),i=o;if(e.is("rawElement")){const o=document.createElement("div");e.render(o,n),t+=Rb(o)}return t}function Rb(n){let e="";if(n.nodeType===Node.TEXT_NODE)return n.textContent;if(n.tagName==="BR")return`
`;for(const t of n.childNodes)e+=Rb(t);return e}function T3(n,e){return e?n.is("element","li")&&!n.isEmpty&&n.getChild(0).is("containerElement")||Tm.includes(n.name)&&Tm.includes(e.name)?`
`:!n.is("containerElement")&&!e.is("containerElement")?"":xm.includes(n.name)||xm.includes(e.name)?`
`:n.is("element")&&n.getCustomProperty("dataPipeline:transparentRendering")||e.is("element")&&e.getCustomProperty("dataPipeline:transparentRendering")?"":`
`:""}class os extends w{constructor(){super(...arguments),h(this,"_markersToCopy",new Map)}static get pluginName(){return"ClipboardMarkersUtils"}static get isOfficialPlugin(){return!0}_registerMarkerToCopy(e,t){this._markersToCopy.set(e,t)}_copySelectedFragmentWithMarkers(e,t,i=o=>o.model.getSelectedContent(o.model.document.selection)){return this.editor.model.change(o=>{const s=o.model.document.selection;o.setSelection(t);const r=this._insertFakeMarkersIntoSelection(o,o.model.document.selection,e),a=i(o),l=this._removeFakeMarkersInsideElement(o,a);for(const[c,u]of Object.entries(r)){l[c]||(l[c]=o.createRangeIn(a));for(const d of u)o.remove(d)}a.markers.clear();for(const[c,u]of Object.entries(l))a.markers.set(c,u);return o.setSelection(s),a})}_pasteMarkersIntoTransformedElement(e,t){const i=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change(o=>{const s=this._insertFakeMarkersElements(o,i),r=t(o),a=this._removeFakeMarkersInsideElement(o,r);for(const l of Object.values(s).flat())o.remove(l);for(const[l,c]of Object.entries(a))o.model.markers.has(l)||o.addMarker(l,{usingOperation:!0,affectsData:!0,range:c});return r})}_pasteFragmentWithMarkers(e){const t=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const i of t)e.markers.set(i.name,i.range);return this.editor.model.insertContent(e)}_forceMarkersCopy(e,t,i={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const o=this._markersToCopy.get(e);this._markersToCopy.set(e,i),t(),o?this._markersToCopy.set(e,o):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const i=this._getMarkerClipboardConfig(e);if(!i)return!1;if(!t)return!0;const{allowedActions:o}=i;return o==="all"||o.includes(t)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[t]=e.split(":");return this._markersToCopy.get(t)||null}_insertFakeMarkersIntoSelection(e,t,i){const o=this._getCopyableMarkersFromSelection(e,t,i);return this._insertFakeMarkersElements(e,o)}_getCopyableMarkersFromSelection(e,t,i){const o=Array.from(t.getRanges()),s=new Set(o.flatMap(a=>Array.from(e.model.markers.getMarkersIntersectingRange(a)))),r=a=>{if(!this._isMarkerCopyable(a.name,i))return!1;const{copyPartiallySelected:l}=this._getMarkerClipboardConfig(a.name);if(!l){const c=a.getRange();return o.some(u=>u.containsRange(c,!0))}return!0};return Array.from(s).filter(r).map(a=>({name:i==="dragstart"?this._getUniqueMarkerName(a.name):a.name,range:a.getRange()}))}_getPasteMarkersFromRangeMap(e,t=null){const{model:i}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap(([o,s])=>{if(!this._hasMarkerConfiguration(o))return[{name:o,range:s}];if(this._isMarkerCopyable(o,t)){const r=this._getMarkerClipboardConfig(o),a=i.markers.has(o)&&i.markers.get(o).getRange().root.rootName==="$graveyard";return(r.duplicateOnPaste||a)&&(o=this._getUniqueMarkerName(o)),[{name:o,range:s}]}return[]})}_insertFakeMarkersElements(e,t){const i={},o=t.flatMap(s=>{const{start:r,end:a}=s.range;return[{position:r,marker:s,type:"start"},{position:a,marker:s,type:"end"}]}).sort(({position:s},{position:r})=>s.isBefore(r)?1:-1);for(const{position:s,marker:r,type:a}of o){const l=e.createElement("$marker",{"data-name":r.name,"data-type":a});i[r.name]||(i[r.name]=[]),i[r.name].push(l),e.insert(l,s)}return i}_removeFakeMarkersInsideElement(e,t){const i=this._getAllFakeMarkersFromElement(e,t).reduce((o,s)=>{const r=s.markerElement&&e.createPositionBefore(s.markerElement);let a=o[s.name],l=!1;return a!=null&&a.start&&a!=null&&a.end&&(this._getMarkerClipboardConfig(s.name).duplicateOnPaste?o[this._getUniqueMarkerName(s.name)]=o[s.name]:l=!0,a=null),l||(o[s.name]={...a,[s.type]:r}),s.markerElement&&e.remove(s.markerElement),o},{});return __(i,o=>new y(o.start||e.createPositionFromPath(t,[0]),o.end||e.createPositionAt(t,"end")))}_getAllFakeMarkersFromElement(e,t){const i=Array.from(e.createRangeIn(t)).flatMap(({item:r})=>{if(!r.is("element","$marker"))return[];const a=r.getAttribute("data-name"),l=r.getAttribute("data-type");return[{markerElement:r,name:a,type:l}]}),o=[],s=[];for(const r of i)r.type==="end"&&(i.some(a=>a.name===r.name&&a.type==="start")||o.push({markerElement:null,name:r.name,type:"start"})),r.type==="start"&&(i.some(a=>a.name===r.name&&a.type==="end")||s.unshift({markerElement:null,name:r.name,type:"end"}));return[...o,...i,...s]}_getUniqueMarkerName(e){const t=e.split(":"),i=ze().substring(1,6);return t.length===3?`${t.slice(0,2).join(":")}:${i}`:`${t.join(":")}:${i}`}}class pt extends w{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[os]}init(){this.editor.editing.view.addObserver(bs),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const o=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:i==="cut"},()=>{const s=o._copySelectedFragmentWithMarkers(i,t);this.fire("outputTransformation",{dataTransfer:e,content:s,method:i})})}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,o=i.document,s=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(o,"clipboardInput",(r,a)=>{a.method=="paste"&&!e.model.canEditAt(e.model.document.selection)&&r.stop()},{priority:"highest"}),this.listenTo(o,"clipboardInput",(r,a)=>{const l=a.dataTransfer;let c;if(a.content)c=a.content;else{let m="";l.getData("text/html")?m=x3(l.getData("text/html")):l.getData("text/plain")&&(m=A3(l.getData("text/plain"))),c=this.editor.data.htmlProcessor.toView(m)}const u=new Ti(this,"inputTransformation"),d=l.getData("application/ckeditor5-editor-id")||null;this.fire(u,{content:c,dataTransfer:l,sourceEditorId:d,targetRanges:a.targetRanges,method:a.method}),u.stop.called&&r.stop(),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(r,a)=>{if(a.content.isEmpty)return;const l=this.editor.data.toModel(a.content,"$clipboardHolder");l.childCount!=0&&(r.stop(),t.change(()=>{this.fire("contentInsertion",{content:l,method:a.method,sourceEditorId:a.sourceEditorId,dataTransfer:a.dataTransfer,targetRanges:a.targetRanges})}))},{priority:"low"}),this.listenTo(this,"contentInsertion",(r,a)=>{a.resultRange=s._pasteFragmentWithMarkers(a.content)},{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,o=(s,r)=>{const a=r.dataTransfer;r.preventDefault(),this._fireOutputTransformationEvent(a,t.selection,s.name)};this.listenTo(i,"copy",o,{priority:"low"}),this.listenTo(i,"cut",(s,r)=>{e.model.canEditAt(e.model.document.selection)?o(s,r):r.preventDefault()},{priority:"low"}),this.listenTo(this,"outputTransformation",(s,r)=>{const a=e.data.toView(r.content,{isClipboardPipeline:!0});i.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:a,method:r.method})},{priority:"low"}),this.listenTo(i,"clipboardOutput",(s,r)=>{r.content.isEmpty||(r.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(r.content)),r.dataTransfer.setData("text/plain",Vb(e.data.htmlProcessor.domConverter,r.content)),r.dataTransfer.setData("application/ckeditor5-editor-id",this.editor.id)),r.method=="cut"&&e.model.deleteContent(t.selection)},{priority:"low"})}}const dl=Vi("px");class E3 extends A{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",t=>!t)],style:{left:e.to("left",t=>dl(t)),top:e.to("top",t=>dl(t)),width:e.to("width",t=>dl(t))}}})}}class Ys extends w{constructor(){super(...arguments),h(this,"removeDropMarkerDelayed",$c(()=>this.removeDropMarker(),40)),h(this,"_updateDropMarkerThrottled",co(e=>this._updateDropMarker(e),40)),h(this,"_reconvertMarkerThrottled",co(()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")},0)),h(this,"_dropTargetLineView",new E3),h(this,"_domEmitter",new(st())),h(this,"_scrollables",new Map)}static get pluginName(){return"DragDropTarget"}static get isOfficialPlugin(){return!0}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,i,o,s,r){this.removeDropMarkerDelayed.cancel();const a=Em(this.editor,e,t,i,o,s,r);/* istanbul ignore next -- @preserve */if(a){if(r&&r.containsRange(a))return this.removeDropMarker();this._updateDropMarkerThrottled(a)}}getFinalDropRange(e,t,i,o,s,r){const a=Em(this.editor,e,t,i,o,s,r);return this.removeDropMarker(),a}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change(t=>{t.removeMarker("drop-target")})}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(i);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const t=this.editor,i=t.model.markers;t.model.change(o=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||o.updateMarker("drop-target",{range:e}):o.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})})}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},function(t){const i=this.toDomElement(t);return i.append("⁠",t.createElement("span"),"⁠"),i})}_updateDropTargetLine(e){const t=this.editor.editing,i=e.start.nodeBefore,o=e.start.nodeAfter,s=e.start.parent,r=i?t.mapper.toViewElement(i):null,a=r?t.view.domConverter.mapViewToDom(r):null,l=o?t.mapper.toViewElement(o):null,c=l?t.view.domConverter.mapViewToDom(l):null,u=t.mapper.toViewElement(s);if(!u)return;const d=t.view.domConverter.mapViewToDom(u),m=this._getScrollableRect(u),{scrollX:f,scrollY:g}=I.window,p=a?new z(a):null,_=c?new z(c):null,v=new z(d).excludeScrollbarsAndBorders(),E=p?p.bottom:v.top,M=_?_.top:v.bottom,G=I.window.getComputedStyle(d),X=E<=M?(E+M)/2:M;if(m.top<X&&X<m.bottom){const T=v.left+parseFloat(G.paddingLeft),F=v.right-parseFloat(G.paddingRight),x=Math.max(T+f,m.left),q=Math.min(F+f,m.right);this._dropTargetLineView.set({isVisible:!0,left:x,top:X+g,width:q-x})}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{const o=this.editor.editing.view.domConverter.mapViewToDom(e);i=P3(o),this._domEmitter.listenTo(i,"scroll",this._reconvertMarkerThrottled,{usePassive:!0});const s=new bo(i,this._reconvertMarkerThrottled);this._scrollables.set(t,{domElement:i,resizeObserver:s})}return new z(i).excludeScrollbarsAndBorders()}}function Em(n,e,t,i,o,s,r){const a=n.model,l=n.editing.mapper;let c=Sm(n,e);for(;c;){if(!s){if(a.schema.checkChild(c,"$text")){if(t){const u=t[0].start,d=l.toModelPosition(u);if(!r||Array.from(r.getItems({shallow:!0})).every(m=>a.schema.checkChild(d,m))){if(a.schema.checkChild(d,"$text"))return a.createRange(d);if(u)return Xs(n,Sm(n,u.parent),i,o)}}}else if(a.schema.isInline(c))return Xs(n,c,i,o)}if(a.schema.isBlock(c))return Xs(n,c,i,o);if(a.schema.checkChild(c,"$block")){const u=Array.from(c.getChildren()).filter(f=>f.is("element")&&!S3(n,f));let d=0,m=u.length;if(m==0)return a.createRange(a.createPositionAt(c,"end"));for(;d<m-1;){const f=Math.floor((d+m)/2);Ob(n,u[f],i,o)=="before"?m=f:d=f}return Xs(n,u[d],i,o)}c=c.parent}return null}function S3(n,e){const t=n.editing.mapper,i=n.editing.view.domConverter,o=t.toViewElement(e);if(!o)return!0;const s=i.mapViewToDom(o);return I.window.getComputedStyle(s).float!="none"}function Xs(n,e,t,i){const o=n.model;return o.createRange(o.createPositionAt(e,Ob(n,e,t,i)))}function Ob(n,e,t,i){const o=n.editing.mapper,s=n.editing.view.domConverter,r=o.toViewElement(e),a=s.mapViewToDom(r),l=new z(a);return n.model.schema.isInline(e)?t<(l.left+l.right)/2?"before":"after":i<(l.top+l.bottom)/2?"before":"after"}function Sm(n,e){const t=n.editing.mapper,i=n.editing.view,o=t.toModelElement(e);if(o)return o;const s=i.createPositionBefore(e),r=t.findMappedViewAncestor(s);return t.toModelElement(r)}function P3(n){let e=n;do{e=e.parentElement;const t=I.window.getComputedStyle(e).overflowY;if(t=="auto"||t=="scroll")break}while(e.tagName!="BODY");return e}class I3 extends w{constructor(){super(...arguments),h(this,"_isBlockDragging",!1),h(this,"_domEmitter",new(st()))}static get pluginName(){return"DragDropBlockToolbar"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(this.listenTo(e,"change:isReadOnly",(t,i,o)=>{o?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")}),N.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const t=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(t,"dragstart",(i,o)=>this._handleBlockDragStart(o)),this._domEmitter.listenTo(I.document,"dragover",(i,o)=>this._handleBlockDragging(o)),this._domEmitter.listenTo(I.document,"drop",(i,o)=>this._handleBlockDragging(o)),this._domEmitter.listenTo(I.document,"dragend",()=>this._handleBlockDragEnd(),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",(i,o,s)=>{t.setAttribute("draggable",s?"true":"false")})}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,o=this.editor.editing.view,s=Array.from(i.getSelectedBlocks()),r=t.createRange(t.createPositionBefore(s[0]),t.createPositionAfter(s[s.length-1]));t.change(a=>a.setSelection(r)),this._isBlockDragging=!0,o.focus(),o.getObserver(bs).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+(this.editor.locale.contentLanguageDirection=="ltr"?100:-100),i=e.clientY,o=document.elementFromPoint(t,i),s=this.editor.editing.view;!o||!o.closest(".ck-editor__editable")||s.getObserver(bs).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:o,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class V3 extends w{constructor(){super(...arguments),h(this,"_draggedRange"),h(this,"_draggingUid"),h(this,"_draggableElement"),h(this,"_clearDraggableAttributesDelayed",$c(()=>this._clearDraggableAttributes(),40)),h(this,"_blockMode",!1),h(this,"_domEmitter",new(st())),h(this,"_previewContainer")}static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[pt,Vt,Ys,I3]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(bs),t.addObserver(ua),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",(i,o,s)=>{s?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}),this.on("change:isEnabled",(i,o,s)=>{s||this._finalizeDragging(!1)}),N.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,i=e.editing.view,o=i.document,s=e.plugins.get(Ys);this.listenTo(o,"dragstart",(r,a)=>{var l;if((l=a.target)!=null&&l.is("editableElement")){a.preventDefault();return}if(this._prepareDraggedRange(a.target),!this._draggedRange){a.preventDefault();return}this._draggingUid=ze(),a.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",a.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(a.dataTransfer,c,"dragstart");const{dataTransfer:u,domTarget:d,domEvent:m}=a,{clientX:f}=m;this._updatePreview({dataTransfer:u,domTarget:d,clientX:f}),a.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")},{priority:"low"}),this.listenTo(o,"dragend",(r,a)=>{this._finalizeDragging(!a.dataTransfer.isCanceled&&a.dataTransfer.dropEffect=="move")},{priority:"low"}),this._domEmitter.listenTo(I.document,"dragend",()=>{this._blockMode=!1},{useCapture:!0}),this.listenTo(o,"dragenter",()=>{this.isEnabled&&i.focus()}),this.listenTo(o,"dragleave",()=>{s.removeDropMarkerDelayed()}),this.listenTo(o,"dragging",(r,a)=>{if(!this.isEnabled){a.dataTransfer.dropEffect="none";return}const{clientX:l,clientY:c}=a.domEvent;s.updateDropMarker(a.target,a.targetRanges,l,c,this._blockMode,this._draggedRange),this._draggedRange||(a.dataTransfer.dropEffect="copy"),N.isGecko||(a.dataTransfer.effectAllowed=="copy"?a.dataTransfer.dropEffect="copy":["all","copyMove"].includes(a.dataTransfer.effectAllowed)&&(a.dataTransfer.dropEffect="move")),r.stop()},{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(Ys);this.listenTo(t,"clipboardInput",(o,s)=>{if(s.method!="drop")return;const{clientX:r,clientY:a}=s.domEvent,l=i.getFinalDropRange(s.target,s.targetRanges,r,a,this._blockMode,this._draggedRange);if(!l){this._finalizeDragging(!1),o.stop();return}if(this._draggedRange&&this._draggingUid!=s.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),Pm(s.dataTransfer)=="move"&&this._draggedRange&&this._draggedRange.containsRange(l,!0)){this._finalizeDragging(!1),o.stop();return}s.targetRanges=[e.editing.mapper.toViewRange(l)]},{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(pt);e.on("contentInsertion",(t,i)=>{if(!this.isEnabled||i.method!=="drop")return;const o=i.targetRanges.map(s=>this.editor.editing.mapper.toModelRange(s));this.editor.model.change(s=>s.setSelection(o))},{priority:"high"}),e.on("contentInsertion",(t,i)=>{if(!this.isEnabled||i.method!=="drop")return;const o=Pm(i.dataTransfer)=="move",s=!i.resultRange||!i.resultRange.isCollapsed;this._finalizeDragging(s&&o)},{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",(o,s)=>{if(N.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let r=Im(s.target);if(N.isBlink&&!e.isReadOnly&&!r&&!i.selection.isCollapsed){const a=i.selection.getSelectedElement();(!a||!Se(a))&&(r=i.selection.editableElement)}r&&(t.change(a=>{a.setAttribute("draggable","true",r)}),this._draggableElement=e.editing.mapper.toModelElement(r))}),this.listenTo(i,"mouseup",()=>{N.isAndroid||this._clearDraggableAttributesDelayed()})}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change(t=>{this._draggableElement&&this._draggableElement.root.rootName!="$graveyard"&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null})}_finalizeDragging(e){const t=this.editor,i=t.model;t.plugins.get(Ys).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&i.change(o=>{const s=i.createSelection(this._draggedRange);i.deleteContent(s,{doNotAutoparagraph:!0});const r=s.getFirstPosition().parent;r.isEmpty&&!i.schema.checkChild(r,"$text")&&i.schema.checkChild(r,"paragraph")&&o.insertElement("paragraph",r,0)}),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,o=i.document.selection,s=e?Im(e):null;if(s){const c=t.editing.mapper.toModelElement(s);this._draggedRange=ht.fromRange(i.createRangeOn(c)),this._blockMode=i.schema.isBlock(c),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop");return}if(o.isCollapsed&&!o.getFirstPosition().parent.isEmpty)return;const r=Array.from(o.getSelectedBlocks()),a=o.getFirstRange();if(r.length==0){this._draggedRange=ht.fromRange(a);return}const l=Bb(i,r);if(r.length>1)this._draggedRange=ht.fromRange(l),this._blockMode=!0;else if(r.length==1){const c=a.start.isTouching(l.start)&&a.end.isTouching(l.end);this._draggedRange=ht.fromRange(c?l:a),this._blockMode=c}i.change(c=>c.setSelection(this._draggedRange.toRange()))}_updatePreview({dataTransfer:e,domTarget:t,clientX:i}){const o=this.editor.editing.view,s=o.document.selection.editableElement,r=o.domConverter.mapViewToDom(s),a=I.window.getComputedStyle(r);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=Ll(I.document,"div",{style:"position: fixed; left: -999999px;"}),I.document.body.appendChild(this._previewContainer));const l=new z(r);if(r.contains(t))return;const c=parseFloat(a.paddingLeft),u=Ll(I.document,"div");u.className="ck ck-content",u.style.width=a.width,u.style.paddingLeft=`${l.left-i+c}px`,N.isiOS&&(u.style.backgroundColor="white"),o.domConverter.setContentOf(u,e.getData("text/html")),e.setDragImage(u,0,0),this._previewContainer.appendChild(u)}}function Pm(n){return N.isGecko?n.dropEffect:["all","copyMove"].includes(n.effectAllowed)?"move":"copy"}function Im(n){if(n.is("editableElement"))return null;if(n.hasClass("ck-widget__selection-handle"))return n.findAncestor(Se);if(Se(n))return n;const e=n.findAncestor(t=>Se(t)||t.is("editableElement"));return Se(e)?e:null}function Bb(n,e){const t=e[0],i=e[e.length-1],o=t.getCommonAncestor(i),s=n.createPositionBefore(t),r=n.createPositionAfter(i);if(o&&o.is("element")&&!n.schema.isLimit(o)){const a=n.createRangeOn(o),l=s.isTouching(a.start),c=r.isTouching(a.end);if(l&&c)return Bb(n,[o])}return n.createRange(s,r)}class R3 extends w{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[pt]}init(){const e=this.editor,t=e.model,i=e.editing.view,o=t.document.selection;i.addObserver(bs),e.plugins.get(pt).on("contentInsertion",(s,r)=>{O3(r.content,t)&&t.change(a=>{const l=Array.from(o.getAttributes()).filter(([u])=>t.schema.getAttributeProperties(u).isFormatting);o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),l.push(...o.getAttributes());const c=a.createRangeIn(r.content);for(const u of c.getItems())for(const d of l)t.schema.checkAttribute(u,d[0])&&a.setAttribute(d[0],d[1],u)})})}}function O3(n,e){let t=e.createRangeIn(n);if(n.childCount==1){const i=n.getChild(0);i.is("element")&&e.schema.isBlock(i)&&!e.schema.isObject(i)&&!e.schema.isLimit(i)&&(t=e.createRangeIn(i))}for(const i of t.getItems())if(!e.schema.isInline(i)||Array.from(i.getAttributeKeys()).find(o=>e.schema.getAttributeProperties(o).isFormatting))return!1;return!0}class _s extends w{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[os,pt,V3,R3]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Hr(n){const e=n.t,t=n.config.get("codeBlock.languages");for(const i of t)i.label==="Plain text"&&(i.label=e("Plain text")),i.class===void 0&&(i.class=`language-${i.language}`);return t}function $r(n,e,t){const i={};for(const o of n)if(e==="class"){const s=o[e].split(" ").shift();i[s]=o[t]}else i[o[e]]=o[t];return i}function xu(n){return n.data.match(/^(\s*)/)[0]}function B3(n,e){const t=n.createDocumentFragment(),i=e.split(`
`),o=i.reduce((s,r,a)=>(s.push(r),a<i.length-1&&s.push(n.createElement("br")),s),[]);return n.appendChild(o,t),t}function sc(n){const e=n.document.selection,t=[];if(e.isCollapsed)return[e.anchor];const i=e.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:o}of i){let s=o.is("$textProxy")?o.textNode:o;const r=s.parent;if(!r.is("element","codeBlock")||s.is("element","softBreak"))continue;for(;s.previousSibling&&!s.previousSibling.is("element","softBreak");)s=s.previousSibling;const a=s.is("$text")?s.startOffset+xu(s).length:s.startOffset,l=n.createPositionAt(r,a);t.every(c=>!c.isEqual(l))&&t.push(l)}return t}function Mb(n){const e=ae(n.getSelectedBlocks());return!!e&&e.is("element","codeBlock")}function Vm(n,e){return e.is("rootElement")||n.isLimit(e)?!1:n.checkChild(e.parent,"codeBlock")}function Rm(n,e,t,i){const o=$r(e,"language","label"),s=t.getAttribute("language");if(s in o){const r=o[s];return n(i==="enter"?"Entering %0 code snippet":"Leaving %0 code snippet",r)}return n(i==="enter"?"Entering code snippet":"Leaving code snippet")}function Lb(n,e){for(n.textNode&&(n=e.createPositionBefore(n.textNode));n.nodeBefore&&!n.nodeBefore.is("element","softBreak");)n=e.createPositionBefore(n.nodeBefore);const t=n.nodeAfter;return t&&t.is("$text")?t:null}class M3 extends O{constructor(e){super(e),h(this,"_lastLanguage"),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,o=i.document.selection,s=Hr(t)[0],r=Array.from(o.getSelectedBlocks()),a=e.forceValue==null?!this.value:e.forceValue,l=L3(e,this._lastLanguage,s.language);i.change(c=>{a?this._applyCodeBlock(c,r,l):this._removeCodeBlock(c,r)})}_getValue(){const e=this.editor.model.document.selection,t=ae(e.getSelectedBlocks());return t!=null&&t.is("element","codeBlock")?t.getAttribute("language"):!1}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=ae(e.getSelectedBlocks());return i?Vm(t,i):!1}_applyCodeBlock(e,t,i){this._lastLanguage=i;const o=this.editor.model.schema,s=t.filter(r=>Vm(o,r));for(const r of s)e.rename(r,"codeBlock"),e.setAttribute("language",i,r),o.removeDisallowedAttributes([r],e),Array.from(r.getChildren()).filter(a=>!o.checkChild(r,a)).forEach(a=>e.remove(a));s.reverse().forEach((r,a)=>{const l=s[a+1];r.previousSibling===l&&(e.appendElement("softBreak",l),e.merge(e.createPositionBefore(r)))})}_removeCodeBlock(e,t){const i=t.filter(o=>o.is("element","codeBlock"));for(const o of i){const s=e.createRangeOn(o);for(const r of Array.from(s.getItems()).reverse())if(r.is("element","softBreak")&&r.parent.is("element","codeBlock")){const{position:a}=e.split(e.createPositionBefore(r)),l=a.nodeAfter;e.rename(l,"paragraph"),e.removeAttribute("language",l),e.remove(r)}e.rename(o,"paragraph"),e.removeAttribute("language",o)}}}function L3(n,e,t){return n.language?n.language:n.usePreviousLanguageChoice&&e?e:t}class F3 extends O{constructor(e){super(e),h(this,"_indentSequence"),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(t=>{const i=sc(e);for(const o of i){const s=t.createText(this._indentSequence);e.insertContent(s,o)}})}_checkEnabled(){return this._indentSequence?Mb(this.editor.model.document.selection):!1}}class N3 extends O{constructor(e){super(e),h(this,"_indentSequence"),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change(()=>{const t=sc(e);for(const i of t){const o=Om(e,i,this._indentSequence);o&&e.deleteContent(e.createSelection(o))}})}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return Mb(e.document.selection)?sc(e).some(t=>Om(e,t,this._indentSequence)):!1}}function Om(n,e,t){const i=Lb(e,n);if(!i)return null;const o=xu(i),s=o.lastIndexOf(t);if(s+t.length!==o.length||s===-1)return null;const{parent:r,startOffset:a}=i;return n.createRange(n.createPositionAt(r,a+s),n.createPositionAt(r,a+s+t.length))}function Bm(n,e,t=!1){const i=$r(e,"language","class"),o=$r(e,"language","label");return(s,r,a)=>{const{writer:l,mapper:c,consumable:u}=a;if(!u.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),m=c.toViewPosition(n.createPositionBefore(r.item)),f={};t&&(f["data-language"]=o[d],f.class="hljs",f.spellcheck="false");const g=i[d]?{class:i[d]}:void 0,p=l.createContainerElement("code",g),_=l.createContainerElement("pre",f,p);l.insert(m,_),c.bindElements(r.item,p)}}function D3(n){return(e,t,i)=>{if(t.item.parent.name!=="codeBlock")return;const{writer:o,mapper:s,consumable:r}=i;if(!r.consume(t.item,"insert"))return;const a=s.toViewPosition(n.createPositionBefore(t.item));o.insert(a,o.createText(`
`))}}function z3(n,e){const t=$r(e,"class","language"),i=e[0].language;return(o,s,r)=>{const a=s.viewItem,l=a.parent;if(!l||!l.is("element","pre")||s.modelCursor.findAncestor("codeBlock"))return;const{consumable:c,writer:u}=r;if(!c.test(a,{name:!0}))return;const d=u.createElement("codeBlock"),m=[...a.getClassNames()];m.length||m.push("");for(const f of m){const g=t[f];if(g){u.setAttribute("language",g,d);break}}d.hasAttribute("language")||u.setAttribute("language",i,d),r.convertChildren(a,d),r.safeInsert(d,s.modelCursor)&&(c.consume(a,{name:!0}),r.updateConversionResult(d,s))}}function H3(){return(n,e,{consumable:t,writer:i})=>{let o=e.modelCursor;if(!t.test(e.viewItem)||!o.findAncestor("codeBlock"))return;t.consume(e.viewItem);const s=e.viewItem.data.split(`
`).map(a=>i.createText(a)),r=s[s.length-1];for(const a of s)if(i.insert(a,o),o=o.getShiftedBy(a.offsetSize),a!==r){const l=i.createElement("softBreak");i.insert(l,o),o=i.createPositionAfter(l)}e.modelRange=i.createRange(e.modelCursor,o),e.modelCursor=o}}function $3(){return(n,e,{consumable:t})=>{const i=e.viewItem;if(i.findAncestor("pre"))return;const o=Array.from(i.getChildren()),s=o.find(r=>r.is("element","code"));if(s)for(const r of o)r===s||!r.is("$text")||t.consume(r,{name:!0})}}const Fb="paragraph";class W3 extends w{static get pluginName(){return"CodeBlockEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Tb]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"go",label:"Go"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:" "})}init(){const e=this.editor,t=e.model.schema,i=e.model,o=e.editing.view,s=Hr(e);e.commands.add("codeBlock",new M3(e)),e.commands.add("indentCodeBlock",new F3(e)),e.commands.add("outdentCodeBlock",new N3(e)),this.listenTo(o.document,"tab",(r,a)=>{const l=a.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(l).isEnabled&&(e.execute(l),a.stopPropagation(),a.preventDefault(),r.stop())},{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",disallowChildren:"$inlineObject",allowAttributes:["language"],allowAttributesOf:"$listItem",isBlock:!0}),t.addAttributeCheck((r,a)=>{const l=r.getItem(r.length-2);if(t.getAttributeProperties(a).isFormatting&&l&&l.name=="codeBlock")return!1}),e.editing.downcastDispatcher.on("insert:codeBlock",Bm(i,s,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Bm(i,s)),e.data.downcastDispatcher.on("insert:softBreak",D3(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",z3(o,s)),e.data.upcastDispatcher.on("text",H3()),e.data.upcastDispatcher.on("element:pre",$3(),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",(r,a)=>{let l=i.createRange(i.document.selection.anchor);if(a.targetRanges&&(l=e.editing.mapper.toModelRange(a.targetRanges[0])),!l.start.parent.is("element","codeBlock"))return;const c=a.dataTransfer.getData("text/plain"),u=new Ht(e.editing.view.document);a.content=B3(u,c)}),e.plugins.has("ClipboardPipeline")&&e.plugins.get(pt).on("contentInsertion",(r,a)=>{const l=e.model,c=l.document.selection;c.anchor.parent.is("element","codeBlock")&&l.change(u=>{const d=u.createRangeIn(a.content);for(const m of[...d.getItems()])m.is("node")&&!t.checkChild(c.anchor,m)&&u.remove(m)})}),this.listenTo(i,"getSelectedContent",(r,[a])=>{const l=a.anchor;a.isCollapsed||!l.parent.is("element","codeBlock")||!l.hasSameParentAs(a.focus)||i.change(c=>{const u=r.return;if(l.parent.is("element")&&(u.childCount>1||a.containsEntireContent(l.parent))){const m=c.createElement("codeBlock",l.parent.getAttributes());c.append(u,m);const f=c.createDocumentFragment();c.append(m,f),r.return=f;return}const d=u.getChild(0);t.checkAttribute(d,"code")&&c.setAttribute("code",!0,d)})})}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),o=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),o&&o.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",(s,r)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(!U3(e,r.isSoft)&&!q3(e,r.isSoft)&&j3(e),r.preventDefault(),s.stop())},{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor,o=Hr(this.editor);let s=null;e.document.selection.on("change:range",()=>{const r=e.document.selection.focus.parent;!t||s===r||!r.is("element")||(s&&s.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(Rm(i,o,s,"leave")),r.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(Rm(i,o,r,"enter")),s=r)})}}function j3(n){const e=n.model,t=e.document,i=t.selection.getLastPosition();let o;const s=Lb(i,e);s&&s.is("$text")&&(o=xu(s)),n.model.change(r=>{n.execute("shiftEnter"),o&&r.insertText(o,t.selection.anchor)})}function U3(n,e){const t=n.model.document,i=n.editing.view,o=t.selection.getLastPosition(),s=o.nodeAfter;return e||!t.selection.isCollapsed||!o.isAtStart||!fn(s)?!1:(n.model.change(r=>{n.execute("enter");const a=t.selection.anchor.parent.previousSibling;r.rename(a,Fb),r.setSelection(a,"in"),n.model.schema.removeDisallowedAttributes([a],r),r.remove(s)}),i.scrollToTheSelection(),!0)}function q3(n,e){const t=n.model,i=t.document,o=n.editing.view,s=i.selection.getLastPosition(),r=s.nodeBefore;let a;if(e||!i.selection.isCollapsed||!s.isAtEnd||!r||!r.previousSibling)return!1;if(fn(r)&&fn(r.previousSibling))a=t.createRange(t.createPositionBefore(r.previousSibling),t.createPositionAfter(r));else if(ml(r)&&fn(r.previousSibling)&&fn(r.previousSibling.previousSibling))a=t.createRange(t.createPositionBefore(r.previousSibling.previousSibling),t.createPositionAfter(r));else if(ml(r)&&fn(r.previousSibling)&&ml(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&fn(r.previousSibling.previousSibling.previousSibling))a=t.createRange(t.createPositionBefore(r.previousSibling.previousSibling.previousSibling),t.createPositionAfter(r));else return!1;return n.model.change(l=>{l.remove(a),n.execute("enter");const c=i.selection.anchor.parent;l.rename(c,Fb),n.model.schema.removeDisallowedAttributes([c],l)}),o.scrollToTheSelection(),!0}function ml(n){return n&&n.is("$text")&&!n.data.match(/\S/)}function fn(n){return n&&n.is("element","softBreak")}class G3 extends w{static get pluginName(){return"CodeBlockUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,o=Hr(e),s=this._getLanguageListItemDefinitions(o),r=e.commands.get("codeBlock");i.add("codeBlock",a=>{const l=Ee(a,Xi),c=l.buttonView,u=t("Insert code block");return c.set({label:u,tooltip:!0,icon:md,isToggleable:!0}),c.bind("isOn").to(r,"value",d=>!!d),c.on("execute",()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()}),l.on("execute",d=>{e.execute("codeBlock",{language:d.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),l.class="ck-code-block-dropdown",l.bind("isEnabled").to(r),wt(l,s,{role:"menu",ariaLabel:u}),l}),i.add("menuBar:codeBlock",a=>{const l=new Tt(a);l.buttonView.set({role:"menuitem",label:t("Code block"),icon:md}),l.bind("isEnabled").to(r);const c=new Si(a);c.set({ariaLabel:t("Insert code block")});for(const u of s){const d=new Oi(a,l),m=new ve(a);m.bind(...Object.keys(u.model)).to(u.model),m.set({isToggleable:!0,role:"menuitemcheckbox"}),m.delegate("execute").to(l),m.on("execute",()=>{e.execute("codeBlock",{language:u.model._codeBlockLanguage,forceValue:r.value!=u.model._codeBlockLanguage}),e.editing.view.focus()}),d.children.add(m),c.items.add(d)}return l.panelView.children.add(c),l})}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new _e;for(const o of e){const s={type:"button",model:new et({_codeBlockLanguage:o.language,label:o.label,role:"menuitemradio",withText:!0})};s.model.bind("isOn").to(t,"value",r=>r===s.model._codeBlockLanguage),i.add(s)}return i}}class Tu extends w{static get requires(){return[W3,G3]}static get pluginName(){return"CodeBlock"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class K3 extends ab{constructor(e,t){super(e),h(this,"view"),this.view=t}get element(){return this.view.editable.element}init(){const e=this.editor,t=this.view,i=e.editing.view,o=t.editable,s=i.document.getRoot();o.name=s.rootName,t.render();const r=o.element;this.setEditableElement(o.name,r),o.bind("isFocused").to(this.focusTracker),i.attachDomRoot(r),this._initPlaceholder(),this.initMenuBar(this.view.menuBarView),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),o=e.config.get("placeholder");if(o){const s=typeof o=="string"?o:o[i.rootName];s&&(i.placeholder=s)}sa({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}}class Z3 extends lb{constructor(e,t,i,o){super(e),h(this,"editable"),h(this,"menuBarView"),this.editable=new cb(e,t,i,{label:o}),this.menuBarView=new fb(e),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}render(){super.render(),this.registerChild(this.editable),this.registerChild(this.menuBarView)}}class Nb extends Br(pn){constructor(e,t={}){if(!fr(e)&&t.initialData!==void 0)throw new b("editor-create-initial-data",null);super(t),h(this,"ui"),this.config.get("initialData")===void 0&&this.config.set("initialData",J3(e)),fr(e)&&(this.sourceElement=e,hw(this,e));const i=this.config.get("plugins");i.push(bT),this.config.set("plugins",i),this.config.define("balloonToolbar",this.config.get("toolbar")),this.model.document.createRoot();const o=new Z3(this.locale,this.editing.view,this.sourceElement,this.config.get("label"));this.ui=new K3(this,o),eC(this)}static get editorName(){return"BalloonEditor"}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,t={}){return new Promise(i=>{if(fr(e)&&e.tagName==="TEXTAREA")throw new b("editor-wrong-element",null);const o=new this(e,t);i(o.initPlugins().then(()=>o.ui.init()).then(()=>o.data.init(o.config.get("initialData"))).then(()=>o.fire("ready")).then(()=>o))})}}function J3(n){return fr(n)?Jg(n):n}function fr(n){return xi(n)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Q3 extends ab{constructor(e,t){super(e),h(this,"view"),this.view=t}init(){const e=this.editor,t=this.view,i=e.editing.view,o=t.editable,s=i.document.getRoot();o.name=s.rootName,t.render();const r=o.element;this.setEditableElement(o.name,r),t.editable.bind("isFocused").to(this.focusTracker),i.attachDomRoot(r),this._initPlaceholder(),this._initToolbar(),this.initMenuBar(this.view.menuBarView),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.editor,t=this.view;t.toolbar.fillFromConfig(e.config.get("toolbar"),this.componentFactory),this.addToolbar(t.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),o=e.config.get("placeholder");if(o){const s=typeof o=="string"?o:o[i.rootName];s&&(i.placeholder=s)}sa({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}}class Y3 extends lb{constructor(e,t,i={}){super(e),h(this,"toolbar"),h(this,"editable"),h(this,"menuBarView"),this.toolbar=new Ei(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.menuBarView=new fb(e),this.editable=new cb(e,t,i.editableElement,{label:i.label}),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}}),this.menuBarView.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:e.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.menuBarView,this.toolbar,this.editable])}}class X3 extends Br(pn){constructor(e,t={}){if(!gr(e)&&t.initialData!==void 0)throw new b("editor-create-initial-data",null);super(t),h(this,"ui"),this.config.get("initialData")===void 0&&this.config.set("initialData",eS(e)),gr(e)&&(this.sourceElement=e,hw(this,e)),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),o=new Y3(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:i,label:this.config.get("label")});this.ui=new Q3(this,o)}static get editorName(){return"DecoupledEditor"}destroy(){const e=this.getData();return this.ui.destroy(),super.destroy().then(()=>{this.sourceElement&&this.updateSourceElement(e)})}static create(e,t={}){return new Promise(i=>{if(gr(e)&&e.tagName==="TEXTAREA")throw new b("editor-wrong-element",null);const o=new this(e,t);i(o.initPlugins().then(()=>o.ui.init()).then(()=>o.data.init(o.config.get("initialData"))).then(()=>o.fire("ready")).then(()=>o))})}}function eS(n){return gr(n)?Jg(n):n}function gr(n){return xi(n)}var rc={exports:{}},tS=rc.exports,Mm;function iS(){return Mm||(Mm=1,function(n){((e,t)=>{n.exports?n.exports=t():e.fuzzysort=t()})(tS,e=>{var t=(S,k)=>{if(!S||!k)return He;var R=g(S);nn(k)||(k=f(k));var H=R.bitflags;return(H&k._bitflags)!==H?He:_(R,k)},i=(S,k,R)=>{if(!S)return R!=null&&R.all?p(k,R):Ta;var H=g(S),W=H.bitflags,D=H.containsSpace,B=d(R?.threshold||0),K=R?.limit||Zu,j=0,le=0,oe=k.length;function rt(on){j<K?(Ls.add(on),++j):(++le,on._score>Ls.peek()._score&&Ls.replaceTop(on))}if(R!=null&&R.key)for(var Ze=R.key,ce=0;ce<oe;++ce){var tt=k[ce],me=Ms(tt,Ze);if(me&&(nn(me)||(me=f(me)),(W&me._bitflags)===W)){var ye=_(H,me);ye!==He&&(ye._score<B||(ye.obj=tt,rt(ye)))}}else if(R!=null&&R.keys){var Mi=R.keys,Rt=Mi.length;e:for(var ce=0;ce<oe;++ce){var tt=k[ce];{for(var Je=0,se=0;se<Rt;++se){var Ze=Mi[se],me=Ms(tt,Ze);if(!me){Bn[se]=xo;continue}nn(me)||(me=f(me)),Bn[se]=me,Je|=me._bitflags}if((W&Je)!==W)continue}if(D)for(let fe=0;fe<H.spaceSearches.length;fe++)pe[fe]=bt;for(var se=0;se<Rt;++se){if(me=Bn[se],me===xo){Mn[se]=xo;continue}if(Mn[se]=_(H,me,!1,D),Mn[se]===He){Mn[se]=xo;continue}if(D)for(let ke=0;ke<H.spaceSearches.length;ke++){if(di[ke]>-1e3&&pe[ke]>bt){var Ot=(pe[ke]+di[ke])/4;Ot>pe[ke]&&(pe[ke]=Ot)}di[ke]>pe[ke]&&(pe[ke]=di[ke])}}if(D){for(let fe=0;fe<H.spaceSearches.length;fe++)if(pe[fe]===bt)continue e}else{var Y=!1;for(let fe=0;fe<Rt;fe++)if(Mn[fe]._score!==bt){Y=!0;break}if(!Y)continue}var _t=new l(Rt);for(let fe=0;fe<Rt;fe++)_t[fe]=Mn[fe];if(D){var Fe=0;for(let fe=0;fe<H.spaceSearches.length;fe++)Fe+=pe[fe]}else{var Fe=bt;for(let ke=0;ke<Rt;ke++){var ye=_t[ke];if(ye._score>-1e3&&Fe>bt){var Ot=(Fe+ye._score)/4;Ot>Fe&&(Fe=Ot)}ye._score>Fe&&(Fe=ye._score)}}if(_t.obj=tt,_t._score=Fe,R!=null&&R.scoreFn){if(Fe=R.scoreFn(_t),!Fe)continue;Fe=d(Fe),_t._score=Fe}Fe<B||rt(_t)}}else for(var ce=0;ce<oe;++ce){var me=k[ce];if(me&&(nn(me)||(me=f(me)),(W&me._bitflags)===W)){var ye=_(H,me);ye!==He&&(ye._score<B||rt(ye))}}if(j===0)return Ta;for(var Li=new Array(j),ce=j-1;ce>=0;--ce)Li[ce]=Ls.poll();return Li.total=j+le,Li},o=(S,k="<b>",R="</b>")=>{for(var H=typeof k=="function"?k:void 0,W=S.target,D=W.length,B=S.indexes,K="",j=0,le=0,oe=!1,rt=[],Ze=0;Ze<D;++Ze){var ce=W[Ze];if(B[le]===Ze){if(++le,oe||(oe=!0,H?(rt.push(K),K=""):K+=k),le===B.length){H?(K+=ce,rt.push(H(K,j++)),K="",rt.push(W.substr(Ze+1))):K+=ce+R+W.substr(Ze+1);break}}else oe&&(oe=!1,H?(rt.push(H(K,j++)),K=""):K+=R);K+=ce}return H?rt:K},s=S=>{typeof S=="number"?S=""+S:typeof S!="string"&&(S="");var k=M(S);return c(S,{_targetLower:k._lower,_targetLowerCodes:k.lowerCodes,_bitflags:k.bitflags})},r=()=>{T.clear(),F.clear()};class a{get indexes(){return this._indexes.slice(0,this._indexes.len).sort((k,R)=>k-R)}set indexes(k){return this._indexes=k}highlight(k,R){return o(this,k,R)}get score(){return u(this._score)}set score(k){this._score=d(k)}}class l extends Array{get score(){return u(this._score)}set score(k){this._score=d(k)}}var c=(S,k)=>{const R=new a;return R.target=S,R.obj=k.obj??He,R._score=k._score??bt,R._indexes=k._indexes??[],R._targetLower=k._targetLower??"",R._targetLowerCodes=k._targetLowerCodes??He,R._nextBeginningIndexes=k._nextBeginningIndexes??He,R._bitflags=k._bitflags??0,R},u=S=>S===bt?0:S>1?S:Math.E**(((-S+1)**.04307-1)*-2),d=S=>S===0?bt:S>1?S:1-Math.pow(Math.log(S)/-2+1,1/.04307),m=S=>{typeof S=="number"?S=""+S:typeof S!="string"&&(S=""),S=S.trim();var k=M(S),R=[];if(k.containsSpace){var H=S.split(/\s+/);H=[...new Set(H)];for(var W=0;W<H.length;W++)if(H[W]!==""){var D=M(H[W]);R.push({lowerCodes:D.lowerCodes,_lower:H[W].toLowerCase(),containsSpace:!1})}}return{lowerCodes:k.lowerCodes,_lower:k._lower,containsSpace:k.containsSpace,bitflags:k.bitflags,spaceSearches:R}},f=S=>{if(S.length>999)return s(S);var k=T.get(S);return k!==void 0||(k=s(S),T.set(S,k)),k},g=S=>{if(S.length>999)return m(S);var k=F.get(S);return k!==void 0||(k=m(S),F.set(S,k)),k},p=(S,k)=>{var R=[];R.total=S.length;var H=k?.limit||Zu;if(k!=null&&k.key)for(var W=0;W<S.length;W++){var D=S[W],B=Ms(D,k.key);if(B!=He){nn(B)||(B=f(B));var K=c(B.target,{_score:B._score,obj:D});if(R.push(K),R.length>=H)return R}}else if(k!=null&&k.keys)for(var W=0;W<S.length;W++){for(var D=S[W],j=new l(k.keys.length),le=k.keys.length-1;le>=0;--le){var B=Ms(D,k.keys[le]);if(!B){j[le]=xo;continue}nn(B)||(B=f(B)),B._score=bt,B._indexes.len=0,j[le]=B}if(j.obj=D,j._score=bt,R.push(j),R.length>=H)return R}else for(var W=0;W<S.length;W++){var B=S[W];if(B!=He&&(nn(B)||(B=f(B)),B._score=bt,B._indexes.len=0,R.push(B),R.length>=H))return R}return R},_=(S,k,R=!1,H=!1)=>{if(R===!1&&S.containsSpace)return v(S,k,H);for(var W=S._lower,D=S.lowerCodes,B=D[0],K=k._targetLowerCodes,j=D.length,le=K.length,ce=0,oe=0,rt=0;;){var Ze=B===K[oe];if(Ze){if(x[rt++]=oe,++ce,ce===j)break;B=D[ce]}if(++oe,oe>=le)return He}var ce=0,tt=!1,me=0,ye=k._nextBeginningIndexes;ye===He&&(ye=k._nextBeginningIndexes=X(k.target)),oe=x[0]===0?0:ye[x[0]-1];var Mi=0;if(oe!==le)for(;;)if(oe>=le){if(ce<=0||(++Mi,Mi>200))break;--ce;var Rt=q[--me];oe=ye[Rt]}else{var Ze=D[ce]===K[oe];if(Ze){if(q[me++]=oe,++ce,ce===j){tt=!0;break}++oe}else oe=ye[oe]}var Je=j<=1?-1:k._targetLower.indexOf(W,x[0]),se=!!~Je,Ot=se?Je===0||k._nextBeginningIndexes[Je-1]===Je:!1;if(se&&!Ot){for(var Y=0;Y<ye.length;Y=ye[Y])if(!(Y<=Je)){for(var _t=0;_t<j&&D[_t]===k._targetLowerCodes[Y+_t];_t++);if(_t===j){Je=Y,Ot=!0;break}}}var Fe=fe=>{for(var ke=0,Ju=0,mi=1;mi<j;++mi)fe[mi]-fe[mi-1]!==1&&(ke-=fe[mi],++Ju);var $0=fe[j-1]-fe[0]-(j-1);if(ke-=(12+$0)*Ju,fe[0]!==0&&(ke-=fe[0]*fe[0]*.2),!tt)ke*=1e3;else{for(var Ea=1,mi=ye[0];mi<le;mi=ye[mi])++Ea;Ea>24&&(ke*=(Ea-24)*10)}return ke-=(le-j)/2,se&&(ke/=1+j*j*1),Ot&&(ke/=1+j*j*1),ke-=(le-j)/2,ke};if(tt)if(Ot){for(var Y=0;Y<j;++Y)x[Y]=Je+Y;var Li=x,on=Fe(x)}else var Li=q,on=Fe(q);else{if(se)for(var Y=0;Y<j;++Y)x[Y]=Je+Y;var Li=x,on=Fe(Li)}k._score=on;for(var Y=0;Y<j;++Y)k._indexes[Y]=Li[Y];k._indexes.len=j;const Fs=new a;return Fs.target=k.target,Fs._score=k._score,Fs._indexes=k._indexes,Fs},v=(S,k,R)=>{for(var H=new Set,W=0,D=He,B=0,K=S.spaceSearches,j=K.length,le=0,oe=()=>{for(let Y=le-1;Y>=0;Y--)k._nextBeginningIndexes[Ve[Y*2+0]]=Ve[Y*2+1]},rt=!1,se=0;se<j;++se){di[se]=bt;var Ze=K[se];if(D=_(Ze,k),R){if(D===He)continue;rt=!0}else if(D===He)return oe(),He;var ce=se===j-1;if(!ce){var tt=D._indexes,me=!0;for(let Y=0;Y<tt.len-1;Y++)if(tt[Y+1]-tt[Y]!==1){me=!1;break}if(me){var ye=tt[tt.len-1]+1,Mi=k._nextBeginningIndexes[ye-1];for(let Y=ye-1;Y>=0&&Mi===k._nextBeginningIndexes[Y];Y--)k._nextBeginningIndexes[Y]=ye,Ve[le*2+0]=Y,Ve[le*2+1]=Mi,le++}}W+=D._score/j,di[se]=D._score/j,D._indexes[0]<B&&(W-=(B-D._indexes[0])*2),B=D._indexes[0];for(var Rt=0;Rt<D._indexes.len;++Rt)H.add(D._indexes[Rt])}if(R&&!rt)return He;oe();var Je=_(S,k,!0);if(Je!==He&&Je._score>W){if(R)for(var se=0;se<j;++se)di[se]=Je._score/j;return Je}R&&(D=k),D._score=W;var se=0;for(let Ot of H)D._indexes[se++]=Ot;return D._indexes.len=se,D},E=S=>S.replace(new RegExp("\\p{Script=Latin}+","gu"),k=>k.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),M=S=>{S=E(S);for(var k=S.length,R=S.toLowerCase(),H=[],W=0,D=!1,B=0;B<k;++B){var K=H[B]=R.charCodeAt(B);if(K===32){D=!0;continue}var j=K>=97&&K<=122?K-97:K>=48&&K<=57?26:K<=127?30:31;W|=1<<j}return{lowerCodes:H,bitflags:W,containsSpace:D,_lower:R}},G=S=>{for(var k=S.length,R=[],H=0,W=!1,D=!1,B=0;B<k;++B){var K=S.charCodeAt(B),j=K>=65&&K<=90,le=j||K>=97&&K<=122||K>=48&&K<=57,oe=j&&!W||!D||!le;W=j,D=le,oe&&(R[H++]=B)}return R},X=S=>{S=E(S);for(var k=S.length,R=G(S),H=[],W=R[0],D=0,B=0;B<k;++B)W>B?H[B]=W:(W=R[++D],H[B]=W===void 0?k:W);return H},T=new Map,F=new Map,x=[],q=[],Ve=[],pe=[],di=[],Bn=[],Mn=[],Ms=(S,k)=>{var R=S[k];if(R!==void 0)return R;if(typeof k=="function")return k(S);var H=k;Array.isArray(k)||(H=k.split("."));for(var W=H.length,D=-1;S&&++D<W;)S=S[H[D]];return S},nn=S=>typeof S=="object"&&typeof S._bitflags=="number",Zu=1/0,bt=-1/0,Ta=[];Ta.total=0;var He=null,xo=s(""),H0=S=>{var k=[],R=0,H={},W=D=>{for(var B=0,K=k[B],j=1;j<R;){var le=j+1;B=j,le<R&&k[le]._score<k[j]._score&&(B=le),k[B-1>>1]=k[B],j=1+(B<<1)}for(var oe=B-1>>1;B>0&&K._score<k[oe]._score;oe=(B=oe)-1>>1)k[B]=k[oe];k[B]=K};return H.add=D=>{var B=R;k[R++]=D;for(var K=B-1>>1;B>0&&D._score<k[K]._score;K=(B=K)-1>>1)k[B]=k[K];k[B]=D},H.poll=D=>{if(R!==0){var B=k[0];return k[0]=k[--R],W(),B}},H.peek=D=>{if(R!==0)return k[0]},H.replaceTop=D=>{k[0]=D,W()},H},Ls=H0();return{single:t,go:i,prepare:s,cleanup:r}})}(rc)),rc.exports}var nS=iS();const oS=lu(nS);/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2023, Koala Interactive SAS
* For licensing, see https://github.com/koala-interactive/is-emoji-supported/blob/master/LICENSE.md
*/function sS(n){const e=rS();/* istanbul ignore next -- @preserve */if(!e)return!1;const t=25,i=20,o=Math.floor(t/2);e.font=o+"px Arial, Sans-Serif",e.textBaseline="top",e.canvas.width=i*2,e.canvas.height=t,e.clearRect(0,0,i*2,t),e.fillStyle="#FF0000",e.fillText(n,0,22),e.fillStyle="#0000FF",e.fillText(n,i,22);const s=e.getImageData(0,0,i,t).data,r=s.length;let a=0;for(;a<r&&!s[a+3];a+=4);/* istanbul ignore next -- @preserve */if(a>=r)return!1;const l=i+a/4%i,c=Math.floor(a/4/i),u=e.getImageData(l,c,1,1).data;/* istanbul ignore next -- @preserve */if(s[a]!==u[0]||s[a+2]!==u[2])return!1;/* istanbul ignore next -- @preserve */return!(e.measureText(n).width>=i)}function rS(){try{return document.createElement("canvas").getContext("2d",{willReadFrequently:!0})}catch{/* istanbul ignore next -- @preserve */return null}}const aS={0:"default",1:"light",2:"medium-light",3:"medium",4:"medium-dark",5:"dark"},lS={"🫩":16,"🫨":15.1,"🫠":14,"😶‍🌫️":13.1,"🧑‍💻":12.1,"🥰":11,"🤪":5,"⚕️":4,"🤣":3,"👋🏽":2,"😀":1,"😐":.7,"😂":.6},Lm=24,Db=class zb extends w{static get pluginName(){return"EmojiUtils"}static get isOfficialPlugin(){return!0}isEmojiSupported(e,t,i){return e.version<=t?this.hasZwj(e.emoji)?this.isEmojiZwjSupported(e,i):!0:!1}getEmojiSupportedVersionByOs(){for(const[e,t]of Object.entries(lS))if(zb._isEmojiSupported(e))return t;return 0}hasZwj(e){return e.includes("‍")}isEmojiZwjSupported(e,t){return this.getNodeWidth(t,e.emoji)<Lm*1.8}getNodeWidth(e,t){const i=document.createElement("span");i.textContent=t,e.appendChild(i);const o=i.offsetWidth;return e.removeChild(i),o}createEmojiWidthTestingContainer(){const e=document.createElement("div");return e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.whiteSpace="nowrap",e.style.fontSize=Lm+"px",e}normalizeEmojiSkinTone(e){const t={...e,skins:{default:e.emoji}};return e.skins&&e.skins.forEach(i=>{const o=aS[i.tone];t.skins[o]=i.emoji}),t}isEmojiCategoryAllowed(e){return e.group!==2}};h(Db,"_isEmojiSupported",sS);let cS=Db;const uS="https://cdn.ckeditor.com/ckeditor5/data/emoji/{version}/en.json",hS=16,Hb=class pr extends w{constructor(e){super(e),h(this,"_items"),h(this,"_url"),h(this,"_repositoryPromise"),e.config.define("emoji",{version:void 0,skinTone:"default",definitionsUrl:void 0,useCustomFont:!1}),this._url=this._getUrl(),this._repositoryPromise=new Promise(t=>{this._repositoryPromiseResolveCallback=t}),this._items=null}static get requires(){return[cS]}static get pluginName(){return"EmojiRepository"}static get isOfficialPlugin(){return!0}async init(){return this._warnAboutCdnUse(),await this._loadAndCacheEmoji(),this._items=this._getItems(),this._items?this._repositoryPromiseResolveCallback(!0):(J("emoji-repository-empty"),this._repositoryPromiseResolveCallback(!1))}getEmojiByQuery(e){return this._items?e.split(/\s/).filter(Boolean).some(t=>t.length>=2)?oS.go(e,this._items,{threshold:.6,keys:["emoticon","annotation",t=>e.split(/\s/).filter(Boolean).flatMap(i=>{var o;return(o=t.tags)==null?void 0:o.filter(s=>s.startsWith(i))}).join()]}).map(t=>t.obj):[]:[]}getEmojiCategories(){const e=this._getItems();if(!e)return[];const{t}=this.editor.locale,i=[{title:t("Smileys & Expressions"),icon:"😄",groupId:0},{title:t("Gestures & People"),icon:"👋",groupId:1},{title:t("Animals & Nature"),icon:"🐻",groupId:3},{title:t("Food & Drinks"),icon:"🍎",groupId:4},{title:t("Travel & Places"),icon:"🚘",groupId:5},{title:t("Activities"),icon:"🏀",groupId:6},{title:t("Objects"),icon:"💡",groupId:7},{title:t("Symbols"),icon:"🔵",groupId:8},{title:t("Flags"),icon:"🏁",groupId:9}],o=q0(e,s=>s.group);return i.map(s=>({...s,items:o[s.groupId]}))}getSkinTones(){const{t:e}=this.editor.locale;return[{id:"default",icon:"👋",tooltip:e("Default skin tone")},{id:"light",icon:"👋🏻",tooltip:e("Light skin tone")},{id:"medium-light",icon:"👋🏼",tooltip:e("Medium Light skin tone")},{id:"medium",icon:"👋🏽",tooltip:e("Medium skin tone")},{id:"medium-dark",icon:"👋🏾",tooltip:e("Medium Dark skin tone")},{id:"dark",icon:"👋🏿",tooltip:e("Dark skin tone")}]}isReady(){return this._repositoryPromise}_getUrl(){const{definitionsUrl:e,version:t}=this.editor.config.get("emoji");if(!e||e==="cdn"){const i=t||hS,o=new URL(uS.replace("{version}",i.toString()));return o.searchParams.set("editorVersion",zg),o}return t&&J("emoji-repository-redundant-version"),new URL(e)}_warnAboutCdnUse(){const e=this.editor,t=e.config.get("emoji"),i=e.config.get("licenseKey"),o=window[Symbol.for("cke distribution")];i!=="GPL"&&o!=="cloud"&&(t&&t.definitionsUrl||J("emoji-repository-cdn-use"))}_getItems(){const e=pr._results[this._url.href];return e&&e.length?e:null}async _loadAndCacheEmoji(){if(pr._results[this._url.href])return;const e=await fetch(this._url,{cache:"force-cache"}).then(t=>t.ok?t.json():[]).catch(()=>[]);pr._results[this._url.href]=this._normalizeEmoji(e)}_normalizeEmoji(e){const t=this.editor,i=t.config.get("emoji.useCustomFont"),o=t.plugins.get("EmojiUtils"),s=e.filter(c=>o.isEmojiCategoryAllowed(c));if(i)return s.map(c=>o.normalizeEmojiSkinTone(c));const r=o.getEmojiSupportedVersionByOs(),a=o.createEmojiWidthTestingContainer();document.body.appendChild(a);const l=s.filter(c=>o.isEmojiSupported(c,r,a)).map(c=>o.normalizeEmojiSkinTone(c));return a.remove(),l}};h(Hb,"_results",{});let $b=Hb;const Wn=":",fl=":__EMOJI_SHOW_ALL:",gl=":__EMOJI_HINT:";class dS extends w{constructor(e){super(e),h(this,"_emojiDropdownLimit"),h(this,"_skinTone"),this.editor.config.define("emoji",{dropdownLimit:6}),this._emojiDropdownLimit=e.config.get("emoji.dropdownLimit"),this._skinTone=e.config.get("emoji.skinTone"),this._setupMentionConfiguration(e)}static get requires(){return[$b,pa,"Mention"]}static get pluginName(){return"EmojiMention"}static get isOfficialPlugin(){return!0}_setupMentionConfiguration(e){const t=e.config.get("mergeFields.prefix"),i=e.config.get("mention.feeds"),o=t?t[0]===Wn:!1;if(i.filter(r=>!r._isEmojiMarker).some(r=>r.marker===Wn)||o){J("emoji-config-marker-already-used",{marker:Wn});return}if(i.some(r=>r._isEmojiMarker))return;const s={_isEmojiMarker:!0,marker:Wn,dropdownLimit:this._emojiDropdownLimit,itemRenderer:this._customItemRendererFactory(this.editor.t),feed:this._queryEmojiCallbackFactory()};this.editor.config.set("mention.feeds",[...i,s])}async init(){const e=this.editor;this.emojiPickerPlugin=e.plugins.has("EmojiPicker")?e.plugins.get("EmojiPicker"):null,this.emojiRepositoryPlugin=e.plugins.get("EmojiRepository"),this._isEmojiRepositoryAvailable=await this.emojiRepositoryPlugin.isReady(),this._isEmojiRepositoryAvailable&&e.once("ready",this._overrideMentionExecuteListener.bind(this))}_customItemRendererFactory(e){return t=>{const i=document.createElement("button");i.classList.add("ck"),i.classList.add("ck-button"),i.classList.add("ck-button_with-text"),i.id=`mention-list-item-id${t.id.slice(0,-1)}`,i.type="button",i.tabIndex=-1;const o=document.createElement("span");return o.classList.add("ck"),o.classList.add("ck-button__label"),i.appendChild(o),t.id===gl?(i.classList.add("ck-list-item-button"),i.classList.add("ck-disabled"),o.textContent=e("Keep on typing to see the emoji.")):t.id===fl?o.textContent=e("Show all emoji..."):o.textContent=`${t.text} ${t.id}`,i}}_overrideMentionExecuteListener(){const e=this.editor;e.commands.get("mention").on("execute",(t,i)=>{const o=i[0];if(o.marker===Wn&&(t.stop(),o.mention.id!==gl))if(o.mention.id===fl){const s=[...o.range.getItems()].filter(a=>a.is("$textProxy")).map(a=>a.data).reduce((a,l)=>a+l,"");e.model.change(a=>{e.model.deleteContent(a.createSelection(o.range))});const r=this.emojiPickerPlugin;r.showUI(s.slice(1)),setTimeout(()=>{r.emojiPickerView.focus()})}else e.execute("insertText",{text:o.mention.text,range:o.range})},{priority:"high"})}_queryEmojiCallbackFactory(){return e=>{if(e.startsWith(" "))return[];if(e.startsWith(Wn))return[];if(!this._isEmojiRepositoryAvailable)return[];const t=this.emojiRepositoryPlugin.getEmojiByQuery(e).map(o=>{let s=o.skins[this._skinTone]||o.skins.default;return this.emojiPickerPlugin&&(s=o.skins[this.emojiPickerPlugin.skinTone]||o.skins.default),{id:`:${o.annotation}:`,text:s}});if(!this.emojiPickerPlugin)return t.slice(0,this._emojiDropdownLimit);const i={id:e.length>1?fl:gl};return[...t.slice(0,this._emojiDropdownLimit-1),i]}}}class mS extends O{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=t.checkChild(i.getFirstPosition(),"$text")}execute(e=""){this.editor.plugins.get("EmojiPicker").showUI(e)}}class fS extends A{constructor(e,{categoryName:t,emojiCategories:i,getEmojiByQuery:o,skinTone:s}){super(e),h(this,"tiles"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"emojiCategories"),h(this,"cachedTiles"),h(this,"_getEmojiByQuery"),this.set("isEmpty",!0),this.set("categoryName",t),this.set("skinTone",s),this.tiles=this.createCollection(),this.cachedTiles=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this._getEmojiByQuery=o,this.emojiCategories=i;const r=this.bindTemplate;this.setTemplate({tag:"div",children:[{tag:"div",attributes:{role:"grid",class:["ck","ck-emoji__grid"]},children:this.tiles}],attributes:{role:"tabpanel",class:["ck","ck-emoji__tiles",r.if("isEmpty","ck-hidden",a=>a)]}}),vo({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.tiles,numberOfColumns:()=>I.window.getComputedStyle(this.element.firstChild).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy(),this.focusTracker.destroy()}focus(){const e=this.tiles.first;e&&e.focus()}filter(e){const{matchingItems:t,allItems:i}=e?this._getItemsByQuery(e.source):this._getItemsByCategory();return this._updateGrid(t),this.set("isEmpty",t.length===0),{resultsCount:t.length,totalItemsCount:i.length}}_getItemsByQuery(e){return{matchingItems:this._getEmojiByQuery(e),allItems:this.emojiCategories.flatMap(t=>t.items)}}_getItemsByCategory(){const e=this.emojiCategories.find(i=>i.title===this.categoryName),{items:t}=e;return{matchingItems:t,allItems:t}}_updateGrid(e){[...this.tiles].forEach(t=>{this.focusTracker.remove(t),this.tiles.remove(t)}),e.map(t=>{const i=t.skins[this.skinTone]||t.skins.default;return this.cachedTiles.get(i)||this._createTile(i,t.annotation)}).forEach(t=>{this.tiles.add(t),this.focusTracker.add(t)})}_createTile(e,t){const i=new P(this.locale);return i.viewUid=e,i.extendTemplate({attributes:{class:["ck-emoji__tile"]}}),i.set({label:e,tooltip:t,withText:!0,ariaLabel:t,ariaLabelledBy:void 0}),i.on("execute",()=>{this.fire("execute",{name:t,emoji:e})}),this.cachedTiles.add(i),i}}class gS extends A{constructor(e,{emojiCategories:t,categoryName:i}){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"focusCycler"),h(this,"buttonViews"),this.buttonViews=this.createCollection(t.map(o=>this._createCategoryButton(o))),this.focusTracker=new ee,this.keystrokes=new te,this.focusCycler=new Ae({focusables:this.buttonViews,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-emoji__categories-list"],role:"tablist"},children:this.buttonViews}),this.on("change:categoryName",(o,s,r,a)=>{const l=this.buttonViews.find(u=>u.tooltip===a);l&&(l.isOn=!1);const c=this.buttonViews.find(u=>u.tooltip===r);c.isOn=!0}),this.set("categoryName",i)}render(){super.render(),this.buttonViews.forEach(e=>{this.focusTracker.add(e)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),this.buttonViews.destroy()}focus(){this.buttonViews.first.focus()}enableCategories(){this.buttonViews.forEach(e=>{e.isEnabled=!0})}disableCategories(){this.buttonViews.forEach(e=>{e.set({class:"",isEnabled:!1,isOn:!1})})}_createCategoryButton(e){const t=new P,i=t.bindTemplate;return t.extendTemplate({attributes:{"aria-selected":i.to("isOn",o=>o.toString()),class:["ck-emoji__category-item"]}}),t.set({ariaLabel:e.title,label:e.icon,role:"tab",tooltip:e.title,withText:!0,ariaLabelledBy:void 0}),t.on("execute",()=>{this.categoryName=e.title}),t.on("change:isEnabled",()=>{t.isEnabled&&t.tooltip===this.categoryName&&(t.isOn=!0)}),t}}class pS extends A{constructor(e,{gridView:t,resultsView:i}){super(e),h(this,"inputView"),h(this,"gridView"),this.gridView=t;const o=e.t;this.inputView=new pT(this.locale,{queryView:{label:o("Find an emoji (min. 2 characters)"),creator:nt},filteredView:this.gridView,infoView:{instance:i}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search"],tabindex:"-1"},children:[this.inputView.queryView]}),this.inputView.delegate("search").to(this)}destroy(){super.destroy(),this.inputView.destroy()}search(e){const t=e?new RegExp(ta(e),"ig"):null,i=this.gridView.filter(t);this.inputView.fire("search",{query:e,...i})}setInputValue(e){e?this.inputView.queryView.fieldView.value=e:this.inputView.queryView.fieldView.reset()}getInputValue(){return this.inputView.queryView.fieldView.element.value}focus(){this.inputView.focus()}}class wS extends A{constructor(e,{skinTone:t,skinTones:i}){super(e),h(this,"dropdownView"),h(this,"_skinTones"),this.set("skinTone",t),this._skinTones=i;const o=e.t,s=o("Select skin tone"),r=Ee(e),a=new _e;for(const{id:l,icon:c,tooltip:u}of this._skinTones){const d={type:"button",model:new et({value:l,label:c,ariaLabel:u,tooltip:u,tooltipPosition:"e",role:"menuitemradio",withText:!0,ariaLabelledBy:void 0})};d.model.bind("isOn").to(this,"skinTone",m=>m===l),a.add(d)}wt(r,a,{ariaLabel:s,role:"menu"}),r.buttonView.set({label:this._getSkinTone().icon,ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),this.dropdownView=r,this.listenTo(r,"execute",l=>{this.skinTone=l.source.value}),r.buttonView.bind("label").to(this,"skinTone",()=>this._getSkinTone().icon),r.buttonView.bind("ariaLabel").to(this,"skinTone",()=>`${this._getSkinTone().tooltip}, ${s}`),this.setTemplate({tag:"div",attributes:{class:["ck","ck-emoji__skin-tone"]},children:[r]})}focus(){this.dropdownView.buttonView.focus()}_getSkinTone(){return this._skinTones.find(e=>e.id===this.skinTone)}}class bS extends A{constructor(e,{emojiCategories:t,getEmojiByQuery:i,skinTone:o,skinTones:s}){super(e),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"focusCycler"),h(this,"searchView"),h(this,"toneView"),h(this,"categoriesView"),h(this,"gridView"),h(this,"infoView");const r=t[0].title;this.gridView=new fS(e,{categoryName:r,emojiCategories:t,getEmojiByQuery:i,skinTone:o}),this.infoView=new ub,this.searchView=new pS(e,{gridView:this.gridView,resultsView:this.infoView}),this.categoriesView=new gS(e,{emojiCategories:t,categoryName:r}),this.toneView=new wS(e,{skinTone:o,skinTones:s}),this.items=this.createCollection([this.searchView,this.toneView,this.categoriesView,this.gridView,this.infoView]),this.focusTracker=new ee,this.keystrokes=new te,this.focusCycler=new Ae({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",children:[{tag:"div",children:[this.searchView,this.toneView],attributes:{class:["ck","ck-emoji__search"]}},this.categoriesView,this.gridView,{tag:"div",children:[this.infoView],attributes:{class:["ck","ck-search__results"]}}],attributes:{tabindex:"-1",class:["ck","ck-emoji","ck-search"]}}),this._setupEventListeners()}render(){super.render(),this.focusTracker.add(this.searchView.element),this.focusTracker.add(this.toneView.element),this.focusTracker.add(this.categoriesView.element),this.focusTracker.add(this.gridView.element),this.focusTracker.add(this.infoView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.searchView.focus()}_setupEventListeners(){const e=this.locale.t;this.searchView.on("search",(t,i)=>{i.query?this.categoriesView.disableCategories():this.categoriesView.enableCategories()}),this.searchView.on("search",(t,i)=>{i.query.length===1?this.infoView.set({primaryText:e("Keep on typing to see the emoji."),secondaryText:e("The query must contain at least two characters."),isVisible:!0}):i.resultsCount?this.infoView.set({isVisible:!1}):this.infoView.set({primaryText:e('No emojis were found matching "%0".',i.query),secondaryText:e("Please try a different phrase or check the spelling."),isVisible:!0})}),this.searchView.on("search",()=>{this.fire("update"),this.gridView.element.scrollTo(0,0)}),this.categoriesView.on("change:categoryName",(t,i,o)=>{this.gridView.categoryName=o,this.searchView.search("")}),this.toneView.on("change:skinTone",(t,i,o)=>{this.gridView.skinTone=o,this.searchView.search(this.searchView.getInputValue())})}}class _S extends A{constructor(e){super(e),h(this,"backButtonView"),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"children"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this.backButtonView=this._createBackButton(),this.children=this.createCollection([this._createHeaderView()]),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form","ck-emoji-picker-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),[...this.children.filter(yo),this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element),Nw(e)&&this._focusCycler.chain(e.focusCycler)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Emoji picker")});return t.children.add(this.backButtonView,0),t}}const Ni="emoji-picker";class vS extends w{static get requires(){return[$b,Ue,du,pa]}static get pluginName(){return"EmojiPicker"}static get isOfficialPlugin(){return!0}async init(){const e=this.editor;if(this.balloonPlugin=e.plugins.get("ContextualBalloon"),this.emojiRepositoryPlugin=e.plugins.get("EmojiRepository"),!await this.emojiRepositoryPlugin.isReady())return;const t=new mS(e);e.commands.add("emoji",t),e.ui.componentFactory.add("emoji",()=>{const i=this._createButton(P,t);return i.set({tooltip:!0}),i}),e.ui.componentFactory.add("menuBar:emoji",()=>this._createButton(ve,t)),this._setupConversion()}destroy(){super.destroy(),this.emojiPickerView&&this.emojiPickerView.destroy()}get skinTone(){return this.emojiPickerView?this.emojiPickerView.gridView.skinTone:this.editor.config.get("emoji.skinTone")}showUI(e=""){this._showFakeVisualSelection(),this.emojiPickerView||(this.emojiPickerView=this._createEmojiPickerView()),e&&this.emojiPickerView.searchView.setInputValue(e),this.emojiPickerView.searchView.search(e),this.emojiPickerFormView||(this.emojiPickerFormView=this._createEmojiPickerFormView()),this.balloonPlugin.hasView(this.emojiPickerFormView)||(this.emojiPickerFormView.backButtonView.isVisible=!!this.balloonPlugin.visibleView,this.balloonPlugin.add({view:this.emojiPickerFormView,position:this._getBalloonPositionData(),balloonClassName:"ck-emoji-picker-balloon"})),this.emojiPickerView.focus()}_createButton(e,t){const i=new e(this.editor.locale),o=this.editor.locale.t;return i.bind("isEnabled").to(t,"isEnabled"),i.set({label:o("Emoji"),icon:yC,isToggleable:!0}),i.on("execute",()=>{this.editor.editing.view.scrollToTheSelection(),this.showUI()}),i}_createEmojiPickerView(){const e=new bS(this.editor.locale,{emojiCategories:this.emojiRepositoryPlugin.getEmojiCategories(),skinTone:this.editor.config.get("emoji.skinTone"),skinTones:this.emojiRepositoryPlugin.getSkinTones(),getEmojiByQuery:t=>this.emojiRepositoryPlugin.getEmojiByQuery(t)});return this.listenTo(e.gridView,"execute",(t,i)=>{const o=this.editor,s=i.emoji;this._hideUI(),o.execute("insertText",{text:s})}),e}_createEmojiPickerFormView(){const e=new _S(this.editor.locale);return e.children.add(this.emojiPickerView),this.listenTo(this.emojiPickerView,"update",()=>{this.balloonPlugin.visibleView===e&&this.balloonPlugin.updatePosition()}),this.listenTo(e,"cancel",()=>{this._hideUI()}),e.keystrokes.set("Esc",(t,i)=>{this._hideUI(),i()}),$t({emitter:e,contextElements:[this.balloonPlugin.view.element],callback:()=>{this._hideUI(!1)},activator:()=>this.balloonPlugin.visibleView===e}),e}_hideUI(e=!0){this.balloonPlugin.remove(this.emojiPickerFormView),this.emojiPickerView.searchView.setInputValue(""),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection()}_setupConversion(){const e=this.editor;e.conversion.for("editingDowncast").markerToHighlight({model:Ni,view:{classes:["ck-fake-emoji-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Ni,view:(t,{writer:i})=>{if(!t.markerRange.isCollapsed)return null;const o=i.createUIElement("span");return i.addClass(["ck-fake-emoji-selection","ck-fake-emoji-selection_collapsed"],o),o}})}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;return{target:()=>e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(Ni))t.updateMarker(Ni,{range:i});else if(i.start.isAtEnd){const o=i.start.getLastMatchingPosition(({item:s})=>!e.schema.isContent(s),{boundaries:i});t.addMarker(Ni,{usingOperation:!1,affectsData:!1,range:t.createRange(o,i.end)})}else t.addMarker(Ni,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Ni)&&e.change(t=>{t.removeMarker(Ni)})}}class yS extends w{static get requires(){return[dS,vS]}static get pluginName(){return"Emoji"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class kS extends O{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!Fm(e.schema,i))do if(i=i.parent,!i)return;while(!Fm(e.schema,i));e.change(o=>{o.setSelection(i,"in")})}}function Fm(n,e){return n.isLimit(e)&&(n.checkChild(e,"$text")||n.checkChild(e,"paragraph"))}const CS=na("Ctrl+A");class AS extends w{static get pluginName(){return"SelectAllEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.editing.view.document;e.commands.add("selectAll",new kS(e)),this.listenTo(i,"keydown",(o,s)=>{yn(s)===CS&&(e.execute("selectAll"),s.preventDefault())}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class xS extends w{static get pluginName(){return"SelectAllUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:selectAll",()=>this._createButton(ve))}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("selectAll"),s=new e(t.locale),r=i.t;return s.set({label:r("Select all"),icon:aA,keystroke:"Ctrl+A"}),s.bind("isEnabled").to(o,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("selectAll"),t.editing.view.focus()}),s}}class Wb extends w{static get requires(){return[AS,xS]}static get pluginName(){return"SelectAll"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class jb extends O{constructor(e){super(e),h(this,"_stack",[]),h(this,"_createdBatches",new WeakSet),this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",(t,i)=>{i[1]={...i[1]};const o=i[1];o.batchType||(o.batchType={isUndoable:!1})},{priority:"high"}),this.listenTo(e.data,"set",(t,i)=>{i[1].batchType.isUndoable||this.clearStack()})}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(e){const t=this.editor.model.document.selection,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const o=this.editor.model,s=o.document,r=[],a=e.map(c=>c.getTransformedByOperations(i)),l=a.flat();for(const c of a){const u=c.filter(d=>d.root!=s.graveyard).filter(d=>!ES(d,l));u.length&&(TS(u),r.push(u[0]))}r.length&&o.change(c=>{c.setSelection(r,{backward:t})})}_undo(e,t){const i=this.editor.model,o=i.document;this._createdBatches.add(t);const s=e.operations.slice().filter(r=>r.isDocumentOperation);s.reverse();for(const r of s){const a=r.baseVersion+1,l=Array.from(o.history.getOperations(a)),c=A2([r.getReversed()],l,{useRelations:!0,document:this.editor.model.document,forceWeakRemove:!0}).operationsA;for(let u of c){const d=u.affectedSelectable;d&&!i.canEditAt(d)&&(u=new De(u.baseVersion)),t.addOperation(u),i.applyOperation(u),o.history.setOperationAsUndone(r,u)}}}}function TS(n){n.sort((e,t)=>e.start.isBefore(t.start)?-1:1);for(let e=1;e<n.length;e++){const t=n[e-1].getJoined(n[e],!0);t&&(e--,n.splice(e,2,t))}}function ES(n,e){return e.some(t=>t!==n&&t.containsRange(n,!0))}class SS extends jb{execute(e=null){const t=e?this._stack.findIndex(s=>s.batch==e):this._stack.length-1,i=this._stack.splice(t,1)[0],o=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(o,()=>{this._undo(i.batch,o);const s=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,s)}),this.fire("revert",i.batch,o),this.refresh()}}class PS extends jb{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,()=>{const i=e.batch.operations[e.batch.operations.length-1].baseVersion+1,o=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,o),this._undo(e.batch,t)}),this.refresh()}}class IS extends w{constructor(){super(...arguments),h(this,"_undoCommand"),h(this,"_redoCommand"),h(this,"_batchRegistry",new WeakSet)}static get pluginName(){return"UndoEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;this._undoCommand=new SS(e),this._redoCommand=new PS(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",(i,o)=>{const s=o[0];if(!s.isDocumentOperation)return;const r=s.batch,a=this._redoCommand.createdBatches.has(r),l=this._undoCommand.createdBatches.has(r);this._batchRegistry.has(r)||(this._batchRegistry.add(r),r.isUndoable&&(a?this._undoCommand.addBatch(r):l||(this._undoCommand.addBatch(r),this._redoCommand.clearStack())))},{priority:"highest"}),this.listenTo(this._undoCommand,"revert",(i,o,s)=>{this._redoCommand.addBatch(s)}),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Undo"),keystroke:"CTRL+Z"},{label:t("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}class VS extends w{static get pluginName(){return"UndoUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,o=t.uiLanguageDirection=="ltr"?yd:_d,s=t.uiLanguageDirection=="ltr"?_d:yd;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",o),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",s)}_addButtonsToFactory(e,t,i,o){const s=this.editor;s.ui.componentFactory.add(e,()=>{const r=this._createButton(P,e,t,i,o);return r.set({tooltip:!0}),r}),s.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(ve,e,t,i,o))}_createButton(e,t,i,o,s){const r=this.editor,a=r.locale,l=r.commands.get(t),c=new e(a);return c.set({label:i,icon:s,keystroke:o}),c.bind("isEnabled").to(l,"isEnabled"),this.listenTo(c,"execute",()=>{r.execute(t),r.editing.view.focus()}),c}}class Ub extends w{static get requires(){return[IS,VS]}static get pluginName(){return"Undo"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class RS extends A{constructor(e){super(e),h(this,"children"),h(this,"_findInputView"),h(this,"_replaceInputView"),h(this,"_findButtonView"),h(this,"_findPrevButtonView"),h(this,"_findNextButtonView"),h(this,"_advancedOptionsCollapsibleView"),h(this,"_matchCaseSwitchView"),h(this,"_wholeWordsOnlySwitchView"),h(this,"_replaceButtonView"),h(this,"_replaceAllButtonView"),h(this,"_inputsDivView"),h(this,"_actionButtonsDivView"),h(this,"_focusTracker"),h(this,"_keystrokes"),h(this,"_focusables"),h(this,"focusCycler");const t=e.t;this.children=this.createCollection(),this.set("matchCount",0),this.set("highlightOffset",0),this.set("isDirty",!1),this.set("_areCommandsEnabled",{}),this.set("_resultsCounterText",""),this.set("_matchCase",!1),this.set("_wholeWordsOnly",!1),this.bind("_searchResultsFound").to(this,"matchCount",this,"isDirty",(i,o)=>i>0&&!o),this._findInputView=this._createInputField(t("Find in text…")),this._findPrevButtonView=this._createButton({label:t("Previous result"),class:"ck-button-prev",icon:li,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:t("Next result"),class:"ck-button-next",icon:li,keystroke:"F3",tooltip:!0}),this._replaceInputView=this._createInputField(t("Replace with…"),"ck-labeled-field-replace"),this._inputsDivView=this._createInputsDiv(),this._matchCaseSwitchView=this._createMatchCaseSwitch(),this._wholeWordsOnlySwitchView=this._createWholeWordsOnlySwitch(),this._advancedOptionsCollapsibleView=this._createAdvancedOptionsCollapsible(),this._replaceAllButtonView=this._createButton({label:t("Replace all"),class:"ck-button-replaceall",withText:!0}),this._replaceButtonView=this._createButton({label:t("Replace"),class:"ck-button-replace",withText:!0}),this._findButtonView=this._createButton({label:t("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._actionButtonsDivView=this._createActionButtonsDiv(),this._focusTracker=new ee,this._keystrokes=new te,this._focusables=new Ie,this.focusCycler=new Ae({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.addMany([this._inputsDivView,this._advancedOptionsCollapsibleView,this._actionButtonsDivView]),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(e){e===-1?this.focusCycler.focusLast():this.focusCycler.focusFirst()}reset(){this._findInputView.errorText=null,this.isDirty=!0}get _textToFind(){return this._findInputView.fieldView.element.value}get _textToReplace(){return this._replaceInputView.fieldView.element.value}_createInputsDiv(){const e=this.locale,t=e.t,i=new A(e);return this._findInputView.fieldView.on("input",()=>{this.isDirty=!0}),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findPrevious:o})=>o),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",({findNext:o})=>o),this._injectFindResultsCounter(),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:o},s)=>o&&s),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",(o,s)=>o||!s?"":t("Tip: Find some text first in order to replace it.")),i.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__inputs"]},children:[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView]}),i}_onFindButtonExecute(){if(!this._textToFind){const e=this.t;this._findInputView.errorText=e("Text to find must not be empty.");return}this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly})}_injectFindResultsCounter(){const e=this.locale,t=e.t,i=this.bindTemplate,o=new A(this.locale);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",(r,a)=>t("%0 of %1",[r,a])),o.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",i.if("isDirty","ck-hidden")]},children:[{text:i.to("_resultsCounterText")}]});const s=()=>{const r=this._findInputView.fieldView.element;if(!r||!Gt(r))return;const a=new z(o.element).width,l=e.uiLanguageDirection==="ltr"?"paddingRight":"paddingLeft";a?r.style[l]=`calc( 2 * var(--ck-spacing-standard) + ${a}px )`:r.style[l]=""};this.on("change:_resultsCounterText",s,{priority:"low"}),this.on("change:isDirty",s,{priority:"low"}),this._findInputView.template.children[0].children.push(o)}_createAdvancedOptionsCollapsible(){const e=this.locale.t,t=new mu(this.locale,[this._matchCaseSwitchView,this._wholeWordsOnlySwitchView]);return t.set({label:e("Advanced options"),isCollapsed:!0}),t}_createActionButtonsDiv(){const e=new A(this.locale);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replace:t},i)=>t&&i),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",({replaceAll:t},i)=>t&&i),this._replaceButtonView.on("execute",()=>{this.fire("replace",{searchText:this._textToFind,replaceText:this._textToReplace})}),this._replaceAllButtonView.on("execute",()=>{this.fire("replaceAll",{searchText:this._textToFind,replaceText:this._textToReplace}),this.focus()}),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),e.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__actions"]},children:[this._replaceAllButtonView,this._replaceButtonView,this._findButtonView]}),e}_createMatchCaseSwitch(){const e=this.locale.t,t=new Ji(this.locale);return t.set({label:e("Match case"),withText:!0}),t.bind("isOn").to(this,"_matchCase"),t.on("execute",()=>{this._matchCase=!this._matchCase,this.isDirty=!0}),t}_createWholeWordsOnlySwitch(){const e=this.locale.t,t=new Ji(this.locale);return t.set({label:e("Whole words only"),withText:!0}),t.bind("isOn").to(this,"_wholeWordsOnly"),t.on("execute",()=>{this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0}),t}_initFocusCycling(){[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._advancedOptionsCollapsibleView.buttonView,this._matchCaseSwitchView,this._wholeWordsOnlySwitchView,this._replaceAllButtonView,this._replaceButtonView,this._findButtonView].forEach(e=>{this._focusables.add(e),this._focusTracker.add(e.element)})}_initKeystrokeHandling(){const e=i=>i.stopPropagation(),t=i=>{i.stopPropagation(),i.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",i=>{t(i),this._findNextButtonView.fire("execute")}),this._keystrokes.set("shift+f3",i=>{t(i),this._findPrevButtonView.fire("execute")}),this._keystrokes.set("enter",i=>{const o=i.target;o===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),t(i)):o===this._replaceInputView.fieldView.element&&!this.isDirty&&(this._replaceButtonView.fire("execute"),t(i))}),this._keystrokes.set("shift+enter",i=>{i.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),t(i))}),this._keystrokes.set("arrowright",e),this._keystrokes.set("arrowleft",e),this._keystrokes.set("arrowup",e),this._keystrokes.set("arrowdown",e)}_createButton(e){const t=new P(this.locale);return t.set(e),t}_createInputField(e,t){const i=new Te(this.locale,nt);return i.label=e,i.class=t,i}}class OS extends w{constructor(e){super(e),h(this,"formView"),e.config.define("findAndReplace.uiType","dialog"),this.formView=null}static get requires(){return[du]}static get pluginName(){return"FindAndReplaceUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.config.get("findAndReplace.uiType")==="dropdown",i=e.commands.get("find"),o=this.editor.t;e.ui.componentFactory.add("findAndReplace",()=>{let s;return t?(s=this._createDropdown(),s.bind("isEnabled").to(i)):s=this._createDialogButtonForToolbar(),e.keystrokes.set("Ctrl+F",(r,a)=>{if(i.isEnabled){if(s instanceof Jw){const l=s.buttonView;l.isOn||l.fire("execute")}else s.isOn?e.plugins.get("Dialog").view.focus():s.fire("execute");a()}}),s}),t||e.ui.componentFactory.add("menuBar:findAndReplace",()=>this._createDialogButtonForMenuBar()),e.accessibility.addKeystrokeInfos({keystrokes:[{label:o("Find in the document"),keystroke:"CTRL+F"}]})}_createDropdown(){const e=this.editor,t=e.locale.t,i=Ee(e.locale);return i.once("change:isOpen",()=>{this.formView=this._createFormView(),this.formView.children.add(new Jt(e.locale,{label:t("Find and replace")}),0),i.panelView.children.add(this.formView)}),i.on("change:isOpen",(o,s,r)=>{r?this._setupFormView():this.fire("searchReseted")},{priority:"low"}),i.buttonView.set({icon:fd,label:t("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),i}_createDialogButtonForToolbar(){const e=this.editor,t=this._createButton(P),i=e.plugins.get("Dialog");return t.set({tooltip:!0}),t.bind("isOn").to(i,"id",o=>o==="findAndReplace"),t.on("execute",()=>{t.isOn?i.hide():this._showDialog()}),t}_createDialogButtonForMenuBar(){const e=this._createButton(ve),t=this.editor.plugins.get("Dialog"),i=this.editor.plugins.get("Dialog");return e.set({role:"menuitemcheckbox",isToggleable:!0}),e.bind("isOn").to(i,"id",o=>o==="findAndReplace"),e.on("execute",()=>{if(t.id==="findAndReplace"){t.hide();return}this._showDialog()}),e}_createButton(e){const t=this.editor,i=t.commands.get("find"),o=new e(t.locale),s=t.locale.t;return o.bind("isEnabled").to(i),o.set({icon:fd,label:s("Find and replace"),keystroke:"CTRL+F"}),o}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.formView||(this.formView=this._createFormView()),t.show({id:"findAndReplace",title:i("Find and replace"),content:this.formView,position:vt.EDITOR_TOP_SIDE,onShow:()=>{this._setupFormView()},onHide:()=>{this.fire("searchReseted")}})}_createFormView(){const e=this.editor,t=new(ho(RS))(e.locale),i=e.commands,o=this.editor.plugins.get("FindAndReplaceEditing").state;t.bind("highlightOffset").to(o,"highlightedOffset"),t.listenTo(o.results,"change",()=>{t.matchCount=o.results.length});const s=i.get("findNext"),r=i.get("findPrevious"),a=i.get("replace"),l=i.get("replaceAll");return t.bind("_areCommandsEnabled").to(s,"isEnabled",r,"isEnabled",a,"isEnabled",l,"isEnabled",(c,u,d,m)=>({findNext:c,findPrevious:u,replace:d,replaceAll:m})),t.delegate("findNext","findPrevious","replace","replaceAll").to(this),t.on("change:isDirty",(c,u,d)=>{d&&this.fire("searchReseted")}),t}_setupFormView(){this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()}}class BS extends O{constructor(e,t){super(e),h(this,"_state"),this.isEnabled=!0,this.affectsData=!1,this._state=t}execute(e,{matchCase:t,wholeWords:i}={}){const{editor:o}=this,{model:s}=o,r=o.plugins.get("FindAndReplaceUtils");let a,l="";typeof e=="string"?a=(...d)=>({results:r.findByTextCallback(e,{matchCase:t,wholeWords:i})(...d),searchText:e}):a=e;const c=a;a=(...d)=>{const m=c(...d);return m&&"searchText"in m&&(l=m.searchText),m};const u=s.document.getRootNames().reduce((d,m)=>r.updateFindResultFromRange(s.createRangeIn(s.document.getRoot(m)),s,a,d),null);return this._state.clear(s),this._state.results.addMany(u),this._state.highlightedResult=u.get(0),this._state.searchText=l,a&&(this._state.lastSearchCallback=a),this._state.matchCase=!!t,this._state.matchWholeWords=!!i,{results:u,findCallback:a}}}class MS extends ue(){constructor(e){super(),this.set("results",new _e),this.set("highlightedResult",null),this.set("highlightedOffset",0),this.set("searchText",""),this.set("replaceText",""),this.set("lastSearchCallback",null),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",(t,{removed:i,index:o})=>{if(Array.from(i).length){let s=!1;if(e.change(r=>{for(const a of i)this.highlightedResult===a&&(s=!0),e.markers.has(a.marker.name)&&r.removeMarker(a.marker)}),s){const r=o>=this.results.length?0:o;this.highlightedResult=this.results.get(r)}}}),this.on("change:highlightedResult",()=>{this.refreshHighlightOffset(e)})}clear(e){this.searchText="",e.change(t=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],o=e.markers.get(`findResultHighlighted:${i}`);o&&t.removeMarker(o)}[...this.results].forEach(({marker:i})=>{t.removeMarker(i)})}),this.results.clear()}refreshHighlightOffset(e){const{highlightedResult:t,results:i}=this;t?this.highlightedOffset=qb(e,[...i]).indexOf(t)+1:this.highlightedOffset=0}}function qb(n,e){const t={before:-1,same:0,after:1,different:1};return n.document.getRootNames().flatMap(i=>e.filter(o=>o.marker.getStart().root.rootName===i).sort((o,s)=>t[o.marker.getStart().compareWith(s.marker.getStart())]))}class Gb extends O{constructor(e,t){super(e),h(this,"_state"),this.isEnabled=!0,this._state=t,this._isEnabledBasedOnSelection=!1}_replace(e,t){const{model:i}=this.editor,o=t.marker.getRange();i.canEditAt(o)&&i.change(s=>{if(o.root.rootName==="$graveyard"){this._state.results.remove(t);return}let r={};for(const a of o.getItems())if(a.is("$text")||a.is("$textProxy")){r=a.getAttributes();break}i.insertContent(s.createText(e,r),o),this._state.results.has(t)&&this._state.results.remove(t)})}}class LS extends Gb{execute(e,t){const i=Math.max(this._state.highlightedOffset-1,0);if(this._replace(e,t),this._state.results.length){const o=qb(this.editor.model,[...this._state.results]);this._state.highlightedResult=o[i%o.length]}}}class FS extends Gb{execute(e,t){const{editor:i}=this,{model:o}=i,s=i.plugins.get("FindAndReplaceUtils"),r=t instanceof _e?t:o.document.getRootNames().reduce((a,l)=>s.updateFindResultFromRange(o.createRangeIn(o.document.getRoot(l)),o,s.findByTextCallback(t,this._state),a),null);r.length&&o.change(()=>{[...r].forEach(a=>{this._replace(e,a)})})}}class Kb extends O{constructor(e,t){super(e),h(this,"_state"),this.affectsData=!1,this._state=t,this.isEnabled=!1,this.listenTo(this._state.results,"change",()=>{this.isEnabled=this._state.results.length>1})}refresh(){this.isEnabled=this._state.results.length>1}execute(){const e=this._state.results,t=e.getIndex(this._state.highlightedResult),i=t+1>=e.length?0:t+1;this._state.highlightedResult=this._state.results.get(i)}}class NS extends Kb{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),t=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(t)}}class DS extends w{static get pluginName(){return"FindAndReplaceUtils"}static get isOfficialPlugin(){return!0}updateFindResultFromRange(e,t,i,o){const s=o||new _e,r=a=>s.find(l=>{const{marker:c}=l,u=c.getRange(),d=a.getRange();return u.isEqual(d)});return t.change(a=>{[...e].forEach(({type:l,item:c})=>{if(l==="elementStart"&&t.schema.checkChild(c,"$text")){let u=i({item:c,text:this.rangeToText(t.createRangeIn(c))});if(!u)return;"results"in u&&(u=u.results),u.forEach(d=>{const m=`findResult:${ze()}`,f=a.addMarker(m,{usingOperation:!1,affectsData:!1,range:a.createRange(a.createPositionAt(c,d.start),a.createPositionAt(c,d.end))}),g=zS(s,f);r(f)||s.add({id:m,label:d.label,marker:f},g)})}})}),s}rangeToText(e){return Array.from(e.getItems({shallow:!0})).reduce((t,i)=>i.is("$text")||i.is("$textProxy")?t+i.data:`${t}
`,"")}findByTextCallback(e,t){let i="gu";t.matchCase||(i+="i");let o=`(${ta(e)})`;if(t.wholeWords){const a="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+a).test(e)||(o=`(^|${a}|_)${o}`),new RegExp(a+"$").test(e)||(o=`${o}(?=_|${a}|$)`)}const s=new RegExp(o,i);function r({text:a}){return[...a.matchAll(s)].map(HS)}return r}}function zS(n,e){const t=n.find(({marker:i})=>e.getStart().isBefore(i.getStart()));return t?n.getIndex(t):n.length}function HS(n){const e=n.length-1;let t=n.index;return n.length===3&&(t+=n[1].length),{label:n[e],start:t,end:t+n[e].length}}const $S="ck-find-result_selected";class WS extends w{constructor(){super(...arguments),h(this,"state"),h(this,"_onDocumentChange",()=>{const e=new Set,t=new Set,i=this.editor.model,{results:o}=this.state,s=i.document.differ.getChanges(),r=i.document.differ.getChangedMarkers();s.forEach(c=>{c.position&&(c.name==="$text"||c.position.nodeAfter&&i.schema.isInline(c.position.nodeAfter)?(e.add(c.position.parent),[...i.markers.getMarkersAtPosition(c.position)].forEach(u=>{t.add(u.name)})):c.type==="insert"&&c.position.nodeAfter&&e.add(c.position.nodeAfter))}),r.forEach(({name:c,data:{newRange:u}})=>{u&&u.start.root.rootName==="$graveyard"&&t.add(c)}),e.forEach(c=>{[...i.markers.getMarkersIntersectingRange(i.createRangeIn(c))].forEach(u=>t.add(u.name))}),t.forEach(c=>{o.has(c)&&(o.get(c)===this.state.highlightedResult&&(this.state.highlightedResult=null),o.remove(c))});const a=[],l=this.editor.plugins.get("FindAndReplaceUtils");e.forEach(c=>{const u=l.updateFindResultFromRange(i.createRangeOn(c),i,this.state.lastSearchCallback,o);a.push(...u)}),r.forEach(c=>{if(c.data.newRange){const u=l.updateFindResultFromRange(c.data.newRange,i,this.state.lastSearchCallback,o);a.push(...u)}}),!this.state.highlightedResult&&a.length?this.state.highlightedResult=a[0]:this.state.refreshHighlightOffset(i)})}static get requires(){return[DS]}static get pluginName(){return"FindAndReplaceEditing"}static get isOfficialPlugin(){return!0}init(){this.state=new MS(this.editor.model),this.set("_isSearchActive",!1),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",(t,i,o,s)=>{const{model:r}=this.editor;r.change(a=>{if(s){const l=s.marker.name.split(":")[1],c=r.markers.get(`findResultHighlighted:${l}`);c&&a.removeMarker(c)}if(o){const l=o.marker.name.split(":")[1];a.addMarker(`findResultHighlighted:${l}`,{usingOperation:!1,affectsData:!1,range:o.marker.getRange()})}})});/* istanbul ignore next -- @preserve */const e=St(((t,i,o)=>{if(o){const s=this.editor.editing.view.domConverter,r=this.editor.editing.mapper.toViewRange(o.marker.getRange());np({target:s.viewRangeToDom(r),viewportOffset:40})}}).bind(this),32);this.listenTo(this.state,"change:highlightedResult",e,{priority:"low"}),this.listenTo(this.editor,"destroy",e.cancel),this.on("change:_isSearchActive",(t,i,o)=>{o?this.listenTo(this.editor.model.document,"change:data",this._onDocumentChange):this.stopListening(this.editor.model.document,"change:data",this._onDocumentChange)})}find(e,t){return this._isSearchActive=!0,this.editor.execute("find",e,t),this.state.results}stop(){this.state.clear(this.editor.model),this._isSearchActive=!1}_defineCommands(){this.editor.commands.add("find",new BS(this.editor,this.state)),this.editor.commands.add("findNext",new Kb(this.editor,this.state)),this.editor.commands.add("findPrevious",new NS(this.editor,this.state)),this.editor.commands.add("replace",new LS(this.editor,this.state)),this.editor.commands.add("replaceAll",new FS(this.editor,this.state))}_defineConverters(){const{editor:e}=this;e.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:t})=>{const[,i]=t.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":i}}}}),e.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:t})=>{const[,i]=t.split(":");return{name:"span",classes:[$S],attributes:{"data-find-result":i}}}})}}class jS extends w{static get requires(){return[WS,OS]}static get pluginName(){return"FindAndReplace"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get("FindAndReplaceUI"),t=this.editor.plugins.get("FindAndReplaceEditing"),i=t.state;e.on("findNext",(o,s)=>{s?(i.searchText=s.searchText,t.find(s.searchText,s)):this.editor.execute("findNext")}),e.on("findPrevious",(o,s)=>{s&&i.searchText!==s.searchText?t.find(s.searchText):this.editor.execute("findPrevious")}),e.on("replace",(o,s)=>{i.searchText!==s.searchText&&t.find(s.searchText);const r=i.highlightedResult;r&&this.editor.execute("replace",s.replaceText,r)}),e.on("replaceAll",(o,s)=>{i.searchText!==s.searchText&&t.find(s.searchText),this.editor.execute("replaceAll",s.replaceText,i.results)}),e.on("searchReseted",()=>{i.clear(this.editor.model),t.stop()})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ba extends O{constructor(e,t){super(e),h(this,"attributeKey"),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,o=e.value,s=e.batch,r=a=>{if(i.isCollapsed)o?a.setSelectionAttribute(this.attributeKey,o):a.removeSelectionAttribute(this.attributeKey);else{const l=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const c of l)o?a.setAttribute(this.attributeKey,o,c):a.removeAttribute(this.attributeKey,c)}};s?t.enqueueChange(s,a=>{r(a)}):t.change(a=>{r(a)})}}const lt="fontSize",ct="fontFamily",ii="fontColor",vi="fontBackgroundColor";function Zb(n,e){const t={model:{key:n,values:[]},view:{},upcastAlso:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]=i.view,i.upcastAlso&&(t.upcastAlso[i.model]=i.upcastAlso);return t}function Jb(n){return e=>qS(e.getStyle(n))}function Qb(n){return(e,{writer:t})=>t.createAttributeElement("span",{style:`${n}:${e}`},{priority:7})}function US({dropdownView:n,colors:e,columns:t,removeButtonLabel:i,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a}){const l=n.locale,c=new wu(l,{colors:e,columns:t,removeButtonLabel:i,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a});return n.colorSelectorView=c,n.panelView.children.add(c),c}function qS(n){return n.replace(/\s/g,"")}class GS extends ba{constructor(e){super(e,ct)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Yb(n){return n.map(KS).filter(e=>e!==void 0)}function KS(n){if(typeof n=="object")return n;if(n==="default")return{title:"Default",model:void 0};if(typeof n=="string")return ZS(n)}function ZS(n){const e=n.replace(/"|'/g,"").split(","),t=e[0],i=e.map(JS).join(", ");return{title:t,model:i,view:{name:"span",styles:{"font-family":i},priority:7}}}function JS(n){return n=n.trim(),n.indexOf(" ")>0&&(n=`'${n}'`),n}class QS extends w{static get pluginName(){return"FontFamilyEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(ct,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:ct}),e.model.schema.setAttributeProperties(ct,{isFormatting:!0,copyOnEnter:!0});const t=Yb(e.config.get("fontFamily.options")).filter(o=>o.model),i=Zb(ct,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(ct,new GS(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:ct,view:(t,{writer:i})=>i.createAttributeElement("span",{style:"font-family:"+t},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:ct,value:t=>t.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:ct,value:e=>e.getAttribute("face")}})}}class YS extends w{static get pluginName(){return"FontFamilyUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),o=e.commands.get(ct),s=t("Font Family"),r=XS(i,o);e.ui.componentFactory.add(ct,a=>{const l=Ee(a);return wt(l,r,{role:"menu",ariaLabel:s}),l.buttonView.set({label:s,icon:gd,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),l.bind("isEnabled").to(o),this.listenTo(l,"execute",c=>{e.execute(c.source.commandName,{value:c.source.commandParam}),e.editing.view.focus()}),l}),e.ui.componentFactory.add(`menuBar:${ct}`,a=>{const l=new Tt(a);l.buttonView.set({label:s,icon:gd}),l.bind("isEnabled").to(o);const c=new Si(a);for(const u of r){const d=new Oi(a,l),m=new ve(a);m.set({role:"menuitemradio",isToggleable:!0}),m.bind(...Object.keys(u.model)).to(u.model),m.delegate("execute").to(l),m.on("execute",()=>{e.execute(u.model.commandName,{value:u.model.commandParam}),e.editing.view.focus()}),d.children.add(m),c.items.add(d)}return l.panelView.children.add(c),l})}_getLocalizedOptions(){const e=this.editor,t=e.t;return Yb(e.config.get(ct).options).map(i=>(i.title==="Default"&&(i.title=t("Default")),i))}}function XS(n,e){const t=new _e;for(const i of n){const o={type:"button",model:new et({commandName:ct,commandParam:i.model,label:i.title,role:"menuitemradio",withText:!0})};o.model.bind("isOn").to(e,"value",s=>s===i.model?!0:!s||!i.model?!1:s.split(",")[0].replace(/'/g,"").toLowerCase()===i.model.toLowerCase()),i.view&&typeof i.view!="string"&&i.view.styles&&o.model.set("labelStyle",`font-family: ${i.view.styles["font-family"]}`),t.add(o)}return t}class eP extends w{static get requires(){return[QS,YS]}static get pluginName(){return"FontFamily"}static get isOfficialPlugin(){return!0}}class tP extends ba{constructor(e){super(e,lt)}}function Eu(n){return n.map(e=>iP(e)).filter(e=>e!==void 0)}const Nm={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function iP(n){if(typeof n=="number"&&(n=String(n)),typeof n=="object"&&sP(n))return ac(n);const e=oP(n);if(e)return ac(e);if(n==="default")return{model:void 0,title:"Default"};if(!rP(n))return nP(n)}function nP(n){return typeof n=="string"&&(n={title:n,model:`${parseFloat(n)}px`}),n.view={name:"span",styles:{"font-size":n.model}},ac(n)}function ac(n){return n.view&&typeof n.view!="string"&&!n.view.priority&&(n.view.priority=7),n}function oP(n){return typeof n=="string"?Nm[n]:Nm[n.model]}function sP(n){return n.title&&n.model&&n.view}function rP(n){let e;if(typeof n=="object")if(n.model)e=parseFloat(n.model);else throw new b("font-size-invalid-definition",null,n);else e=parseFloat(n);return isNaN(e)}const Dm=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class aP extends w{static get pluginName(){return"FontSizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(lt,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:lt}),e.model.schema.setAttributeProperties(lt,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=Eu(this.editor.config.get("fontSize.options")).filter(s=>s.model),o=Zb(lt,i);t?(this._prepareAnyValueConverters(o),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(o),e.commands.add(lt,new tP(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter(o=>!ha(String(o))&&!iw(String(o)));if(i.length)throw new b("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:lt,view:(o,{writer:s})=>{if(o)return s.createAttributeElement("span",{style:"font-size:"+o},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:lt,value:o=>o.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:lt,value:e=>{const t=e.getAttribute("size"),i=t[0]==="-"||t[0]==="+";let o=parseInt(t,10);i&&(o=3+o);const s=Dm.length-1,r=Math.min(Math.max(o,0),s);return Dm[r]}}})}}class lP extends w{static get pluginName(){return"FontSizeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),o=e.commands.get(lt),s=t("Font Size"),r=cP(i,o);e.ui.componentFactory.add(lt,a=>{const l=Ee(a);return wt(l,r,{role:"menu",ariaLabel:s}),l.buttonView.set({label:s,icon:pd,tooltip:!0}),l.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),l.bind("isEnabled").to(o),this.listenTo(l,"execute",c=>{e.execute(c.source.commandName,{value:c.source.commandParam}),e.editing.view.focus()}),l}),e.ui.componentFactory.add(`menuBar:${lt}`,a=>{const l=new Tt(a);l.buttonView.set({label:s,icon:pd}),l.bind("isEnabled").to(o);const c=new Si(a);for(const u of r){const d=new Oi(a,l),m=new ve(a);m.set({role:"menuitemradio",isToggleable:!0}),m.bind(...Object.keys(u.model)).to(u.model),m.delegate("execute").to(l),m.on("execute",()=>{e.execute(u.model.commandName,{value:u.model.commandParam}),e.editing.view.focus()}),d.children.add(m),c.items.add(d)}return l.panelView.children.add(c),l})}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return Eu(e.config.get(lt).options).map(o=>{const s=i[o.title];return s&&s!=o.title&&(o=Object.assign({},o,{title:s})),o})}}function cP(n,e){const t=new _e;for(const i of n){const o={type:"button",model:new et({commandName:lt,commandParam:i.model,label:i.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};i.view&&typeof i.view!="string"&&(i.view.styles&&o.model.set("labelStyle",`font-size:${i.view.styles["font-size"]}`),i.view.classes&&o.model.set("class",`${o.model.class} ${i.view.classes}`)),o.model.bind("isOn").to(e,"value",s=>s===i.model),t.add(o)}return t}class uP extends w{static get requires(){return[aP,lP]}static get pluginName(){return"FontSize"}static get isOfficialPlugin(){return!0}normalizeSizeOptions(e){return Eu(e)}}class hP extends ba{constructor(e){super(e,ii)}}class dP extends w{static get pluginName(){return"FontColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(ii,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:ii,value:Jb("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:ii,value:t=>t.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:ii,view:Qb("color")}),e.commands.add(ii,new hP(e)),e.model.schema.extend("$text",{allowAttributes:ii}),e.model.schema.setAttributeProperties(ii,{isFormatting:!0,copyOnEnter:!0})}}class Xb extends w{constructor(e,{commandName:t,componentName:i,icon:o,dropdownLabel:s}){super(e),h(this,"commandName"),h(this,"componentName"),h(this,"icon"),h(this,"dropdownLabel"),h(this,"columns"),this.commandName=t,this.componentName=i,this.icon=o,this.dropdownLabel=s,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,t=e.locale,i=t.t,o=e.commands.get(this.commandName),s=e.config.get(this.componentName),r=ws(s.colors),a=ps(t,r),l=s.documentColors,c=s.colorPicker!==!1;e.ui.componentFactory.add(this.componentName,u=>{const d=Ee(u);let m=!1;const f=US({dropdownView:d,colors:a.map(g=>({label:g.label,color:g.model,options:{hasBorder:g.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:l!==0?i("Document colors"):"",documentColorsCount:l===void 0?this.columns:l,colorPickerViewConfig:c?s.colorPicker||{}:!1});return f.bind("selectedColor").to(o,"value"),d.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),d.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),d.bind("isEnabled").to(o),f.on("execute",(g,p)=>{d.isOpen&&e.execute(this.commandName,{value:p.value,batch:this._undoStepBatch}),p.source!=="colorPicker"&&e.editing.view.focus(),p.source==="colorPickerSaveButton"&&(d.isOpen=!1)}),f.on("colorPicker:show",()=>{this._undoStepBatch=e.model.createBatch()}),f.on("colorPicker:cancel",()=>{this._undoStepBatch.operations.length&&(d.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()}),d.on("change:isOpen",(g,p,_)=>{m||(m=!0,d.colorSelectorView.appendUI()),_&&(l!==0&&f.updateDocumentColors(e.model,this.componentName),f.updateSelectedColors(),f.showColorGridsFragment())}),ga(d,()=>d.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find(g=>g.isOn)),d}),e.ui.componentFactory.add(`menuBar:${this.componentName}`,u=>{const d=new Tt(u);d.buttonView.set({label:this.dropdownLabel,icon:this.icon}),d.bind("isEnabled").to(o);let m=!1;const f=new wu(u,{colors:a.map(g=>({label:g.label,color:g.model,options:{hasBorder:g.hasBorder}})),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:l!==0?i("Document colors"):"",documentColorsCount:l===void 0?this.columns:l,colorPickerViewConfig:!1});return f.bind("selectedColor").to(o,"value"),f.delegate("execute").to(d),f.on("execute",(g,p)=>{e.execute(this.commandName,{value:p.value,batch:this._undoStepBatch}),e.editing.view.focus()}),d.on("change:isOpen",(g,p,_)=>{m||(m=!0,f.appendUI()),_&&(l!==0&&f.updateDocumentColors(e.model,this.componentName),f.updateSelectedColors(),f.showColorGridsFragment())}),d.panelView.children.add(f),d})}}class mP extends Xb{constructor(e){const t=e.locale.t;super(e,{commandName:ii,componentName:ii,icon:AC,dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class e1 extends w{static get requires(){return[dP,mP]}static get pluginName(){return"FontColor"}static get isOfficialPlugin(){return!0}}class fP extends ba{constructor(e){super(e,vi)}}class gP extends w{static get pluginName(){return"FontBackgroundColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(vi,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(iu),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:vi,value:Jb("background-color")}}),e.conversion.for("downcast").attributeToElement({model:vi,view:Qb("background-color")}),e.commands.add(vi,new fP(e)),e.model.schema.extend("$text",{allowAttributes:vi}),e.model.schema.setAttributeProperties(vi,{isFormatting:!0,copyOnEnter:!0})}}class pP extends Xb{constructor(e){const t=e.locale.t;super(e,{commandName:vi,componentName:vi,icon:CC,dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class t1 extends w{static get requires(){return[gP,pP]}static get pluginName(){return"FontBackgroundColor"}static get isOfficialPlugin(){return!0}}class wP extends w{static get requires(){return[eP,uP,e1,t1]}static get pluginName(){return"Font"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bP extends O{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document,i=ae(t.selection.getSelectedBlocks());this.value=!!i&&i.is("element","paragraph"),this.isEnabled=!!i&&zm(i,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,o=e.selection||i.selection;t.canEditAt(o)&&t.change(s=>{const r=o.getSelectedBlocks();for(const a of r)!a.is("element","paragraph")&&zm(a,t.schema)&&s.rename(a,"paragraph")})}}function zm(n,e){return e.checkChild(n.parent,"paragraph")&&!e.isObject(n)}class _P extends O{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let o=e.position;return t.canEditAt(o)?t.change(s=>{if(o=this._findPositionToInsertParagraph(o,s),!o)return null;const r=s.createElement("paragraph");return i&&t.schema.setAllowedAttributes(r,i,s),t.insertContent(r,o),s.setSelection(r,"in"),s.createPositionAt(r,0)}):null}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const o=i.schema.findAllowedParent(e,"paragraph");if(!o)return null;const s=e.parent,r=i.schema.checkChild(s,"$text");return s.isEmpty||r&&e.isAtEnd?i.createPositionAfter(s):!s.isEmpty&&r&&e.isAtStart?i.createPositionBefore(s):t.split(e,o).position}}const i1=class n1 extends w{static get pluginName(){return"Paragraph"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new bP(e)),e.commands.add("insertParagraph",new _P(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(i,{writer:o})=>!n1.paragraphLikeElements.has(i.name)||i.isEmpty?null:o.createElement("paragraph"),view:/.+/,converterPriority:"low"})}};h(i1,"paragraphLikeElements",new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]));let Su=i1;class vP extends w{static get requires(){return[Su]}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("paragraph",i=>{const o=new P(i),s=e.commands.get("paragraph");return o.label=t("Paragraph"),o.icon=yw,o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(s),o.bind("isOn").to(s,"value"),o.on("execute",()=>{e.execute("paragraph")}),o})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class yP extends O{constructor(e,t){super(e),h(this,"modelElements"),this.modelElements=t}refresh(){const e=ae(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some(t=>Hm(e,t,this.editor.model.schema))}execute(e){const t=this.editor.model,i=t.document,o=e.value;t.change(s=>{const r=Array.from(i.selection.getSelectedBlocks()).filter(a=>Hm(a,o,t.schema));for(const a of r)a.is("element",o)||s.rename(a,o)})}}function Hm(n,e,t){return t.checkChild(n.parent,e)&&!t.isObject(n)}const $m="paragraph";class kP extends w{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[Su]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const o of t)o.model!=="paragraph"&&(e.model.schema.register(o.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(o),i.push(o.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new yP(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",(o,s)=>{const r=e.model.document.selection.getFirstPosition().parent;i.some(a=>r.is("element",a.model))&&!r.is("element",$m)&&r.childCount===0&&s.writer.rename(r,$m)})}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:kt.low+1})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function o1(n){const e=n.t,t={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return n.config.get("heading.options").map(i=>{const o=t[i.title];return o&&o!=i.title&&(i.title=o),i})}class CP extends w{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=o1(e),o=t("Choose heading"),s=t("Heading");e.ui.componentFactory.add("heading",r=>{const a={},l=new _e,c=e.commands.get("heading"),u=e.commands.get("paragraph"),d=[c];for(const f of i){const g={type:"button",model:new et({label:f.title,class:f.class,role:"menuitemradio",withText:!0})};f.model==="paragraph"?(g.model.bind("isOn").to(u,"value"),g.model.set("commandName","paragraph"),d.push(u)):(g.model.bind("isOn").to(c,"value",p=>p===f.model),g.model.set({commandName:"heading",commandValue:f.model})),l.add(g),a[f.model]=f.title}const m=Ee(r);return wt(m,l,{ariaLabel:s,role:"menu"}),m.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),m.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),m.bind("isEnabled").toMany(d,"isEnabled",(...f)=>f.some(g=>g)),m.buttonView.bind("label").to(c,"value",u,"value",(f,g)=>{const p=g?"paragraph":f;return typeof p=="boolean"||!a[p]?o:a[p]}),m.buttonView.bind("ariaLabel").to(c,"value",u,"value",(f,g)=>{const p=g?"paragraph":f;return typeof p=="boolean"||!a[p]?s:`${a[p]}, ${s}`}),this.listenTo(m,"execute",f=>{const{commandName:g,commandValue:p}=f.source;e.execute(g,p?{value:p}:void 0),e.editing.view.focus()}),m}),e.ui.componentFactory.add("menuBar:heading",r=>{const a=new Tt(r),l=e.commands.get("heading"),c=e.commands.get("paragraph"),u=[l],d=new Si(r);a.set({class:"ck-heading-dropdown"}),d.set({ariaLabel:t("Heading"),role:"menu"}),a.buttonView.set({label:t("Heading")}),a.panelView.children.add(d);for(const m of i){const f=new Oi(r,a),g=new ve(r);f.children.add(g),d.items.add(f),g.set({isToggleable:!0,label:m.title,role:"menuitemradio",class:m.class}),g.delegate("execute").to(a),g.on("execute",()=>{const p=m.model==="paragraph"?"paragraph":"heading";e.execute(p,{value:m.model}),e.editing.view.focus()}),m.model==="paragraph"?(g.bind("isOn").to(c,"value"),u.push(c)):g.bind("isOn").to(l,"value",p=>p===m.model)}return a.bind("isEnabled").toMany(u,"isEnabled",(...m)=>m.some(f=>f)),a})}}class AP extends w{static get requires(){return[kP,CP]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}}const xP={heading1:xC,heading2:TC,heading3:EC,heading4:SC,heading5:PC,heading6:IC};class TP extends w{init(){o1(this.editor).filter(e=>e.model!=="paragraph").map(e=>this._createButton(e))}_createButton(e){const t=this.editor;t.ui.componentFactory.add(e.model,i=>{const o=new P(i),s=t.commands.get("heading");return o.label=e.title,o.icon=e.icon||xP[e.model],o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(s),o.bind("isOn").to(s,"value",r=>r==e.model),o.on("execute",()=>{t.execute("heading",{value:e.model}),t.editing.view.focus()}),o})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class EP extends O{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=SP(i,t,e)}execute(){const e=this.editor.model;e.change(t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})})}}function SP(n,e,t){const i=PP(n,t);return e.checkChild(i,"horizontalLine")}function PP(n,e){const t=ku(n,e).start.parent;return t.isEmpty&&!t.is("element","$root")?t.parent:t}class IP extends w{static get pluginName(){return"HorizontalLineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,o=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),o.for("dataDowncast").elementToElement({model:"horizontalLine",view:(s,{writer:r})=>r.createEmptyElement("hr")}),o.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(s,{writer:r})=>{const a=i("Horizontal line"),l=r.createContainerElement("div",null,r.createEmptyElement("hr"));return r.addClass("ck-horizontal-line",l),r.setCustomProperty("hr",!0,l),VP(l,r,a)}}),o.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new EP(e))}}function VP(n,e,t){return e.setCustomProperty("horizontalLine",!0,n),gt(n,e,{label:t})}class RP extends w{static get pluginName(){return"HorizontalLineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("horizontalLine",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:horizontalLine",()=>this._createButton(ve))}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("horizontalLine"),s=new e(t.locale),r=i.t;return s.set({label:r("Horizontal line"),icon:VC}),s.bind("isEnabled").to(o,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("horizontalLine"),t.editing.view.focus()}),s}}class OP extends w{static get requires(){return[IP,RP,Vt]}static get pluginName(){return"HorizontalLine"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function oi(n,e,t,i){e&&BP(n,e,i),t&&si(n,t,i)}function si(n,e,t){if(e.attributes)for(const[i,o]of Object.entries(e.attributes))n.setAttribute(i,o,t);e.styles&&n.setStyle(e.styles,t),e.classes&&n.addClass(e.classes,t)}function BP(n,e,t){if(e.attributes)for(const[i]of Object.entries(e.attributes))n.removeAttribute(i,t);if(e.styles)for(const i of Object.keys(e.styles))n.removeStyle(i,t);e.classes&&n.removeClass(e.classes,t)}function MP(n,e){const t=mt(n);let i="attributes";for(i in e)i=="classes"?t[i]=Array.from(new Set([...n[i]||[],...e[i]])):t[i]={...n[i],...e[i]};return t}function jn(n,e,t,i,o){const s=e.getAttribute(t),r={};for(const a of["attributes","styles","classes"]){if(a!=i){s&&s[a]&&(r[a]=s[a]);continue}if(i=="classes"){const c=new Set(s&&s.classes||[]);o(c),c.size&&(r[a]=Array.from(c));continue}const l=new Map(Object.entries(s&&s[a]||{}));o(l),l.size&&(r[a]=Object.fromEntries(l))}Object.keys(r).length?e.is("documentSelection")?n.setSelectionAttribute(t,r):n.setAttribute(t,r,e):s&&(e.is("documentSelection")?n.removeSelectionAttribute(t):n.removeAttribute(t,e))}function LP(n){return A_(n).replace(/ /g,"")}function Ft(n){return`html${LP(n)}Attributes`}function Pu({model:n}){return(e,t)=>t.writer.createElement(n,{htmlContent:e.getCustomProperty("$rawContent")})}function FP(n,{view:e,isInline:t}){const i=n.t;return(o,{writer:s})=>{const r=i("HTML object"),a=_a(e,o,s),l=o.getAttribute(Ft(e));s.addClass("html-object-embed__content",a),l&&si(s,l,a);const c=s.createContainerElement(t?"span":"div",{class:"html-object-embed","data-html-object-embed-label":r},a);return gt(c,s,{label:r})}}function _a(n,e,t){return t.createRawElement(n,null,(i,o)=>{o.setContentOf(i,e.getAttribute("htmlContent"))})}function NP({view:n,model:e,allowEmpty:t},i){return s=>{s.on(`element:${n}`,(r,a,l)=>{let c=i.processViewAttributes(a.viewItem,l);if(!(!c&&!l.consumable.test(a.viewItem,{name:!0}))){if(c=c||{},l.consumable.consume(a.viewItem,{name:!0}),a.modelRange||(a=Object.assign(a,l.convertChildren(a.viewItem,a.modelCursor))),t&&a.modelRange.isCollapsed&&Object.keys(c).length){const u=l.writer.createElement("htmlEmptyElement");if(!l.safeInsert(u,a.modelCursor))return;const d=l.getSplitParts(u);a.modelRange=l.writer.createRange(a.modelRange.start,l.writer.createPositionAfter(d[d.length-1])),l.updateConversionResult(u,a),o(u,c,l);return}for(const u of a.modelRange.getItems())o(u,c,l)}},{priority:"low"})};function o(s,r,a){if(a.schema.checkAttribute(s,e)){const l=s.getAttribute(e),c=MP(r,l||{});a.writer.setAttribute(e,c,s)}}}function Wm({model:n,view:e},t){return(i,{writer:o,consumable:s})=>{if(!i.hasAttribute(n))return null;const r=o.createContainerElement(e),a=i.getAttribute(n);return s.consume(i,`attribute:${n}`),si(o,a,r),r.getFillerOffset=()=>null,t?gt(r,o):r}}function DP({priority:n,view:e}){return(t,i)=>{if(!t)return;const{writer:o}=i,s=o.createAttributeElement(e,null,{priority:n});return si(o,t,s),s}}function mo({view:n},e){return t=>{t.on(`element:${n}`,(i,o,s)=>{if(!o.modelRange||o.modelRange.isCollapsed)return;const r=e.processViewAttributes(o.viewItem,s);r&&s.writer.setAttribute(Ft(o.viewItem.name),r,o.modelRange)},{priority:"low"})}}function vs({view:n,model:e}){return t=>{t.on(`attribute:${Ft(n)}:${e}`,(i,o,s)=>{if(!s.consumable.consume(o.item,i.name))return;const{attributeOldValue:r,attributeNewValue:a}=o,l=s.writer,c=s.mapper.toViewElement(o.item);oi(l,r,a,c)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/var jm={block:[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"horizontalLine",view:"hr"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6","$text"],allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowIn:["$root","$container"],allowChildren:["paragraph","htmlP","htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDivDl",view:"div",modelSchema:{allowChildren:["htmlDt","htmlDd"],allowIn:"htmlDl"}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDivDl"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlHr",view:"hr",isEmpty:!0,modelSchema:{inheritAllFrom:"$blockObject"}}],inline:[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref"},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}]};class fo extends w{constructor(){super(...arguments),h(this,"_definitions",[])}static get pluginName(){return"DataSchema"}static get isOfficialPlugin(){return!0}init(){for(const e of jm.block)this.registerBlockElement(e);for(const e of jm.inline)this.registerInlineElement(e)}registerBlockElement(e){this._definitions.push({...e,isBlock:!0})}registerInlineElement(e){this._definitions.push({...e,isInline:!0})}extendBlockElement(e){this._extendDefinition({...e,isBlock:!0})}extendInlineElement(e){this._extendDefinition({...e,isInline:!0})}getDefinitionsForView(e,t=!1){const i=new Set;for(const o of this._getMatchingViewDefinitions(e)){if(t)for(const s of this._getReferences(o.model))i.add(s);i.add(o)}return i}getDefinitionsForModel(e){return this._definitions.filter(t=>t.model==e)}_getMatchingViewDefinitions(e){return this._definitions.filter(t=>t.view&&zP(e,t.view))}*_getReferences(e){const t=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter(o=>o.model==e);for(const{modelSchema:o}of i)if(o)for(const s of t)for(const r of he(o[s]||[])){const a=this._definitions.filter(l=>l.model==r);for(const l of a)r!==e&&(yield*this._getReferences(l.model),yield l)}}_extendDefinition(e){const t=Array.from(this._definitions.entries()).filter(([,i])=>i.model==e.model);if(t.length==0){this._definitions.push(e);return}for(const[i,o]of t)this._definitions[i]=Og({},o,e,(s,r)=>Array.isArray(s)?s.concat(r):void 0)}}function zP(n,e){return typeof n=="string"?n===e:n instanceof RegExp?n.test(e):!1}class Pe extends w{constructor(e){super(e),h(this,"_dataSchema"),h(this,"_allowedAttributes"),h(this,"_disallowedAttributes"),h(this,"_allowedElements"),h(this,"_disallowedElements"),h(this,"_dataInitialized"),h(this,"_coupledAttributes"),this._dataSchema=e.plugins.get("DataSchema"),this._allowedAttributes=new ft,this._disallowedAttributes=new ft,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}static get pluginName(){return"DataFilter"}static get isOfficialPlugin(){return!0}static get requires(){return[fo,Vt]}loadAllowedConfig(e){for(const t of e){const i=t.name||/[\s\S]+/,o=qm(t);this.allowElement(i),o.forEach(s=>this.allowAttributes(s))}}loadDisallowedConfig(e){for(const t of e){const i=t.name||/[\s\S]+/,o=qm(t);o.length==0?this.disallowElement(i):o.forEach(s=>this.disallowAttributes(s))}}loadAllowedEmptyElementsConfig(e){for(const t of e)this.allowEmptyElement(t)}allowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))this._addAllowedElement(t),this._coupledAttributes=null}disallowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!1))this._disallowedElements.add(t.view)}allowEmptyElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))t.isInline&&this._dataSchema.extendInlineElement({...t,allowEmpty:!0})}allowAttributes(e){this._allowedAttributes.add(e)}disallowAttributes(e){this._disallowedAttributes.add(e)}processViewAttributes(e,t){const{consumable:i}=t;return Um(e,this._disallowedAttributes,i),HP(e,Um(e,this._allowedAttributes,i))}_addAllowedElement(e){if(!this._allowedElements.has(e)){if(this._allowedElements.add(e),"appliesToBlock"in e&&typeof e.appliesToBlock=="string")for(const t of this._dataSchema.getDefinitionsForModel(e.appliesToBlock))t.isBlock&&this._addAllowedElement(t);this._dataInitialized&&this.editor.data.once("set",()=>{this._fireRegisterEvent(e)},{priority:kt.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",()=>{this._dataInitialized=!0;for(const e of this._allowedElements)this._fireRegisterEvent(e)},{priority:kt.highest+1})}_registerElementHandlers(){this.on("register",(e,t)=>{const i=this.editor.model.schema;if(t.isObject&&!i.isRegistered(t.model))this._registerObjectElement(t);else if(t.isBlock)this._registerBlockElement(t);else if(t.isInline)this._registerInlineElement(t);else throw new b("data-filter-invalid-definition",null,t);e.stop()},{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const e=this.editor.model,t=e.document.selection;e.document.registerPostFixer(i=>{const o=e.document.differ.getChanges();let s=!1;const r=this._getCoupledAttributesMap();for(const a of o){if(a.type!="attribute"||a.attributeNewValue!==null)continue;const l=r.get(a.attributeKey);if(l)for(const{item:c}of a.range.getWalker())for(const u of l)c.hasAttribute(u)&&(i.removeAttribute(u,c),s=!0)}return s}),this.listenTo(t,"change:attribute",(i,{attributeKeys:o})=>{const s=new Set,r=this._getCoupledAttributesMap();for(const a of o){if(t.hasAttribute(a))continue;const l=r.get(a);if(l)for(const c of l)t.hasAttribute(c)&&s.add(c)}s.size!=0&&e.change(a=>{for(const l of s)a.removeSelectionAttribute(l)})})}_registerAssociatedHtmlAttributesPostFixer(){const e=this.editor.model;e.document.registerPostFixer(t=>{const i=e.document.differ.getChanges();let o=!1;for(const s of i)if(!(s.type!=="insert"||s.name==="$text"))for(const r of s.attributes.keys())!r.startsWith("html")||!r.endsWith("Attributes")||e.schema.checkAttribute(s.name,r)||(t.removeAttribute(r,s.position.nodeAfter),o=!0);return o})}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const e of this._allowedElements)if(e.coupledAttribute&&e.model){const t=this._coupledAttributes.get(e.coupledAttribute);t?t.push(e.model):this._coupledAttributes.set(e.coupledAttribute,[e.model])}return this._coupledAttributes}_fireRegisterEvent(e){e.view&&this._disallowedElements.has(e.view)||this.fire(e.view?`register:${e.view}`:"register",e)}_registerObjectElement(e){const t=this.editor,i=t.model.schema,o=t.conversion,{view:s,model:r}=e;i.register(r,e.modelSchema);/* istanbul ignore next: paranoid check -- @preserve */s&&(i.extend(e.model,{allowAttributes:[Ft(s),"htmlContent"]}),t.data.registerRawContentMatcher({name:s}),o.for("upcast").elementToElement({view:s,model:Pu(e),converterPriority:kt.low+2}),o.for("upcast").add(mo(e,this)),o.for("editingDowncast").elementToStructure({model:{name:r,attributes:[Ft(s)]},view:FP(t,e)}),o.for("dataDowncast").elementToElement({model:r,view:(a,{writer:l})=>_a(s,a,l)}),o.for("dataDowncast").add(vs(e)))}_registerBlockElement(e){const t=this.editor,i=t.model.schema,o=t.conversion,{view:s,model:r}=e;if(!i.isRegistered(e.model)){if(!e.modelSchema||(i.register(e.model,e.modelSchema),!s))return;o.for("upcast").elementToElement({model:r,view:s,converterPriority:kt.low+2}),o.for("downcast").elementToElement({model:r,view:(a,{writer:l})=>e.isEmpty?l.createEmptyElement(s):l.createContainerElement(s)})}s&&(i.extend(e.model,{allowAttributes:Ft(s)}),o.for("upcast").add(mo(e,this)),o.for("downcast").add(vs(e)))}_registerInlineElement(e){const t=this.editor,i=t.model.schema,o=t.conversion,s=e.model;if(!e.appliesToBlock&&(i.extend("$text",{allowAttributes:s}),e.attributeProperties&&i.setAttributeProperties(s,e.attributeProperties),o.for("upcast").add(NP(e,this)),o.for("downcast").attributeToElement({model:s,view:DP(e)}),!!e.allowEmpty)){if(i.setAttributeProperties(s,{copyFromObject:!1}),!i.isRegistered("htmlEmptyElement")){i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"});const r=a=>Array.from(a.getAttributeKeys()).some(l=>l.startsWith("html"));t.model.document.registerPostFixer(a=>{const l=t.model.document.differ.getChanges(),c=new Set;for(const u of l)if(u.type!=="remove"){if(u.type==="attribute"&&u.attributeNewValue===null)for(const{item:d}of u.range)d.is("element","htmlEmptyElement")&&!r(d)&&c.add(d);if(u.type==="insert"&&u.position.nodeAfter){const d=u.position.nodeAfter;for(const{item:m}of a.createRangeOn(d))m.is("element","htmlEmptyElement")&&!r(m)&&c.add(m)}}for(const u of c)a.remove(u);return c.size>0})}t.data.htmlProcessor.domConverter.registerInlineObjectMatcher(r=>r.name==e.view&&r.isEmpty&&Array.from(r.getAttributeKeys()).length?{name:!0}:null),o.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:Wm(e,!0)}),o.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:Wm(e)})}}}function Um(n,e,t){const i=e.matchAll(n)||[],o=n.document.stylesProcessor;return i.reduce((s,{match:r})=>{for(const[a,l]of r.attributes||[])if(a=="style"){const c=l,u=o.getRelatedStyles(c).filter(d=>d.split("-").length>c.split("-").length).sort((d,m)=>m.split("-").length-d.split("-").length);for(const d of u)t.consume(n,{styles:[d]})&&s.styles.push(d);t.consume(n,{styles:[c]})&&s.styles.push(c)}else if(a=="class"){const c=l;t.consume(n,{classes:[c]})&&s.classes.push(c)}else t.consume(n,{attributes:[a]})&&s.attributes.push(a);return s},{attributes:[],classes:[],styles:[]})}function HP(n,{attributes:e,classes:t,styles:i}){return!e.length&&!t.length&&!i.length?null:{...e.length&&{attributes:$P(n,e)},...i.length&&{styles:WP(n,i)},...t.length&&{classes:t}}}function $P(n,e){const t={};for(const i of e){const o=n.getAttribute(i);o!==void 0&&tp(i)&&(t[i]=o)}return t}function WP(n,e){const t=new so(n.document.stylesProcessor);for(const i of e){const o=n.getStyle(i);o!==void 0&&t.set(i,o)}return Object.fromEntries(t.getStylesEntries())}function pl(n,e){const{name:t}=n,i=n[e];return Ut(i)?Object.entries(i).map(([o,s])=>({name:t,[e]:{[o]:s}})):Array.isArray(i)?i.map(o=>({name:t,[e]:[o]})):[n]}function qm(n){const{name:e,attributes:t,classes:i,styles:o}=n,s=[];return t&&s.push(...pl({name:e,attributes:t},"attributes")),i&&s.push(...pl({name:e,classes:i},"classes")),o&&s.push(...pl({name:e,styles:o},"styles")),s}class jP extends w{static get requires(){return[Pe]}static get pluginName(){return"CodeBlockElementSupport"}static get isOfficialPlugin(){return!0}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const e=this.editor.plugins.get(Pe);e.on("register:pre",(t,i)=>{if(i.model!=="codeBlock")return;const o=this.editor,s=o.model.schema,r=o.conversion;s.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),r.for("upcast").add(UP(e)),r.for("downcast").add(qP()),t.stop()})}}function UP(n){return e=>{e.on("element:code",(t,i,o)=>{const s=i.viewItem,r=s.parent;if(!r||!r.is("element","pre"))return;a(r,"htmlPreAttributes"),a(s,"htmlContentAttributes");function a(l,c){const u=n.processViewAttributes(l,o);u&&o.writer.setAttribute(c,u,i.modelRange)}},{priority:"low"})}}function qP(){return n=>{n.on("attribute:htmlPreAttributes:codeBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=t,r=i.mapper.toViewElement(t.item).parent;oi(i.writer,o,s,r)}),n.on("attribute:htmlContentAttributes:codeBlock",(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=t,r=i.mapper.toViewElement(t.item);oi(i.writer,o,s,r)})}}class GP extends w{static get requires(){return[Pe]}static get pluginName(){return"DualContentModelElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.plugins.get(Pe).on("register",(e,t)=>{const i=t,o=this.editor,s=o.model.schema,r=o.conversion;if(!i.paragraphLikeModel||s.isRegistered(i.model)||s.isRegistered(i.paragraphLikeModel))return;const a={model:i.paragraphLikeModel,view:i.view};s.register(i.model,i.modelSchema),s.register(a.model,{inheritAllFrom:"$block"}),r.for("upcast").elementToElement({view:i.view,model:(l,{writer:c})=>this._hasBlockContent(l)?c.createElement(i.model):c.createElement(a.model),converterPriority:kt.low+.5}),r.for("downcast").elementToElement({view:i.view,model:i.model}),this._addAttributeConversion(i),r.for("downcast").elementToElement({view:a.view,model:a.model}),this._addAttributeConversion(a),e.stop()})}_hasBlockContent(e){const t=this.editor.editing.view,i=t.domConverter.blockElements;for(const o of t.createRangeIn(e).getItems())if(o.is("element")&&i.includes(o.name))return!0;return!1}_addAttributeConversion(e){const t=this.editor,i=t.conversion,o=t.plugins.get(Pe);t.model.schema.extend(e.model,{allowAttributes:Ft(e.view)}),i.for("upcast").add(mo(e,o)),i.for("downcast").add(vs(e))}}class KP extends w{static get requires(){return[fo,Ao]}static get pluginName(){return"HeadingElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("HeadingEditing"))return;const t=e.config.get("heading.options");this.registerHeadingElements(e,t)}registerHeadingElements(e,t){const i=e.plugins.get(fo),o=[];for(const s of t)"model"in s&&"view"in s&&(i.registerBlockElement({view:s.view,model:s.model}),o.push(s.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:o}}),i.extendBlockElement({model:"htmlSummary",modelSchema:{allowChildren:o}})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ys(n,e,t){const i=n.createRangeOn(e);for(const{item:o}of i.getWalker())if(o.is("element",t))return o}class ZP extends w{static get requires(){return[Pe]}static get pluginName(){return"ImageElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("ImageInlineEditing")&&!e.plugins.has("ImageBlockEditing"))return;const t=e.model.schema,i=e.conversion,o=e.plugins.get(Pe);o.on("register:figure",()=>{i.for("upcast").add(YP(o))}),o.on("register:img",(s,r)=>{r.model!=="imageBlock"&&r.model!=="imageInline"||(t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(JP(o)),i.for("downcast").add(XP()),e.plugins.has("LinkImage")&&i.for("upcast").add(QP(o,e)),s.stop())})}}function JP(n){return e=>{e.on("element:img",(t,i,o)=>{if(!i.modelRange)return;const s=i.viewItem,r=n.processViewAttributes(s,o);r&&o.writer.setAttribute("htmlImgAttributes",r,i.modelRange)},{priority:"low"})}}function QP(n,e){const t=e.plugins.get("ImageUtils");return i=>{i.on("element:a",(o,s,r)=>{const a=s.viewItem;if(!t.findViewImgElement(a))return;const l=s.modelCursor.parent;if(!l.is("element","imageBlock"))return;const c=n.processViewAttributes(a,r);c&&r.writer.setAttribute("htmlLinkAttributes",c,l)},{priority:"low"})}}function YP(n){return e=>{e.on("element:figure",(t,i,o)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("image"))return;const r=n.processViewAttributes(s,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,i.modelRange)},{priority:"low"})}}function XP(){return n=>{e("htmlImgAttributes"),t("img","htmlImgAttributes"),t("figure","htmlFigureAttributes"),t("a","htmlLinkAttributes");function e(i){n.on(`attribute:${i}:imageInline`,(o,s,r)=>{if(!r.consumable.consume(s.item,o.name))return;const{attributeOldValue:a,attributeNewValue:l}=s,c=r.mapper.toViewElement(s.item);oi(r.writer,a,l,c)},{priority:"low"})}function t(i,o){n.on(`attribute:${o}:imageBlock`,(s,r,a)=>{if(!a.consumable.test(r.item,s.name))return;const{attributeOldValue:l,attributeNewValue:c}=r,u=a.mapper.toViewElement(r.item),d=ys(a.writer,u,i);d&&(oi(a.writer,l,c,d),a.consumable.consume(r.item,s.name))},{priority:"low"}),i==="a"&&n.on("attribute:linkHref:imageBlock",(s,r,a)=>{if(!a.consumable.consume(r.item,"attribute:htmlLinkAttributes:imageBlock"))return;const l=a.mapper.toViewElement(r.item),c=ys(a.writer,l,"a");si(a.writer,r.item.getAttribute("htmlLinkAttributes"),c)},{priority:"low"})}}}class e4 extends w{static get requires(){return[Pe]}static get pluginName(){return"MediaEmbedElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("MediaEmbed")||e.config.get("mediaEmbed.previewsInData"))return;const t=e.model.schema,i=e.conversion,o=this.editor.plugins.get(Pe),s=this.editor.plugins.get(fo),r=e.config.get("mediaEmbed.elementName");s.registerBlockElement({model:"media",view:r}),o.on("register:figure",()=>{i.for("upcast").add(i4(o))}),o.on(`register:${r}`,(a,l)=>{l.model==="media"&&(t.extend("media",{allowAttributes:[Ft(r),"htmlFigureAttributes"]}),i.for("upcast").add(t4(o,r)),i.for("dataDowncast").add(n4(r)),a.stop())})}}function t4(n,e){const t=(i,o,s)=>{const r=o.viewItem;a(r,Ft(e));function a(l,c){const u=n.processViewAttributes(l,s);u&&s.writer.setAttribute(c,u,o.modelRange)}};return i=>{i.on(`element:${e}`,t,{priority:"low"})}}function i4(n){return e=>{e.on("element:figure",(t,i,o)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("media"))return;const r=n.processViewAttributes(s,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,i.modelRange)},{priority:"low"})}}function n4(n){return e=>{t(n,Ft(n)),t("figure","htmlFigureAttributes");function t(i,o){e.on(`attribute:${o}:media`,(s,r,a)=>{if(!a.consumable.consume(r.item,s.name))return;const{attributeOldValue:l,attributeNewValue:c}=r,u=a.mapper.toViewElement(r.item),d=ys(a.writer,u,i);oi(a.writer,l,c,d)})}}}class o4 extends w{static get requires(){return[Pe]}static get pluginName(){return"ScriptElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(Pe);e.on("register:script",(t,i)=>{const o=this.editor,s=o.model.schema,r=o.conversion;s.register("htmlScript",i.modelSchema),s.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),o.data.registerRawContentMatcher({name:"script"}),r.for("upcast").elementToElement({view:"script",model:Pu(i)}),r.for("upcast").add(mo(i,e)),r.for("downcast").elementToElement({model:"htmlScript",view:(a,{writer:l})=>_a("script",a,l)}),r.for("downcast").add(vs(i)),t.stop()})}}const s4=["width","max-width","min-width","height","min-height","max-height"];class r4 extends w{static get requires(){return[Pe]}static get pluginName(){return"TableElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("TableEditing"))return;const t=e.model.schema,i=e.conversion,o=e.plugins.get(Pe),s=e.plugins.get("TableUtils");o.on("register:figure",()=>{i.for("upcast").add(c4(o))}),o.on("register:table",(r,a)=>{a.model==="table"&&(t.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),i.for("upcast").add(l4(o)),i.for("downcast").add(u4()),e.model.document.registerPostFixer(a4(e.model,s)),r.stop())})}}function a4(n,e){return t=>{const i=n.document.differ.getChanges();let o=!1;for(const s of i){if(s.type!="attribute"||s.attributeKey!="headingRows")continue;const r=s.range.start.nodeAfter,a=r.getAttribute("htmlTheadAttributes"),l=r.getAttribute("htmlTbodyAttributes");a&&!s.attributeNewValue?(t.removeAttribute("htmlTheadAttributes",r),o=!0):l&&s.attributeNewValue==e.getRows(r)&&(t.removeAttribute("htmlTbodyAttributes",r),o=!0)}return o}}function l4(n){return e=>{e.on("element:table",(t,i,o)=>{if(!i.modelRange)return;const s=i.viewItem;r(s,"htmlTableAttributes");for(const a of s.getChildren())a.is("element","thead")&&r(a,"htmlTheadAttributes"),a.is("element","tbody")&&r(a,"htmlTbodyAttributes");function r(a,l){const c=n.processViewAttributes(a,o);c&&o.writer.setAttribute(l,c,i.modelRange)}},{priority:"low"})}}function c4(n){return e=>{e.on("element:figure",(t,i,o)=>{const s=i.viewItem;if(!i.modelRange||!s.hasClass("table"))return;const r=n.processViewAttributes(s,o);r&&o.writer.setAttribute("htmlFigureAttributes",r,i.modelRange)},{priority:"low"})}}function u4(){return n=>{e("table","htmlTableAttributes"),e("figure","htmlFigureAttributes"),e("thead","htmlTheadAttributes"),e("tbody","htmlTbodyAttributes");function e(t,i){n.on(`attribute:${i}:table`,(o,s,r)=>{if(!r.consumable.test(s.item,o.name))return;const a=r.mapper.toViewElement(s.item),l=ys(r.writer,a,t);if(l)if(r.consumable.consume(s.item,o.name),i==="htmlTableAttributes"&&a!==l){const c=Gm(s.attributeOldValue),u=Gm(s.attributeNewValue);oi(r.writer,c.tableAttributes,u.tableAttributes,l),oi(r.writer,c.figureAttributes,u.figureAttributes,a)}else oi(r.writer,s.attributeOldValue,s.attributeNewValue,l)})}}}function Gm(n){const e={},t={...n};if(!n||!("styles"in n))return{figureAttributes:e,tableAttributes:t};t.styles={};for(const[i,o]of Object.entries(n.styles))s4.includes(i)?e.styles={...e.styles,[i]:o}:t.styles={...t.styles,[i]:o};return{figureAttributes:e,tableAttributes:t}}class h4 extends w{static get requires(){return[Pe]}static get pluginName(){return"StyleElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(Pe);e.on("register:style",(t,i)=>{const o=this.editor,s=o.model.schema,r=o.conversion;s.register("htmlStyle",i.modelSchema),s.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),o.data.registerRawContentMatcher({name:"style"}),r.for("upcast").elementToElement({view:"style",model:Pu(i)}),r.for("upcast").add(mo(i,e)),r.for("downcast").elementToElement({model:"htmlStyle",view:(a,{writer:l})=>_a("style",a,l)}),r.for("downcast").add(vs(i)),t.stop()})}}class d4 extends w{static get requires(){return[Pe]}static get pluginName(){return"ListElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("ListEditing"))return;const t=e.model.schema,i=e.conversion,o=e.plugins.get(Pe),s=e.plugins.get("ListEditing"),r=e.plugins.get("ListUtils"),a=["ul","ol","li"];s.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:si}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:si}),s.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:si}),o.on("register",(l,c)=>{if(!a.includes(c.view)||(l.stop(),t.checkAttribute("$block","htmlLiAttributes")))return;const u=a.map(d=>Ft(d));t.extend("$listItem",{allowAttributes:u}),i.for("upcast").add(d=>{d.on("element:ul",wl("htmlUlAttributes",o),{priority:"low"}),d.on("element:ol",wl("htmlOlAttributes",o),{priority:"low"}),d.on("element:li",wl("htmlLiAttributes",o),{priority:"low"})})}),s.on("postFixer",(l,{listNodes:c,writer:u})=>{for(const{node:d,previousNodeInList:m}of c)if(m){if(m.getAttribute("listType")==d.getAttribute("listType")){const f=Km(m.getAttribute("listType")),g=m.getAttribute(f);!lo(d.getAttribute(f),g)&&u.model.schema.checkAttribute(d,f)&&(u.setAttribute(f,g,d),l.return=!0)}if(m.getAttribute("listItemId")==d.getAttribute("listItemId")){const f=m.getAttribute("htmlLiAttributes");!lo(d.getAttribute("htmlLiAttributes"),f)&&u.model.schema.checkAttribute(d,"htmlLiAttributes")&&(u.setAttribute("htmlLiAttributes",f,d),l.return=!0)}}}),s.on("postFixer",(l,{listNodes:c,writer:u})=>{for(const{node:d}of c){const m=d.getAttribute("listType");!r.isNumberedListType(m)&&d.getAttribute("htmlOlAttributes")&&(u.removeAttribute("htmlOlAttributes",d),l.return=!0),r.isNumberedListType(m)&&d.getAttribute("htmlUlAttributes")&&(u.removeAttribute("htmlUlAttributes",d),l.return=!0)}})}afterInit(){const e=this.editor;if(!e.commands.get("indentList"))return;const t=e.commands.get("indentList");this.listenTo(t,"afterExecute",(i,o)=>{e.model.change(s=>{for(const r of o){const a=Km(r.getAttribute("listType"));e.model.schema.checkAttribute(r,a)&&s.setAttribute(a,{},r)}})})}}function wl(n,e){return(t,i,o)=>{const s=i.viewItem;i.modelRange||Object.assign(i,o.convertChildren(i.viewItem,i.modelCursor));const r=e.processViewAttributes(s,o);for(const a of i.modelRange.getItems({shallow:!0}))a.hasAttribute("listItemId")&&(a.hasAttribute("htmlUlAttributes")||a.hasAttribute("htmlOlAttributes")||o.writer.model.schema.checkAttribute(a,n)&&o.writer.setAttribute(n,r||{},a))}}function Km(n){return n==="numbered"||n=="customNumbered"?"htmlOlAttributes":"htmlUlAttributes"}class m4 extends w{static get requires(){return[Pe]}static get pluginName(){return"HorizontalLineElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("HorizontalLineEditing"))return;const t=e.model.schema,i=e.conversion,o=e.plugins.get(Pe);o.on("register:hr",(s,r)=>{r.model==="horizontalLine"&&(t.extend("horizontalLine",{allowAttributes:["htmlHrAttributes"]}),i.for("upcast").add(mo(r,o)),i.for("downcast").add(f4()),s.stop())})}}function f4(){return n=>{n.on("attribute:htmlHrAttributes:horizontalLine",(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=t,r=i.mapper.toViewElement(t.item),a=ys(i.writer,r,"hr");a&&(oi(i.writer,o,s,a),i.consumable.consume(t.item,e.name))},{priority:"low"})}}class g4 extends w{static get requires(){return[Pe,fo]}static get pluginName(){return"CustomElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(Pe),t=this.editor.plugins.get(fo);e.on("register:$customElement",(i,o)=>{i.stop();const s=this.editor,r=s.model.schema,a=s.conversion,l=s.editing.view.domConverter.unsafeElements,c=s.data.htmlProcessor.domConverter.preElements;r.register(o.model,o.modelSchema),r.extend(o.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),s.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),a.for("upcast").elementToElement({view:/.*/,model:(u,d)=>{if(u.name=="$comment"||!p4(u.name)||t.getDefinitionsForView(u.name).size)return null;l.includes(u.name)||l.push(u.name),c.includes(u.name)||c.push(u.name);const m=d.writer.createElement(o.model,{htmlElementName:u.name}),f=e.processViewAttributes(u,d);f&&d.writer.setAttribute("htmlCustomElementAttributes",f,m);let g;if(u.is("element","template")&&u.getCustomProperty("$rawContent"))g=u.getCustomProperty("$rawContent");else{const p=new Ht(u.document).createDocumentFragment(u),_=s.data.htmlProcessor.domConverter.viewToDom(p),v=_.firstChild;for(;v.firstChild;)_.appendChild(v.firstChild);v.remove(),g=s.data.htmlProcessor.htmlWriter.getHtml(_)}d.writer.setAttribute("htmlContent",g,m);for(const{item:p}of s.editing.view.createRangeIn(u))d.consumable.consume(p,{name:!0});return m},converterPriority:"low"}),a.for("editingDowncast").elementToElement({model:{name:o.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(u,{writer:d})=>{const m=u.getAttribute("htmlElementName"),f=d.createRawElement(m);return u.hasAttribute("htmlCustomElementAttributes")&&si(d,u.getAttribute("htmlCustomElementAttributes"),f),f}}),a.for("dataDowncast").elementToElement({model:{name:o.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(u,{writer:d})=>{const m=u.getAttribute("htmlElementName"),f=u.getAttribute("htmlContent"),g=d.createRawElement(m,null,(p,_)=>{_.setContentOf(p,f)});return u.hasAttribute("htmlCustomElementAttributes")&&si(d,u.getAttribute("htmlCustomElementAttributes"),g),g}})})}}function p4(n){try{document.createElement(n)}catch{return!1}return!0}class w4 extends w{static get pluginName(){return"GeneralHtmlSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[Pe,jP,GP,KP,ZP,e4,o4,r4,h4,d4,m4,g4]}init(){const e=this.editor,t=e.plugins.get(Pe);t.loadAllowedEmptyElementsConfig(e.config.get("htmlSupport.allowEmpty")||[]),t.loadAllowedConfig(e.config.get("htmlSupport.allow")||[]),t.loadDisallowedConfig(e.config.get("htmlSupport.disallow")||[])}getGhsAttributeNameForElement(e){const t=this.editor.plugins.get("DataSchema"),i=Array.from(t.getDefinitionsForView(e,!1)),o=i.find(s=>s.isInline&&!i[0].isObject);return o?o.model:Ft(e)}addModelHtmlClass(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"classes",l=>{for(const c of he(t))l.add(c)})})}removeModelHtmlClass(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"classes",l=>{for(const c of he(t))l.delete(c)})})}setModelHtmlAttributes(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"attributes",l=>{for(const[c,u]of Object.entries(t))l.set(c,u)})})}removeModelHtmlAttributes(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"attributes",l=>{for(const c of he(t))l.delete(c)})})}setModelHtmlStyles(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"styles",l=>{for(const[c,u]of Object.entries(t))l.set(c,u)})})}removeModelHtmlStyles(e,t,i){const o=this.editor.model,s=this.getGhsAttributeNameForElement(e);o.change(r=>{for(const a of Un(o,i,s))jn(r,a,s,"styles",l=>{for(const c of he(t))l.delete(c)})})}}function*Un(n,e,t){if(e)if(!(Symbol.iterator in e)&&e.is("documentSelection")&&e.isCollapsed)n.schema.checkAttributeInSelection(e,t)&&(yield e);else for(const i of b4(n,e,t))yield*i.getItems({shallow:!0})}function b4(n,e,t){return!(Symbol.iterator in e)&&(e.is("node")||e.is("$text")||e.is("$textProxy"))?n.schema.checkAttribute(e,t)?[n.createRangeOn(e)]:[]:n.schema.getValidRanges(n.createSelection(e).getRanges(),t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function _4(n){return n.createContainerElement("span",{class:"image-inline"},n.createEmptyElement("img"))}function Zm(n){return n.createContainerElement("figure",{class:"image"},[n.createEmptyElement("img"),n.createSlot("children")])}function s1(n,e){const t=n.plugins.get("ImageUtils"),i=n.plugins.has("ImageInlineEditing")&&n.plugins.has("ImageBlockEditing");return s=>t.isInlineImageView(s)?i&&(s.getStyle("display")=="block"||s.findAncestor(t.isBlockImageView)?"imageBlock":"imageInline")!==e?null:o(s):null;function o(s){const r={name:!0};return s.hasAttribute("src")&&(r.attributes=["src"]),r}}function Iu(n,e){const t=ae(e.getSelectedBlocks());return!t||n.isObject(t)||t.isEmpty&&t.name!="listItem"?"imageBlock":"imageInline"}function Wr(n){return n&&n.endsWith("px")?parseInt(n):null}function jr(n){const e=Wr(n.getStyle("width")),t=Wr(n.getStyle("height"));return!!(e&&t)}const v4=/^(image|image-inline)$/;class Ke extends w{constructor(){super(...arguments),h(this,"_domEmitter",new(st()))}static get pluginName(){return"ImageUtils"}static get isOfficialPlugin(){return!0}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null,o={}){const s=this.editor,r=s.model,a=r.document.selection,l=r1(s,t||a,i);e={...Object.fromEntries(a.getAttributes()),...e};for(const c in e)r.schema.checkAttribute(l,c)||delete e[c];return r.change(c=>{const{setImageSizes:u=!0}=o,d=c.createElement(l,e);return r.insertObject(d,t,null,{setSelection:"on",findOptimalPosition:!t&&l!="imageInline"?"auto":void 0}),d.parent?(u&&this.setImageNaturalSizeAttributes(d),d):null})}setImageNaturalSizeAttributes(e){const t=e.getAttribute("src");t&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change(i=>{const o=new I.window.Image;this._domEmitter.listenTo(o,"load",()=>{!e.getAttribute("width")&&!e.getAttribute("height")&&this.editor.model.enqueueChange(i.batch,s=>{s.setAttribute("width",o.naturalWidth,e),s.setAttribute("height",o.naturalHeight,e)}),this._domEmitter.stopListening(o,"load")}),o.src=t}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let o=t.parent;for(;o;){if(o.is("element")&&this.isImageWidget(o))return o;o=o.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:v4})}isImageAllowed(){const e=this.editor.model.document.selection;return y4(this.editor,e)&&k4(e)}toImageWidget(e,t,i){return t.setCustomProperty("image",!0,e),gt(e,t,{label:()=>{const o=this.findViewImgElement(e).getAttribute("alt");return o?`${o} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&Se(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function y4(n,e){if(r1(n,e,null)=="imageBlock"){const t=C4(e,n.model);if(n.model.schema.checkChild(t,"imageBlock"))return!0}else if(n.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}function k4(n){return[...n.focus.getAncestors()].every(e=>!e.is("element","imageBlock"))}function C4(n,e){const t=ku(n,e).start.parent;return t.isEmpty&&!t.is("element","$root")?t.parent:t}function r1(n,e,t){const i=n.model.schema,o=n.config.get("image.insert.type");return n.plugins.has("ImageBlockEditing")?n.plugins.has("ImageInlineEditing")?t||(o==="inline"?"imageInline":o!=="auto"?"imageBlock":e.is("selection")?Iu(i,e):i.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class A4 extends O{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),o=t.model,s=i.getClosestSelectedImageElement(o.document.selection);o.change(r=>{r.setAttribute("alt",e.newValue,s)})}}class x4 extends w{static get requires(){return[Ke]}static get pluginName(){return"ImageTextAlternativeEditing"}static get isOfficialPlugin(){return!0}init(){this.editor.commands.add("imageTextAlternative",new A4(this.editor))}}class T4 extends A{constructor(e){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"labeledInput"),h(this,"backButtonView"),h(this,"saveButtonView"),h(this,"children"),h(this,"_focusables"),h(this,"_focusCycler"),this.focusTracker=new ee,this.keystrokes=new te,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new $e(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new Ie,this.keystrokes.set("Esc",(t,i)=>{this.fire("cancel"),i()}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),[this.backButtonView,this.labeledInput,this.saveButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new P(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Text Alternative")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new Te(this.locale,nt);return t.label=e("Text alternative"),t.class="ck-labeled-field-view_full-width",t}}function E4(n){const e=n.plugins.get("ContextualBalloon");if(n.plugins.get("ImageUtils").getClosestSelectedImageWidget(n.editing.view.document.selection)){const t=Vu(n);e.updatePosition(t)}}function Vu(n){const e=n.editing.view,t=Ne.defaultPositions,i=n.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(i.getClosestSelectedImageWidget(e.document.selection)),positions:[t.northArrowSouth,t.northArrowSouthWest,t.northArrowSouthEast,t.southArrowNorth,t.southArrowNorthWest,t.southArrowNorthEast,t.viewportStickyNorth]}}class S4 extends w{constructor(){super(...arguments),h(this,"_balloon"),h(this,"_form")}static get requires(){return[Ue]}static get pluginName(){return"ImageTextAlternativeUI"}static get isOfficialPlugin(){return!0}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",i=>{const o=e.commands.get("imageTextAlternative"),s=new P(i);return s.set({label:t("Change image text alternative"),icon:bA,tooltip:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",r=>!!r),this.listenTo(s,"execute",()=>{this._showForm()}),s})}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(ho(T4))(e.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),this.listenTo(e.ui,"update",()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&E4(e):this._hideForm(!0)}),$t({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Vu(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class a1 extends w{static get requires(){return[x4,S4]}static get pluginName(){return"ImageTextAlternative"}static get isOfficialPlugin(){return!0}}function P4(n){const e=(t,i,o)=>{if(!o.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const s=n.findViewImgElement(i.viewItem);if(!s||!o.consumable.test(s,{name:!0}))return;o.consumable.consume(i.viewItem,{name:!0,classes:"image"});const r=o.convertItem(s,i.modelCursor),a=ae(r.modelRange.getItems());if(!a){o.consumable.revert(i.viewItem,{name:!0,classes:"image"});return}o.convertChildren(i.viewItem,a),o.updateConversionResult(a,i)};return t=>{t.on("element:figure",e)}}function I4(n){const e=["srcset","media","type","sizes"],t=(i,o,s)=>{const r=o.viewItem;if(!s.consumable.test(r,{name:!0}))return;const a=new Map;for(const u of r.getChildren())if(u.is("element","source")){const d={};for(const m of e)u.hasAttribute(m)&&s.consumable.test(u,{attributes:m})&&(d[m]=u.getAttribute(m));Object.keys(d).length&&a.set(u,d)}const l=n.findViewImgElement(r);if(!l)return;let c=o.modelCursor.parent;if(!c.is("element","imageBlock")){const u=s.convertItem(l,o.modelCursor);o.modelRange=u.modelRange,o.modelCursor=u.modelCursor,c=ae(u.modelRange.getItems())}s.consumable.consume(r,{name:!0});for(const[u,d]of a)s.consumable.consume(u,{attributes:Object.keys(d)});a.size&&s.writer.setAttribute("sources",Array.from(a.values()),c),s.convertChildren(r,c)};return i=>{i.on("element:picture",t)}}function l1(n,e){const t=(i,o,s)=>{if(!s.consumable.consume(o.item,i.name))return;const r=s.writer,a=s.mapper.toViewElement(o.item),l=n.findViewImgElement(a);o.attributeNewValue===null?(r.removeAttribute("srcset",l),r.removeAttribute("sizes",l)):o.attributeNewValue&&(r.setAttribute("srcset",o.attributeNewValue,l),r.setAttribute("sizes","100vw",l))};return i=>{i.on(`attribute:srcset:${e}`,t)}}function V4(n){const e=(t,i,o)=>{if(!o.consumable.consume(i.item,t.name))return;const s=o.writer,r=o.mapper.toViewElement(i.item),a=n.findViewImgElement(r),l=i.attributeNewValue;if(l&&l.length){const c=[];let u=a.parent;for(;u&&u.is("attributeElement");){const f=u.parent;s.unwrap(s.createRangeOn(a),u),c.unshift(u),u=f}const d=a.parent.is("element","picture"),m=d?a.parent:s.createContainerElement("picture",null);d||s.insert(s.createPositionBefore(a),m),s.remove(s.createRangeIn(m)),s.insert(s.createPositionAt(m,"end"),l.map(f=>s.createEmptyElement("source",f))),s.move(s.createRangeOn(a),s.createPositionAt(m,"end"));for(const f of c)s.wrap(s.createRangeOn(m),f)}else if(a.parent.is("element","picture")){const c=a.parent;s.move(s.createRangeOn(a),s.createPositionBefore(c)),s.remove(c)}};return t=>{t.on("attribute:sources:imageBlock",e),t.on("attribute:sources:imageInline",e)}}function Ur(n,e,t){const i=(o,s,r)=>{if(!r.consumable.consume(s.item,o.name))return;const a=r.writer,l=r.mapper.toViewElement(s.item),c=n.findViewImgElement(l);a.setAttribute(s.attributeKey,s.attributeNewValue||"",c)};return o=>{o.on(`attribute:${t}:${e}`,i)}}class Ru extends Zt{observe(e){this.listenTo(e,"load",(t,i)=>{const o=i.target;this.checkShouldIgnoreEventFromTarget(o)||o.tagName=="IMG"&&this._fireEvents(i)},{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class R4 extends O{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||t==="block"&&J("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||t==="inline"&&J("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=he(e.source),i=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((r,a)=>{const l=i.getSelectedElement();if(typeof r=="string"&&(r={src:r}),a&&l&&o.isImage(l)){const c=this.editor.model.createPositionAfter(l);o.insertImage({...r,...s},c,e.imageType)}else e.breakBlock?o.insertImage({...r,...s},i.getFirstPosition(),e.imageType):o.insertImage({...r,...s},null,e.imageType)})}}class O4 extends O{constructor(e){super(e),this.decorate("cleanupImage")}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change(o=>{o.setAttribute("src",e.source,t),this.cleanupImage(o,t),i.setImageNaturalSizeAttributes(t)})}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}}class Ou extends w{static get requires(){return[Ke]}static get pluginName(){return"ImageEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Ru),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new R4(e),o=new O4(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",o),e.commands.add("imageInsert",i)}}class c1 extends w{static get requires(){return[Ke]}static get pluginName(){return"ImageSizeAttributes"}static get isOfficialPlugin(){return!0}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),o=e==="imageBlock"?"figure":"img";t.conversion.for("upcast").attributeToAttribute({view:{name:o,styles:{width:/.+/}},model:{key:"width",value:r=>jr(r)?Wr(r.getStyle("width")):null}}).attributeToAttribute({view:{name:o,key:"width"},model:"width"}).attributeToAttribute({view:{name:o,styles:{height:/.+/}},model:{key:"height",value:r=>jr(r)?Wr(r.getStyle("height")):null}}).attributeToAttribute({view:{name:o,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add(r=>{s(r,"width","width",!0,!0),s(r,"height","height",!0,!0)}),t.conversion.for("dataDowncast").add(r=>{s(r,"width","width",!1),s(r,"height","height",!1)}),t.conversion.for("upcast").add(r=>{r.on("element:img",(a,l,c)=>{const u=l.viewItem.getAttribute("width"),d=l.viewItem.getAttribute("height");u&&d&&c.consumable.consume(l.viewItem,{styles:["aspect-ratio"]})})});function s(r,a,l,c,u=!1){r.on(`attribute:${a}:${e}`,(d,m,f)=>{if(!f.consumable.consume(m.item,d.name))return;const g=f.writer,p=f.mapper.toViewElement(m.item),_=i.findViewImgElement(p);m.attributeNewValue!==null?g.setAttribute(l,m.attributeNewValue,_):g.removeAttribute(l,_);const v=m.item.getAttribute("width"),E=m.item.getAttribute("height"),M=v&&E;if(M&&u&&g.setAttribute("loading","lazy",_),m.item.hasAttribute("sources"))return;const G=m.item.hasAttribute("resizedWidth");e==="imageInline"&&!G&&!c||M&&g.setStyle("aspect-ratio",`${v}/${E}`,_)})}}}class u1 extends O{constructor(e,t){super(e),h(this,"_modelElementName"),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);this._modelElementName==="imageBlock"?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(e={}){const t=this.editor,i=this.editor.model,o=t.plugins.get("ImageUtils"),s=o.getClosestSelectedImageElement(i.document.selection),r=Object.fromEntries(s.getAttributes());return!r.src&&!r.uploadId?null:i.change(a=>{const{setImageSizes:l=!0}=e,c=Array.from(i.markers).filter(m=>m.getRange().containsItem(s)),u=o.insertImage(r,i.createSelection(s,"on"),this._modelElementName,{setImageSizes:l});if(!u)return null;const d=a.createRangeOn(u);for(const m of c){const f=m.getRange(),g=f.root.rootName!="$graveyard"?f.getJoined(d,!0):d;a.updateMarker(m,{range:g})}return{oldElement:s,newElement:u}})}}class h1 extends w{static get requires(){return[Ke]}static get pluginName(){return"ImagePlaceholder"}static get isOfficialPlugin(){return!0}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add(o=>{o.on("attribute:placeholder",(s,r,a)=>{if(!a.consumable.test(r.item,s.name)||!r.item.is("element","imageBlock")&&!r.item.is("element","imageInline"))return;a.consumable.consume(r.item,s.name);const l=a.writer,c=a.mapper.toViewElement(r.item),u=i.findViewImgElement(c);r.attributeNewValue?(l.addClass("image_placeholder",u),l.setStyle("background-image",`url(${r.attributeNewValue})`,u),l.setCustomProperty("editingPipeline:doNotReuseOnce",!0,u)):(l.removeClass("image_placeholder",u),l.removeStyle("background-image",u))})})}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,o=i.view,s=e.plugins.get("ImageUtils");o.addObserver(Ru),this.listenTo(o.document,"imageLoaded",(r,a)=>{const l=o.domConverter.mapDomToView(a.target);if(!l)return;const c=s.getImageWidgetFromImageView(l);if(!c)return;const u=i.mapper.toModelElement(c);!u||!u.hasAttribute("placeholder")||t.enqueueChange({isUndoable:!1},d=>{d.removeAttribute("placeholder",u)})})}}class d1 extends w{static get requires(){return[Ou,c1,Ke,h1,pt]}static get pluginName(){return"ImageBlockEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new u1(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,o=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(s,{writer:r})=>Zm(r)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(s,{writer:r})=>o.toImageWidget(Zm(r),r,t("image widget"))}),i.for("downcast").add(Ur(o,"imageBlock","src")).add(Ur(o,"imageBlock","alt")).add(l1(o,"imageBlock")),i.for("upcast").elementToElement({view:s1(e,"imageBlock"),model:(s,{writer:r})=>r.createElement("imageBlock",s.hasAttribute("src")?{src:s.getAttribute("src")}:void 0)}).add(P4(o))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,o=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(r,a)=>{const l=Array.from(a.content.getChildren());let c;if(!l.every(o.isInlineImageView))return;a.targetRanges?c=e.editing.mapper.toModelRange(a.targetRanges[0]):c=t.document.selection.getFirstRange();const u=t.createSelection(c);if(Iu(t.schema,u)==="imageBlock"){const d=new Ht(i.document),m=l.map(f=>d.createElement("figure",{class:"image"},f));a.content=d.createDocumentFragment(m)}}),this.listenTo(s,"contentInsertion",(r,a)=>{a.method==="paste"&&t.change(l=>{const c=l.createRangeIn(a.content);for(const u of c.getItems())u.is("element","imageBlock")&&o.setImageNaturalSizeAttributes(u)})})}}class B4 extends A{constructor(e,t=[]){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"_focusables"),h(this,"_focusCycler"),h(this,"children"),this.focusTracker=new ee,this.keystrokes=new te,this._focusables=new Ie,this.children=this.createCollection(),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const i of t)this.children.add(i),this._focusables.add(i),i instanceof mu&&this._focusables.addMany(i.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),Ri({view:this});for(const t of this._focusables)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element);const e=t=>t.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class m1 extends w{constructor(e){super(e),h(this,"dropdownView"),h(this,"_integrations",new Map),e.config.define("image.insert.integrations",["upload","assetManager","url"])}static get pluginName(){return"ImageInsertUI"}static get isOfficialPlugin(){return!0}static get requires(){return[Ke]}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",()=>{this.isImageSelected=i.isImage(t.getSelectedElement())});const o=r=>this._createToolbarComponent(r),s=r=>this._createMenuBarComponent(r);e.ui.componentFactory.add("insertImage",o),e.ui.componentFactory.add("imageInsert",o),e.ui.componentFactory.add("menuBar:insertImage",s)}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:o,menuBarButtonViewCreator:s,requiresForm:r=!1,override:a=!1}){this._integrations.has(e)&&!a&&J("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,menuBarButtonViewCreator:s,formViewCreator:o,requiresForm:r})}_createToolbarComponent(e){const t=this.editor,i=e.t,o=this._prepareIntegrations();if(!o.length)return null;let s;const r=o[0];if(o.length==1){if(!r.requiresForm)return r.buttonViewCreator(!0);s=r.buttonViewCreator(!0)}else{const c=r.buttonViewCreator(!1);s=new Xi(e,c),s.tooltip=!0,s.bind("label").to(this,"isImageSelected",u=>i(u?"Replace image":"Insert image"))}const a=this.dropdownView=Ee(e,s),l=o.map(({observable:c})=>typeof c=="function"?c():c);return a.bind("isEnabled").toMany(l,"isEnabled",(...c)=>c.some(u=>u)),a.once("change:isOpen",()=>{const c=o.flatMap(({formViewCreator:d})=>d(o.length==1)),u=new B4(t.locale,c);a.panelView.children.add(u)}),a}_createMenuBarComponent(e){const t=e.t,i=this._prepareIntegrations();if(!i.length)return null;const o=i.flatMap(({menuBarButtonViewCreator:a})=>a(i.length==1)),s=new Tt(e),r=new Si(e);s.panelView.children.add(r),s.buttonView.set({icon:RC,label:t("Image")});for(const a of o){const l=new Oi(e,s);l.children.add(a),r.items.add(l),a.delegate("execute").to(s)}return s}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return J("image-insert-integrations-not-specified"),t;for(const i of e){if(!this._integrations.has(i)){["upload","assetManager","url"].includes(i)||J("image-insert-unknown-integration",{item:i});continue}t.push(this._integrations.get(i))}return t.length||J("image-insert-integrations-not-registered"),t}}class M4 extends w{static get requires(){return[d1,Vt,a1,m1]}static get pluginName(){return"ImageBlock"}static get isOfficialPlugin(){return!0}}class L4 extends w{static get requires(){return[Ou,c1,Ke,h1,pt]}static get pluginName(){return"ImageInlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"],disallowIn:["caption"]}),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new u1(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,o=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(s,{writer:r})=>r.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(s,{writer:r})=>o.toImageWidget(_4(r),r,t("image widget"))}),i.for("downcast").add(Ur(o,"imageInline","src")).add(Ur(o,"imageInline","alt")).add(l1(o,"imageInline")),i.for("upcast").elementToElement({view:s1(e,"imageInline"),model:(s,{writer:r})=>r.createElement("imageInline",s.hasAttribute("src")?{src:s.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,o=e.plugins.get("ImageUtils"),s=e.plugins.get("ClipboardPipeline");this.listenTo(s,"inputTransformation",(r,a)=>{const l=Array.from(a.content.getChildren());let c;if(!l.every(o.isBlockImageView))return;a.targetRanges?c=e.editing.mapper.toModelRange(a.targetRanges[0]):c=t.document.selection.getFirstRange();const u=t.createSelection(c);if(Iu(t.schema,u)==="imageInline"){const d=new Ht(i.document),m=l.map(f=>f.childCount===1?(Array.from(f.getAttributes()).forEach(g=>d.setAttribute(...g,o.findViewImgElement(f))),f.getChild(0)):f);a.content=d.createDocumentFragment(m)}}),this.listenTo(s,"contentInsertion",(r,a)=>{a.method==="paste"&&t.change(l=>{const c=l.createRangeIn(a.content);for(const u of c.getItems())u.is("element","imageInline")&&o.setImageNaturalSizeAttributes(u)})})}}class f1 extends w{static get requires(){return[L4,Vt,a1,m1]}static get pluginName(){return"ImageInline"}static get isOfficialPlugin(){return!0}}class F4 extends w{static get requires(){return[M4,f1]}static get pluginName(){return"Image"}static get isOfficialPlugin(){return!0}}class g1 extends w{static get pluginName(){return"ImageCaptionUtils"}static get isOfficialPlugin(){return!0}static get requires(){return[Ke]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return e.name=="figcaption"&&t.isBlockImageView(e.parent)?{name:!0}:null}}class N4 extends O{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(d1)){this.isEnabled=!1,this.value=!1;return}const o=e.model.document.selection,s=o.getSelectedElement();if(!s){const r=t.getCaptionFromModelSelection(o);this.isEnabled=!!r,this.value=!!r;return}this.isEnabled=i.isImage(s),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(s):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change(i=>{this.value?this._hideImageCaption(i):this._showImageCaption(i,t)})}_showImageCaption(e,t){const i=this.editor.model.document.selection,o=this.editor.plugins.get("ImageCaptionEditing"),s=this.editor.plugins.get("ImageUtils");let r=i.getSelectedElement();const a=o._getSavedCaption(r);s.isInlineImage(r)&&(this.editor.execute("imageTypeBlock"),r=i.getSelectedElement());const l=a||e.createElement("caption");e.append(l,r),t&&e.setSelection(l,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,o=t.plugins.get("ImageCaptionEditing"),s=t.plugins.get("ImageCaptionUtils");let r=i.getSelectedElement(),a;r?a=s.getCaptionFromImageModelElement(r):(a=s.getCaptionFromModelSelection(i),r=a.parent),o._saveCaption(r,a),e.setSelection(r,"on"),e.remove(a)}}class D4 extends w{constructor(e){super(e),h(this,"_savedCaptionsMap"),this._savedCaptionsMap=new WeakMap}static get requires(){return[Ke,g1]}static get pluginName(){return"ImageCaptionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new N4(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),o=e.plugins.get("ImageCaptionUtils"),s=e.t;e.conversion.for("upcast").elementToElement({view:r=>o.matchImageCaptionViewElement(r),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(r,{writer:a})=>i.isBlockImage(r.parent)?a.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(r,{writer:a})=>{if(!i.isBlockImage(r.parent))return null;const l=a.createEditableElement("figcaption");a.setCustomProperty("imageCaption",!0,l),l.placeholder=s("Enter image caption"),sa({view:t,element:l,keepOnFocus:!0});const c=r.parent.getAttribute("alt"),u=c?s("Caption for image: %0",[c]):s("Caption for the image");return wa(l,a,{label:u})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),o=e.commands.get("imageTypeInline"),s=e.commands.get("imageTypeBlock"),r=a=>{if(!a.return)return;const{oldElement:l,newElement:c}=a.return;/* istanbul ignore if: paranoid check -- @preserve */if(!l)return;if(t.isBlockImage(l)){const d=i.getCaptionFromImageModelElement(l);if(d){this._saveCaption(c,d);return}}const u=this._getSavedCaption(l);u&&this._saveCaption(c,u)};o&&this.listenTo(o,"execute",r,{priority:"low"}),s&&this.listenTo(s,"execute",r,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?ne.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),o=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",()=>{const s=t.document.differ.getChanges();for(const r of s){if(r.attributeKey!=="alt")continue;const a=r.range.start.nodeAfter;if(i.isBlockImage(a)){const l=o.getCaptionFromImageModelElement(a);if(!l)return;e.editing.reconvertItem(l)}}})}}class z4 extends w{static get requires(){return[g1]}static get pluginName(){return"ImageCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),o=e.t;e.ui.componentFactory.add("toggleImageCaption",s=>{const r=e.commands.get("toggleImageCaption"),a=new P(s);return a.set({icon:pw,tooltip:!0,isToggleable:!0}),a.bind("isOn","isEnabled").to(r,"value","isEnabled"),a.bind("label").to(r,"value",l=>o(l?"Toggle caption off":"Toggle caption on")),this.listenTo(a,"execute",()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const l=i.getCaptionFromModelSelection(e.model.document.selection);if(l){const c=e.editing.mapper.toViewElement(l);t.scrollToTheSelection(),t.change(u=>{u.addClass("image__caption_highlighted",c)})}e.editing.view.focus()}),a})}}class H4 extends w{static get requires(){return[D4,z4]}static get pluginName(){return"ImageCaption"}static get isOfficialPlugin(){return!0}}function p1(n){const e=n.map(t=>t.replace("+","\\+"));return new RegExp(`^image\\/(${e.join("|")})$`)}function $4(n){return new Promise((e,t)=>{const i=n.getAttribute("src");fetch(i).then(o=>o.blob()).then(o=>{const s=w1(o,i),r=`image.${s.replace("image/","")}`,a=new File([o],r,{type:s});e(a)}).catch(o=>o&&o.name==="TypeError"?j4(i).then(e).catch(t):t(o))})}function W4(n,e){return!n.isInlineImageView(e)||!e.getAttribute("src")?!1:!!e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||!!e.getAttribute("src").match(/^blob:/g)}function w1(n,e){return n.type?n.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}function j4(n){return U4(n).then(e=>{const t=w1(e,n),i=`image.${t.replace("image/","")}`;return new File([e],i,{type:t})})}function U4(n){return new Promise((e,t)=>{const i=I.document.createElement("img");i.addEventListener("load",()=>{const o=I.document.createElement("canvas");o.width=i.width,o.height=i.height,o.getContext("2d").drawImage(i,0,0),o.toBlob(s=>s?e(s):t())}),i.addEventListener("error",()=>t()),i.src=n})}class q4 extends w{static get pluginName(){return"ImageUploadUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("uploadImage",()=>this._createToolbarButton()),e.ui.componentFactory.add("imageUpload",()=>this._createToolbarButton()),e.ui.componentFactory.add("menuBar:uploadImage",()=>this._createMenuBarButton("standalone")),e.plugins.has("ImageInsertUI")&&e.plugins.get("ImageInsertUI").registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:t=>this._createMenuBarButton(t?"insertOnly":"insertNested")})}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("uploadImage"),s=t.config.get("image.upload.types"),r=p1(s),a=new e(t.locale),l=i.t;return a.set({acceptedType:s.map(c=>`image/${c}`).join(","),allowMultipleFiles:!0,label:l("Upload from computer"),icon:OC}),a.bind("isEnabled").to(o),a.on("done",(c,u)=>{const d=Array.from(u).filter(m=>r.test(m.type));d.length&&(t.execute("uploadImage",{file:d}),t.editing.view.focus())}),a}_createToolbarButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this.editor.commands.get("uploadImage"),o=this._createButton(jd);return o.tooltip=!0,o.bind("label").to(t,"isImageSelected",i,"isAccessAllowed",(s,r)=>e(r?s?"Replace image from computer":"Upload image from computer":"You have no image upload permissions.")),o}_createDropdownButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this._createButton(jd);return i.withText=!0,i.bind("label").to(t,"isImageSelected",o=>e(o?"Replace from computer":"Upload from computer")),i.on("execute",()=>{t.dropdownView.isOpen=!1}),i}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createButton(mb);switch(i.withText=!0,e){case"standalone":i.label=t("Image from computer");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("From computer");break}return i}}class G4 extends w{constructor(e){super(e),h(this,"placeholder"),h(this,"uploadStatusChange",(t,i,o)=>{const s=this.editor,r=i.item,a=r.getAttribute("uploadId");if(!o.consumable.consume(i.item,t.name))return;const l=s.plugins.get("ImageUtils"),c=s.plugins.get(At),u=a?i.attributeNewValue:null,d=this.placeholder,m=s.editing.mapper.toViewElement(r),f=o.writer;if(u=="reading"){Jm(m,f),Qm(l,d,m,f);return}if(u=="uploading"){const g=c.loaders.get(a);Jm(m,f),g?(Ym(m,f),Z4(m,f,g,s.editing.view),eI(l,m,f,g)):Qm(l,d,m,f);return}u=="complete"&&c.loaders.get(a)&&Q4(m,f,s.editing.view),J4(m,f),Ym(m,f),K4(m,f)}),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}static get pluginName(){return"ImageUploadProgress"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}}function Jm(n,e){n.hasClass("ck-appear")||e.addClass("ck-appear",n)}function K4(n,e){e.removeClass("ck-appear",n)}function Qm(n,e,t,i){t.hasClass("ck-image-upload-placeholder")||i.addClass("ck-image-upload-placeholder",t);const o=n.findViewImgElement(t);o.getAttribute("src")!==e&&i.setAttribute("src",e,o),b1(t,"placeholder")||i.insert(i.createPositionAfter(o),X4(i))}function Ym(n,e){n.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",n),_1(n,e,"placeholder")}function Z4(n,e,t,i){const o=Y4(e);e.insert(e.createPositionAt(n,"end"),o),t.on("change:uploadedPercent",(s,r,a)=>{i.change(l=>{l.setStyle("width",a+"%",o)})})}function J4(n,e){_1(n,e,"progressBar")}function Q4(n,e,t){const i=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(n,"end"),i),setTimeout(()=>{t.change(o=>o.remove(o.createRangeOn(i)))},3e3)}function Y4(n){const e=n.createUIElement("div",{class:"ck-progress-bar"});return n.setCustomProperty("progressBar",!0,e),e}function X4(n){const e=n.createUIElement("div",{class:"ck-upload-placeholder-loader"});return n.setCustomProperty("placeholder",!0,e),e}function b1(n,e){for(const t of n.getChildren())if(t.getCustomProperty(e))return t}function _1(n,e,t){const i=b1(n,t);i&&e.remove(e.createRangeOn(i))}function eI(n,e,t,i){if(i.data){const o=n.findViewImgElement(e);t.setAttribute("src",i.data,o)}}class tI extends O{constructor(e){super(e),this.set("isAccessAllowed",!0)}refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=he(e.file),i=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),s=Object.fromEntries(i.getAttributes());t.forEach((r,a)=>{const l=i.getSelectedElement();if(a&&l&&o.isImage(l)){const c=this.editor.model.createPositionAfter(l);this._uploadImage(r,s,c)}else this._uploadImage(r,s)})}_uploadImage(e,t,i){const o=this.editor,s=o.plugins.get(At).createLoader(e),r=o.plugins.get("ImageUtils");s&&r.insertImage({...t,uploadId:s.id},i)}}class iI extends w{constructor(e){super(e),h(this,"_uploadImageElements"),h(this,"_uploadedImages",new Map),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}static get requires(){return[At,Nr,pt,Ke]}static get pluginName(){return"ImageUploadEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.document,i=e.conversion,o=e.plugins.get(At),s=e.plugins.get("ImageUtils"),r=e.plugins.get("ClipboardPipeline"),a=p1(e.config.get("image.upload.types")),l=new tI(e);e.commands.add("uploadImage",l),e.commands.add("imageUpload",l),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}).add(c=>c.on("element:img",(u,d,m)=>{if(!m.consumable.test(d.viewItem,{attributes:["data-ck-upload-id"]}))return;const f=d.viewItem.getAttribute("data-ck-upload-id");if(!f)return;const[g]=Array.from(d.modelRange.getItems({shallow:!0})),p=o.loaders.get(f);g&&(m.writer.setAttribute("uploadId",f,g),m.consumable.consume(d.viewItem,{attributes:["data-ck-upload-id"]}),p&&p.data&&m.writer.setAttribute("uploadStatus",p.status,g))},{priority:"low"})),this.listenTo(e.editing.view.document,"clipboardInput",(c,u)=>{if(nI(u.dataTransfer))return;const d=Array.from(u.dataTransfer.files).filter(m=>m?a.test(m.type):!1);if(d.length&&(c.stop(),e.model.change(m=>{u.targetRanges&&m.setSelection(u.targetRanges.map(f=>e.editing.mapper.toModelRange(f))),e.execute("uploadImage",{file:d})}),!e.commands.get("uploadImage").isAccessAllowed)){const m=e.plugins.get("Notification"),f=e.locale.t;m.showWarning(f("You have no image upload permissions."),{namespace:"image"})}}),this.listenTo(r,"inputTransformation",(c,u)=>{const d=Array.from(e.editing.view.createRangeIn(u.content)).map(f=>f.item).filter(f=>W4(s,f)&&!f.getAttribute("uploadProcessed")).map(f=>({promise:$4(f),imageElement:f}));if(!d.length)return;const m=new Ht(e.editing.view.document);for(const f of d){m.setAttribute("uploadProcessed",!0,f.imageElement);const g=o.createLoader(f.promise);g&&(m.setAttribute("src","",f.imageElement),m.setAttribute("uploadId",g.id,f.imageElement))}}),e.editing.view.document.on("dragover",(c,u)=>{u.preventDefault()}),t.on("change",()=>{const c=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),u=new Set;for(const d of c)if(d.type=="insert"&&d.name!="$text"){const m=d.position.nodeAfter,f=d.position.root.rootName=="$graveyard";for(const g of oI(e,m)){const p=g.getAttribute("uploadId");if(!p)continue;const _=o.loaders.get(p);if(!_){!f&&this._uploadedImages.has(p)&&e.model.enqueueChange({isUndoable:!1},v=>{v.setAttribute("uploadStatus","complete",g),this.fire("uploadComplete",{data:this._uploadedImages.get(p),imageElement:g})});continue}f?u.has(p)||Array.from(this._uploadImageElements.get(p)).every(v=>v.root.rootName=="$graveyard")&&_.abort():(u.add(p),this._uploadImageElements.has(p)?this._uploadImageElements.get(p).add(g):this._uploadImageElements.set(p,new Set([g])),_.status=="idle"&&this._readAndUpload(_))}}}),this.on("uploadComplete",(c,{imageElement:u,data:d})=>{const m=d.urls?d.urls:d;this.editor.model.change(f=>{f.setAttribute("src",m.default,u),this._parseAndSetSrcsetAttributeOnImage(m,u,f),s.setImageNaturalSizeAttributes(u)})},{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageBlock")),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageInline"))}_readAndUpload(e){const t=this.editor,i=t.model,o=t.locale.t,s=t.plugins.get(At),r=t.plugins.get(Nr),a=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},u=>{const d=l.get(e.id);for(const m of d)u.setAttribute("uploadStatus","reading",m)}),e.read().then(()=>{const u=e.upload();t.ui&&t.ui.ariaLiveAnnouncer.announce(o("Uploading image"));for(const d of l.get(e.id)){/* istanbul ignore next -- @preserve */if(N.isSafari){const m=t.editing.mapper.toViewElement(d),f=a.findViewImgElement(m);t.editing.view.once("render",()=>{if(!f.parent)return;const g=t.editing.view.domConverter.mapViewToDom(f.parent);if(!g)return;const p=g.style.display;g.style.display="none",g._ckHack=g.offsetHeight,g.style.display=p})}i.enqueueChange({isUndoable:!1},m=>{m.setAttribute("uploadStatus","uploading",d)})}return u}).then(u=>{i.enqueueChange({isUndoable:!1},d=>{for(const m of l.get(e.id))d.setAttribute("uploadStatus","complete",m),this.fire("uploadComplete",{data:u,imageElement:m});t.ui&&t.ui.ariaLiveAnnouncer.announce(o("Image upload complete")),this._uploadedImages.set(e.id,u)}),c()}).catch(u=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(o("Error during image upload")),e.status!=="error"&&e.status!=="aborted")throw u;e.status=="error"&&u&&r.showWarning(u,{title:o("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},d=>{for(const m of l.get(e.id))m.root.rootName!=="$graveyard"&&d.remove(m)}),c()});function c(){i.enqueueChange({isUndoable:!1},u=>{for(const d of l.get(e.id))u.removeAttribute("uploadId",d),u.removeAttribute("uploadStatus",d);l.delete(e.id)}),s.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let o=0;const s=Object.keys(e).filter(r=>{const a=parseInt(r,10);if(!isNaN(a))return o=Math.max(o,a),!0}).map(r=>`${e[r]} ${r}w`).join(", ");if(s!=""){const r={srcset:s};!t.hasAttribute("width")&&!t.hasAttribute("height")&&(r.width=o),i.setAttributes(r,t)}}_registerConverters(e){const{conversion:t,plugins:i}=this.editor,o=i.get(At),s=i.get(Ke);t.for("dataDowncast").add(r=>{r.on(`attribute:uploadId:${e}`,(a,l,c)=>{if(!c.consumable.test(l.item,a.name))return;const u=o.loaders.get(l.attributeNewValue);if(!u||!u.data)return null;const d=c.mapper.toViewElement(l.item),m=s.findViewImgElement(d);m&&(c.consumable.consume(l.item,a.name),c.writer.setAttribute("data-ck-upload-id",u.id,m))})})}}function nI(n){return Array.from(n.types).includes("text/html")&&n.getData("text/html")!==""}function oI(n,e){const t=n.plugins.get("ImageUtils");return Array.from(n.model.createRangeOn(e)).filter(i=>t.isImage(i.item)).map(i=>i.item)}class sI extends w{static get pluginName(){return"ImageUpload"}static get isOfficialPlugin(){return!0}static get requires(){return[iI,q4,G4]}}class rI extends O{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,!t||!t.hasAttribute("resizedWidth")?this.value=null:this.value={width:t.getAttribute("resizedWidth"),height:null}}execute(e){const t=this.editor,i=t.model,o=t.plugins.get("ImageUtils"),s=o.getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},s&&i.change(r=>{r.setAttribute("resizedWidth",e.width,s),r.removeAttribute("resizedHeight",s),o.setImageNaturalSizeAttributes(s)})}}class v1 extends w{static get requires(){return[Ke]}static get pluginName(){return"ImageResizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new rI(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add(o=>o.on(`attribute:resizedWidth:${e}`,(s,r,a)=>{if(!a.consumable.consume(r.item,s.name))return;const l=a.writer,c=a.mapper.toViewElement(r.item);r.attributeNewValue!==null?(l.setStyle("width",r.attributeNewValue,c),l.addClass("image_resized",c)):(l.removeStyle("width",c),l.removeClass("image_resized",c))})),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:o=>({key:"style",value:{height:o}})}),t.conversion.for("editingDowncast").add(o=>o.on(`attribute:resizedHeight:${e}`,(s,r,a)=>{if(!a.consumable.consume(r.item,s.name))return;const l=a.writer,c=a.mapper.toViewElement(r.item),u=e==="imageInline"?i.findViewImgElement(c):c;r.attributeNewValue!==null?l.setStyle("height",r.attributeNewValue,u):l.removeStyle("height",u)})),t.conversion.for("upcast").attributeToAttribute({view:{name:e==="imageBlock"?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:o=>jr(o)?null:o.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:e==="imageBlock"?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:o=>jr(o)?null:o.getStyle("height")}}),t.conversion.for("upcast").add(o=>{o.on(`element:${e==="imageBlock"?"figure":"img"}`,(s,r,a)=>{a.consumable.consume(r.viewItem,{classes:["image_resized"]})})})}}const bl={small:YC,medium:QC,large:JC,custom:KC,original:ZC};class aI extends w{constructor(e){super(e),h(this,"_resizeUnit"),this._resizeUnit=e.config.get("image.resizeUnit")}static get requires(){return[v1]}static get pluginName(){return"ImageResizeButtons"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const o of t)this._registerImageResizeButton(o);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:o,icon:s}=e;t.ui.componentFactory.add(i,r=>{const a=new P(r),l=t.commands.get("resizeImage"),c=this._getOptionLabelValue(e,!0);if(!bl[s])throw new b("imageresizebuttons-missing-icon",t,e);if(a.set({label:c,icon:bl[s],tooltip:c,isToggleable:!0}),a.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&zo(e)){const u=t.plugins.get("ImageCustomResizeUI");this.listenTo(a,"execute",()=>{u._showForm(this._resizeUnit)})}else{const u=o?o+this._resizeUnit:null;a.bind("isOn").to(l,"value",l,"isEnabled",lc(u)),this.listenTo(a,"execute",()=>{t.execute("resizeImage",{width:u})})}return a})}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,o=e.find(r=>!r.value),s=r=>{const a=t.commands.get("resizeImage"),l=Ee(r,fu),c=l.buttonView,u=i("Resize image");return c.set({tooltip:u,commandValue:o.value,icon:bl.medium,isToggleable:!0,label:this._getOptionLabelValue(o),withText:!0,class:"ck-resize-image-button",ariaLabel:u,ariaLabelledBy:void 0}),c.bind("label").to(a,"value",d=>d&&d.width?d.width:this._getOptionLabelValue(o)),l.bind("isEnabled").to(this),wt(l,()=>this._getResizeDropdownListItemDefinitions(e,a),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(l,"execute",d=>{"onClick"in d.source?d.source.onClick():(t.execute(d.source.commandName,{width:d.source.commandValue}),t.editing.view.focus())}),l};t.ui.componentFactory.add("resizeImage",s),t.ui.componentFactory.add("imageResize",s)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?zo(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):zo(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,o=new _e,s=e.map(r=>zo(r)?{...r,valueWithUnits:"custom"}:r.value?{...r,valueWithUnits:`${r.value}${this._resizeUnit}`}:{...r,valueWithUnits:null});for(const r of s){let a=null;if(i.plugins.has("ImageCustomResizeUI")&&zo(r)){const l=i.plugins.get("ImageCustomResizeUI");a={type:"button",model:new et({label:this._getOptionLabelValue(r),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{l._showForm(this._resizeUnit)}})};const c=Object.values(s).map(u=>u.valueWithUnits);a.model.bind("isOn").to(t,"value",t,"isEnabled",lI(c))}else a={type:"button",model:new et({commandName:"resizeImage",commandValue:r.valueWithUnits,label:this._getOptionLabelValue(r),role:"menuitemradio",withText:!0,icon:null})},a.model.bind("isOn").to(t,"value",t,"isEnabled",lc(r.valueWithUnits));a.model.bind("isEnabled").to(t,"isEnabled"),o.add(a)}return o}}function zo(n){return n.value==="custom"}function lc(n){return(e,t)=>{const i=e;return i===void 0||!t?!1:n===null&&i===n?!0:i!==null&&i.width===n}}function lI(n){return(e,t)=>!n.some(i=>lc(i)(e,t))}const cI="figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img",_l="image_resized";class uI extends w{static get requires(){return[ul,Ke]}static get pluginName(){return"ImageResizeHandles"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils");t.addObserver(Ru),this.listenTo(t.document,"imageLoaded",(o,s)=>{if(!s.target.matches(cI))return;const r=e.editing.view.domConverter,a=r.domToView(s.target),l=i.getImageWidgetFromImageView(a);let c=this.editor.plugins.get(ul).getResizerByViewElement(l);if(c){c.redraw();return}const u=e.editing.mapper,d=u.toModelElement(l);c=e.plugins.get(ul).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:d,viewElement:l,editor:e,getHandleHost(m){return m.querySelector("img")},getResizeHost(){return r.mapViewToDom(u.toViewElement(d))},isCentered(){return d.getAttribute("imageStyle")=="alignCenter"},onCommit(m){t.change(f=>{f.removeClass(_l,l)}),e.execute("resizeImage",{width:m})}}),c.on("updateSize",()=>{l.hasClass(_l)||t.change(f=>{f.addClass(_l,l)});const m=d.name==="imageInline"?a:l;m.getStyle("height")&&t.change(f=>{f.removeStyle("height",m)})}),c.bind("isEnabled").to(this)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function y1(n){if(!n)return null;const[,e,t]=n.trim().match(/([.,\d]+)(%|px)$/)||[],i=Number.parseFloat(e);return Number.isNaN(i)?null:{value:i,unit:t}}function k1(n,e,t){return t==="px"?{value:e.value,unit:"px"}:{value:e.value/n*100,unit:"%"}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function C1(n){const{editing:e}=n,t=n.plugins.get("ImageUtils").getClosestSelectedImageElement(n.model.document.selection);if(!t)return null;const i=e.mapper.toViewElement(t),o=e.view.domConverter.mapViewToDom(i);return{model:t,view:i,dom:o}}function hI(n,e){const t=C1(n);if(!t)return null;const i=y1(t.model.getAttribute("resizedWidth")||null);if(!i)return null;if(i.unit===e)return i;const o=Au(t.dom),s={value:new z(t.dom).width};return k1(o,s,e)}class dI extends A{constructor(e,t,i){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"unit"),h(this,"backButtonView"),h(this,"saveButtonView"),h(this,"labeledInput"),h(this,"children"),h(this,"_focusables"),h(this,"_focusCycler"),h(this,"_validators"),this.focusTracker=new ee,this.keystrokes=new te,this.unit=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new $e(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new Ie,this._validators=i,this.keystrokes.set("Esc",(o,s)=>{this.fire("cancel"),s()}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),[this.backButtonView,this.labeledInput,this.saveButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new P(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Image Resize")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new Te(this.locale,eb);return t.label=e("Resize image (in %0)",this.unit),t.class="ck-labeled-field-view_full-width",t.fieldView.set({step:.1}),t}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.labeledInput.errorText=t,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:e}=this.labeledInput.fieldView;return e?e.value:null}get parsedSize(){const{rawSize:e}=this;if(e===null)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return e===null?null:`${e}${t}`}}function mI(n,e){const t=C1(n);if(!t)return null;const i=Au(t.dom),o=y1(window.getComputedStyle(t.dom).minWidth)||{value:1},s=Math.max(.1,k1(i,o,e).value);return{unit:e,lower:s,upper:e==="px"?i:100}}class fI extends w{constructor(){super(...arguments),h(this,"_balloon"),h(this,"_form")}static get requires(){return[Ue]}static get pluginName(){return"ImageCustomResizeUI"}static get isOfficialPlugin(){return!0}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(e){const t=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(ho(dI))(t.locale,e,gI(t)),this._form.render(),this.listenTo(this._form,"submit",()=>{this._form.isValid()&&(t.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))}),this.listenTo(this._form.labeledInput,"change:errorText",()=>{t.ui.update()}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),$t({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(e){if(this._isVisible)return;this._form||this._createForm(e);const t=this.editor,i=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:Vu(t)});const o=hI(t,e),s=o?o.value.toFixed(1):"",r=mI(t,e);i.fieldView.value=i.fieldView.element.value=s,r&&Object.assign(i.fieldView,{min:r.lower.toFixed(1),max:Math.ceil(r.upper).toFixed(1)}),this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}function gI(n){const e=n.t;return[t=>{if(t.rawSize.trim()==="")return e("The value must not be empty.");if(t.parsedSize===null)return e("The value should be a plain number.")}]}class pI extends w{static get requires(){return[v1,uI,fI,aI]}static get pluginName(){return"ImageResize"}static get isOfficialPlugin(){return!0}}class wI extends O{constructor(e,t){super(e),h(this,"_defaultStyles"),h(this,"_styles"),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map(i=>{if(i.isDefault)for(const o of i.modelElements)this._defaultStyles[o]=i.name;return[i.name,i]}))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,o=t.plugins.get("ImageUtils");i.change(s=>{const r=e.value,{setImageSizes:a=!0}=e;let l=o.getClosestSelectedImageElement(i.document.selection);r&&this.shouldConvertImageType(r,l)&&(this.editor.execute(o.isBlockImage(l)?"imageTypeInline":"imageTypeBlock",{setImageSizes:a}),l=o.getClosestSelectedImageElement(i.document.selection)),!r||this._styles.get(r).isDefault?s.removeAttribute("imageStyle",l):s.setAttribute("imageStyle",r,l),a&&o.setImageNaturalSizeAttributes(l)})}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const wr={get inline(){return{name:"inline",title:"In line",icon:bw,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:ru,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:_w,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:Mr,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:Lr,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:vw,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:Mr,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:Lr,modelElements:["imageBlock"],className:"image-style-side"}}},A1={full:GC,left:_w,right:vw,center:Mr,inlineLeft:ru,inlineRight:Lr,inline:bw},x1=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function bI(n){return(n.configuredStyles.options||[]).map(e=>yI(e)).filter(e=>kI(e,n))}function _I(n,e){return n&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:n?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}}function vI(n){return n.has("ImageBlockEditing")&&n.has("ImageInlineEditing")?[...x1]:[]}function yI(n){return typeof n=="string"?wr[n]?n={...wr[n]}:n={name:n}:n=CI(wr[n.name],n),typeof n.icon=="string"&&(n.icon=A1[n.icon]||n.icon),n}function kI(n,{isBlockPluginLoaded:e,isInlinePluginLoaded:t}){const{modelElements:i,name:o}=n;if(!i||!i.length||!o)return T1({style:n}),!1;{const s=[e?"imageBlock":null,t?"imageInline":null];if(!i.some(r=>s.includes(r)))return J("image-style-missing-dependency",{style:n,missingPlugins:i.map(r=>r==="imageBlock"?"ImageBlockEditing":"ImageInlineEditing")}),!1}return!0}function CI(n,e){const t={...e};for(const i in n)Object.prototype.hasOwnProperty.call(e,i)||(t[i]=n[i]);return t}function T1(n){J("image-style-configuration-definition-invalid",n)}var cc={normalizeStyles:bI,getDefaultStylesConfiguration:_I,getDefaultDropdownDefinitions:vI,warnInvalidStyle:T1,DEFAULT_OPTIONS:wr,DEFAULT_ICONS:A1,DEFAULT_DROPDOWN_DEFINITIONS:x1};function AI(n){return(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const o=Xm(t.attributeNewValue,n),s=Xm(t.attributeOldValue,n),r=i.mapper.toViewElement(t.item),a=i.writer;s&&a.removeClass(s.className,r),o&&a.addClass(o.className,r)}}function xI(n){const e={imageInline:n.filter(t=>!t.isDefault&&t.modelElements.includes("imageInline")),imageBlock:n.filter(t=>!t.isDefault&&t.modelElements.includes("imageBlock"))};return(t,i,o)=>{if(!i.modelRange)return;const s=i.viewItem,r=ae(i.modelRange.getItems());if(r&&o.schema.checkAttribute(r,"imageStyle"))for(const a of e[r.name])o.consumable.consume(s,{classes:a.className})&&o.writer.setAttribute("imageStyle",a.name,r)}}function Xm(n,e){for(const t of e)if(t.name===n)return t}class E1 extends w{constructor(){super(...arguments),h(this,"normalizedStyles")}static get pluginName(){return"ImageStyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Ke]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=cc,i=this.editor,o=i.plugins.has("ImageBlockEditing"),s=i.plugins.has("ImageInlineEditing");i.config.define("image.styles",t(o,s)),this.normalizedStyles=e({configuredStyles:i.config.get("image.styles"),isBlockPluginLoaded:o,isInlinePluginLoaded:s}),this._setupConversion(o,s),this._setupPostFixer(),i.commands.add("imageStyle",new wI(i,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,o=i.model.schema,s=AI(this.normalizedStyles),r=xI(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",s),i.data.downcastDispatcher.on("attribute:imageStyle",s),e&&(o.extend("imageBlock",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(o.extend("imageInline",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(Ke),o=new Map(this.normalizedStyles.map(s=>[s.name,s]));t.registerPostFixer(s=>{let r=!1;for(const a of t.differ.getChanges())if(a.type=="insert"||a.type=="attribute"&&a.attributeKey=="imageStyle"){let l=a.type=="insert"?a.position.nodeAfter:a.range.start.nodeAfter;if(l&&l.is("element","paragraph")&&l.childCount>0&&(l=l.getChild(0)),!i.isImage(l))continue;const c=l.getAttribute("imageStyle");if(!c)continue;const u=o.get(c);(!u||!u.modelElements.includes(l.name))&&(s.removeAttribute("imageStyle",l),r=!0)}return r})}}class TI extends w{static get requires(){return[E1]}static get pluginName(){return"ImageStyleUI"}static get isOfficialPlugin(){return!0}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=e.get("ImageStyleEditing"),o=ef(i.normalizedStyles,this.localizedDefaultStylesTitles);for(const r of o)this._createButton(r);const s=ef([...t.filter(Et),...cc.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const r of s)this._createDropdown(r,o)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,o=>{let s;const{defaultItem:r,items:a,title:l}=e,c=a.filter(f=>t.find(({name:g})=>tf(g)===f)).map(f=>{const g=i.create(f);return f===r&&(s=g),g});a.length!==c.length&&cc.warnInvalidStyle({dropdown:e});const u=Ee(o,Xi),d=u.buttonView,m=d.arrowView;return fa(u,c,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:nf(l,s.label),class:null,tooltip:!0}),m.unbind("label"),m.set({label:l}),d.bind("icon").toMany(c,"isOn",(...f)=>{const g=f.findIndex(qn);return g<0?s.icon:c[g].icon}),d.bind("label").toMany(c,"isOn",(...f)=>{const g=f.findIndex(qn);return nf(l,g<0?s.label:c[g].label)}),d.bind("isOn").toMany(c,"isOn",(...f)=>f.some(qn)),d.bind("class").toMany(c,"isOn",(...f)=>f.some(qn)?"ck-splitbutton_flatten":void 0),d.on("execute",()=>{c.some(({isOn:f})=>f)?u.isOpen=!u.isOpen:s.fire("execute")}),u.bind("isEnabled").toMany(c,"isEnabled",(...f)=>f.some(qn)),this.listenTo(u,"execute",()=>{this.editor.editing.view.focus()}),u})}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(tf(t),i=>{const o=this.editor.commands.get("imageStyle"),s=new P(i);return s.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",r=>r===t),s.on("execute",this._executeCommand.bind(this,t)),s})}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function ef(n,e){for(const t of n)e[t.title]&&(t.title=e[t.title]);return n}function tf(n){return`imageStyle:${n}`}function nf(n,e){return(n?n+": ":"")+e}class EI extends w{static get requires(){return[E1,TI]}static get pluginName(){return"ImageStyle"}static get isOfficialPlugin(){return!0}}class SI extends w{static get requires(){return[ci,Ke]}static get pluginName(){return"ImageToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(ci),o=e.plugins.get("ImageUtils");i.register("image",{ariaLabel:t("Image toolbar"),items:PI(e.config.get("image.toolbar")||[]),getRelatedElement:s=>o.getClosestSelectedImageWidget(s)})}}function PI(n){return n.map(e=>Et(e)?e.name:e)}class II extends w{static get requires(){return[Ou,Ke]}static get pluginName(){return"PictureEditing"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:["sources"]}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:["sources"]}),this._setupConversion(),this._setupImageUploadEditingIntegration()}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("upcast").add(I4(i)),t.for("downcast").add(V4(i))}_setupImageUploadEditingIntegration(){const e=this.editor;if(!e.plugins.has("ImageUploadEditing"))return;const t=e.plugins.get("ImageUploadEditing");this.listenTo(t,"uploadComplete",(i,{imageElement:o,data:s})=>{const r=s.sources;r&&e.model.change(a=>{a.setAttributes({sources:r},o)})})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class VI extends w{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("indent",new rd(e)),e.commands.add("outdent",new rd(e))}}class RI extends w{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,o=t.uiLanguageDirection=="ltr"?wd:bd,s=t.uiLanguageDirection=="ltr"?bd:wd;this._defineButton("indent",i("Increase indent"),o),this._defineButton("outdent",i("Decrease indent"),s)}_defineButton(e,t,i){const o=this.editor;o.ui.componentFactory.add(e,()=>{const s=this._createButton(P,e,t,i);return s.set({tooltip:!0}),s}),o.ui.componentFactory.add("menuBar:"+e,()=>this._createButton(ve,e,t,i))}_createButton(e,t,i,o){const s=this.editor,r=s.commands.get(t),a=new e(s.locale);return a.set({label:i,icon:o}),a.bind("isEnabled").to(r,"isEnabled"),this.listenTo(a,"execute",()=>{s.execute(t),s.editing.view.focus()}),a}}class OI extends w{static get pluginName(){return"Indent"}static get isOfficialPlugin(){return!0}static get requires(){return[VI,RI]}}class er extends O{constructor(e,t){super(e),h(this,"_indentBehavior"),this._indentBehavior=t}refresh(){const e=this.editor.model,t=ae(e.document.selection.getSelectedBlocks());if(!t||!this._isIndentationChangeAllowed(t)){this.isEnabled=!1;return}this.isEnabled=this._indentBehavior.checkEnabled(t.getAttribute("blockIndent"))}execute(){const e=this.editor.model,t=this._getBlocksToChange();e.change(i=>{for(const o of t){const s=o.getAttribute("blockIndent"),r=this._indentBehavior.getNextIndent(s);r?i.setAttribute("blockIndent",r,o):i.removeAttribute("blockIndent",o)}})}_getBlocksToChange(){const e=this.editor.model.document.selection;return Array.from(e.getSelectedBlocks()).filter(t=>this._isIndentationChangeAllowed(t))}_isIndentationChangeAllowed(e){const t=this.editor;return t.model.schema.checkAttribute(e,"blockIndent")?!t.plugins.has("ListUtils")||!this._indentBehavior.isForward?!0:!t.plugins.get("ListUtils").isListItemBlock(e):!1}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class of{constructor(e){h(this,"isForward"),h(this,"offset"),h(this,"unit"),this.isForward=e.direction==="forward",this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(!(!e||e.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=this.isForward?this.offset:-this.offset,o=t+i;return o>0?o+this.unit:void 0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class sf{constructor(e){h(this,"isForward"),h(this,"classes"),this.isForward=e.direction==="forward",this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t<this.classes.length-1:t>=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const BI=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class MI extends w{constructor(e){super(e),e.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.config.get("indentBlock");t.classes&&t.classes.length?(this._setupConversionUsingClasses(t.classes),e.commands.add("indentBlock",new er(e,new sf({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlock",new er(e,new sf({direction:"backward",classes:t.classes})))):(e.data.addStyleProcessorRules(L5),this._setupConversionUsingOffset(),e.commands.add("indentBlock",new er(e,new of({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlock",new er(e,new of({direction:"backward",offset:t.offset,unit:t.unit}))))}afterInit(){const e=this.editor,t=e.model.schema,i=e.commands.get("indent"),o=e.commands.get("outdent"),s=e.config.get("heading.options");(s&&s.map(r=>r.model)||BI).forEach(r=>{t.isRegistered(r)&&t.extend(r,{allowAttributes:"blockIndent"})}),t.setAttributeProperties("blockIndent",{isFormatting:!0}),i.registerChildCommand(e.commands.get("indentBlock")),o.registerChildCommand(e.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const e=this.editor.conversion,t=this.editor.locale.contentLanguageDirection==="rtl"?"margin-right":"margin-left";e.for("upcast").attributeToAttribute({view:{styles:{[t]:/[\s\S]+/}},model:{key:"blockIndent",value:i=>{if(!i.is("element","li"))return i.getStyle(t)}}}),e.for("downcast").attributeToAttribute({model:"blockIndent",view:i=>({key:"style",value:{[t]:i}})})}_setupConversionUsingClasses(e){const t={model:{key:"blockIndent",values:[]},view:{}};for(const i of e)t.model.values.push(i),t.view[i]={key:"class",value:[i]};this.editor.conversion.attributeToAttribute(t)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Bu(n,e){return e=e||Dl(n),`${n}:${e}`}function LI(n){const[e,t]=n.split(":");return{languageCode:e,textDirection:t}}class FI extends O{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"language")}execute({languageCode:e,textDirection:t}={}){const i=this.editor.model,o=i.document.selection,s=e?Bu(e,t):!1;i.change(r=>{if(o.isCollapsed)s?r.setSelectionAttribute("language",s):r.removeSelectionAttribute("language");else{const a=i.schema.getValidRanges(o.getRanges(),"language");for(const l of a)s?r.setAttribute("language",s,l):r.removeAttribute("language",l)}})}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.getAttribute("language")||!1;for(const o of i.getRanges())for(const s of o.getItems())if(t.checkAttribute(s,"language"))return s.getAttribute("language")||!1;return!1}}class NI extends w{static get pluginName(){return"TextPartLanguageEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"language"}),e.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),e.commands.add("textPartLanguage",new FI(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:t=>{const i=t.getAttribute("lang"),o=t.getAttribute("dir");return Bu(i,o)}},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(t,{writer:i},o)=>{if(!t||!o.item.is("$textProxy")&&!o.item.is("documentSelection"))return;const{languageCode:s,textDirection:r}=LI(t);return i.createAttributeElement("span",{lang:s,dir:r})}})}}class DI extends w{static get pluginName(){return"TextPartLanguageUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=t("Choose language"),o=t("Language");e.ui.componentFactory.add("textPartLanguage",s=>{const{definitions:r,titles:a}=this._getItemMetadata(),l=e.commands.get("textPartLanguage"),c=Ee(s);return wt(c,r,{ariaLabel:o,role:"menu"}),c.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),c.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),c.bind("isEnabled").to(l,"isEnabled"),c.buttonView.bind("label").to(l,"value",u=>u&&a[u]||i),c.buttonView.bind("ariaLabel").to(l,"value",u=>{const d=u&&a[u];return d?`${d}, ${o}`:o}),this.listenTo(c,"execute",u=>{l.execute({languageCode:u.source.languageCode,textDirection:u.source.textDirection}),e.editing.view.focus()}),c}),e.ui.componentFactory.add("menuBar:textPartLanguage",s=>{const{definitions:r}=this._getItemMetadata(),a=e.commands.get("textPartLanguage"),l=new Tt(s);l.buttonView.set({label:o});const c=new Si(s);c.set({ariaLabel:t("Language"),role:"menu"});for(const u of r){if(u.type!="button"){c.items.add(new ma(s));continue}const d=new Oi(s,l),m=new ve(s);m.set({role:"menuitemradio",isToggleable:!0}),m.bind(...Object.keys(u.model)).to(u.model),m.delegate("execute").to(l),d.children.add(m),c.items.add(d)}return l.bind("isEnabled").to(a,"isEnabled"),l.panelView.children.add(c),l.on("execute",u=>{a.execute({languageCode:u.source.languageCode,textDirection:u.source.textDirection}),e.editing.view.focus()}),l})}_getItemMetadata(){const e=this.editor,t=new _e,i={},o=e.commands.get("textPartLanguage"),s=e.config.get("language.textPartLanguage"),r=e.locale.t,a=r("Remove language");t.add({type:"button",model:new et({label:a,languageCode:!1,withText:!0})}),t.add({type:"separator"});for(const l of s){const c={type:"button",model:new et({label:l.title,languageCode:l.languageCode,role:"menuitemradio",textDirection:l.textDirection,withText:!0})},u=Bu(l.languageCode,l.textDirection);c.model.bind("isOn").to(o,"value",d=>d===u),t.add(c),i[u]=l.title}return{definitions:t,titles:i}}}class zI extends w{static get requires(){return[NI,DI]}static get pluginName(){return"TextPartLanguage"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class HI{constructor(){h(this,"_definitions",new Set)}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach(t=>this._definitions.add(t)):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",(t,i,o)=>{if(!o.consumable.test(i.item,"attribute:linkHref")||!(i.item.is("selection")||o.schema.isInline(i.item)))return;const s=o.writer,r=s.document.selection;for(const a of this._definitions){const l=s.createAttributeElement("a",a.attributes,{priority:5});a.classes&&s.addClass(a.classes,l);for(const c in a.styles)s.setStyle(c,a.styles[c],l);s.setCustomProperty("link",!0,l),a.callback(i.attributeNewValue)?i.item.is("selection")?s.wrap(r.getFirstRange(),l):s.wrap(o.mapper.toViewRange(i.range),l):s.unwrap(o.mapper.toViewRange(i.range),l)}},{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",(t,i,{writer:o,mapper:s})=>{const r=s.toViewElement(i.item),a=Array.from(r.getChildren()).find(l=>l.is("element","a"));if(a)for(const l of this._definitions){const c=ri(l.attributes);if(l.callback(i.attributeNewValue)){for(const[u,d]of c)u==="class"?o.addClass(d,a):o.setAttribute(u,d,a);l.classes&&o.addClass(l.classes,a);for(const u in l.styles)o.setStyle(u,l.styles[u],a)}else{for(const[u,d]of c)u==="class"?o.removeClass(d,a):o.removeAttribute(u,a);l.classes&&o.removeClass(l.classes,a);for(const u in l.styles)o.removeStyle(u,a)}}})}}}const $I=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,WI="^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))",jI=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,UI=/^((\w+:(\/{2,})?)|(\W))/i,qI=["https?","ftps?","mailto"],tr="Ctrl+K";function GI(n){return n.is("attributeElement")&&!!n.getCustomProperty("link")}function rf(n,{writer:e}){const t=e.createAttributeElement("a",{href:n},{priority:5});return e.setCustomProperty("link",!0,t),t}function S1(n,e=qI){const t=String(n),i=e.join("|"),o=new RegExp(`${WI.replace("<protocols>",i)}`,"i");return KI(t,o)?t:"#"}function KI(n,e){return!!n.replace($I,"").match(e)}function ZI(n,e){const t={"Open in a new tab":n("Open in a new tab"),Downloadable:n("Downloadable")};return e.forEach(i=>("label"in i&&t[i.label]&&(i.label=t[i.label]),i)),e}function JI(n){const e=[];if(n)for(const[t,i]of Object.entries(n)){const o=Object.assign({},i,{id:`link${T_(t)}`});e.push(o)}return e}function uc(n,e){return n?e.checkAttribute(n.name,"linkHref"):!1}function QI(n){return jI.test(n)}function Mu(n,e){const t=QI(n)?"mailto:":e,i=!!t&&!P1(n);return n&&i?t+n:n}function P1(n){return UI.test(n)}function YI(n){window.open(n,"_blank","noopener")}function hc(n){let e="";for(const t of n.getItems()){if(!t.is("$text")&&!t.is("$textProxy"))return;e+=t.data}return e}class XI extends O{constructor(){super(...arguments),h(this,"manualDecorators",new _e),h(this,"automaticDecorators",new HI)}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||ae(t.getSelectedBlocks());uc(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const o of this.manualDecorators)o.value=this._getDecoratorStateFromModel(o.id)}execute(e,t={},i){const o=this.editor.model,s=o.document.selection,r=[],a=[];for(const l in t)t[l]?r.push(l):a.push(l);o.change(l=>{const c=m=>{l.setAttribute("linkHref",e,m),r.forEach(f=>l.setAttribute(f,!0,m)),a.forEach(f=>l.removeAttribute(f,m))},u=(m,f)=>{const g=hc(m);if(!g)return m;let p=i;if(p||(p=f&&f==g?e:g),p!=g){const _=eV(g,p);let v=0;for(const{offset:E,actual:M,expected:G}of _){const X=E+v,T=l.createRange(m.start.getShiftedBy(X),m.start.getShiftedBy(X+M.length)),F=tV(T,m).getAttributes(),x=Array.from(F).filter(([Ve])=>o.schema.getAttributeProperties(Ve).isFormatting),q=l.createText(G,x);c(q),o.insertContent(q,T),v+=G.length}return l.createRange(m.start,m.start.getShiftedBy(p.length))}},d=m=>{const{plugins:f}=this.editor;if(l.setSelection(m.end),f.has("TwoStepCaretMovement"))f.get("TwoStepCaretMovement")._handleForwardMovement();else for(const g of["linkHref",...r,...a])l.removeSelectionAttribute(g)};if(s.isCollapsed){const m=s.getFirstPosition();if(s.hasAttribute("linkHref")){const f=s.getAttribute("linkHref"),g=Ps(m,"linkHref",f,o),p=u(g,f);c(p||g),p&&d(p)}else if(e!==""){const f=ri(s.getAttributes());f.set("linkHref",e),r.forEach(p=>{f.set(p,!0)});const g=o.insertContent(l.createText(i||e,f),m);d(g)}}else{const m=Array.from(s.getRanges()),f=o.schema.getValidRanges(m,"linkHref"),g=[];for(const v of s.getSelectedBlocks())o.schema.checkAttribute(v,"linkHref")&&g.push(l.createRangeOn(v));const p=g.slice();for(const v of f)this._isRangeToUpdate(v,g)&&p.push(v);const _=m.map(v=>({start:Me.fromPosition(v.start,"toPrevious"),end:Me.fromPosition(v.end,"toNext")}));for(let v of p){const E=(v.start.textNode||v.start.nodeAfter).getAttribute("linkHref");v=u(v,E)||v,c(v)}l.setSelection(_.map(v=>{const E=v.start.toPosition(),M=v.end.toPosition();return v.start.detach(),v.end.detach(),o.createRange(E,M)}))}})}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,o=i.getSelectedElement();return uc(o,t.schema)?o.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}function eV(n,e){const t=oo(n,e),i={equal:0,insert:0,delete:0},o=[];let s="",r="";for(const a of[...t,null])a=="insert"?r+=e[i.equal+i.insert]:a=="delete"?s+=n[i.equal+i.delete]:(s.length||r.length)&&(o.push({offset:i.equal,actual:s,expected:r}),s="",r=""),a&&i[a]++;return o}function tV(n,e){if(!n.isCollapsed)return ae(n.getItems());const t=n.start;return t.textNode?t.textNode:!t.nodeBefore||t.isEqual(e.start)?t.nodeAfter:t.nodeBefore}class iV extends O{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();uc(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,o=e.commands.get("link");t.change(s=>{const r=i.isCollapsed?[Ps(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const a of r)if(s.removeAttribute("linkHref",a),o)for(const l of o.manualDecorators)s.removeAttribute(l.id,a)})}}class nV extends ue(){constructor({id:e,label:t,attributes:i,classes:o,styles:s,defaultValue:r}){super(),h(this,"id"),h(this,"defaultValue"),h(this,"label"),h(this,"attributes"),h(this,"classes"),h(this,"styles"),this.id=e,this.set("value",void 0),this.defaultValue=r,this.label=t,this.attributes=i,this.classes=o,this.styles=s}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const oV="ck-link_selected",af="automatic",sV="manual",rV=/^(https?:)?\/\//;class ks extends w{constructor(e){super(e),h(this,"_linkOpeners",[]),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1,toolbar:["linkPreview","|","editLink","linkProperties","unlink"]})}static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Dr,vb,pt]}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:rf}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(o,s)=>rf(S1(o,t),s)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:o=>o.getAttribute("href")}}),e.commands.add("link",new XI(e)),e.commands.add("unlink",new iV(e));const i=ZI(e.t,JI(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter(o=>o.mode===af)),this._enableManualDecorators(i.filter(o=>o.mode===sV)),e.plugins.get(Dr).registerAttribute("linkHref"),Cb(e,"linkHref","a",oV),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_registerLinkOpener(e){this._linkOpeners.push(e)}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:af,callback:o=>!!o&&rV.test(o),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach(o=>{t.model.schema.extend("$text",{allowAttributes:o.id});const s=new nV(o);i.add(s),t.conversion.for("downcast").attributeToElement({model:s.id,view:(r,{writer:a,schema:l},{item:c})=>{if((c.is("selection")||l.isInline(c))&&r){const u=a.createAttributeElement("a",s.attributes,{priority:5});s.classes&&a.addClass(s.classes,u);for(const d in s.styles)a.setStyle(d,s.styles[d],u);return a.setCustomProperty("link",!0,u),u}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...s._createPattern()},model:{key:s.id}})})}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document,i=o=>{this._linkOpeners.some(s=>s(o))||YI(o)};this.listenTo(t,"click",(o,s)=>{if(!(N.isMac?s.domEvent.metaKey:s.domEvent.ctrlKey))return;let r=s.domTarget;if(r.tagName.toLowerCase()!="a"&&(r=r.closest("a")),!r)return;const a=r.getAttribute("href");a&&(o.stop(),s.preventDefault(),i(a))},{context:"$capture"}),this.listenTo(t,"keydown",(o,s)=>{const r=e.commands.get("link").value;r&&s.keyCode===Z.enter&&s.altKey&&(o.stop(),i(r))})}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",(i,{attributeKeys:o})=>{!o.includes("linkHref")||t.hasAttribute("linkHref")||e.change(s=>{aV(s,lV(e.schema))})})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",(o,s)=>{t.change(r=>{const a=r.createRangeIn(s.content);for(const l of a.getItems())if(l.hasAttribute("linkHref")){const c=Mu(l.getAttribute("linkHref"),i);r.setAttribute("linkHref",c,l)}})})}}function aV(n,e){n.removeSelectionAttribute("linkHref");for(const t of e)n.removeSelectionAttribute(t)}function lV(n){return n.getDefinition("$text").allowAttributes.filter(e=>e.startsWith("link"))}class cV extends P{constructor(e){super(e);const t=this.bindTemplate;this.set({href:void 0,withText:!0}),this.extendTemplate({attributes:{class:["ck-link-toolbar__preview"],href:t.to("href"),target:"_blank",rel:"noopener noreferrer"},on:{click:t.to(i=>{if(this.href){const o=()=>i.preventDefault();this.fire("navigate",this.href,o)}})}}),this.template.tag="a"}}class uV extends A{constructor(e,t){super(e),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"backButtonView"),h(this,"saveButtonView"),h(this,"displayedTextInputView"),h(this,"urlInputView"),h(this,"children"),h(this,"providersListChildren"),h(this,"_validators"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.displayedTextInputView=this._createDisplayedTextInput(),this.urlInputView=this._createUrlInput(),this.providersListChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView()]),this._createFormChildren(),this.listenTo(this.providersListChildren,"add",()=>{this.stopListening(this.providersListChildren,"add"),this.children.add(this._createProvidersListView())}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-link-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),Ri({view:this}),[this.urlInputView,this.saveButtonView,...this.providersListChildren,this.backButtonView,this.displayedTextInputView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new P(this.locale);return t.set({label:e("Insert"),tooltip:!1,withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Link")});return t.children.add(this.backButtonView,0),t}_createProvidersListView(){const e=new En(this.locale);return e.extendTemplate({attributes:{class:["ck-link-form__providers-list"]}}),e.items.bindTo(this.providersListChildren).using(t=>{const i=new Nt(this.locale);return i.children.add(t),i}),e}_createDisplayedTextInput(){const e=this.locale.t,t=new Te(this.locale,nt);return t.label=e("Displayed text"),t.class="ck-labeled-field-view_full-width",t}_createUrlInput(){const e=this.locale.t,t=new Te(this.locale,nt);return t.fieldView.inputMode="url",t.label=e("Link URL"),t.class="ck-labeled-field-view_full-width",t}_createFormChildren(){this.children.add(new $e(this.locale,{children:[this.displayedTextInputView],class:["ck-form__row_large-top-padding"]})),this.children.add(new $e(this.locale,{children:[this.urlInputView,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding","ck-form__row_large-bottom-padding"]}))}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}class hV extends A{constructor(e){super(e),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"backButtonView"),h(this,"listView"),h(this,"listChildren"),h(this,"emptyListInformation"),h(this,"children"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this.listChildren=this.createCollection(),this.backButtonView=this._createBackButton(),this.listView=this._createListView(),this.emptyListInformation=this._createEmptyLinksListItemView(),this.children=this.createCollection([this._createHeaderView(),this.emptyListInformation]),this.set("title",""),this.set("emptyListPlaceholder",""),this.set("hasItems",!1),this.listenTo(this.listChildren,"change",()=>{this.hasItems=this.listChildren.length>0}),this.on("change:hasItems",(t,i,o)=>{o?(this.children.remove(this.emptyListInformation),this.children.add(this.listView)):(this.children.remove(this.listView),this.children.add(this.emptyListInformation))}),this.keystrokes.set("Esc",(t,i)=>{this.fire("cancel"),i()}),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-providers"],tabindex:"-1"},children:this.children})}render(){super.render(),[this.listView,this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createListView(){const e=new En(this.locale);return e.extendTemplate({attributes:{class:["ck-link-providers__list"]}}),e.items.bindTo(this.listChildren).using(t=>{const i=new Nt(this.locale);return i.children.add(t),i}),e}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=new Jt(this.locale);return e.bind("label").to(this,"title"),e.children.add(this.backButtonView,0),e}_createEmptyLinksListItemView(){const e=new A(this.locale);return e.setTemplate({tag:"p",attributes:{class:["ck","ck-link__empty-list-info"]},children:[{text:this.bindTemplate.to("emptyListPlaceholder")}]}),e}}class dV extends A{constructor(e){super(e),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"backButtonView"),h(this,"children"),h(this,"listChildren"),h(this,"_focusables",new Ie),h(this,"_focusCycler"),this.backButtonView=this._createBackButton(),this.listChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView(),this._createListView()]),this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-properties"],tabindex:"-1"},children:this.children}),this.keystrokes.set("Esc",(t,i)=>{this.fire("back"),i()})}render(){super.render(),[...this.listChildren,this.backButtonView].forEach(e=>{this._focusables.add(e),this.focusTracker.add(e.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new P(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:li,tooltip:!0}),t.delegate("execute").to(this,"back"),t}_createHeaderView(){const e=this.locale.t,t=new Jt(this.locale,{label:e("Link properties")});return t.children.add(this.backButtonView,0),t}_createListView(){const e=new En(this.locale);return e.extendTemplate({attributes:{class:["ck-link__list"]}}),e.items.bindTo(this.listChildren).using(t=>{const i=new Nt(this.locale);return i.children.add(t),i}),e}}class mV extends P{constructor(e){super(e),h(this,"arrowView"),this.set({withText:!0}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-link__button"]}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new hi;return e.content=ww,e}}const Xt="link-ui";class fV extends w{constructor(){super(...arguments),h(this,"toolbarView",null),h(this,"formView",null),h(this,"linkProviderItemsView",null),h(this,"propertiesView",null),h(this,"_balloon"),h(this,"_linksProviders",new _e)}static get requires(){return[Ue,ks]}static get pluginName(){return"LinkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;this.set("selectedLinkableText",void 0),e.editing.view.addObserver(ew),this._balloon=e.plugins.get(Ue),this._registerComponents(),this._registerEditingOpeners(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:Xt,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:Xt,view:(i,{writer:o})=>{if(!i.markerRange.isCollapsed)return null;const s=o.createUIElement("span");return o.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],s),s}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:tr},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.propertiesView&&this.propertiesView.destroy(),this.formView&&this.formView.destroy(),this.toolbarView&&this.toolbarView.destroy(),this.linkProviderItemsView&&this.linkProviderItemsView.destroy()}registerLinksListProvider(e){const t=this._linksProviders.filter(i=>(i.order||0)<=(e.order||0)).length;this._linksProviders.add(e,t)}_createViews(){const e=this.editor.commands.get("link");this.toolbarView=this._createToolbarView(),this.formView=this._createFormView(),e.manualDecorators.length&&(this.propertiesView=this._createPropertiesView()),this._enableUserBalloonInteractions()}_createToolbarView(){const e=this.editor,t=new Ei(e.locale),i=e.commands.get("link");t.class="ck-link-toolbar";let o=e.config.get("link.toolbar");return i.manualDecorators.length||(o=o.filter(s=>s!=="linkProperties")),t.fillFromConfig(o,e.ui.componentFactory),t.keystrokes.set("Esc",(s,r)=>{this._hideUI(),r()}),t.keystrokes.set(tr,(s,r)=>{this._addFormView(),r()}),e.ui.addToolbar(t,{isContextual:!0,beforeFocus:()=>{this._getSelectedLinkElement()&&!this._isToolbarVisible&&this._showUI(!0)},afterBlur:()=>{this._hideUI(!1)}}),t}_createFormView(){const e=this.editor,t=e.locale.t,i=e.commands.get("link"),o=e.config.get("link.defaultProtocol"),s=new(ho(uV))(e.locale,gV(e));return s.displayedTextInputView.bind("isEnabled").to(this,"selectedLinkableText",r=>r!==void 0),s.urlInputView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("isEnabled").to(i,"isEnabled"),s.saveButtonView.bind("label").to(i,"value",r=>t(r?"Update":"Insert")),this.listenTo(s,"submit",()=>{if(s.isValid()){const r=s.urlInputView.fieldView.element.value,a=Mu(r,o),l=s.displayedTextInputView.fieldView.element.value;e.execute("link",a,this._getDecoratorSwitchesState(),l!==this.selectedLinkableText?l:void 0),this._closeFormView()}}),this.listenTo(s.urlInputView,"change:errorText",()=>{e.ui.update()}),this.listenTo(s,"cancel",()=>{this._closeFormView()}),s.keystrokes.set("Esc",(r,a)=>{this._closeFormView(),a()}),s.providersListChildren.bindTo(this._linksProviders).using(r=>this._createLinksListProviderButton(r)),s}_createLinkProviderListView(e){return e.getListItems().map(({href:t,label:i,icon:o})=>{const s=new P;return s.set({label:i,icon:o,tooltip:!1,withText:!0}),s.on("execute",()=>{this.formView.resetFormStatus(),this.formView.urlInputView.fieldView.value=t,this.editor.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),s})}_createLinkProviderItemsView(e){const t=this.editor,i=t.locale.t,o=new hV(t.locale),{emptyListPlaceholder:s,label:r}=e;return o.emptyListPlaceholder=s||i("No links available"),o.title=r,this.listenTo(o,"cancel",()=>{t.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()}),o}_createPropertiesView(){const e=this.editor,t=this.editor.commands.get("link"),i=new(ho(dV))(e.locale);return this.listenTo(i,"back",()=>{e.editing.view.focus(),this._removePropertiesView()}),i.listChildren.bindTo(t.manualDecorators).using(o=>{const s=new Ji(e.locale);return s.set({label:o.label,withText:!0}),s.bind("isOn").toMany([o,t],"value",(r,a)=>a===void 0&&r===void 0?!!o.defaultValue:!!r),s.on("execute",()=>{o.set("value",!s.isOn),e.execute("link",t.value,this._getDecoratorSwitchesState())}),s}),i}_getDecoratorSwitchesState(){const e=this.editor.commands.get("link");return Array.from(e.manualDecorators).reduce((t,i)=>{const o=e.value===void 0&&i.value===void 0?i.defaultValue:i.value;return{...t,[i.id]:!!o}},{})}_registerEditingOpeners(){this.editor.plugins.get(ks)._registerLinkOpener(e=>{const t=this._getLinkProviderLinkByHref(e);if(!t)return!1;const{item:i,provider:o}=t;return o.navigate?o.navigate(i):!1})}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("link",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:link",()=>{const t=this._createButton(ve);return t.set({role:"menuitemcheckbox"}),t}),e.ui.componentFactory.add("linkPreview",t=>{const i=new cV(t),o=e.config.get("link.allowedProtocols"),s=e.commands.get("link"),r=t.t;i.bind("isEnabled").to(s,"value",l=>!!l),i.bind("href").to(s,"value",l=>l&&S1(l,o));const a=l=>{if(!l){i.label=void 0,i.icon=void 0,i.tooltip=r("Open link in new tab");return}const c=this._getLinkProviderLinkByHref(l);if(c){const{label:u,tooltip:d,icon:m}=c.item;i.label=u,i.tooltip=d||!1,i.icon=m}else i.label=l,i.icon=void 0,i.tooltip=r("Open link in new tab")};return a(s.value),this.listenTo(s,"change:value",(l,c,u)=>{a(u)}),this.listenTo(i,"navigate",(l,c,u)=>{const d=this._getLinkProviderLinkByHref(c);if(!d)return;const{provider:m,item:f}=d,{navigate:g}=m;g&&g(f)&&(l.stop(),u())}),i}),e.ui.componentFactory.add("unlink",t=>{const i=e.commands.get("unlink"),o=new P(t),s=t.t;return o.set({label:s("Unlink"),icon:kA,tooltip:!0}),o.bind("isEnabled").to(i),this.listenTo(o,"execute",()=>{e.execute("unlink"),this._hideUI()}),o}),e.ui.componentFactory.add("editLink",t=>{const i=e.commands.get("link"),o=new P(t),s=t.t;return o.set({label:s("Edit link"),icon:kw,tooltip:!0}),o.bind("isEnabled").to(i),this.listenTo(o,"execute",()=>{this._addFormView()}),o}),e.ui.componentFactory.add("linkProperties",t=>{const i=e.commands.get("link"),o=new P(t),s=t.t;return o.set({label:s("Link properties"),icon:lA,tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled",i,"value",i,"manualDecorators",(r,a,l)=>r&&!!a&&l.length>0),this.listenTo(o,"execute",()=>{this._addPropertiesView()}),o})}_createLinksListProviderButton(e){const t=this.editor.locale,i=new mV(t);return i.set({label:e.label}),this.listenTo(i,"execute",()=>{this._showLinksProviderView(e)}),i}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("link"),s=new e(t.locale),r=i.t;return s.set({label:r("Link"),icon:LC,keystroke:tr,isToggleable:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",a=>!!a),this.listenTo(s,"execute",()=>{t.editing.view.scrollToTheSelection(),this._showUI(!0),this._getSelectedLinkElement()&&this._addFormView()}),s}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),e.keystrokes.set(tr,(i,o)=>{o(),e.commands.get("link").isEnabled&&(e.editing.view.scrollToTheSelection(),this._showUI(!0))})}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",(e,t)=>{this._isToolbarVisible&&!this.toolbarView.focusTracker.isFocused&&(this.toolbarView.focus(),t())},{priority:"high"}),this.editor.keystrokes.set("Esc",(e,t)=>{this._isUIVisible&&(this._hideUI(),t())}),$t({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideUI(!1)}})}_addToolbarView(){this.toolbarView||this._createViews(),!this._isToolbarInPanel&&this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this.formView.backButtonView.isVisible=e.isEnabled&&!!e.value,this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.selectedLinkableText=this._getSelectedLinkableText(),this.formView.displayedTextInputView.fieldView.value=this.selectedLinkableText||"",this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_addPropertiesView(){this.propertiesView||this._createViews(),!this._arePropertiesInPanel&&(this.propertiesView.disableCssTransitions(),this._balloon.add({view:this.propertiesView,position:this._getBalloonPositionData()}),this.propertiesView.enableCssTransitions(),this.propertiesView.focus())}_showLinksProviderView(e){this.linkProviderItemsView&&this._removeLinksProviderView(),this.linkProviderItemsView=this._createLinkProviderItemsView(e),this._addLinkProviderItemsView(e)}_addLinkProviderItemsView(e){this.linkProviderItemsView.listChildren.clear(),this.linkProviderItemsView.listChildren.addMany(this._createLinkProviderListView(e)),this._balloon.add({view:this.linkProviderItemsView,position:this._getBalloonPositionData()}),this.linkProviderItemsView.focus()}_closeFormView(){const e=this.editor.commands.get("link");this.selectedLinkableText=void 0,e.value!==void 0?this._removeFormView():this._hideUI()}_removePropertiesView(){this._arePropertiesInPanel&&this._balloon.remove(this.propertiesView)}_removeLinksProviderView(){this._isLinksListInPanel&&this._balloon.remove(this.linkProviderItemsView)}_removeFormView(e=!0){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.displayedTextInputView.fieldView.reset(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._isToolbarVisible?this._addFormView():this._addToolbarView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addToolbarView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(e=!0){const t=this.editor;this._isUIInPanel&&(this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e&&t.editing.view.focus(),this._removeLinksProviderView(),this._removePropertiesView(),this._removeFormView(e),this._isToolbarInPanel&&this._balloon.remove(this.toolbarView),this._hideFakeVisualSelection())}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),o=r();const s=()=>{const a=this._getSelectedLinkElement(),l=r();i&&!a||!i&&l!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=a,o=l};function r(){return t.selection.focus.getAncestors().reverse().find(a=>a.is("element"))}this.listenTo(e.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _arePropertiesInPanel(){return!!this.propertiesView&&this._balloon.hasView(this.propertiesView)}get _isLinksListInPanel(){return!!this.linkProviderItemsView&&this._balloon.hasView(this.linkProviderItemsView)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isToolbarInPanel(){return!!this.toolbarView&&this._balloon.hasView(this.toolbarView)}get _isPropertiesVisible(){return!!this.propertiesView&&this._balloon.visibleView===this.propertiesView}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}get _isToolbarVisible(){return!!this.toolbarView&&this._balloon.visibleView===this.toolbarView}get _isUIInPanel(){return this._arePropertiesInPanel||this._isLinksListInPanel||this._isFormInPanel||this._isToolbarInPanel}get _isUIVisible(){return this._isPropertiesVisible||this._isLinksListInPanel||this._isFormVisible||this._isToolbarVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;if(this.editor.model.markers.has(Xt)){const i=this.editor.editing.mapper.markerNameToElements(Xt);if(i){const o=Array.from(i),s=e.createRange(e.createPositionBefore(o[0]),e.createPositionAfter(o[o.length-1]));return{target:e.domConverter.viewRangeToDom(s)}}}return{target:()=>{const i=this._getSelectedLinkElement();return i?e.domConverter.mapViewToDom(i):e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&Se(i))return vl(t.getFirstPosition());{const o=t.getFirstRange().getTrimmed(),s=vl(o.start),r=vl(o.end);return!s||s!=r?null:e.createRangeIn(s).getTrimmed().isEqual(o)?s:null}}_getSelectedLinkableText(){const e=this.editor.model,t=this.editor.editing,i=this._getSelectedLinkElement();if(!i)return hc(e.document.selection.getFirstRange());const o=t.view.createRangeOn(i),s=t.mapper.toModelRange(o);return hc(s)}_getLinkProviderLinkByHref(e){if(!e)return null;for(const t of this._linksProviders){const i=t.getItem?t.getItem(e):t.getListItems().find(o=>o.href===e);if(i)return{provider:t,item:i}}return null}_showFakeVisualSelection(){const e=this.editor.model;e.change(t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(Xt))t.updateMarker(Xt,{range:i});else if(i.start.isAtEnd){const o=i.start.getLastMatchingPosition(({item:s})=>!e.schema.isContent(s),{boundaries:i});t.addMarker(Xt,{usingOperation:!1,affectsData:!1,range:t.createRange(o,i.end)})}else t.addMarker(Xt,{usingOperation:!1,affectsData:!1,range:i})})}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(Xt)&&e.change(t=>{t.removeMarker(Xt)})}}function vl(n){return n.getAncestors().find(e=>GI(e))||null}function gV(n){const e=n.t,t=n.config.get("link.allowCreatingEmptyLinks");return[i=>{if(!t&&!i.url.length)return e("Link URL must not be empty.")}]}const pV=4,I1=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63}))|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i"),wV=2;class V1 extends w{static get requires(){return[en,ks]}static get pluginName(){return"AutoLink"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.model.document.selection;e.on("change:range",()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")}),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?Ps(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,o=i.document.selection,s=o.getFirstPosition(),r=o.getLastPosition();let a=t.getJoined(this._expandLinkRange(i,s)||t);a&&(a=a.getJoined(this._expandLinkRange(i,r)||t)),a&&(a.start.isBefore(s)||a.end.isAfter(r))&&e.setSelection(a)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,o=e.plugins.get("ClipboardPipeline"),s=e.commands.get("link");o.on("inputTransformation",(r,a)=>{if(!this.isEnabled||!s.isEnabled||i.isCollapsed||a.method!=="paste"||i.rangeCount>1)return;const l=i.getFirstRange(),c=a.dataTransfer.getData("text/plain");if(!c)return;const u=c.match(I1);u&&u[2]===c&&(t.change(d=>{this._selectEntireLinks(d,l),s.execute(c)}),r.stop())},{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new vu(e.model,i=>{let o=i;if(!bV(o))return;o=o.slice(0,-1),"!.:,;?".includes(o[o.length-1])&&(o=o.slice(0,-1));const s=lf(o);if(s)return{url:s,removedTrailingCharacters:i.length-o.length}});t.on("matched:data",(i,o)=>{const{batch:s,range:r,url:a,removedTrailingCharacters:l}=o;if(!s.isTyping)return;const c=r.end.getShiftedBy(-l),u=c.getShiftedBy(-a.length),d=e.model.createRange(u,c);this._applyAutoLink(a,d)}),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",()=>{var o;const s=t.document.selection.getFirstPosition();let r;(o=s.parent.previousSibling)!=null&&o.is("element")?r=t.createRangeIn(s.parent.previousSibling):r=t.createRange(t.createPositionAt(s.parent,0),s),this._checkAndApplyAutoLinkOnRange(r)})}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",()=>{const o=t.document.selection.getFirstPosition(),s=t.createRange(t.createPositionAt(o.parent,0),o.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(s)})}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:o}=kb(e,t),s=lf(i);if(s){const r=t.createRange(o.end.getShiftedBy(-s.length),o.end);this._applyAutoLink(s,r)}}_applyAutoLink(e,t){const i=this.editor.model,o=this.editor.config.get("link.defaultProtocol"),s=Mu(e,o);!this.isEnabled||!_V(t,i)||!P1(s)||vV(t)||this._persistAutoLink(s,t)}_persistAutoLink(e,t){const i=this.editor.model,o=this.editor.plugins.get("Delete");i.enqueueChange(s=>{s.setAttribute("linkHref",e,t),i.enqueueChange(()=>{o.requestUndoOnBackspace()})})}}function bV(n){return n.length>pV&&n[n.length-1]===" "&&n[n.length-2]!==" "}function lf(n){const e=I1.exec(n);return e?e[wV]:null}function _V(n,e){return e.schema.checkAttributeInSelection(e.createSelection(n),"linkHref")}function vV(n){const e=n.start.nodeAfter;return!!e&&e.hasAttribute("linkHref")}class yV extends w{static get requires(){return[ks,fV,V1]}static get pluginName(){return"Link"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Dt{constructor(e,t){h(this,"_startElement"),h(this,"_referenceIndent"),h(this,"_isForward"),h(this,"_includeSelf"),h(this,"_sameAttributes"),h(this,"_sameIndent"),h(this,"_lowerIndent"),h(this,"_higherIndent"),this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward=t.direction=="forward",this._includeSelf=!!t.includeSelf,this._sameAttributes=he(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){const i=new this(e,t)[Symbol.iterator]();return ae(i)}*[Symbol.iterator](){const e=[];for(const{node:t}of new Is(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(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(o=>t.getAttribute(o)!==this._startElement.getAttribute(o)))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}class Is{constructor(e,t="forward"){h(this,"_node"),h(this,"_isForward"),h(this,"_previousNodesByIndent",[]),h(this,"_previous",null),h(this,"_previousNodeIndent",null),this._node=e,this._isForward=t==="forward"}[Symbol.iterator](){return this}next(){if(!be(this._node))return{done:!0,value:void 0};const e=this._node.getAttribute("listIndent");let t=null;if(this._previous){const o=this._previousNodeIndent;e>o?this._previousNodesByIndent[o]=this._previous:e<o?(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 kV{constructor(e){h(this,"_listHead"),this._listHead=e}[Symbol.iterator](){return new Is(this._listHead)}}class go{static next(){return ze()}}function be(n){return!!n&&n.is("element")&&n.hasAttribute("listItemId")}function po(n,e={}){return[...Qi(n,{...e,direction:"backward"}),...Qi(n,{...e,direction:"forward"})]}function Qi(n,e={}){const t=e.direction=="forward",i=Array.from(new Dt(n,{...e,includeSelf:t,sameIndent:!0,sameAttributes:"listItemId"}));return t?i:i.reverse()}function CV(n){return Array.from(new Dt(n,{direction:"forward",higherIndent:!0}))}function R1(n,e){const t=new Dt(n,{sameIndent:!0,sameAttributes:"listType",...e}),i=new Dt(n,{sameIndent:!0,sameAttributes:"listType",includeSelf:!0,direction:"forward",...e});return[...Array.from(t).reverse(),...i]}function Pi(n){return!Dt.first(n,{sameIndent:!0,sameAttributes:"listItemId"})}function cf(n){return!Dt.first(n,{direction:"forward",sameIndent:!0,sameAttributes:"listItemId"})}function Vs(n,e={}){n=he(n);const t=e.withNested!==!1,i=new Set;for(const o of n)for(const s of po(o,{higherIndent:t}))i.add(s);return Pn(i)}function va(n){n=he(n);const e=new Set;for(const t of n)for(const i of R1(t))e.add(i);return Pn(e)}function Lu(n,e){const t=Qi(n,{direction:"forward"}),i=go.next();for(const o of t)e.setAttribute("listItemId",i,o);return t}function dc(n,e,t){const i={};for(const[s,r]of e.getAttributes())s.startsWith("list")&&(i[s]=r);const o=Qi(n,{direction:"forward"});for(const s of o)t.setAttributes(i,s);return o}function mc(n,e,{expand:t,indentBy:i=1}={}){n=he(n);const o=t?Vs(n):n;for(const s of o){const r=s.getAttribute("listIndent")+i;r<0?ya(s,e):e.setAttribute("listIndent",r,s)}return o}function AV(n,e){n=he(n);const t=Vs(n),i=new Set,o=Math.min(...t.map(r=>r.getAttribute("listIndent"))),s=new Map;for(const r of t)s.set(r,Dt.first(r,{lowerIndent:!0}));for(const r of t){if(i.has(r))continue;i.add(r);const a=r.getAttribute("listIndent")-1;if(a<0){ya(r,e);continue}if(r.getAttribute("listIndent")==o){const l=TV(r,s.get(r),e);for(const c of l)i.add(c);if(l.length)continue}e.setAttribute("listIndent",a,r)}return Pn(i)}function ya(n,e){n=he(n);for(const t of n)t.is("element","listItem")&&e.rename(t,"paragraph");for(const t of n)for(const i of t.getAttributeKeys())i.startsWith("list")&&e.removeAttribute(i,t);return n}function Cs(n){if(!n.length)return!1;const e=n[0].getAttribute("listItemId");return e?!n.some(t=>t.getAttribute("listItemId")!=e):!1}function xV(n,e){const t=[];let i=Number.POSITIVE_INFINITY;for(const{node:o}of new Is(n.nextSibling)){const s=o.getAttribute("listIndent");if(s==0)break;s<i&&(i=s);const r=s-i;e.setAttribute("listIndent",r,o),t.push(o)}return t}function Pn(n){return Array.from(n).filter(e=>e.root.rootName!=="$graveyard").sort((e,t)=>e.index-t.index)}function As(n){const e=n.document.selection.getSelectedElement();return e&&n.schema.isObject(e)&&n.schema.isBlock(e)?e:null}function yl(n,e){return e.checkChild(n.parent,"listItem")&&e.checkChild(n,"$text")&&!e.isObject(n)}function qr(n){return n=="numbered"||n=="customNumbered"}function TV(n,e,t){return Qi(e,{direction:"forward"}).pop().index>n.index?dc(n,e,t):[]}class uf extends O{constructor(e,t){super(e),h(this,"_direction"),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=hf(e.document.selection);e.change(i=>{const o=[];Cs(t)&&!Pi(t[0])?(this._direction=="forward"&&o.push(...mc(t,i)),o.push(...Lu(t[0],i))):this._direction=="forward"?o.push(...mc(t,i,{expand:!0})):o.push(...AV(t,i));for(const s of o){if(!s.hasAttribute("listType"))continue;const r=Dt.first(s,{sameIndent:!0});r&&i.setAttribute("listType",r.getAttribute("listType"),s)}this._fireAfterExecute(o)})}_fireAfterExecute(e){this.fire("afterExecute",Pn(new Set(e)))}_checkEnabled(){let e=hf(this.editor.model.document.selection),t=e[0];if(!t)return!1;if(this._direction=="backward"||Cs(e)&&!Pi(e[0]))return!0;e=Vs(e),t=e[0];const i=Dt.first(t,{sameIndent:!0});return i?i.getAttribute("listType")==t.getAttribute("listType"):!1}}function hf(n){const e=Array.from(n.getSelectedBlocks()),t=e.findIndex(i=>!be(i));return t!=-1&&(e.length=t),e}class Go extends O{constructor(e,t,i={}){super(e),h(this,"type"),h(this,"_listWalkerOptions"),this.type=t,this._listWalkerOptions=i.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,o=As(t),s=Array.from(i.selection.getSelectedBlocks()).filter(a=>t.schema.checkAttribute(a,"listType")||yl(a,t.schema)),r=e.forceValue!==void 0?!e.forceValue:this.value;t.change(a=>{if(r){const l=s[s.length-1],c=Qi(l,{direction:"forward"}),u=[];c.length>1&&u.push(...Lu(c[1],a)),u.push(...ya(s,a)),u.push(...xV(l,a)),this._fireAfterExecute(u)}else if((o||i.selection.isCollapsed)&&be(s[0])){const l=R1(o||s[0],this._listWalkerOptions);for(const c of l)a.setAttributes({...e.additionalAttributes,listType:this.type},c);this._fireAfterExecute(l)}else{const l=[];for(const c of s)if(!c.hasAttribute("listType"))!c.is("element","listItem")&&yl(c,t.schema)&&a.rename(c,"listItem"),a.setAttributes({...e.additionalAttributes,listIndent:0,listItemId:go.next(),listType:this.type},c),l.push(c);else for(const u of Vs(c,{withNested:!1}))u.getAttribute("listType")!=this.type&&(a.setAttributes({...e.additionalAttributes,listType:this.type},u),l.push(u));this._fireAfterExecute(l)}})}_fireAfterExecute(e){this.fire("afterExecute",Pn(new Set(e)))}_getValue(){const e=this.editor.model.document.selection,t=Array.from(e.getSelectedBlocks());if(!t.length)return!1;for(const i of t)if(i.getAttribute("listType")!=this.type)return!1;return!0}_checkEnabled(){const e=this.editor.model,t=e.schema,i=e.document.selection,o=Array.from(i.getSelectedBlocks());if(!o.length)return!1;if(this.value)return!0;for(const s of o)if(t.checkAttribute(s,"listType")||yl(s,t))return!0;return!1}}class df extends O{constructor(e,t){super(e),h(this,"_direction"),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute({shouldMergeOnBlocksContentLevel:e=!1}={}){const t=this.editor.model,i=t.document.selection,o=[];t.change(s=>{const{firstElement:r,lastElement:a}=this._getMergeSubjectElements(i,e),l=r.getAttribute("listIndent")||0,c=a.getAttribute("listIndent"),u=a.getAttribute("listItemId");if(l!=c){const d=CV(a);o.push(...mc([a,...d],s,{indentBy:l-c,expand:l<c}))}if(e){let d=i;i.isCollapsed&&(d=s.createSelection(s.createRange(s.createPositionAt(r,"end"),s.createPositionAt(a,0)))),t.deleteContent(d,{doNotResetEntireContent:i.isCollapsed});const m=d.getLastPosition().parent,f=m.nextSibling;o.push(m),f&&f!==a&&f.getAttribute("listItemId")==u&&o.push(...dc(f,m,s))}else o.push(...dc(a,r,s));this._fireAfterExecute(o)})}_fireAfterExecute(e){this.fire("afterExecute",Pn(new Set(e)))}_checkEnabled(){const e=this.editor.model,t=e.document.selection,i=As(e);if(t.isCollapsed||i){const o=i||t.getFirstPosition().parent;if(!be(o))return!1;const s=this._direction=="backward"?o.previousSibling:o.nextSibling;if(!s||Cs([o,s]))return!1}else{const o=t.getLastPosition(),s=t.getFirstPosition();if(o.parent===s.parent||!be(o.parent))return!1}return!0}_getMergeSubjectElements(e,t){const i=this.editor.model,o=As(i);let s,r;if(e.isCollapsed||o){const a=o||e.getFirstPosition().parent,l=Pi(a);this._direction=="backward"?(r=a,l&&!t?s=Dt.first(a,{sameIndent:!0,lowerIndent:!0}):s=a.previousSibling):(s=a,r=a.nextSibling)}else s=e.getFirstPosition().parent,r=e.getLastPosition().parent;return{firstElement:s,lastElement:r}}}class mf extends O{constructor(e,t){super(e),h(this,"_direction"),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){this.editor.model.change(e=>{const t=Lu(this._getStartBlock(),e);this._fireAfterExecute(t)})}_fireAfterExecute(e){this.fire("afterExecute",Pn(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&be(t)&&!Pi(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return this._direction=="before"?e:e.nextSibling}}class EV extends w{static get pluginName(){return"ListUtils"}static get isOfficialPlugin(){return!0}expandListBlocksToCompleteList(e){return va(e)}isFirstBlockOfListItem(e){return Pi(e)}isListItemBlock(e){return be(e)}expandListBlocksToCompleteItems(e,t={}){return Vs(e,t)}isNumberedListType(e){return qr(e)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function SV(n){return n.is("element","ol")||n.is("element","ul")}function fc(n){return n.is("element","li")}function PV(n){let e=0,t=n.parent;for(;t;){if(fc(t))e++;else{const i=t.previousSibling;i&&fc(i)&&e++}t=t.parent}return e}function IV(n,e,t,i=B1(t,e)){return n.createAttributeElement(O1(t),null,{priority:2*e/100-100,id:i})}function VV(n,e,t){return n.createAttributeElement("li",null,{priority:(2*e+1)/100-100,id:t})}function O1(n){return n=="numbered"||n=="customNumbered"?"ol":"ul"}function B1(n,e){return`list-${n}-${e}`}function jt(n,e,t){const i=n.nodeBefore;if(be(i)){let o=i;for(const{node:s}of new Is(o,"backward"))if(o=s,t.has(o)||(t.add(o),e.has(i)))return;e.add(o)}else{const o=n.nodeAfter;be(o)&&e.add(o)}}function RV(n,e){let t=0,i=-1,o=null,s=!1;for(const{node:r}of n){const a=r.getAttribute("listIndent");if(a>t){let l;o===null?(o=a-t,l=t):(o>a&&(o=a),l=a-o),l>i+1&&(l=i+1),e.setAttribute("listIndent",l,r),s=!0,i=l}else o=null,t=a+1,i=a}return s}function OV(n,e,t){const i=new Set;let o=!1;for(const{node:s}of n){if(i.has(s))continue;let r=s.getAttribute("listType"),a=s.getAttribute("listItemId");if(e.has(a)&&(a=go.next()),e.add(a),s.is("element","listItem")){s.getAttribute("listItemId")!=a&&(t.setAttribute("listItemId",a,s),o=!0);continue}for(const l of Qi(s,{direction:"forward"}))i.add(l),l.getAttribute("listType")!=r&&(a=go.next(),r=l.getAttribute("listType")),l.getAttribute("listItemId")!=a&&(t.setAttribute("listItemId",a,l),o=!0)}return o}function BV(){return(n,e,t)=>{const{writer:i,schema:o}=t;if(!e.modelRange)return;const s=Array.from(e.modelRange.getItems({shallow:!0})).filter(d=>o.checkAttribute(d,"listItemId"));if(!s.length)return;const r=go.next(),a=PV(e.viewItem);let l=e.viewItem.parent&&e.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=s[0].getAttribute("listType");c&&(l=c);const u={listItemId:r,listIndent:a,listType:l};for(const d of s)d.hasAttribute("listItemId")||i.setAttributes(u,d);s.length>1&&s[1].getAttribute("listItemId")!=u.listItemId&&t.keepEmptyElement(s[0])}}function MV(n,e,t,i){return()=>{const a=n.document.differ.getChanges(),l=[],c=new Set,u=new Set,d=new Set;for(const m of a)if(m.type=="insert"&&m.name!="$text")jt(m.position,c,d),m.attributes.has("listItemId")?u.add(m.position.nodeAfter):jt(m.position.getShiftedBy(m.length),c,d);else if(m.type=="remove"&&m.attributes.has("listItemId"))jt(m.position,c,d);else if(m.type=="attribute"){const f=m.range.start.nodeAfter;t.includes(m.attributeKey)?(jt(m.range.start,c,d),m.attributeNewValue===null?(jt(m.range.start.getShiftedBy(1),c,d),s(f)&&l.push(f)):u.add(f)):be(f)&&s(f)&&l.push(f)}for(const m of c.values())l.push(...o(m,u));for(const m of new Set(l))e.reconvertItem(m)};function o(a,l){const c=[],u=new Set,d=[];for(const{node:m,previous:f}of new Is(a)){if(u.has(m))continue;const g=m.getAttribute("listIndent");f&&g<f.getAttribute("listIndent")&&(d.length=g+1),d[g]=Object.fromEntries(Array.from(m.getAttributes()).filter(([_])=>t.includes(_)));const p=Qi(m,{direction:"forward"});for(const _ of p)u.add(_),(s(_,p)||r(_,d,l))&&c.push(_)}return c}function s(a,l){const c=e.mapper.toViewElement(a);if(!c)return!1;if(i.fire("checkElement",{modelElement:a,viewElement:c}))return!0;if(!a.is("element","paragraph")&&!a.is("element","listItem"))return!1;const u=L1(a,t,l);return u&&c.is("element","p")?!0:!!(!u&&c.is("element","span"))}function r(a,l,c){if(c.has(a))return!1;const u=e.mapper.toViewElement(a);let d=l.length-1;for(let m=u.parent;!m.is("editableElement");m=m.parent){const f=fc(m),g=SV(m);if(!g&&!f)continue;const p=`checkAttributes:${f?"item":"list"}`;if(i.fire(p,{viewElement:m,modelAttributes:l[d]}))break;if(g&&(d--,d<0))return!1}return!0}}function ff(n,e,t,{dataPipeline:i}={}){const o=$V(n);return(s,r,a)=>{const{writer:l,mapper:c,consumable:u}=a,d=r.item;if(!n.includes(r.attributeKey)||!o(d,u))return;const m=FV(d,c,t);M1(m,l,c),zV(m,l);const f=DV(d,m,e,l,{dataPipeline:i});HV(d,f,e,l)}}function LV(n){return(e,t,i)=>{const{writer:o,mapper:s}=i,r=e.name.split(":")[1];if(!n.checkAttribute(r,"listItemId"))return;const a=s.toViewPosition(t.position),l=t.position.getShiftedBy(t.length),c=s.toViewPosition(l,{isPhantom:!0}),u=o.createRange(a,c).getTrimmed().end.nodeBefore;/* istanbul ignore next -- @preserve */u&&M1(u,o,s)}}function gf(n,{dataPipeline:e}={}){return(t,{writer:i})=>{if(!L1(t,n))return null;if(!e)return i.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=i.createContainerElement("p");return i.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function FV(n,e,t){const i=t.createRangeOn(n);return e.toViewRange(i).getTrimmed().end.nodeBefore}function NV(n,e){return(t,i)=>{if(i.modelPosition.offset>0)return;const o=i.modelPosition.parent;if(!be(o)||!n.some(c=>c.scope=="itemMarker"&&c.canInjectMarkerIntoElement&&c.canInjectMarkerIntoElement(o)))return;const s=i.mapper.toViewElement(o),r=e.createRangeIn(s),a=r.getWalker();let l=r.start;for(const{item:c}of a){if(c.is("element")&&i.mapper.toModelElement(c)||c.is("$textProxy"))break;c.is("element")&&c.getCustomProperty("listItemMarker")&&(l=e.createPositionAfter(c),a.skip(({previousPosition:u})=>!u.isEqual(l)))}i.viewPosition=l}}function M1(n,e,t){for(;n.parent.is("attributeElement")&&n.parent.getCustomProperty("listItemWrapper");)e.unwrap(e.createRangeOn(n),n.parent);const i=[];o(e.createPositionBefore(n).getWalker({direction:"backward"})),o(e.createRangeIn(n).getWalker());for(const s of i)e.remove(s);function o(s){for(const{item:r}of s){if(r.is("element")&&t.toModelElement(r))break;r.is("element")&&r.getCustomProperty("listItemMarker")&&i.push(r)}}}function DV(n,e,t,i,{dataPipeline:o}){let s=i.createRangeOn(e);if(!Pi(n))return s;for(const r of t){if(r.scope!="itemMarker")continue;const a=r.createElement(i,n,{dataPipeline:o});if(!a||(i.setCustomProperty("listItemMarker",!0,a),r.canInjectMarkerIntoElement&&r.canInjectMarkerIntoElement(n)?i.insert(i.createPositionAt(e,0),a):(i.insert(s.start,a),s=i.createRange(i.createPositionBefore(a),i.createPositionAfter(e))),!r.createWrapperElement||!r.canWrapElement))continue;const l=r.createWrapperElement(i,n,{dataPipeline:o});i.setCustomProperty("listItemWrapper",!0,l),r.canWrapElement(n)?s=i.wrap(s,l):(s=i.wrap(i.createRangeOn(a),l),s=i.createRange(s.start,i.createPositionAfter(e)))}return s}function zV(n,e){let t=n.parent;for(;t.is("attributeElement")&&["ul","ol","li"].includes(t.name);){const i=t.parent;e.unwrap(e.createRangeOn(n),t),t=i}}function HV(n,e,t,i){if(!n.hasAttribute("listIndent"))return;const o=n.getAttribute("listIndent");let s=n;for(let r=o;r>=0;r--){const a=VV(i,r,s.getAttribute("listItemId")),l=IV(i,r,s.getAttribute("listType"));for(const c of t)(c.scope=="list"||c.scope=="item")&&s.hasAttribute(c.attributeName)&&c.setAttributeOnDowncast(i,s.getAttribute(c.attributeName),c.scope=="list"?l:a);if(e=i.wrap(e,a),e=i.wrap(e,l),r==0||(s=Dt.first(s,{lowerIndent:!0}),!s))break}}function $V(n){return(e,t)=>{const i=[];for(const o of n)e.hasAttribute(o)&&i.push(`attribute:${o}`);return i.every(o=>t.test(e,o)!==!1)?(i.forEach(o=>t.consume(e,o)),!0):!1}}function L1(n,e,t=po(n)){if(!be(n))return!1;for(const i of n.getAttributeKeys())if(!(i.startsWith("selection:")||i=="htmlEmptyBlock")&&!e.includes(i))return!1;return t.length<2}const br=["listType","listIndent","listItemId"];class xs extends w{constructor(e){super(e),h(this,"_downcastStrategies",[]),e.config.define("list.multiBlock",!0)}static get pluginName(){return"ListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Ao,en,EV,pt]}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new b("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:br}),i?(t.schema.extend("$container",{allowAttributesOf:"$listItem"}),t.schema.extend("$block",{allowAttributesOf:"$listItem"}),t.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):t.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const o of br)t.schema.setAttributeProperties(o,{copyOnReplace:!0});e.commands.add("numberedList",new Go(e,"numbered")),e.commands.add("bulletedList",new Go(e,"bulleted")),e.commands.add("customNumberedList",new Go(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new Go(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new uf(e,"forward")),e.commands.add("outdentList",new uf(e,"backward")),e.commands.add("splitListItemBefore",new mf(e,"before")),e.commands.add("splitListItemAfter",new mf(e,"after")),i&&(e.commands.add("mergeListItemBackward",new df(e,"backward")),e.commands.add("mergeListItemForward",new df(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}getListAttributeNames(){return[...br,...this._downcastStrategies.map(e=>e.attributeName)]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",(o,s)=>{const r=e.model.document.selection;As(e.model)||e.model.change(()=>{const a=r.getFirstPosition();if(r.isCollapsed&&s.direction=="backward"){if(!a.isAtStart)return;const l=a.parent;if(!be(l))return;if(!Dt.first(l,{sameAttributes:"listType",sameIndent:!0})&&l.getAttribute("listIndent")===0)cf(l)||e.execute("splitListItemAfter"),e.execute("outdentList");else{if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:pf(e.model,"backward")})}s.preventDefault(),o.stop()}else{if(r.isCollapsed&&!r.getLastPosition().isAtEnd||!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:pf(e.model,"forward")}),s.preventDefault(),o.stop()}})},{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,o=i.get("enter");this.listenTo(e.editing.view.document,"enter",(s,r)=>{const a=t.document,l=a.selection.getFirstPosition().parent;if(a.selection.isCollapsed&&be(l)&&l.isEmpty&&!r.isSoft){const c=Pi(l),u=cf(l);c&&u?(e.execute("outdentList"),r.preventDefault(),s.stop()):c&&!u?(e.execute("splitListItemAfter"),r.preventDefault(),s.stop()):u&&(e.execute("splitListItemBefore"),r.preventDefault(),s.stop())}},{context:"li"}),this.listenTo(o,"afterExecute",()=>{const s=i.get("splitListItemBefore");if(s.refresh(),!s.isEnabled)return;const r=e.model.document.selection.getLastPosition().parent;po(r).length===2&&s.execute()})}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",(t,i)=>{const o=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(o).isEnabled&&(e.execute(o),i.stopPropagation(),i.preventDefault(),t.stop())},{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),o=e.config.get("list.multiBlock"),s=o?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(a,{writer:l})=>l.createElement(s,{listType:""})}).elementToElement({view:"p",model:(a,{writer:l})=>a.parent&&a.parent.is("element","li")?l.createElement(s,{listType:""}):null,converterPriority:"high"}).add(a=>{a.on("element:li",BV())}),o||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:s,view:gf(i),converterPriority:"high"}).add(a=>{a.on("attribute",ff(i,this._downcastStrategies,t)),a.on("remove",LV(t.schema))}),e.conversion.for("dataDowncast").elementToElement({model:s,view:gf(i,{dataPipeline:!0}),converterPriority:"high"}).add(a=>{a.on("attribute",ff(i,this._downcastStrategies,t,{dataPipeline:!0}))});const r=NV(this._downcastStrategies,e.editing.view);e.editing.mapper.on("modelToViewPosition",r),e.data.mapper.on("modelToViewPosition",r),this.listenTo(t.document,"change:data",MV(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",(a,{viewElement:l,modelAttributes:c})=>{l.id!=c.listItemId&&(a.return=!0,a.stop())}),this.on("checkAttributes:list",(a,{viewElement:l,modelAttributes:c})=>{(l.name!=O1(c.listType)||l.id!=B1(c.listType,c.listIndent))&&(a.return=!0,a.stop())})}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer(i=>WV(e,i,t,this)),this.on("postFixer",(i,{listNodes:o,writer:s})=>{i.return=RV(o,s)||i.return},{priority:"high"}),this.on("postFixer",(i,{listNodes:o,writer:s,seenIds:r})=>{i.return=OV(o,r,s)||i.return},{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",jV(e),{priority:"high"}),this.listenTo(t,"outputTransformation",(i,o)=>{e.change(s=>{const r=Array.from(o.content.getChildren()),a=r[r.length-1];if(r.length>1&&a.is("element")&&a.isEmpty&&r.slice(0,-1).every(be)&&s.remove(a),o.method=="copy"||o.method=="cut"){const l=Array.from(o.content.getChildren());Cs(l)&&ya(l,s)}})})}_setupAccessibilityIntegration(){const e=this.editor,t=e.t;e.accessibility.addKeystrokeInfoGroup({id:"list",label:t("Keystrokes that can be used in a list"),keystrokes:[{label:t("Increase list item indent"),keystroke:"Tab"},{label:t("Decrease list item indent"),keystroke:"Shift+Tab"}]})}}function WV(n,e,t,i){const o=n.document.differ.getChanges(),s=new Set,r=new Set,a=i.editor.config.get("list.multiBlock");let l=!1;for(const u of o){if(u.type=="insert"&&u.name!="$text"){const d=u.position.nodeAfter;if(!n.schema.checkAttribute(d,"listItemId"))for(const m of Array.from(d.getAttributeKeys()))t.includes(m)&&(e.removeAttribute(m,d),l=!0);jt(u.position,r,s),u.attributes.has("listItemId")||jt(u.position.getShiftedBy(u.length),r,s);for(const{item:m,previousPosition:f}of n.createRangeIn(d))be(m)&&jt(f,r,s)}else u.type=="remove"?jt(u.position,r,s):u.type=="attribute"&&t.includes(u.attributeKey)&&(jt(u.range.start,r,s),u.attributeNewValue===null&&jt(u.range.start.getShiftedBy(1),r,s));if(!a&&u.type=="attribute"&&br.includes(u.attributeKey)){const d=u.range.start.nodeAfter;u.attributeNewValue===null&&d&&d.is("element","listItem")?(e.rename(d,"paragraph"),l=!0):u.attributeOldValue===null&&d&&d.is("element")&&d.name!="listItem"&&(e.rename(d,"listItem"),l=!0)}}const c=new Set;for(const u of r.values())l=i.fire("postFixer",{listNodes:new kV(u),listHead:u,writer:e,seenIds:c})||l;return l}function jV(n){return(e,[t,i])=>{const o=t.is("documentFragment")?Array.from(t.getChildren()):[t];if(!o.length)return;const s=(i?n.createSelection(i):n.document.selection).getFirstPosition();let r;if(be(s.parent))r=s.parent;else if(be(s.nodeBefore)&&be(s.nodeAfter))r=s.nodeBefore;else return;n.change(a=>{const l=r.getAttribute("listType"),c=r.getAttribute("listIndent"),u=o[0].getAttribute("listIndent")||0,d=Math.max(c-u,0);for(const m of o){const f=be(m);r.is("element","listItem")&&m.is("element","paragraph")&&a.rename(m,"listItem"),a.setAttributes({listIndent:(f?m.getAttribute("listIndent"):0)+d,listItemId:f?m.getAttribute("listItemId"):go.next(),listType:l},m)}})}}function pf(n,e){const t=n.document.selection;if(!t.isCollapsed)return!As(n);if(e==="forward")return!0;const i=t.getFirstPosition().parent,o=i.previousSibling;return n.schema.isObject(o)?!1:o.isEmpty?!0:Cs([i,o])}function gc(n,e,t,i){n.ui.componentFactory.add(e,()=>{const o=wf(P,n,e,t,i);return o.set({tooltip:!0,isToggleable:!0}),o}),n.ui.componentFactory.add(`menuBar:${e}`,()=>{const o=wf(ve,n,e,t,i);return o.set({role:"menuitemcheckbox",isToggleable:!0}),o})}function wf(n,e,t,i,o){const s=e.commands.get(t),r=new n(e.locale);return r.set({label:i,icon:o}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.on("execute",()=>{e.execute(t),e.editing.view.focus()}),r}class UV extends w{static get pluginName(){return"ListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||gc(this.editor,"numberedList",e("Numbered List"),su),this.editor.ui.componentFactory.has("bulletedList")||gc(this.editor,"bulletedList",e("Bulleted List"),ou)}}class qV extends w{static get requires(){return[xs,UV]}static get pluginName(){return"List"}static get isOfficialPlugin(){return!0}}class GV extends O{refresh(){const e=this._getValue();this.value=e,this.isEnabled=e!=null}execute({startIndex:e=1}={}){const t=this.editor.model,i=t.document;let o=Array.from(i.selection.getSelectedBlocks()).filter(s=>be(s)&&qr(s.getAttribute("listType")));o=va(o),t.change(s=>{for(const r of o)s.setAttribute("listStart",e>=0?e:1,r)})}_getValue(){const e=this.editor.model.document,t=ae(e.selection.getSelectedBlocks());return t&&be(t)&&qr(t.getAttribute("listType"))?t.getAttribute("listStart"):null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const F1={},N1={},D1={},z1=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:n,typeAttribute:e,listType:t}of z1)F1[n]=t,N1[n]=e,e&&(D1[e]=n);function H1(){return z1.map(n=>n.listStyle)}function Fu(n){return F1[n]||null}function $1(n){return D1[n]||null}function pc(n){return N1[n]||null}function KV(n){switch(n){case"lower-alpha":return"lower-latin";case"upper-alpha":return"upper-latin";default:return n}}class ZV extends O{constructor(e,t,i){super(e),h(this,"defaultType"),h(this,"_supportedTypes"),this.defaultType=t,this._supportedTypes=i}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document;t.change(o=>{this._tryToConvertItemsToList(e);let s=Array.from(i.selection.getSelectedBlocks()).filter(r=>r.hasAttribute("listType"));if(s.length){s=va(s);for(const r of s)o.setAttribute("listStyle",e.type||this.defaultType,r)}})}isStyleTypeSupported(e){return this._supportedTypes?this._supportedTypes.includes(e):!0}_getValue(){const e=ae(this.editor.model.document.selection.getSelectedBlocks());return be(e)?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=Fu(e.type);if(!t)return;const i=this.editor,o=`${t}List`;i.commands.get(o).value||i.execute(o)}}class JV extends O{refresh(){const e=this._getValue();this.value=e,this.isEnabled=e!=null}execute(e={}){const t=this.editor.model,i=t.document;let o=Array.from(i.selection.getSelectedBlocks()).filter(s=>be(s)&&s.getAttribute("listType")=="numbered");o=va(o),t.change(s=>{for(const r of o)s.setAttribute("listReversed",!!e.reversed,r)})}_getValue(){const e=this.editor.model.document,t=ae(e.selection.getSelectedBlocks());return be(t)&&t.getAttribute("listType")=="numbered"?t.getAttribute("listReversed"):null}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function bf(n){return(e,t,i)=>{const{writer:o,schema:s,consumable:r}=i;if(r.test(t.viewItem,n.viewConsumables)===!1)return;t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor));let a=!1;for(const l of t.modelRange.getItems({shallow:!0}))s.checkAttribute(l,n.attributeName)&&n.appliesToListItem(l)&&(l.hasAttribute(n.attributeName)||(o.setAttribute(n.attributeName,n.getAttributeOnUpcast(t.viewItem),l),a=!0));a&&r.consume(t.viewItem,n.viewConsumables)}}class QV extends w{static get pluginName(){return"ListPropertiesUtils"}static get isOfficialPlugin(){return!0}getAllSupportedStyleTypes(){return H1()}getListTypeFromListStyleType(e){return Fu(e)}getListStyleTypeFromTypeAttribute(e){return $1(e)}getTypeAttributeFromListStyleType(e){return pc(e)}}function W1(n){const{startIndex:e,reversed:t,styles:i}=n;return{styles:YV(i),startIndex:e||!1,reversed:t||!1}}function YV(n){const e={listTypes:["bulleted","numbered"],useAttribute:!1};return n===!0||(n?Array.isArray(n)||typeof n=="string"?e.listTypes=he(n):(e.listTypes=n.listTypes?he(n.listTypes):e.listTypes,e.useAttribute=!!n.useAttribute,n.listStyleTypes&&(e.listStyleTypes=n.listStyleTypes)):e.listTypes=[]),e}const Ho="default";class XV extends w{static get requires(){return[xs,QV]}static get pluginName(){return"ListPropertiesEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("list.properties",{styles:!0,startIndex:!1,reversed:!1})}init(){const e=this.editor,t=e.model,i=e.plugins.get(xs),o=e.config.get("list.properties"),s=e7(o);for(const r of s)r.addCommand(e),t.schema.extend("$listItem",{allowAttributes:r.attributeName}),i.registerDowncastStrategy({scope:"list",attributeName:r.attributeName,setAttributeOnDowncast(a,l,c){r.setAttributeOnDowncast(a,l,c)}});e.conversion.for("upcast").add(r=>{for(const a of s)r.on("element:ol",bf(a)),r.on("element:ul",bf(a))}),i.on("checkAttributes:list",(r,{viewElement:a,modelAttributes:l})=>{for(const c of s)c.getAttributeOnUpcast(a)!=l[c.attributeName]&&(r.return=!0,r.stop())}),this.listenTo(e.commands.get("indentList"),"afterExecute",(r,a)=>{t.change(l=>{for(const c of a)for(const u of s)u.appliesToListItem(c)&&l.setAttribute(u.attributeName,u.defaultValue,c)})}),i.on("postFixer",(r,{listNodes:a,writer:l})=>{for(const{node:c}of a)for(const u of s)u.hasValidAttribute(c)||(u.appliesToListItem(c)?l.setAttribute(u.attributeName,u.defaultValue,c):l.removeAttribute(u.attributeName,c),r.return=!0)}),i.on("postFixer",(r,{listNodes:a,writer:l})=>{for(const{node:c,previousNodeInList:u}of a)if(u&&u.getAttribute("listType")==c.getAttribute("listType"))for(const d of s){const{attributeName:m}=d;if(!d.appliesToListItem(c))continue;const f=u.getAttribute(m);c.getAttribute(m)!=f&&(l.setAttribute(m,f,c),r.return=!0)}})}}function e7(n){const e=[],t=W1(n);if(n.styles){const i=t.styles.useAttribute;e.push({attributeName:"listStyle",defaultValue:Ho,viewConsumables:{styles:"list-style-type"},addCommand(o){let s=H1();i&&(s=s.filter(r=>!!pc(r))),o.commands.add("listStyle",new ZV(o,Ho,s))},appliesToListItem(o){return o.getAttribute("listType")=="numbered"||o.getAttribute("listType")=="bulleted"},hasValidAttribute(o){if(!this.appliesToListItem(o))return!o.hasAttribute("listStyle");if(!o.hasAttribute("listStyle"))return!1;const s=o.getAttribute("listStyle");return s==Ho?!0:Fu(s)==o.getAttribute("listType")},setAttributeOnDowncast(o,s,r){if(s&&s!==Ho)if(i){const a=pc(s);if(a){o.setAttribute("type",a,r);return}}else{o.setStyle("list-style-type",s,r);return}o.removeStyle("list-style-type",r),o.removeAttribute("type",r)},getAttributeOnUpcast(o){const s=o.getStyle("list-style-type");if(s)return KV(s);const r=o.getAttribute("type");return r?$1(r):Ho}})}return n.reversed&&e.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(i){i.commands.add("listReversed",new JV(i))},appliesToListItem(i){return i.getAttribute("listType")=="numbered"},hasValidAttribute(i){return this.appliesToListItem(i)==i.hasAttribute("listReversed")},setAttributeOnDowncast(i,o,s){o?i.setAttribute("reversed","reversed",s):i.removeAttribute("reversed",s)},getAttributeOnUpcast(i){return i.hasAttribute("reversed")}}),n.startIndex&&e.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(i){i.commands.add("listStart",new GV(i))},appliesToListItem(i){return qr(i.getAttribute("listType"))},hasValidAttribute(i){return this.appliesToListItem(i)==i.hasAttribute("listStart")},setAttributeOnDowncast(i,o,s){o==0||o>1?i.setAttribute("start",o,s):i.removeAttribute("start",s)},getAttributeOnUpcast(i){const o=i.getAttribute("start");return o>=0?o:1}}),e}class j1 extends A{constructor(e,{enabledProperties:t,styleButtonViews:i,styleGridAriaLabel:o}){super(e),h(this,"children"),h(this,"stylesView",null),h(this,"additionalPropertiesCollapsibleView",null),h(this,"startIndexFieldView",null),h(this,"reversedSwitchButtonView",null),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"focusables",new Ie),h(this,"focusCycler");const s=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new Ae({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),i&&i.length?(this.stylesView=this._createStylesView(i,o),this.children.add(this.stylesView)):s.push("ck-list-properties_without-styles"),(t.startIndex||t.reversed)&&(this._addNumberedListPropertyViews(t),s.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:s},children:this.children})}render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const e of this.stylesView.children)this.stylesView.focusTracker.add(e.element);vo({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>I.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const e=t=>t.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(e,t){const i=new A(this.locale);return i.children=i.createCollection(),i.children.addMany(e),i.setTemplate({tag:"div",attributes:{"aria-label":t,class:["ck","ck-list-styles-list"]},children:i.children}),i.children.delegate("execute").to(this),i.focus=function(){for(const o of this.children)if(o instanceof P&&o.isOn){o.focus();return}this.children.first.focus()},i.focusTracker=new ee,i.keystrokes=new te,i.render(),i.keystrokes.listenTo(i.element),i}_addNumberedListPropertyViews(e){const t=this.locale.t,i=[];e.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),i.push(this.startIndexFieldView)),e.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),i.push(this.reversedSwitchButtonView)),this.stylesView?(this.additionalPropertiesCollapsibleView=new mu(this.locale,i),this.additionalPropertiesCollapsibleView.set({label:t("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(i,"isEnabled",(...o)=>o.some(s=>s)),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",(o,s,r)=>{r||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)}),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(i)}_createStartIndexField(){const e=this.locale.t,t=new Te(this.locale,eb);return t.set({label:e("Start at"),class:"ck-numbered-list-properties__start-index"}),t.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),t.fieldView.on("input",()=>{const i=t.fieldView.element,o=i.valueAsNumber;if(Number.isNaN(o)){t.errorText=e("Invalid start index value.");return}i.checkValidity()?this.fire("listStart",{startIndex:o}):t.errorText=e("Start index must be greater than 0.")}),t}_createReversedSwitchButton(){const e=this.locale.t,t=new Ji(this.locale);return t.set({withText:!0,label:e("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),t.delegate("execute").to(this,"listReversed"),t}}class t7 extends w{static get pluginName(){return"ListPropertiesUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=e.config.get("list.properties"),o=W1(i),s=o.styles.listTypes;if(s.includes("bulleted")){const r=[{label:t("Toggle the disc list style"),tooltip:t("Disc"),type:"disc",icon:zC},{label:t("Toggle the circle list style"),tooltip:t("Circle"),type:"circle",icon:FC},{label:t("Toggle the square list style"),tooltip:t("Square"),type:"square",icon:WC}],a=t("Bulleted List"),l=t("Bulleted list styles toolbar"),c="bulletedList";e.ui.componentFactory.add(c,_f({editor:e,normalizedConfig:o,parentCommandName:c,buttonLabel:a,buttonIcon:ou,styleGridAriaLabel:l,styleDefinitions:r})),e.ui.componentFactory.add(`menuBar:${c}`,vf({editor:e,normalizedConfig:o,parentCommandName:c,buttonLabel:a,styleGridAriaLabel:l,styleDefinitions:r}))}if(s.includes("numbered")||i.startIndex||i.reversed){const r=[{label:t("Toggle the decimal list style"),tooltip:t("Decimal"),type:"decimal",icon:DC},{label:t("Toggle the decimal with leading zero list style"),tooltip:t("Decimal with leading zero"),type:"decimal-leading-zero",icon:NC},{label:t("Toggle the lower–roman list style"),tooltip:t("Lower–roman"),type:"lower-roman",icon:$C},{label:t("Toggle the upper–roman list style"),tooltip:t("Upper-roman"),type:"upper-roman",icon:UC},{label:t("Toggle the lower–latin list style"),tooltip:t("Lower-latin"),type:"lower-latin",icon:HC},{label:t("Toggle the upper–latin list style"),tooltip:t("Upper-latin"),type:"upper-latin",icon:jC}],a=t("Numbered List"),l=t("Numbered list styles toolbar"),c="numberedList";e.ui.componentFactory.add(c,_f({editor:e,normalizedConfig:o,parentCommandName:c,buttonLabel:a,buttonIcon:su,styleGridAriaLabel:l,styleDefinitions:r})),s.includes("numbered")&&e.ui.componentFactory.add(`menuBar:${c}`,vf({editor:e,normalizedConfig:o,parentCommandName:c,buttonLabel:a,styleGridAriaLabel:l,styleDefinitions:r}))}}}function _f({editor:n,normalizedConfig:e,parentCommandName:t,buttonLabel:i,buttonIcon:o,styleGridAriaLabel:s,styleDefinitions:r}){const a=n.commands.get(t);return l=>{const c=Ee(l,Xi),u=c.buttonView;return c.bind("isEnabled").to(a),c.class="ck-list-styles-dropdown",u.on("execute",()=>{n.execute(t),n.editing.view.focus()}),u.set({label:i,icon:o,tooltip:!0,isToggleable:!0}),u.bind("isOn").to(a,"value",d=>!!d),c.once("change:isOpen",()=>{const d=i7({editor:n,normalizedConfig:e,dropdownView:c,parentCommandName:t,styleGridAriaLabel:s,styleDefinitions:r});c.panelView.children.add(d)}),c.on("execute",()=>{n.editing.view.focus()}),c}}function U1({editor:n,listStyleCommand:e,parentCommandName:t}){const i=n.locale,o=n.commands.get(t);return({label:s,type:r,icon:a,tooltip:l})=>{const c=new P(i);return c.set({label:s,icon:a,tooltip:l}),c.bind("isOn").to(e,"value",u=>u===r),c.on("execute",()=>{o.value?e.value===r?n.execute(t):e.value!==r&&n.execute("listStyle",{type:r}):n.model.change(()=>{n.execute("listStyle",{type:r})})}),c}}function i7({editor:n,normalizedConfig:e,dropdownView:t,parentCommandName:i,styleDefinitions:o,styleGridAriaLabel:s}){const r=n.locale,a={...e,...i!="numberedList"?{startIndex:!1,reversed:!1}:null},l=i.replace("List","");let c=null;if(e.styles.listTypes.includes(l)){const d=n.commands.get("listStyle"),m=U1({editor:n,parentCommandName:i,listStyleCommand:d}),f=e.styles.listStyleTypes;let g=o;if(f){const _=f[l];_&&(g=o.filter(v=>_.includes(v.type)))}const p=q1(d);c=g.filter(p).map(m)}const u=new j1(r,{styleGridAriaLabel:s,enabledProperties:a,styleButtonViews:c});if(e.styles.listTypes.includes(l)&&ga(t,()=>u.stylesView.children.find(d=>d.isOn)),a.startIndex){const d=n.commands.get("listStart");u.startIndexFieldView.bind("isEnabled").to(d),u.startIndexFieldView.fieldView.bind("value").to(d),u.on("listStart",(m,f)=>n.execute("listStart",f))}if(a.reversed){const d=n.commands.get("listReversed");u.reversedSwitchButtonView.bind("isEnabled").to(d),u.reversedSwitchButtonView.bind("isOn").to(d,"value",m=>!!m),u.on("listReversed",()=>{const m=d.value;n.execute("listReversed",{reversed:!m})})}return u.delegate("execute").to(t),u}function vf({editor:n,normalizedConfig:e,parentCommandName:t,buttonLabel:i,styleGridAriaLabel:o,styleDefinitions:s}){return r=>{const a=new Tt(r),l=n.commands.get(t),c=n.commands.get("listStyle"),u=q1(c),d=U1({editor:n,parentCommandName:t,listStyleCommand:c}),m=e.styles.listStyleTypes;let f=s;if(m){const _=l.type,v=m[_];v&&(f=s.filter(E=>v.includes(E.type)))}const g=f.filter(u).map(d),p=new j1(r,{styleGridAriaLabel:o,enabledProperties:{...e,startIndex:!1,reversed:!1},styleButtonViews:g});return p.delegate("execute").to(a),a.buttonView.set({label:i,icon:t==="bulletedList"?ou:su}),a.panelView.children.add(p),a.bind("isEnabled").to(l,"isEnabled"),a.on("execute",()=>{n.editing.view.focus()}),a}}function q1(n){return typeof n.isStyleTypeSupported=="function"?e=>n.isStyleTypeSupported(e.type):()=>!0}class n7 extends w{static get requires(){return[XV,t7]}static get pluginName(){return"ListProperties"}static get isOfficialPlugin(){return!0}}class o7 extends O{constructor(e){super(e),this.on("execute",()=>{this.refresh()},{priority:"highest"})}refresh(){const e=this._getSelectedItems();this.value=this._getValue(e),this.isEnabled=!!e.length}execute(e={}){this.editor.model.change(t=>{const i=this._getSelectedItems(),o=e.forceValue===void 0?!this._getValue(i):e.forceValue;for(const s of i)o?t.setAttribute("todoListChecked",!0,s):t.removeAttribute("todoListChecked",s)})}_getValue(e){return e.every(t=>t.getAttribute("todoListChecked"))}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),o=i.start.parent,s=[];t.checkAttribute(o,"todoListChecked")&&s.push(...po(o));for(const r of i.getItems({shallow:!0}))t.checkAttribute(r,"todoListChecked")&&!s.includes(r)&&s.push(...po(r));return s}}class s7 extends ui{constructor(){super(...arguments),h(this,"domEventType",["change"])}onDomEvent(e){if(e.target){const t=this.view.domConverter.mapDomToView(e.target);t&&t.is("element","input")&&t.getAttribute("type")=="checkbox"&&t.findAncestor({classes:"todo-list__label"})&&this.fire("todoCheckboxChange",e)}}}const r7=na("Ctrl+Enter");class a7 extends w{static get pluginName(){return"TodoListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[xs]}init(){const e=this.editor,t=e.model,i=e.editing,o=e.plugins.get(xs),s=e.config.get("list.multiBlock")?"paragraph":"listItem";e.commands.add("todoList",new Go(e,"todo")),e.commands.add("checkTodoList",new o7(e)),i.view.addObserver(s7),t.schema.extend("$listItem",{allowAttributes:"todoListChecked"}),t.schema.addAttributeCheck(r=>{const a=r.last;if(!a.getAttribute("listItemId")||a.getAttribute("listType")!="todo")return!1},"todoListChecked"),e.conversion.for("upcast").add(r=>{r.on("element:input",c7()),r.on("element:li",l7(),{priority:"low"}),r.on("element:label",kl({name:"label",classes:"todo-list__label"})),r.on("element:label",kl({name:"label",classes:["todo-list__label","todo-list__label_without-description"]})),r.on("element:span",kl({name:"span",classes:"todo-list__label__description"})),r.on("element:ul",u7({name:"ul",classes:"todo-list"}))}),e.conversion.for("downcast").elementToElement({model:s,view:(r,{writer:a})=>{if(ir(r,o.getListAttributeNames()))return a.createContainerElement("span",{class:"todo-list__label__description"})},converterPriority:"highest"}),o.registerDowncastStrategy({scope:"list",attributeName:"listType",setAttributeOnDowncast(r,a,l){a=="todo"?r.addClass("todo-list",l):r.removeClass("todo-list",l)}}),o.registerDowncastStrategy({scope:"itemMarker",attributeName:"todoListChecked",createElement(r,a,{dataPipeline:l}){if(a.getAttribute("listType")!="todo")return null;const c=r.createUIElement("input",{type:"checkbox",...a.getAttribute("todoListChecked")?{checked:"checked"}:null,...l?{disabled:"disabled"}:{tabindex:"-1"}});if(l)return c;const u=r.createContainerElement("span",{contenteditable:"false"},c);return u.getFillerOffset=()=>null,u},canWrapElement(r){return ir(r,o.getListAttributeNames())},createWrapperElement(r,a,{dataPipeline:l}){const c=["todo-list__label"];return ir(a,o.getListAttributeNames())||c.push("todo-list__label_without-description"),r.createAttributeElement(l?"label":"span",{class:c.join(" ")})}}),o.on("checkElement",(r,{modelElement:a,viewElement:l})=>{const c=ir(a,o.getListAttributeNames());l.hasClass("todo-list__label__description")!=c&&(r.return=!0,r.stop())}),o.on("checkElement",(r,{modelElement:a,viewElement:l})=>{const c=a.getAttribute("listType")=="todo"&&Pi(a);let u=!1;const d=e.editing.view.createPositionBefore(l).getWalker({direction:"backward"});for(const{item:m}of d){if(m.is("element")&&e.editing.mapper.toModelElement(m))break;m.is("element","input")&&m.getAttribute("type")=="checkbox"&&(u=!0)}u!=c&&(r.return=!0,r.stop())}),o.on("postFixer",(r,{listNodes:a,writer:l})=>{for(const{node:c,previousNodeInList:u}of a){if(!u||u.getAttribute("listItemId")!=c.getAttribute("listItemId"))continue;const d=u.hasAttribute("todoListChecked"),m=c.hasAttribute("todoListChecked");m&&!d?(l.removeAttribute("todoListChecked",c),r.return=!0):!m&&d&&(l.setAttribute("todoListChecked",!0,c),r.return=!0)}}),t.document.registerPostFixer(r=>{const a=t.document.differ.getChanges();let l=!1;for(const c of a)if(c.type=="attribute"&&c.attributeKey=="listType"){const u=c.range.start.nodeAfter;c.attributeOldValue=="todo"&&u.hasAttribute("todoListChecked")&&(r.removeAttribute("todoListChecked",u),l=!0)}else if(c.type=="insert"&&c.name!="$text")for(const{item:u}of r.createRangeOn(c.position.nodeAfter))u.is("element")&&u.getAttribute("listType")!="todo"&&u.hasAttribute("todoListChecked")&&(r.removeAttribute("todoListChecked",u),l=!0);return l}),this.listenTo(i.view.document,"keydown",(r,a)=>{yn(a)===r7&&(e.execute("checkTodoList"),r.stop())},{priority:"high"}),this.listenTo(i.view.document,"todoCheckboxChange",(r,a)=>{const l=a.target;if(!l||!l.is("element","input"))return;const c=i.view.createPositionAfter(l),u=i.mapper.toModelPosition(c).parent;u&&be(u)&&u.getAttribute("listType")=="todo"&&this._handleCheckmarkChange(u)}),this.listenTo(i.view.document,"arrowKey",d7(t,e.locale),{context:"$text"}),this.listenTo(i.mapper,"viewToModelPosition",(r,a)=>{const l=a.viewPosition.parent,c=l.is("attributeElement","li")&&a.viewPosition.offset==0,u=yf(l)&&a.viewPosition.offset<=1,d=l.is("element","span")&&l.getAttribute("contenteditable")=="false"&&yf(l.parent);if(!c&&!u&&!d)return;const m=a.modelPosition.nodeAfter;m&&m.getAttribute("listType")=="todo"&&(a.modelPosition=t.createPositionAt(m,0))},{priority:"low"}),this._initAriaAnnouncements()}_handleCheckmarkChange(e){const t=this.editor,i=t.model,o=Array.from(i.document.selection.getRanges());i.change(s=>{s.setSelection(e,"end"),t.execute("checkTodoList"),s.setSelection(o)})}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor;let o=null;t&&e.document.selection.on("change:range",()=>{const s=e.document.selection.focus.parent,r=kf(o),a=kf(s);r&&!a?t.ariaLiveAnnouncer.announce(i("Leaving a to-do list")):!r&&a&&t.ariaLiveAnnouncer.announce(i("Entering a to-do list")),o=s})}}function l7(){return(n,e,t)=>{const{writer:i,schema:o}=t;if(!e.modelRange)return;const s=Array.from(e.modelRange.getItems({shallow:!0})).filter(r=>r.getAttribute("listType")==="todo"&&o.checkAttribute(r,"listItemId")).reduce((r,a)=>{const l=a.getAttribute("listItemId");return r.has(l)||r.set(l,po(a)),r},new Map);for(const[,r]of s.entries())if(r.some(a=>a.getAttribute("todoListChecked")))for(const a of r)i.setAttribute("todoListChecked",!0,a)}}function c7(){return(n,e,t)=>{const i=e.modelCursor,o=i.parent,s=e.viewItem;if(!t.consumable.test(s,{name:!0})||s.getAttribute("type")!="checkbox"||!i.isAtStart||!o.hasAttribute("listType"))return;t.consumable.consume(s,{name:!0});const r=t.writer;r.setAttribute("listType","todo",o),e.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,o),e.modelRange=r.createRange(i)}}function kl(n){const e=new ft(n);return(t,i,o)=>{const s=e.match(i.viewItem);s&&o.consumable.consume(i.viewItem,s.match)&&Object.assign(i,o.convertChildren(i.viewItem,i.modelCursor))}}function u7(n){const e=new ft(n);return(t,i,o)=>{const s=e.match(i.viewItem);if(!s)return;const r=s.match;r.name=!1,o.consumable.consume(i.viewItem,r)}}function ir(n,e){return(n.is("element","paragraph")||n.is("element","listItem"))&&n.getAttribute("listType")=="todo"&&Pi(n)&&h7(n,e)}function h7(n,e){for(const t of n.getAttributeKeys())if(!t.startsWith("selection:")&&!e.includes(t))return!1;return!0}function d7(n,e){return(t,i)=>{const o=oa(i.keyCode,e.contentLanguageDirection),s=n.schema,r=n.document.selection;if(!r.isCollapsed)return;const a=r.getFirstPosition(),l=a.parent;if(o=="right"&&a.isAtEnd){const c=s.getNearestSelectionRange(n.createPositionAfter(l),"forward");if(!c)return;const u=c.start.parent;u&&be(u)&&u.getAttribute("listType")=="todo"&&(n.change(d=>d.setSelection(c)),i.preventDefault(),i.stopPropagation(),t.stop())}else if(o=="left"&&a.isAtStart&&be(l)&&l.getAttribute("listType")=="todo"){const c=s.getNearestSelectionRange(n.createPositionBefore(l),"backward");if(!c)return;n.change(u=>u.setSelection(c)),i.preventDefault(),i.stopPropagation(),t.stop()}}}function yf(n){return!!n&&n.is("attributeElement")&&n.hasClass("todo-list__label")}function kf(n){return!n||!n.is("element","paragraph")&&!n.is("element","listItem")?!1:n.getAttribute("listType")=="todo"}class m7 extends w{static get pluginName(){return"TodoListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;gc(this.editor,"todoList",e("To-do List"),vA)}}class f7 extends w{static get requires(){return[a7,m7]}static get pluginName(){return"TodoList"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Cf={"(":")","[":"]","{":"}"};class g7 extends O{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,o=typeof e.mention=="string"?{id:e.mention}:e.mention,s=o.id,r=e.range||i.getFirstRange();if(!t.canEditAt(r))return;const a=e.text||s,l=G1({_text:a,id:s},o);if(!s.startsWith(e.marker))throw new b("mentioncommand-incorrect-id",this);t.change(c=>{const u=ri(i.getAttributes()),d=new Map(u.entries());d.set("mention",l);const m=t.insertContent(c.createText(a,d),r),f=m.start.nodeBefore,g=m.end.nodeAfter,p=g&&g.is("$text")&&g.data.startsWith(" ");let _=!1;if(f&&g&&f.is("$text")&&g.is("$text")){const v=f.data.slice(-1),E=v in Cf,M=E&&g.data.startsWith(Cf[v]);_=E&&M}!_&&!p&&t.insertContent(c.createText(" ",u),r.start.getShiftedBy(a.length))})}}class p7 extends w{static get pluginName(){return"MentionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",attributes:"data-mention",classes:"mention"},model:{key:"mention",value:o=>K1(o)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:b7}),e.conversion.for("downcast").add(w7),i.registerPostFixer(o=>y7(o,i,t.schema)),i.registerPostFixer(o=>k7(o,i)),i.registerPostFixer(o=>_7(o,i)),e.commands.add("mention",new g7(e))}}function G1(n,e){return Object.assign({uid:ze()},n,e||{})}function K1(n,e){const t=n.getAttribute("data-mention"),i=n.getChild(0);if(!i)return;const o={id:t,_text:i.data};return G1(o,e)}function w7(n){n.on("attribute:mention",(e,t,i)=>{const o=t.attributeNewValue;if(!t.item.is("$textProxy")||!o)return;const s=t.range.start;(s.textNode||s.nodeAfter).data!=o._text&&i.consumable.consume(t.item,e.name)},{priority:"highest"})}function b7(n,{writer:e}){if(!n)return;const t={class:"mention","data-mention":n.id},i={id:n.uid,priority:20};return e.createAttributeElement("span",t,i)}function _7(n,e){const t=e.selection,i=t.focus;return t.isCollapsed&&t.hasAttribute("mention")&&v7(i)?(n.removeSelectionAttribute("mention"),!0):!1}function v7(n){const e=n.isAtStart;return n.nodeBefore&&n.nodeBefore.is("$text")||e}function y7(n,e,t){const i=e.differ.getChanges();let o=!1;for(const s of i){if(s.type=="attribute")continue;const r=s.position;if(s.name=="$text"){const a=r.textNode&&r.textNode.nextSibling;o=un(r.textNode,n)||o,o=un(a,n)||o,o=un(r.nodeBefore,n)||o,o=un(r.nodeAfter,n)||o}if(s.name!="$text"&&s.type=="insert"){const a=r.nodeAfter;for(const l of n.createRangeIn(a).getItems())o=un(l,n)||o}if(s.type=="insert"&&t.isInline(s.name)){const a=r.nodeAfter&&r.nodeAfter.nextSibling;o=un(r.nodeBefore,n)||o,o=un(a,n)||o}}return o}function k7(n,e){const t=e.differ.getChanges();let i=!1;for(const o of t)if(o.type==="attribute"&&o.attributeKey!="mention"){const s=o.range.start.nodeBefore,r=o.range.end.nodeAfter;for(const a of[s,r])Z1(a)&&a.getAttribute(o.attributeKey)!=o.attributeNewValue&&(n.setAttribute(o.attributeKey,o.attributeNewValue,a),i=!0)}return i}function Z1(n){if(!n||!(n.is("$text")||n.is("$textProxy"))||!n.hasAttribute("mention"))return!1;const e=n.data,t=n.getAttribute("mention")._text;return e!=t}function un(n,e){return Z1(n)?(e.removeAttribute("mention",n),!0):!1}class C7 extends En{constructor(e){super(e),h(this,"selected"),h(this,"position"),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e<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 z(this.element).contains(new z(e.element))}}class A7 extends A{constructor(e,t){super(e),h(this,"domElement"),this.template=void 0,this.domElement=t,this.domElement.classList.add("ck-button"),this.set("isOn",!1),this.on("change:isOn",(i,o,s)=>{s?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))}),this.listenTo(this.domElement,"click",()=>{this.fire("execute")})}render(){super.render(),this.element=this.domElement}focus(){this.domElement.focus()}}class x7 extends Nt{constructor(){super(...arguments),h(this,"item"),h(this,"marker")}highlight(){const e=this.children.first;e.isOn=!0}removeHighlight(){const e=this.children.first;e.isOn=!1}}const nr=3,T7=[Z.arrowup,Z.arrowdown,Z.esc],E7=[Z.enter,Z.tab];class S7 extends w{constructor(e){super(e),h(this,"_mentionsView"),h(this,"_mentionsConfigurations"),h(this,"_balloon"),h(this,"_items",new _e),h(this,"_lastRequested"),h(this,"_requestFeedDebounced"),this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=St(this._requestFeed,100),e.config.define("mention",{feeds:[]})}static get pluginName(){return"MentionUI"}static get isOfficialPlugin(){return!0}static get requires(){return[Ue]}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||E7,i=T7.concat(t);this._balloon=e.plugins.get(Ue),e.editing.view.document.on("keydown",(r,a)=>{s(a.keyCode)&&this._isUIVisible&&(a.preventDefault(),r.stop(),a.keyCode==Z.arrowdown&&this._mentionsView.selectNext(),a.keyCode==Z.arrowup&&this._mentionsView.selectPrevious(),t.includes(a.keyCode)&&this._mentionsView.executeSelected(),a.keyCode==Z.esc&&(this._hideUIAndRemoveMarker(),e.model.change(l=>{const c=e.model.document.selection.getLastPosition();c!==null&&l.insertText(" ",c)})))},{priority:"highest"}),$t({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const o=e.config.get("mention.feeds");for(const r of o){const{feed:a,marker:l,dropdownLimit:c}=r;if(!M7(l))throw new b("mentionconfig-incorrect-marker",null,{marker:l});const u=typeof a=="function"?a.bind(this.editor):R7(a),d=r.itemRenderer,m={marker:l,feedCallback:u,itemRenderer:d,dropdownLimit:c};this._mentionsConfigurations.set(l,m)}this._setupTextWatcher(o),this.listenTo(e,"change:isReadOnly",()=>{this._hideUIAndRemoveMarker()}),this.on("requestFeed:response",(r,a)=>this._handleFeedResponse(a)),this.on("requestFeed:error",()=>this._hideUIAndRemoveMarker());function s(r){return i.includes(r)}}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new C7(e);return t.items.bindTo(this._items).using(i=>{const{item:o,marker:s}=i,{dropdownLimit:r}=this._mentionsConfigurations.get(s),a=r||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=a)return null;const l=new x7(e),c=this._renderItem(o,s);return c.delegate("execute").to(l),l.children.add(c),l.item=o,l.marker=s,l.on("execute",()=>{t.fire("execute",{item:o,marker:s})}),l}),t.on("execute",(i,o)=>{const s=this.editor,r=s.model,a=o.item,l=o.marker,c=s.model.markers.get("mention"),u=r.createPositionAt(r.document.selection.focus),d=r.createPositionAt(c.getStart()),m=r.createRange(d,u);this._hideUIAndRemoveMarker(),s.execute("mention",{mention:a,text:a.text,marker:l,range:m}),s.editing.view.focus()}),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),o=i(t);if(!(o instanceof Promise)){this.fire("requestFeed:response",{feed:o,marker:e,feedText:t});return}o.then(s=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:s,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:s,marker:e,feedText:t})}).catch(s=>{this.fire("requestFeed:error",{error:s}),J("mention-feed-callback-error",{marker:e})})}_setupTextWatcher(e){const t=this.editor,i=e.map(r=>({...r,pattern:Q1(r.marker,r.minimumCharacters||0)})),o=new vu(t.model,I7(i));o.on("matched",(r,a)=>{const l=J1(i,a.text),c=t.model.document.selection.focus,u=t.model.createPositionAt(c.parent,l.position);if(O7(c)||B7(u)){this._hideUIAndRemoveMarker();return}const d=V7(l,a.text),m=l.marker.length+d.length,f=c.getShiftedBy(-m),g=c.getShiftedBy(-d.length),p=t.model.createRange(f,g);if(Cl(t)){const _=t.model.markers.get("mention");t.model.change(v=>{v.updateMarker(_,{range:p})})}else t.model.change(_=>{_.addMarker("mention",{range:p,usingOperation:!1,affectsData:!1})});this._requestFeedDebounced(l.marker,d)}),o.on("unmatched",()=>{this._hideUIAndRemoveMarker()});const s=t.commands.get("mention");return o.bind("isEnabled").to(s),o}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!Cl(this.editor))return;this._items.clear();for(const s of t){const r=typeof s!="object"?{id:s,text:s}:s;this._items.add({item:r,marker:i})}const o=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(o):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0,balloonClassName:"ck-mention-balloon"}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),Cl(this.editor)&&this.editor.model.change(e=>e.removeMarker("mention")),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let o,s=e.id;const r=this._getItemRenderer(t);if(r){const a=r(e);typeof a!="string"?o=new A7(i.locale,a):s=a}if(!o){const a=new P(i.locale);a.label=s,a.withText=!0,o=a}return o}_getBalloonPanelPositionData(e,t){const i=this.editor,o=i.editing,s=o.view.domConverter,r=o.mapper,a=i.locale.uiLanguageDirection;return{target:()=>{let l=e.getRange();l.start.root.rootName=="$graveyard"&&(l=i.model.document.selection.getFirstRange());const c=r.toViewRange(l);return z.getDomRangeRects(s.viewRangeToDom(c)).pop()},limiter:()=>{const l=this.editor.editing.view,c=l.document.selection.editableElement;return c?l.domConverter.mapViewToDom(c.root):null},positions:P7(t,a)}}}function P7(n,e){const t={caret_se:i=>({top:i.bottom+nr,left:i.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(i,o)=>({top:i.top-o.height-nr,left:i.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(i,o)=>({top:i.bottom+nr,left:i.right-o.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(i,o)=>({top:i.top-o.height-nr,left:i.right-o.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(t,n)?[t[n]]:e!=="rtl"?[t.caret_se,t.caret_sw,t.caret_ne,t.caret_nw]:[t.caret_sw,t.caret_se,t.caret_nw,t.caret_ne]}function J1(n,e){let t;for(const i of n){const o=e.lastIndexOf(i.marker);o>0&&!e.substring(o-1).match(i.pattern)||(!t||o>=t.position)&&(t={marker:i.marker,position:o,minimumCharacters:i.minimumCharacters,pattern:i.pattern})}return t}function Q1(n,e){const t=e==0?"*":`{${e},}`,i=`(?:^|[= \\(\\[{"'])([${n}])([^= ]${t})$`;return new RegExp(i,"u")}function I7(n){return e=>{const t=J1(n,e);if(!t)return!1;let i=0;t.position!==0&&(i=t.position-1);const o=e.substring(i);return t.pattern.test(o)}}function V7(n,e){let t=0;n.position!==0&&(t=n.position-1);const i=Q1(n.marker,0);return e.substring(t).match(i)[2]}function R7(n){return e=>n.filter(t=>(typeof t=="string"?t:String(t.id)).toLowerCase().includes(e.toLowerCase()))}function O7(n){const e=n.textNode&&n.textNode.hasAttribute("mention"),t=n.nodeBefore;return e||t&&t.is("$text")&&t.hasAttribute("mention")}function B7(n){const e=n.nodeAfter;return e&&e.is("$text")&&e.hasAttribute("mention")}function M7(n){return!!n}function Cl(n){return n.model.markers.has("mention")}class Y1 extends w{toMentionAttribute(e,t){return K1(e,t)}static get pluginName(){return"Mention"}static get isOfficialPlugin(){return!0}static get requires(){return[p7,S7]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class L7 extends O{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=F7(i,t,e)}execute(){const e=this.editor.model;e.change(t=>{const i=t.createElement("pageBreak");e.insertObject(i,null,null,{setSelection:"after"})})}}function F7(n,e,t){const i=N7(n,t);return e.checkChild(i,"pageBreak")}function N7(n,e){const t=ku(n,e).start.parent;return t.isEmpty&&!t.is("element","$root")?t.parent:t}class D7 extends w{static get pluginName(){return"PageBreakEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,o=e.conversion;t.register("pageBreak",{inheritAllFrom:"$blockObject"}),o.for("dataDowncast").elementToStructure({model:"pageBreak",view:(s,{writer:r})=>r.createContainerElement("div",{class:"page-break",style:"page-break-after: always"},r.createContainerElement("span",{style:"display: none"}))}),o.for("editingDowncast").elementToStructure({model:"pageBreak",view:(s,{writer:r})=>{const a=i("Page break"),l=r.createContainerElement("div"),c=r.createRawElement("span",{class:"page-break__label"},function(u){u.innerText=i("Page break")});return r.addClass("page-break",l),r.insert(r.createPositionAt(l,0),c),z7(l,r,a)}}),o.for("upcast").elementToElement({view:s=>{const r=s.getStyle("page-break-before")=="always",a=s.getStyle("page-break-after")=="always";if(!r&&!a)return null;if(s.childCount==1){const l=s.getChild(0);if(!l.is("element","span")||l.getStyle("display")!="none")return null}else if(s.childCount>1)return null;return{name:!0}},model:"pageBreak",converterPriority:"high"}),e.commands.add("pageBreak",new L7(e))}}function z7(n,e,t){return e.setCustomProperty("pageBreak",!0,n),gt(n,e,{label:t})}class H7 extends w{static get pluginName(){return"PageBreakUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("pageBreak",()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:pageBreak",()=>this._createButton(ve))}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get("pageBreak"),s=new e(t.locale),r=i.t;return s.set({label:r("Page break"),icon:XC}),s.bind("isEnabled").to(o,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute("pageBreak"),t.editing.view.focus()}),s}}class $7 extends w{static get requires(){return[D7,H7,Vt]}static get pluginName(){return"PageBreak"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*//**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function W7(n,e){const t=[];for(const i of e.createRangeIn(n)){const o=i.item;o.is("element","a")&&!o.hasAttribute("href")&&(o.hasAttribute("id")||o.hasAttribute("name"))&&t.push(o)}for(const i of t){const o=i.parent.getChildIndex(i)+1,s=i.getChildren();e.insertChild(o,s,i.parent)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function X1(n){const e=parseFloat(n);return n.endsWith("pt")?Yn(e*96/72):n.endsWith("pc")?Yn(e*12*96/72):n.endsWith("in")?Yn(e*96):n.endsWith("cm")?Yn(e*96/2.54):n.endsWith("mm")?Yn(e/10*96/2.54):n}function Af(n){return n!==void 0&&n.endsWith("px")}function Yn(n){return Math.round(n)+"px"}function j7(n,e,t){if(!n.childCount)return;const i=new Ht(n.document),o=q7(n,i);if(!o.length)return;const s={},r=[];for(const a of o)if(a.indent!==void 0){G7(a)||(r.length=0);const l=`${a.id}:${a.indent}`,c=Math.min(a.indent-1,r.length);if(c<r.length&&r[c].id!==a.id&&(r.length=c),c<r.length-1)r.length=c+1;else{const d=Z7(a,e);if(c>r.length-1||r[c].listElement.name!=d.type){c==0&&d.type=="ol"&&a.id!==void 0&&s[l]&&(d.startIndex=s[l]);const m=X7(d,i,t);if(Af(a.marginLeft)&&(c==0||Af(r[c-1].marginLeft))){let f=a.marginLeft;c>0&&(f=Yn(parseFloat(f)-parseFloat(r[c-1].marginLeft))),i.setStyle("padding-left",f,m)}if(r.length==0){const f=a.element.parent,g=f.getChildIndex(a.element)+1;i.insertChild(g,m,f)}else{const f=r[c-1].listItemElements;i.appendChild(m,f[f.length-1])}r[c]={...a,listElement:m,listItemElements:[]},c==0&&a.id!==void 0&&(s[l]=d.startIndex||1)}}const u=a.element.name=="li"?a.element:i.createElement("li");i.appendChild(u,r[c].listElement),r[c].listItemElements.push(u),c==0&&a.id!==void 0&&s[l]++,a.element!=u&&i.appendChild(a.element,u),t6(a.element,i),i.removeStyle("text-indent",a.element),i.removeStyle("margin-left",a.element)}else{const l=r.find(c=>c.marginLeft==a.marginLeft);if(l){const c=l.listItemElements;i.appendChild(a.element,c[c.length-1]),i.removeStyle("margin-left",a.element)}else r.length=0}}function U7(n,e){for(const t of e.createRangeIn(n)){const i=t.item;if(i.is("element","li")){const o=i.getChild(0);o&&o.is("element","p")&&e.unwrapElement(o)}}}function q7(n,e){const t=e.createRangeIn(n),i=[],o=new Set;for(const s of t.getItems()){if(!s.is("element")||!s.name.match(/^(p|h\d+|li|div)$/))continue;let r=i6(s);if(r!==void 0&&parseFloat(r)==0&&!Array.from(s.getClassNames()).find(a=>a.startsWith("MsoList"))&&(r=void 0),s.hasStyle("mso-list")||r!==void 0&&o.has(r)){const a=e6(s);i.push({element:s,id:a.id,order:a.order,indent:a.indent,marginLeft:r}),r!==void 0&&o.add(r)}else o.clear()}return i}function G7(n){const e=n.element.previousSibling;return K7(e||n.element.parent)}function K7(n){return n.is("element","ol")||n.is("element","ul")}function Z7(n,e){const t=new RegExp(`@list l${n.id}:level${n.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,s=new RegExp(`@list\\s+l${n.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),r=new RegExp(`@list l${n.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=s.exec(e),l=r.exec(e),c=a&&!l,u=t.exec(e);let d="decimal",m="ol",f=null;if(u&&u[1]){const g=i.exec(u[1]);if(g&&g[1]&&(d=g[1].trim(),m=d!=="bullet"&&d!=="image"?"ol":"ul"),d==="bullet"){const p=J7(n.element);p&&(d=p)}else{const p=o.exec(u[1]);p&&p[1]&&(f=parseInt(p[1]))}c&&(m="ol")}return{type:m,startIndex:f,style:Y7(d),isLegalStyleList:c}}function J7(n){if(n.name=="li"&&n.parent.name=="ul"&&n.parent.hasAttribute("type"))return n.parent.getAttribute("type");const e=Q7(n);if(!e)return null;const t=e._data;return t==="o"?"circle":t==="·"?"disc":t==="§"?"square":null}function Q7(n){if(n.getChild(0).is("$text"))return null;for(const e of n.getChildren()){if(!e.is("element","span"))continue;const t=e.getChild(0);if(t)return t.is("$text")?t:t.getChild(0)}/* istanbul ignore next -- @preserve */return null}function Y7(n){if(n.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(n){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return n;default:return null}}function X7(n,e,t){const i=e.createElement(n.type);return n.style&&e.setStyle("list-style-type",n.style,i),n.startIndex&&n.startIndex>1&&e.setAttribute("start",n.startIndex,i),n.isLegalStyleList&&t&&e.addClass("legal-list",i),i}function e6(n){const e=n.getStyle("mso-list");if(e===void 0)return{};const t=e.match(/(^|\s{1,100})l(\d+)/i),i=e.match(/\s{0,100}lfo(\d+)/i),o=e.match(/\s{0,100}level(\d+)/i);return t&&i&&o?{id:t[2],order:i[1],indent:parseInt(o[1])}:{indent:1}}function t6(n,e){const t=new ft({name:"span",styles:{"mso-list":"Ignore"}}),i=e.createRangeIn(n);for(const o of i)o.type==="elementStart"&&t.match(o.item)&&e.remove(o.item)}function i6(n){const e=n.getStyle("margin-left");return e===void 0||e.endsWith("px")?e:X1(e)}function n6(n,e){if(!n.childCount)return;const t=new Ht(n.document),i=s6(n,t);r6(i,n,t),l6(i,n,t),a6(n,t);const o=c6(n,t);o.length&&h6(o,u6(e),t)}function o6(n){return btoa(n.match(/\w{2}/g).map(e=>String.fromCharCode(parseInt(e,16))).join(""))}function s6(n,e){const t=e.createRangeIn(n),i=new ft({name:/v:(.+)/}),o=[];for(const s of t){if(s.type!="elementStart")continue;const r=s.item,a=r.previousSibling,l=a&&a.is("element")?a.name:null,c=["Chart"],u=i.match(r),d=r.getAttribute("o:gfxdata"),m=l==="v:shapetype",f=d&&c.some(g=>r.getAttribute("id").includes(g));u&&d&&!m&&!f&&o.push(s.item.getAttribute("id"))}return o}function r6(n,e,t){const i=t.createRangeIn(e),o=new ft({name:"img"}),s=[];for(const r of i)if(r.item.is("element")&&o.match(r.item)){const a=r.item,l=a.getAttribute("v:shapes")?a.getAttribute("v:shapes").split(" "):[];l.length&&l.every(c=>n.indexOf(c)>-1)?s.push(a):a.getAttribute("src")||s.push(a)}for(const r of s)t.remove(r)}function a6(n,e){const t=e.createRangeIn(n),i=new ft({name:/v:(.+)/}),o=[];for(const s of t)s.type=="elementStart"&&i.match(s.item)&&o.push(s.item);for(const s of o)e.remove(s)}function l6(n,e,t){const i=t.createRangeIn(e),o=[];for(const a of i)if(a.type=="elementStart"&&a.item.is("element","v:shape")){const l=a.item.getAttribute("id");if(n.includes(l))continue;s(a.item.parent.getChildren(),l)||o.push(a.item)}for(const a of o){const l={src:r(a)};a.hasAttribute("alt")&&(l.alt=a.getAttribute("alt"));const c=t.createElement("img",l);t.insertChild(a.index+1,c,a.parent)}function s(a,l){for(const c of a){/* istanbul ignore else -- @preserve */if(c.is("element")&&(c.name=="img"&&c.getAttribute("v:shapes")==l||s(c.getChildren(),l)))return!0}return!1}function r(a){for(const l of a.getChildren()){/* istanbul ignore else -- @preserve */if(l.is("element")&&l.getAttribute("src"))return l.getAttribute("src")}}}function c6(n,e){const t=e.createRangeIn(n),i=new ft({name:"img"}),o=[];let s=0;for(const r of t)r.item.is("element")&&i.match(r.item)&&(r.item.getAttribute("src").startsWith("file://")&&o.push({element:r.item,imageIndex:s}),s++);return o}function u6(n){if(!n)return[];const e=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,t=new RegExp("(?:("+e.source+"))([\\da-fA-F\\s]+)\\}","g"),i=n.match(t),o=[];if(i)for(const s of i){let r=!1;s.includes("\\pngblip")?r="image/png":s.includes("\\jpegblip")&&(r="image/jpeg"),r&&o.push({hex:s.replace(e,"").replace(/[^\da-fA-F]/g,""),type:r})}return o}function h6(n,e,t){for(let i=0;i<n.length;i++){const{element:o,imageIndex:s}=n[i],r=e[s];if(r){const a=`data:${r.type};base64,${o6(r.hex)}`;t.setAttribute("src",a,o)}}}function d6(n){const e=[],t=new Ht(n.document);for(const{item:i}of t.createRangeIn(n))if(i.is("element")){for(const o of i.getClassNames())/\bmso/gi.exec(o)&&t.removeClass(o,i);for(const o of i.getStyleNames())/\bmso/gi.exec(o)&&t.removeStyle(o,i);(i.is("element","w:sdt")||i.is("element","w:sdtpr")&&i.isEmpty||i.is("element","o:p")&&i.isEmpty)&&e.push(i)}for(const i of e){const o=i.parent,s=o.getChildIndex(i);t.insertChild(s,i.getChildren(),o),t.remove(i)}}function m6(n,e){for(const t of e.createRangeIn(n).getItems()){if(!t.is("element","table")&&!t.is("element","td")&&!t.is("element","th"))continue;const i=["left","top","right","bottom"];if(i.every(s=>!t.hasStyle(`border-${s}-style`)))e.setStyle("border-style","none",t);else for(const s of i)t.hasStyle(`border-${s}-style`)||e.setStyle(`border-${s}-style`,"none",t);const o=["width","height",...i.map(s=>`border-${s}-width`),...i.map(s=>`padding-${s}`)];for(const s of o)t.hasStyle(s)&&e.setStyle(s,X1(t.getStyle(s)),t)}}const f6=/<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i,g6=/xmlns:o="urn:schemas-microsoft-com/i;class p6{constructor(e,t=!1){h(this,"document"),h(this,"hasMultiLevelListPlugin"),this.document=e,this.hasMultiLevelListPlugin=t}isActive(e){return f6.test(e)||g6.test(e)}execute(e){const t=new Ht(this.document),{body:i,stylesString:o}=e._parsedData;W7(i,t),j7(i,o,this.hasMultiLevelListPlugin),n6(i,e.dataTransfer.getData("text/rtf")),m6(i,t),d6(i),e.content=i}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function w6(n,e){for(const t of n.getChildren())if(t.is("element","b")&&t.getStyle("font-weight")==="normal"){const i=n.getChildIndex(t);e.remove(t),e.insertChild(i,t.getChildren(),n)}}function b6(n,e){const t=new aa(e.document.stylesProcessor),i=new ca(t,{renderingMode:"data"}),o=i.blockElements,s=i.inlineObjectElements,r=[];for(const a of e.createRangeIn(n)){const l=a.item;if(l.is("element","br")){const c=xf(l,"forward",e,{blockElements:o,inlineObjectElements:s}),u=xf(l,"backward",e,{blockElements:o,inlineObjectElements:s}),d=Tf(c,o);(Tf(u,o)||d)&&r.push(l)}}for(const a of r)a.hasClass("Apple-interchange-newline")?e.remove(a):e.replace(a,e.createElement("p"))}function xf(n,e,t,{blockElements:i,inlineObjectElements:o}){let s=t.createPositionAt(n,e=="forward"?"after":"before");return s=s.getLastMatchingPosition(({item:r})=>r.is("element")&&!i.includes(r.name)&&!o.includes(r.name),{direction:e}),e=="forward"?s.nodeAfter:s.nodeBefore}function Tf(n,e){return!!n&&n.is("element")&&e.includes(n.name)}const _6=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class v6{constructor(e){h(this,"document"),this.document=e}isActive(e){return _6.test(e)}execute(e){const t=new Ht(this.document),{body:i}=e._parsedData;w6(i,t),U7(i,t),b6(i,t),e.content=i}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function y6(n,e){for(const t of n.getChildren())t.is("element","table")&&t.hasAttribute("xmlns")&&e.removeAttribute("xmlns",t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function k6(n,e){for(const t of n.getChildren())if(t.is("element","google-sheets-html-origin")){const i=n.getChildIndex(t);e.remove(t),e.insertChild(i,t.getChildren(),n)}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function C6(n,e){for(const t of n.getChildren())t.is("element","table")&&t.getStyle("width")==="0px"&&e.removeStyle("width",t)}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function A6(n,e){for(const t of Array.from(n.getChildren()))t.is("element","style")&&e.remove(t)}const x6=/<google-sheets-html-origin/i;class T6{constructor(e){h(this,"document"),this.document=e}isActive(e){return x6.test(e)}execute(e){const t=new Ht(this.document),{body:i}=e._parsedData;k6(i,t),y6(i,t),C6(i,t),A6(i,t),e.content=i}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function E6(n){return Ef(Ef(n)).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>(&nbsp;|\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)</g,"><")}function S6(n){n.querySelectorAll("span[style*=spacerun]").forEach(e=>{const t=e,i=t.innerText.length||0;t.innerText=Array(i+1).join("  ").substr(0,i)})}function Ef(n){return n.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(e,t)=>t.length===1?" ":Array(t.length+1).join("  ").substr(0,t.length))}function P6(n,e){const t=new DOMParser;n=n.replace(/<!--\[if gte vml 1]>/g,""),n=n.replace(/<o:SmartTagType(?:\s+[^\s>=]+(?:="[^"]*")?)*\s*\/?>/gi,"");const i=E6(R6(n)),o=t.parseFromString(i,"text/html");S6(o);const s=o.body.innerHTML,r=I6(o,e),a=V6(o);return{body:r,bodyString:s,styles:a.styles,stylesString:a.stylesString}}function I6(n,e){const t=new aa(e),i=new ca(t,{renderingMode:"data"}),o=n.createDocumentFragment(),s=n.body.childNodes;for(;s.length>0;)o.appendChild(s[0]);return i.domToView(o,{skipComments:!0})}function V6(n){const e=[],t=[],i=Array.from(n.getElementsByTagName("style"));for(const o of i)o.sheet&&o.sheet.cssRules&&o.sheet.cssRules.length&&(e.push(o.sheet),t.push(o.innerHTML));return{styles:e,stylesString:t.join(" ")}}function R6(n){const e="</body>",t="</html>",i=n.indexOf(e);if(i<0)return n;const o=n.indexOf(t,i+e.length);return n.substring(0,i+e.length)+(o>=0?n.substring(o):"")}class O6 extends w{static get pluginName(){return"PasteFromOffice"}static get isOfficialPlugin(){return!0}static get requires(){return[pt]}init(){const e=this.editor,t=e.plugins.get("ClipboardPipeline"),i=e.editing.view.document,o=[],s=this.editor.plugins.has("MultiLevelList");o.push(new p6(i,s)),o.push(new v6(i)),o.push(new T6(i)),t.on("inputTransformation",(r,a)=>{if(a._isTransformedWithPasteFromOffice||e.model.document.selection.getFirstPosition().parent.is("element","codeBlock"))return;const l=a.dataTransfer.getData("text/html"),c=o.find(u=>u.isActive(l));c&&(a._parsedData||(a._parsedData=P6(l,i.stylesProcessor)),c.execute(a),a._isTransformedWithPasteFromOffice=!0)},{priority:"high"})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const or="removeFormat";class B6 extends w{static get pluginName(){return"RemoveFormatUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add(or,()=>{const t=this._createButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add(`menuBar:${or}`,()=>this._createButton(ve))}_createButton(e){const t=this.editor,i=t.locale,o=t.commands.get(or),s=new e(t.locale),r=i.t;return s.set({label:r("Remove Format"),icon:oA}),s.bind("isEnabled").to(o,"isEnabled"),this.listenTo(s,"execute",()=>{t.execute(or),t.editing.view.focus()}),s}}class M6 extends O{refresh(){const e=this.editor.model;this.isEnabled=!!ae(this._getFormattingItems(e.document.selection,e.schema))}execute(){const e=this.editor.model,t=e.schema;e.change(i=>{for(const o of this._getFormattingItems(e.document.selection,t))if(o.is("selection"))for(const s of this._getFormattingAttributes(o,t))i.removeSelectionAttribute(s);else{const s=i.createRangeOn(o);for(const r of this._getFormattingAttributes(o,t))i.removeAttribute(r,s)}})}*_getFormattingItems(e,t){const i=o=>!!ae(this._getFormattingAttributes(o,t));for(const o of e.getRanges())for(const s of o.getItems())!t.isBlock(s)&&i(s)&&(yield s);for(const o of e.getSelectedBlocks())i(o)&&(yield o);i(e)&&(yield e)}*_getFormattingAttributes(e,t){for(const[i]of e.getAttributes()){const o=t.getAttributeProperties(i);o&&o.isFormatting&&(yield i)}}}class L6 extends w{static get pluginName(){return"RemoveFormatEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("removeFormat",new M6(e))}}class e0 extends w{static get requires(){return[L6,B6]}static get pluginName(){return"RemoveFormat"}static get isOfficialPlugin(){return!0}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class F6 extends A{constructor(e){super(e),h(this,"tiles"),h(this,"focusTracker"),h(this,"keystrokes"),this.tiles=this.createCollection(),this.setTemplate({tag:"div",children:[{tag:"div",attributes:{class:["ck","ck-character-grid__tiles"]},children:this.tiles}],attributes:{class:["ck","ck-character-grid"]}}),this.focusTracker=new ee,this.keystrokes=new te,vo({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.tiles,numberOfColumns:()=>I.window.getComputedStyle(this.element.firstChild).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}createTile(e,t){const i=new P(this.locale);return i.set({label:e,withText:!0,class:"ck-character-grid__tile"}),i.extendTemplate({attributes:{title:t},on:{mouseover:i.bindTemplate.to("mouseover"),focus:i.bindTemplate.to("focus")}}),i.on("mouseover",()=>{this.fire("tileHover",{name:t,character:e})}),i.on("focus",()=>{this.fire("tileFocus",{name:t,character:e})}),i.on("execute",()=>{this.fire("execute",{name:t,character:e})}),i}render(){super.render();for(const e of this.tiles)this.focusTracker.add(e.element);this.tiles.on("change",(e,{added:t,removed:i})=>{if(t.length>0)for(const o of t)this.focusTracker.add(o.element);if(i.length>0)for(const o of i)this.focusTracker.remove(o.element)}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy()}focus(){this.tiles.first.focus()}}class N6 extends A{constructor(e){super(e);const t=this.bindTemplate;this.set("character",null),this.set("name",null),this.bind("code").to(this,"character",D6),this.setTemplate({tag:"div",children:[{tag:"span",attributes:{class:["ck-character-info__name"]},children:[{text:t.to("name",i=>i||"​")}]},{tag:"span",attributes:{class:["ck-character-info__code"]},children:[{text:t.to("code")}]}],attributes:{class:["ck","ck-character-info"]}})}}function D6(n){return n===null?"":"U+"+("0000"+n.codePointAt(0).toString(16)).slice(-4)}class z6 extends A{constructor(e,t,i,o){super(e),h(this,"items"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"_focusCycler"),h(this,"categoriesView"),h(this,"gridView"),h(this,"infoView"),this.categoriesView=t,this.gridView=i,this.infoView=o,this.items=this.createCollection(),this.focusTracker=new ee,this.keystrokes=new te,this._focusCycler=new Ae({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",children:[this.categoriesView,this.gridView,this.infoView],attributes:{tabindex:"-1"}}),this.items.add(this.categoriesView),this.items.add(this.gridView)}render(){super.render(),this.focusTracker.add(this.categoriesView.element),this.focusTracker.add(this.gridView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class H6 extends A{constructor(e,t){super(e),h(this,"_groupNames"),h(this,"_dropdownView"),this.set("currentGroupName",Array.from(t.entries())[0][0]),this._groupNames=t,this._dropdownView=new Te(e,pu),this.setTemplate({tag:"div",attributes:{class:["ck","ck-character-categories"]},children:[this._dropdownView]})}render(){super.render(),this._setupDropdown()}focus(){this._dropdownView.focus()}_setupDropdown(){const e=new _e;for(const[o,s]of this._groupNames){const r={type:"button",model:new et({name:o,label:s,role:"menuitemradio",withText:!0})};r.model.bind("isOn").to(this,"currentGroupName",a=>a===o),e.add(r)}const t=this.locale.t,i=t("Category");this._dropdownView.set({label:i,isEmpty:!1}),this._dropdownView.fieldView.panelPosition=this.locale.uiLanguageDirection==="rtl"?"se":"sw",this._dropdownView.fieldView.buttonView.set({withText:!0,tooltip:i,ariaLabel:i,ariaLabelledBy:void 0,isOn:!1}),this._dropdownView.fieldView.buttonView.bind("label").to(this,"currentGroupName",o=>this._groupNames.get(o)),this._dropdownView.fieldView.on("execute",({source:o})=>{this.currentGroupName=o.name}),wt(this._dropdownView.fieldView,e,{ariaLabel:i,role:"menu"})}}const Al="All";class $6 extends w{constructor(e){super(e),h(this,"_characters"),h(this,"_groups"),h(this,"_allSpecialCharactersGroupLabel");const t=e.t;this._characters=new Map,this._groups=new Map,this._allSpecialCharactersGroupLabel=t("All")}static get requires(){return[pa,du]}static get pluginName(){return"SpecialCharacters"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("specialCharacters",()=>{const t=this._createDialogButton(P);return t.set({tooltip:!0}),t}),e.ui.componentFactory.add("menuBar:specialCharacters",()=>this._createDialogButton(ve))}addItems(e,t,i={label:e}){if(e===Al)throw new b("special-character-invalid-group-name",null);const o=this._getGroup(e,i.label);for(const s of t)o.items.add(s.title),this._characters.set(s.title,s.character)}getGroups(){const e=Array.from(this._groups.keys()),t=this.editor.config.get("specialCharacters.order")||[],i=t.find(o=>!e.includes(o));if(i)throw new b("special-character-invalid-order-group-name",null,{invalidGroup:i});return new Set([...t,...e])}getCharactersForGroup(e){if(e===Al)return new Set(this._characters.keys());const t=this._groups.get(e);if(t)return t.items}getCharacter(e){return this._characters.get(e)}_getGroup(e,t){return this._groups.has(e)||this._groups.set(e,{items:new Set,label:t}),this._groups.get(e)}_updateGrid(e,t){t.tiles.clear();const i=this.getCharactersForGroup(e);for(const o of i){const s=this.getCharacter(o);t.tiles.add(t.createTile(s,o))}}_createDropdownPanelContent(e){const t=Array.from(this.getGroups()).map(a=>[a,this._groups.get(a).label]),i=new Map([[Al,this._allSpecialCharactersGroupLabel],...t]),o=new H6(e,i),s=new F6(e),r=new N6(e);return s.on("tileHover",(a,l)=>{r.set(l)}),s.on("tileFocus",(a,l)=>{r.set(l)}),o.on("change:currentGroupName",(a,l,c)=>{this._updateGrid(c,s)}),this._updateGrid(o.currentGroupName,s),{categoriesView:o,gridView:s,infoView:r}}_createDialogButton(e){const t=this.editor,i=t.locale,o=new e(t.locale),s=t.commands.get("insertText"),r=i.t,a=this.editor.plugins.get("Dialog");return o.set({label:r("Special characters"),icon:cA,isToggleable:!0}),o.bind("isOn").to(a,"id",l=>l==="specialCharacters"),o.bind("isEnabled").to(s,"isEnabled"),o.on("execute",()=>{if(a.id==="specialCharacters"){a.hide();return}this._showDialog()}),o}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale,o=i.t,{categoriesView:s,gridView:r,infoView:a}=this._createDropdownPanelContent(i),l=new z6(i,s,r,a);r.on("execute",(c,u)=>{e.execute("insertText",{text:u.character})}),t.show({id:"specialCharacters",title:o("Special characters"),className:"ck-special-characters",content:l,position:vt.EDITOR_TOP_SIDE})}}class W6 extends w{static get pluginName(){return"SpecialCharactersArrows"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Arrows",[{title:t("leftwards simple arrow"),character:"←"},{title:t("rightwards simple arrow"),character:"→"},{title:t("upwards simple arrow"),character:"↑"},{title:t("downwards simple arrow"),character:"↓"},{title:t("leftwards double arrow"),character:"⇐"},{title:t("rightwards double arrow"),character:"⇒"},{title:t("upwards double arrow"),character:"⇑"},{title:t("downwards double arrow"),character:"⇓"},{title:t("leftwards dashed arrow"),character:"⇠"},{title:t("rightwards dashed arrow"),character:"⇢"},{title:t("upwards dashed arrow"),character:"⇡"},{title:t("downwards dashed arrow"),character:"⇣"},{title:t("leftwards arrow to bar"),character:"⇤"},{title:t("rightwards arrow to bar"),character:"⇥"},{title:t("upwards arrow to bar"),character:"⤒"},{title:t("downwards arrow to bar"),character:"⤓"},{title:t("up down arrow with base"),character:"↨"},{title:t("back with leftwards arrow above"),character:"🔙"},{title:t("end with leftwards arrow above"),character:"🔚"},{title:t("on with exclamation mark with left right arrow above"),character:"🔛"},{title:t("soon with rightwards arrow above"),character:"🔜"},{title:t("top with upwards arrow above"),character:"🔝"}],{label:t("Arrows")})}}class j6 extends w{static get pluginName(){return"SpecialCharactersText"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Text",[{character:"‹",title:t("Single left-pointing angle quotation mark")},{character:"›",title:t("Single right-pointing angle quotation mark")},{character:"«",title:t("Left-pointing double angle quotation mark")},{character:"»",title:t("Right-pointing double angle quotation mark")},{character:"‘",title:t("Left single quotation mark")},{character:"’",title:t("Right single quotation mark")},{character:"“",title:t("Left double quotation mark")},{character:"”",title:t("Right double quotation mark")},{character:"‚",title:t("Single low-9 quotation mark")},{character:"„",title:t("Double low-9 quotation mark")},{character:"¡",title:t("Inverted exclamation mark")},{character:"¿",title:t("Inverted question mark")},{character:"‥",title:t("Two dot leader")},{character:"…",title:t("Horizontal ellipsis")},{character:"‡",title:t("Double dagger")},{character:"‰",title:t("Per mille sign")},{character:"‱",title:t("Per ten thousand sign")},{character:"‼",title:t("Double exclamation mark")},{character:"⁈",title:t("Question exclamation mark")},{character:"⁉",title:t("Exclamation question mark")},{character:"⁇",title:t("Double question mark")},{character:"©",title:t("Copyright sign")},{character:"®",title:t("Registered sign")},{character:"™",title:t("Trade mark sign")},{character:"§",title:t("Section sign")},{character:"¶",title:t("Paragraph sign")},{character:"⁋",title:t("Reversed paragraph sign")}],{label:t("Text")})}}class U6 extends w{static get pluginName(){return"SpecialCharactersMathematical"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Mathematical",[{character:"<",title:t("Less-than sign")},{character:">",title:t("Greater-than sign")},{character:"≤",title:t("Less-than or equal to")},{character:"≥",title:t("Greater-than or equal to")},{character:"–",title:t("En dash")},{character:"—",title:t("Em dash")},{character:"¯",title:t("Macron")},{character:"‾",title:t("Overline")},{character:"°",title:t("Degree sign")},{character:"−",title:t("Minus sign")},{character:"±",title:t("Plus-minus sign")},{character:"÷",title:t("Division sign")},{character:"⁄",title:t("Fraction slash")},{character:"×",title:t("Multiplication sign")},{character:"ƒ",title:t("Latin small letter f with hook")},{character:"∫",title:t("Integral")},{character:"∑",title:t("N-ary summation")},{character:"∞",title:t("Infinity")},{character:"√",title:t("Square root")},{character:"∼",title:t("Tilde operator")},{character:"≅",title:t("Approximately equal to")},{character:"≈",title:t("Almost equal to")},{character:"≠",title:t("Not equal to")},{character:"≡",title:t("Identical to")},{character:"∈",title:t("Element of")},{character:"∉",title:t("Not an element of")},{character:"∋",title:t("Contains as member")},{character:"∏",title:t("N-ary product")},{character:"∧",title:t("Logical and")},{character:"∨",title:t("Logical or")},{character:"¬",title:t("Not sign")},{character:"∩",title:t("Intersection")},{character:"∪",title:t("Union")},{character:"∂",title:t("Partial differential")},{character:"∀",title:t("For all")},{character:"∃",title:t("There exists")},{character:"∅",title:t("Empty set")},{character:"∇",title:t("Nabla")},{character:"∗",title:t("Asterisk operator")},{character:"∝",title:t("Proportional to")},{character:"∠",title:t("Angle")},{character:"¼",title:t("Vulgar fraction one quarter")},{character:"½",title:t("Vulgar fraction one half")},{character:"¾",title:t("Vulgar fraction three quarters")}],{label:t("Mathematical")})}}class q6 extends w{static get pluginName(){return"SpecialCharactersLatin"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Latin",[{character:"Ā",title:t("Latin capital letter a with macron")},{character:"ā",title:t("Latin small letter a with macron")},{character:"Ă",title:t("Latin capital letter a with breve")},{character:"ă",title:t("Latin small letter a with breve")},{character:"Ą",title:t("Latin capital letter a with ogonek")},{character:"ą",title:t("Latin small letter a with ogonek")},{character:"Ć",title:t("Latin capital letter c with acute")},{character:"ć",title:t("Latin small letter c with acute")},{character:"Ĉ",title:t("Latin capital letter c with circumflex")},{character:"ĉ",title:t("Latin small letter c with circumflex")},{character:"Ċ",title:t("Latin capital letter c with dot above")},{character:"ċ",title:t("Latin small letter c with dot above")},{character:"Č",title:t("Latin capital letter c with caron")},{character:"č",title:t("Latin small letter c with caron")},{character:"Ď",title:t("Latin capital letter d with caron")},{character:"ď",title:t("Latin small letter d with caron")},{character:"Đ",title:t("Latin capital letter d with stroke")},{character:"đ",title:t("Latin small letter d with stroke")},{character:"Ē",title:t("Latin capital letter e with macron")},{character:"ē",title:t("Latin small letter e with macron")},{character:"Ĕ",title:t("Latin capital letter e with breve")},{character:"ĕ",title:t("Latin small letter e with breve")},{character:"Ė",title:t("Latin capital letter e with dot above")},{character:"ė",title:t("Latin small letter e with dot above")},{character:"Ę",title:t("Latin capital letter e with ogonek")},{character:"ę",title:t("Latin small letter e with ogonek")},{character:"Ě",title:t("Latin capital letter e with caron")},{character:"ě",title:t("Latin small letter e with caron")},{character:"Ĝ",title:t("Latin capital letter g with circumflex")},{character:"ĝ",title:t("Latin small letter g with circumflex")},{character:"Ğ",title:t("Latin capital letter g with breve")},{character:"ğ",title:t("Latin small letter g with breve")},{character:"Ġ",title:t("Latin capital letter g with dot above")},{character:"ġ",title:t("Latin small letter g with dot above")},{character:"Ģ",title:t("Latin capital letter g with cedilla")},{character:"ģ",title:t("Latin small letter g with cedilla")},{character:"Ĥ",title:t("Latin capital letter h with circumflex")},{character:"ĥ",title:t("Latin small letter h with circumflex")},{character:"Ħ",title:t("Latin capital letter h with stroke")},{character:"ħ",title:t("Latin small letter h with stroke")},{character:"Ĩ",title:t("Latin capital letter i with tilde")},{character:"ĩ",title:t("Latin small letter i with tilde")},{character:"Ī",title:t("Latin capital letter i with macron")},{character:"ī",title:t("Latin small letter i with macron")},{character:"Ĭ",title:t("Latin capital letter i with breve")},{character:"ĭ",title:t("Latin small letter i with breve")},{character:"Į",title:t("Latin capital letter i with ogonek")},{character:"į",title:t("Latin small letter i with ogonek")},{character:"İ",title:t("Latin capital letter i with dot above")},{character:"ı",title:t("Latin small letter dotless i")},{character:"IJ",title:t("Latin capital ligature ij")},{character:"ij",title:t("Latin small ligature ij")},{character:"Ĵ",title:t("Latin capital letter j with circumflex")},{character:"ĵ",title:t("Latin small letter j with circumflex")},{character:"Ķ",title:t("Latin capital letter k with cedilla")},{character:"ķ",title:t("Latin small letter k with cedilla")},{character:"ĸ",title:t("Latin small letter kra")},{character:"Ĺ",title:t("Latin capital letter l with acute")},{character:"ĺ",title:t("Latin small letter l with acute")},{character:"Ļ",title:t("Latin capital letter l with cedilla")},{character:"ļ",title:t("Latin small letter l with cedilla")},{character:"Ľ",title:t("Latin capital letter l with caron")},{character:"ľ",title:t("Latin small letter l with caron")},{character:"Ŀ",title:t("Latin capital letter l with middle dot")},{character:"ŀ",title:t("Latin small letter l with middle dot")},{character:"Ł",title:t("Latin capital letter l with stroke")},{character:"ł",title:t("Latin small letter l with stroke")},{character:"Ń",title:t("Latin capital letter n with acute")},{character:"ń",title:t("Latin small letter n with acute")},{character:"Ņ",title:t("Latin capital letter n with cedilla")},{character:"ņ",title:t("Latin small letter n with cedilla")},{character:"Ň",title:t("Latin capital letter n with caron")},{character:"ň",title:t("Latin small letter n with caron")},{character:"ʼn",title:t("Latin small letter n preceded by apostrophe")},{character:"Ŋ",title:t("Latin capital letter eng")},{character:"ŋ",title:t("Latin small letter eng")},{character:"Ō",title:t("Latin capital letter o with macron")},{character:"ō",title:t("Latin small letter o with macron")},{character:"Ŏ",title:t("Latin capital letter o with breve")},{character:"ŏ",title:t("Latin small letter o with breve")},{character:"Ő",title:t("Latin capital letter o with double acute")},{character:"ő",title:t("Latin small letter o with double acute")},{character:"Œ",title:t("Latin capital ligature oe")},{character:"œ",title:t("Latin small ligature oe")},{character:"Ŕ",title:t("Latin capital letter r with acute")},{character:"ŕ",title:t("Latin small letter r with acute")},{character:"Ŗ",title:t("Latin capital letter r with cedilla")},{character:"ŗ",title:t("Latin small letter r with cedilla")},{character:"Ř",title:t("Latin capital letter r with caron")},{character:"ř",title:t("Latin small letter r with caron")},{character:"Ś",title:t("Latin capital letter s with acute")},{character:"ś",title:t("Latin small letter s with acute")},{character:"Ŝ",title:t("Latin capital letter s with circumflex")},{character:"ŝ",title:t("Latin small letter s with circumflex")},{character:"Ş",title:t("Latin capital letter s with cedilla")},{character:"ş",title:t("Latin small letter s with cedilla")},{character:"Š",title:t("Latin capital letter s with caron")},{character:"š",title:t("Latin small letter s with caron")},{character:"Ţ",title:t("Latin capital letter t with cedilla")},{character:"ţ",title:t("Latin small letter t with cedilla")},{character:"Ť",title:t("Latin capital letter t with caron")},{character:"ť",title:t("Latin small letter t with caron")},{character:"Ŧ",title:t("Latin capital letter t with stroke")},{character:"ŧ",title:t("Latin small letter t with stroke")},{character:"Ũ",title:t("Latin capital letter u with tilde")},{character:"ũ",title:t("Latin small letter u with tilde")},{character:"Ū",title:t("Latin capital letter u with macron")},{character:"ū",title:t("Latin small letter u with macron")},{character:"Ŭ",title:t("Latin capital letter u with breve")},{character:"ŭ",title:t("Latin small letter u with breve")},{character:"Ů",title:t("Latin capital letter u with ring above")},{character:"ů",title:t("Latin small letter u with ring above")},{character:"Ű",title:t("Latin capital letter u with double acute")},{character:"ű",title:t("Latin small letter u with double acute")},{character:"Ų",title:t("Latin capital letter u with ogonek")},{character:"ų",title:t("Latin small letter u with ogonek")},{character:"Ŵ",title:t("Latin capital letter w with circumflex")},{character:"ŵ",title:t("Latin small letter w with circumflex")},{character:"Ŷ",title:t("Latin capital letter y with circumflex")},{character:"ŷ",title:t("Latin small letter y with circumflex")},{character:"Ÿ",title:t("Latin capital letter y with diaeresis")},{character:"Ź",title:t("Latin capital letter z with acute")},{character:"ź",title:t("Latin small letter z with acute")},{character:"Ż",title:t("Latin capital letter z with dot above")},{character:"ż",title:t("Latin small letter z with dot above")},{character:"Ž",title:t("Latin capital letter z with caron")},{character:"ž",title:t("Latin small letter z with caron")},{character:"ſ",title:t("Latin small letter long s")}],{label:t("Latin")})}}class G6 extends w{static get pluginName(){return"SpecialCharactersCurrency"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Currency",[{character:"$",title:t("Dollar sign")},{character:"€",title:t("Euro sign")},{character:"¥",title:t("Yen sign")},{character:"£",title:t("Pound sign")},{character:"¢",title:t("Cent sign")},{character:"₠",title:t("Euro-currency sign")},{character:"₡",title:t("Colon sign")},{character:"₢",title:t("Cruzeiro sign")},{character:"₣",title:t("French franc sign")},{character:"₤",title:t("Lira sign")},{character:"¤",title:t("Currency sign")},{character:"₿",title:t("Bitcoin sign")},{character:"₥",title:t("Mill sign")},{character:"₦",title:t("Naira sign")},{character:"₧",title:t("Peseta sign")},{character:"₨",title:t("Rupee sign")},{character:"₩",title:t("Won sign")},{character:"₪",title:t("New sheqel sign")},{character:"₫",title:t("Dong sign")},{character:"₭",title:t("Kip sign")},{character:"₮",title:t("Tugrik sign")},{character:"₯",title:t("Drachma sign")},{character:"₰",title:t("German penny sign")},{character:"₱",title:t("Peso sign")},{character:"₲",title:t("Guarani sign")},{character:"₳",title:t("Austral sign")},{character:"₴",title:t("Hryvnia sign")},{character:"₵",title:t("Cedi sign")},{character:"₶",title:t("Livre tournois sign")},{character:"₷",title:t("Spesmilo sign")},{character:"₸",title:t("Tenge sign")},{character:"₹",title:t("Indian rupee sign")},{character:"₺",title:t("Turkish lira sign")},{character:"₻",title:t("Nordic mark sign")},{character:"₼",title:t("Manat sign")},{character:"₽",title:t("Ruble sign")}],{label:t("Currency")})}}class K6 extends w{static get pluginName(){return"SpecialCharactersEssentials"}static get isOfficialPlugin(){return!0}static get requires(){return[G6,j6,U6,W6,q6]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Z6 extends P{constructor(e,t){super(e),h(this,"styleDefinition"),h(this,"previewView"),this.styleDefinition=t,this.previewView=this._createPreview(),this.set({label:t.name,class:"ck-style-grid__button",withText:!0}),this.extendTemplate({attributes:{role:"option"}}),this.children.add(this.previewView,0)}_createPreview(){const e=new A(this.locale);return e.setTemplate({tag:"div",attributes:{class:["ck","ck-reset_all-excluded","ck-style-grid__button__preview","ck-content"],"aria-hidden":"true"},children:[this.styleDefinition.previewTemplate]}),e}}class J6 extends A{constructor(e,t){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"children"),this.focusTracker=new ee,this.keystrokes=new te,this.set("activeStyles",[]),this.set("enabledStyles",[]),this.children=this.createCollection(),this.children.delegate("execute").to(this);for(const i of t){const o=new Z6(e,i);this.children.add(o)}this.on("change:activeStyles",()=>{for(const i of this.children)i.isOn=this.activeStyles.includes(i.styleDefinition.name)}),this.on("change:enabledStyles",()=>{for(const i of this.children)i.isEnabled=this.enabledStyles.includes(i.styleDefinition.name)}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-grid"],role:"listbox"},children:this.children})}render(){super.render();for(const e of this.children)this.focusTracker.add(e.element);vo({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.children,numberOfColumns:3,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection}),this.keystrokes.listenTo(this.element)}focus(){this.children.first.focus()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}class Sf extends A{constructor(e,t,i){super(e),h(this,"gridView"),h(this,"labelView"),this.labelView=new xt(e),this.labelView.text=t,this.gridView=new J6(e,i),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel__style-group"],role:"group","aria-labelledby":this.labelView.id},children:[this.labelView,this.gridView]})}}class Q6 extends A{constructor(e,t){super(e),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"children"),h(this,"blockStylesGroupView"),h(this,"inlineStylesGroupView"),h(this,"_focusables"),h(this,"_focusCycler");const i=e.t;this.focusTracker=new ee,this.keystrokes=new te,this.children=this.createCollection(),this.blockStylesGroupView=new Sf(e,i("Block styles"),t.block),this.inlineStylesGroupView=new Sf(e,i("Text styles"),t.inline),this.set("activeStyles",[]),this.set("enabledStyles",[]),this._focusables=new Ie,this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:["shift + tab"],focusNext:["tab"]}}),t.block.length&&this.children.add(this.blockStylesGroupView),t.inline.length&&this.children.add(this.inlineStylesGroupView),this.blockStylesGroupView.gridView.delegate("execute").to(this),this.inlineStylesGroupView.gridView.delegate("execute").to(this),this.blockStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.inlineStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel"]},children:this.children})}render(){super.render(),this._focusables.add(this.blockStylesGroupView.gridView),this._focusables.add(this.inlineStylesGroupView.gridView),this.focusTracker.add(this.blockStylesGroupView.gridView.element),this.focusTracker.add(this.inlineStylesGroupView.gridView.element),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}const Y6=["caption","colgroup","dd","dt","figcaption","legend","li","optgroup","option","rp","rt","summary","tbody","td","tfoot","th","thead","tr"];class Ii extends w{constructor(e){super(e),h(this,"_htmlSupport"),this.decorate("isStyleEnabledForBlock"),this.decorate("isStyleActiveForBlock"),this.decorate("getAffectedBlocks"),this.decorate("isStyleEnabledForInlineSelection"),this.decorate("isStyleActiveForInlineSelection"),this.decorate("getAffectedInlineSelectable"),this.decorate("getStylePreview"),this.decorate("configureGHSDataFilter")}static get pluginName(){return"StyleUtils"}static get isOfficialPlugin(){return!0}init(){this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport")}normalizeConfig(e,t=[]){const i={block:[],inline:[]};for(const o of t){const s=[],r=[];for(const l of e.getDefinitionsForView(o.element)){const c="appliesToBlock"in l?l.appliesToBlock:!1;if(l.isBlock||c){if(typeof c=="string")s.push(c);else if(l.isBlock){const u=l;s.push(l.model),u.paragraphLikeModel&&s.push(u.paragraphLikeModel)}}else r.push(l.model)}const a=this.getStylePreview(o,[{text:"AaBbCcDdEeFfGgHhIiJj"}]);s.length?i.block.push({...o,previewTemplate:a,modelElements:s,isBlock:!0}):i.inline.push({...o,previewTemplate:a,ghsAttributes:r})}return i}isStyleEnabledForBlock(e,t){const i=this.editor.model,o=this._htmlSupport.getGhsAttributeNameForElement(e.element);return i.schema.checkAttribute(t,o)?e.modelElements.includes(t.name):!1}isStyleActiveForBlock(e,t){const i=this._htmlSupport.getGhsAttributeNameForElement(e.element),o=t.getAttribute(i);return this.hasAllClasses(o,e.classes)}getAffectedBlocks(e,t){return e.modelElements.includes(t.name)?[t]:null}isStyleEnabledForInlineSelection(e,t){const i=this.editor.model;for(const o of e.ghsAttributes)if(i.schema.checkAttributeInSelection(t,o))return!0;return!1}isStyleActiveForInlineSelection(e,t){for(const i of e.ghsAttributes){const o=this._getValueFromFirstAllowedNode(t,i);if(this.hasAllClasses(o,e.classes))return!0}return!1}getAffectedInlineSelectable(e,t){return t}getStylePreview(e,t){const{element:i,classes:o}=e;return{tag:eR(i)?i:"div",attributes:{class:o},children:t}}hasAllClasses(e,t){return Et(e)&&X6(e)&&t.every(i=>e.classes.includes(i))}configureGHSDataFilter({block:e,inline:t}){const i=this.editor.plugins.get("DataFilter");i.loadAllowedConfig(e.map(Pf)),i.loadAllowedConfig(t.map(Pf))}_getValueFromFirstAllowedNode(e,t){const i=this.editor.model.schema;if(e.isCollapsed)return e.getAttribute(t);for(const o of e.getRanges())for(const s of o.getItems())if(i.checkAttribute(s,t))return s.getAttribute(t);return null}}function X6(n){return!!n.classes&&Array.isArray(n.classes)}function eR(n){return!Y6.includes(n)}function Pf({element:n,classes:e}){return{name:n,classes:e}}class tR extends w{static get pluginName(){return"StyleUI"}static get isOfficialPlugin(){return!0}static get requires(){return[Ii]}init(){const e=this.editor,t=e.plugins.get("DataSchema"),i=e.plugins.get("StyleUtils"),o=e.config.get("style.definitions"),s=i.normalizeConfig(t,o);e.ui.componentFactory.add("style",r=>{const a=r.t,l=Ee(r),c=e.commands.get("style");return l.once("change:isOpen",()=>{const u=new Q6(r,s);l.panelView.children.add(u),u.delegate("execute").to(l),u.bind("activeStyles").to(c,"value"),u.bind("enabledStyles").to(c,"enabledStyles")}),l.bind("isEnabled").to(c),l.buttonView.withText=!0,l.buttonView.bind("label").to(c,"value",u=>u.length>1?a("Multiple styles"):u.length===1?u[0]:a("Styles")),l.bind("class").to(c,"value",u=>{const d=["ck-style-dropdown"];return u.length>1&&d.push("ck-style-dropdown_multiple-active"),d.join(" ")}),l.on("execute",u=>{e.execute("style",{styleName:u.source.styleDefinition.name}),e.editing.view.focus()}),l})}}class iR extends O{constructor(e,t){super(e),h(this,"_styleDefinitions"),h(this,"_styleUtils"),this.set("value",[]),this.set("enabledStyles",[]),this._styleDefinitions=t,this._styleUtils=this.editor.plugins.get(Ii)}refresh(){const e=this.editor.model,t=e.document.selection,i=new Set,o=new Set;for(const r of this._styleDefinitions.inline)this._styleUtils.isStyleEnabledForInlineSelection(r,t)&&o.add(r.name),this._styleUtils.isStyleActiveForInlineSelection(r,t)&&i.add(r.name);const s=ae(t.getSelectedBlocks())||t.getFirstPosition().parent;if(s){const r=s.getAncestors({includeSelf:!0,parentFirst:!0});for(const a of r){if(a.is("rootElement"))break;for(const l of this._styleDefinitions.block)this._styleUtils.isStyleEnabledForBlock(l,a)&&(o.add(l.name),this._styleUtils.isStyleActiveForBlock(l,a)&&i.add(l.name));if(e.schema.isObject(a))break}}this.enabledStyles=Array.from(o).sort(),this.isEnabled=this.enabledStyles.length>0,this.value=this.isEnabled?Array.from(i).sort():[]}execute({styleName:e,forceValue:t}){if(!this.enabledStyles.includes(e)){J("style-command-executed-with-incorrect-style-name");return}const i=this.editor.model,o=i.document.selection,s=this.editor.plugins.get("GeneralHtmlSupport"),r=[...this._styleDefinitions.inline,...this._styleDefinitions.block],a=r.filter(({name:u})=>this.value.includes(u)),l=r.find(({name:u})=>u==e),c=t===void 0?!this.value.includes(l.name):t;i.change(()=>{let u;oR(l)?u=this._findAffectedBlocks(sR(o),l):u=[this._styleUtils.getAffectedInlineSelectable(l,o)];for(const d of u)c?s.addModelHtmlClass(l.element,l.classes,d):s.removeModelHtmlClass(l.element,nR(a,l),d)})}_findAffectedBlocks(e,t){const i=new Set;for(const o of e){const s=o.getAncestors({includeSelf:!0,parentFirst:!0});for(const r of s){if(r.is("rootElement"))break;const a=this._styleUtils.getAffectedBlocks(t,r);if(a){for(const l of a)i.add(l);break}}}return i}}function nR(n,e){return n.reduce((t,i)=>i.name===e.name?t:t.filter(o=>!i.classes.includes(o)),e.classes)}function oR(n){return"isBlock"in n}function sR(n){const e=Array.from(n.getSelectedBlocks());return e.length?e:[n.getFirstPosition().parent]}class rR extends w{constructor(){super(...arguments),h(this,"_listUtils"),h(this,"_styleUtils"),h(this,"_htmlSupport")}static get pluginName(){return"ListStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[Ii,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("ListEditing")&&(this._styleUtils=e.plugins.get(Ii),this._listUtils=this.editor.plugins.get("ListUtils"),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",(t,[i,o])=>{this._isStyleEnabledForBlock(i,o)&&(t.return=!0,t.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForBlock",(t,[i,o])=>{this._isStyleActiveForBlock(i,o)&&(t.return=!0,t.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",(t,[i,o])=>{const s=this._getAffectedBlocks(i,o);s&&(t.return=s,t.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getStylePreview",(t,[i,o])=>{const s=this._getStylePreview(i,o);s&&(t.return=s,t.stop())},{priority:"high"}))}_isStyleEnabledForBlock(e,t){const i=this.editor.model;if(!["ol","ul","li"].includes(e.element)||!this._listUtils.isListItemBlock(t))return!1;const o=this._htmlSupport.getGhsAttributeNameForElement(e.element);if(e.element=="ol"||e.element=="ul"){if(!i.schema.checkAttribute(t,o))return!1;const s=this._listUtils.isNumberedListType(t.getAttribute("listType"))?"ol":"ul";return e.element==s}else return i.schema.checkAttribute(t,o)}_isStyleActiveForBlock(e,t){const i=this._htmlSupport.getGhsAttributeNameForElement(e.element),o=t.getAttribute(i);return this._styleUtils.hasAllClasses(o,e.classes)}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?e.element=="li"?this._listUtils.expandListBlocksToCompleteItems(t,{withNested:!1}):this._listUtils.expandListBlocksToCompleteList(t):null}_getStylePreview(e,t){const{element:i,classes:o}=e;return i=="ol"||i=="ul"?{tag:i,attributes:{class:o},children:[{tag:"li",children:t}]}:i=="li"?{tag:"ol",children:[{tag:i,attributes:{class:o},children:t}]}:null}}class aR extends w{constructor(){super(...arguments),h(this,"_tableUtils"),h(this,"_styleUtils")}static get pluginName(){return"TableStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[Ii]}init(){const e=this.editor;e.plugins.has("TableEditing")&&(this._styleUtils=e.plugins.get(Ii),this._tableUtils=this.editor.plugins.get("TableUtils"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",(t,[i,o])=>{this._isApplicable(i,o)&&(t.return=this._isStyleEnabledForBlock(i,o),t.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",(t,[i,o])=>{this._isApplicable(i,o)&&(t.return=this._getAffectedBlocks(i,o),t.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"configureGHSDataFilter",(t,[{block:i}])=>{this.editor.plugins.get("DataFilter").loadAllowedConfig(i.filter(o=>o.element=="figcaption").map(o=>({name:"caption",classes:o.classes})))}))}_isApplicable(e,t){return["td","th"].includes(e.element)?t.name=="tableCell":["thead","tbody"].includes(e.element)?t.name=="table":!1}_isStyleEnabledForBlock(e,t){if(["td","th"].includes(e.element)){const i=this._tableUtils.getCellLocation(t),o=t.parent.parent,s=o.getAttribute("headingRows")||0,r=o.getAttribute("headingColumns")||0,a=i.row<s||i.column<r;return e.element=="th"?a:!a}if(["thead","tbody"].includes(e.element)){const i=t.getAttribute("headingRows")||0;return e.element=="thead"?i>0:i<this._tableUtils.getRows(t)}/* istanbul ignore next -- @preserve */return!1}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?[t]:null}}class lR extends w{constructor(){super(...arguments),h(this,"_styleUtils"),h(this,"_htmlSupport")}static get pluginName(){return"LinkStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[Ii,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("LinkEditing")&&(this._styleUtils=e.plugins.get(Ii),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForInlineSelection",(t,[i,o])=>{i.element=="a"&&(t.return=this._isStyleEnabled(i,o),t.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForInlineSelection",(t,[i,o])=>{i.element=="a"&&(t.return=this._isStyleActive(i,o),t.stop())},{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedInlineSelectable",(t,[i,o])=>{if(i.element!="a")return;const s=this._getAffectedSelectable(i,o);s&&(t.return=s,t.stop())},{priority:"high"}))}_isStyleEnabled(e,t){const i=this.editor.model;if(t.isCollapsed)return t.hasAttribute("linkHref");for(const o of t.getRanges())for(const s of o.getItems())if((s.is("$textProxy")||i.schema.isInline(s))&&s.hasAttribute("linkHref"))return!0;return!1}_isStyleActive(e,t){const i=this.editor.model,o=this._htmlSupport.getGhsAttributeNameForElement(e.element);if(t.isCollapsed){if(t.hasAttribute("linkHref")){const s=t.getAttribute(o);if(this._styleUtils.hasAllClasses(s,e.classes))return!0}return!1}for(const s of t.getRanges())for(const r of s.getItems())if((r.is("$textProxy")||i.schema.isInline(r))&&r.hasAttribute("linkHref")){const a=r.getAttribute(o);return this._styleUtils.hasAllClasses(a,e.classes)}return!1}_getAffectedSelectable(e,t){const i=this.editor.model;if(t.isCollapsed){const s=t.getAttribute("linkHref");return Ps(t.getFirstPosition(),"linkHref",s,i)}const o=[];for(const s of t.getRanges()){const r=i.createRange(If(s.start,"linkHref",!0,i),If(s.end,"linkHref",!1,i));for(const a of r.getItems())(a.is("$textProxy")||i.schema.isInline(a))&&a.hasAttribute("linkHref")&&o.push(this.editor.model.createRangeOn(a))}return cR(o)}}function If(n,e,t,i){const o=n.textNode||(t?n.nodeAfter:n.nodeBefore);if(!o||!o.hasAttribute(e))return n;const s=o.getAttribute(e);return ic(n,e,s,t,i)}function cR(n){for(let e=1;e<n.length;e++){const t=n[e-1].getJoined(n[e]);t&&n.splice(--e,2,t)}return n}class uR extends w{static get pluginName(){return"StyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return["GeneralHtmlSupport",Ii,rR,aR,lR]}init(){const e=this.editor,t=e.plugins.get("DataSchema"),i=e.plugins.get("StyleUtils"),o=e.config.get("style.definitions"),s=i.normalizeConfig(t,o);e.commands.add("style",new iR(e,s)),i.configureGHSDataFilter(s)}}class hR extends w{static get pluginName(){return"Style"}static get isOfficialPlugin(){return!0}static get requires(){return[uR,tR]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Nu(n,e){const{modelAttribute:t,styleName:i,viewElement:o,defaultValue:s,reduceBoxSides:r=!1,shouldUpcast:a=()=>!0}=e;n.for("upcast").attributeToAttribute({view:{name:o,styles:{[i]:/[\s\S]+/}},model:{key:t,value:(l,c,u)=>{if(!a(l))return;const d=qi(s,"",u),m=l.getNormalizedStyle(i),f=r?vr(m):m;if(d!==f)return f}}})}function wc(n,e,t,i){n.for("upcast").add(o=>o.on("element:"+e,(s,r,a)=>{if(!r.modelRange)return;const l=["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(p=>r.viewItem.hasStyle(p));if(!l.length)return;const c={styles:l};if(!a.consumable.test(r.viewItem,c))return;const u=[...r.modelRange.getItems({shallow:!0})].pop(),d=u.findAncestor("table",{includeSelf:!0});let m=i;d&&d.getAttribute("tableType")=="layout"&&(m={style:"none",color:"",width:""}),a.consumable.consume(r.viewItem,c);const f={style:r.viewItem.getNormalizedStyle("border-style"),color:r.viewItem.getNormalizedStyle("border-color"),width:r.viewItem.getNormalizedStyle("border-width")},g={style:vr(f.style),color:vr(f.color),width:vr(f.width)};g.style!==m.style&&a.writer.setAttribute(t.style,g.style,u),g.color!==m.color&&a.writer.setAttribute(t.color,g.color,u),g.width!==m.width&&a.writer.setAttribute(t.width,g.width,u)}))}function ss(n,e){const{modelElement:t,modelAttribute:i,styleName:o}=e;n.for("downcast").attributeToAttribute({model:{name:t,key:i},view:s=>({key:"style",value:{[o]:s}})})}function _r(n,e){const{modelAttribute:t,styleName:i}=e;n.for("downcast").add(o=>o.on(`attribute:${t}:table`,(s,r,a)=>{const{item:l,attributeNewValue:c}=r,{mapper:u,writer:d}=a;if(!a.consumable.consume(r.item,s.name))return;const m=[...u.toViewElement(l).getChildren()].find(f=>f.is("element","table"));c?d.setStyle(i,c,m):d.removeStyle(i,m)}))}function qi(n,e,t){const i=t.modelRange&&ae(t.modelRange.getItems({shallow:!0})),o=i&&i.is("element")&&i.findAncestor("table",{includeSelf:!0});return o&&o.getAttribute("tableType")==="layout"?e:n}function vr(n){if(!n)return;const e=["top","right","bottom","left"];if(!e.every(i=>n[i]))return n;const t=n.top;return e.every(i=>n[i]===t)?t:n}function Re(n,e,t,i,o=1){e!=null&&o!==void 0&&o!==null&&e>o?i.setAttribute(n,e,t):i.removeAttribute(n,t)}function In(n,e,t={}){const i=n.createElement("tableCell",t);return n.insertElement("paragraph",i),n.insert(i,e),i}function bc(n,e){const t=e.parent.parent,i=parseInt(t.getAttribute("headingColumns")||"0"),{column:o}=n.getCellLocation(e);return!!i&&o<i}function yr(n,e,t){const{modelAttribute:i}=t;n.extend("tableCell",{allowAttributes:[i]}),Nu(e,{viewElement:/^(td|th)$/,...t}),ss(e,{modelElement:"tableCell",...t})}function Gi(n){const e=n.getSelectedElement();return e&&e.is("element","table")?e:n.getFirstPosition().findAncestor("table")}function dR(){return n=>{n.on("element:figure",(e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const o=gR(t.viewItem);if(!o||!i.consumable.test(o,{name:!0}))return;i.consumable.consume(t.viewItem,{name:!0,classes:"table"});const s=i.convertItem(o,t.modelCursor),r=ae(s.modelRange.getItems());if(!r){i.consumable.revert(t.viewItem,{name:!0,classes:"table"});return}i.convertChildren(t.viewItem,i.writer.createPositionAt(r,"end")),i.updateConversionResult(r,t)})}}function mR(){return n=>{n.on("element:table",(e,t,i)=>{const o=t.viewItem;if(!i.consumable.test(o,{name:!0}))return;const{rows:s,headingRows:r,headingColumns:a}=pR(o),l={};a&&(l.headingColumns=a),r&&(l.headingRows=r);const c=i.writer.createElement("table",l);if(i.safeInsert(c,t.modelCursor)){if(i.consumable.consume(o,{name:!0}),s.forEach(u=>i.convertItem(u,i.writer.createPositionAt(c,"end"))),i.convertChildren(o,i.writer.createPositionAt(c,"end")),c.isEmpty){const u=i.writer.createElement("tableRow");i.writer.insert(u,i.writer.createPositionAt(c,"end")),In(i.writer,i.writer.createPositionAt(u,"end"))}i.updateConversionResult(c,t)}})}}function fR(){return n=>{n.on("element:tr",(e,t)=>{t.viewItem.isEmpty&&t.modelCursor.index==0&&e.stop()},{priority:"high"})}}function Vf(n){return e=>{e.on(`element:${n}`,(t,i,{writer:o})=>{if(!i.modelRange)return;const s=i.modelRange.start.nodeAfter,r=o.createPositionAt(s,0);if(i.viewItem.isEmpty){o.insertElement("paragraph",r);return}const a=Array.from(s.getChildren());if(a.every(l=>l.is("element","$marker"))){const l=o.createElement("paragraph");o.insert(l,o.createPositionAt(s,0));for(const c of a)o.move(o.createRangeOn(c),o.createPositionAt(l,"end"))}},{priority:"low"})}}function gR(n){for(const e of n.getChildren())if(e.is("element","table"))return e}function pR(n){let e=0,t;const i=[],o=[];let s;for(const r of Array.from(n.getChildren())){if(r.name!=="tbody"&&r.name!=="thead"&&r.name!=="tfoot")continue;r.name==="thead"&&!s&&(s=r);const a=Array.from(r.getChildren()).filter(c=>c.is("element","tr"));let l=null;for(const c of a){const u=Array.from(c.getChildren()).filter(d=>d.is("element","td")||d.is("element","th"));if(s&&r===s||r.name==="tbody"&&u.length>0&&(l===null||u.length===l)&&u.every(d=>d.is("element","th")))e++,i.push(c);else{o.push(c);const d=wR(c);(!t||d<t)&&(t=d)}l=Math.max(l||0,u.length)}}return{headingRows:e,headingColumns:t||0,rows:[...i,...o]}}function wR(n){let e=0,t=0;const i=Array.from(n.getChildren()).filter(o=>o.name==="th"||o.name==="td");for(;t<i.length&&i[t].name==="th";){const o=i[t],s=parseInt(o.getAttribute("colspan")||"1");e=e+s,t++}return e}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class de{constructor(e,t={}){h(this,"_table"),h(this,"_startRow"),h(this,"_endRow"),h(this,"_startColumn"),h(this,"_endColumn"),h(this,"_includeAllSlots"),h(this,"_skipRows"),h(this,"_row"),h(this,"_rowIndex"),h(this,"_column"),h(this,"_cellIndex"),h(this,"_spannedCells"),h(this,"_nextCellAtColumn"),h(this,"_jumpedToStartRow",!1),this._table=e,this._startRow=t.row!==void 0?t.row:t.startRow||0,this._endRow=t.row!==void 0?t.row:t.endRow,this._startColumn=t.column!==void 0?t.column:t.startColumn||0,this._endColumn=t.column!==void 0?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){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 o=e.getChild(this._cellIndex);if(!o)return this._advanceToNextRow();const s=parseInt(o.getAttribute("colspan")||"1"),r=parseInt(o.getAttribute("rowspan")||"1");(s>1||r>1)&&this._recordSpans(o,r,s),this._shouldSkipSlot()||(t=this._formatOutValue(o)),this._nextCellAtColumn=this._column+s}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return this._endRow!==void 0&&this._row>this._endRow}_isOverEndColumn(){return this._endColumn!==void 0&&this._column>this._endColumn}_formatOutValue(e,t=this._row,i=this._column){return{done:!1,value:new bR(this,e,t,i)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._row<this._startRow,i=this._column<this._startColumn,o=this._endColumn!==void 0&&this._column>this._endColumn;return e||t||i||o}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,i){const o={cell:e,row:this._row,column:this._column};for(let s=this._row;s<this._row+t;s++)for(let r=this._column;r<this._column+i;r++)(s!=this._row||r!=this._column)&&this._markSpannedCell(s,r,o)}_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((t,i)=>t+parseInt(i.getAttribute("colspan")||"1"),0)}}class bR{constructor(e,t,i,o){h(this,"cell"),h(this,"row"),h(this,"column"),h(this,"cellAnchorRow"),h(this,"cellAnchorColumn"),h(this,"_cellIndex"),h(this,"_rowIndex"),h(this,"_table"),this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=i,this.cellAnchorColumn=o,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 Rf(n,e){return(t,{writer:i})=>{const o=t.getAttribute("headingRows")||0,s=i.createContainerElement("table",null,[]),r=i.createContainerElement("figure",{class:"table"},s);o>0&&i.insert(i.createPositionAt(s,"end"),i.createContainerElement("thead",null,i.createSlot(a=>a.is("element","tableRow")&&a.index<o))),o<n.getRows(t)&&i.insert(i.createPositionAt(s,"end"),i.createContainerElement("tbody",null,i.createSlot(a=>a.is("element","tableRow")&&a.index>=o)));for(const{positionOffset:a,filter:l}of e.additionalSlots)i.insert(i.createPositionAt(s,a),i.createSlot(l));return i.insert(i.createPositionAt(s,"after"),i.createSlot(a=>a.is("element","tableRow")?!1:!e.additionalSlots.some(({filter:l})=>l(a)))),e.asWidget?vR(r,i):r}}function _R(){return(n,{writer:e})=>n.isEmpty?e.createEmptyElement("tr"):e.createContainerElement("tr")}function Of(n={}){return(e,{writer:t})=>{const i=e.parent,o=i.parent,s=o.getChildIndex(i),r=new de(o,{row:s}),a=o.getAttribute("headingRows")||0,l=o.getAttribute("headingColumns")||0;let c=null;for(const u of r)if(u.cell==e){const d=u.row<a||u.column<l?"th":"td";c=n.asWidget?wa(t.createEditableElement(d),t,{withAriaRole:!1}):t.createContainerElement(d);break}return c}}function Bf(n={}){return(e,{writer:t})=>{if(!e.parent.is("element","tableCell")||!t0(e))return null;if(n.asWidget)return t.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const i=t.createContainerElement("p");return t.setCustomProperty("dataPipeline:transparentRendering",!0,i),i}}}function t0(n){return n.parent.childCount==1&&!yR(n)}function vR(n,e){return e.setCustomProperty("table",!0,n),gt(n,e,{hasSelectionHandle:!0})}function yR(n){for(const e of n.getAttributeKeys())if(!(e.startsWith("selection:")||e=="htmlEmptyBlock"))return!0;return!1}class kR extends O{refresh(){const e=this.editor.model,t=e.document.selection,i=e.schema;this.isEnabled=CR(t,i)}execute(e={}){const t=this.editor,i=t.model,o=t.plugins.get("TableUtils"),s=t.config.get("table.defaultHeadings.rows"),r=t.config.get("table.defaultHeadings.columns");e.headingRows===void 0&&s&&(e.headingRows=s),e.headingColumns===void 0&&r&&(e.headingColumns=r),i.change(a=>{const l=o.createTable(a,e);i.insertObject(l,null,null,{findOptimalPosition:"auto"}),a.setSelection(a.createPositionAt(l.getNodeByPath([0,0,0]),0))})}}function CR(n,e){const t=n.getFirstPosition().parent,i=t===t.root?t:t.parent;return e.checkChild(i,"table")}class Mf extends O{constructor(e,t={}){super(e),h(this,"order"),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"),o=this.order==="above",s=i.getSelectionAffectedTableCells(t),r=i.getRowIndexes(s),a=o?r.first:r.last,l=s[0].findAncestor("table");i.insertRows(l,{at:o?a:a+1,copyStructureFromAbove:!o})}}class Lf extends O{constructor(e,t={}){super(e),h(this,"order"),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"),o=this.order==="left",s=i.getSelectionAffectedTableCells(t),r=i.getColumnIndexes(s),a=o?r.first:r.last,l=s[0].findAncestor("table");i.insertColumns(l,{columns:1,at:o?a:a+1})}}class Ff extends O{constructor(e,t={}){super(e),h(this,"direction"),this.direction=t.direction||"horizontally"}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length===1}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];this.direction==="horizontally"?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}function i0(n,e,t){const{startRow:i,startColumn:o,endRow:s,endColumn:r}=e,a=t.createElement("table"),l=n.getAttribute("tableType");l&&t.setAttribute("tableType",l,a);const c=s-i+1;for(let d=0;d<c;d++)t.insertElement("tableRow",a,"end");const u=[...new de(n,{startRow:i,endRow:s,startColumn:o,endColumn:r,includeAllSlots:!0})];for(const{row:d,column:m,cell:f,isAnchor:g,cellAnchorRow:p,cellAnchorColumn:_}of u){const v=d-i,E=a.getChild(v);if(!g)(p<i||_<o)&&In(t,t.createPositionAt(E,"end"));else{const M=t.cloneElement(f);t.append(M,E),a0(M,d,m,s,r,t)}}return AR(a,n,i,o,t),a}function n0(n,e,t=0){const i=[],o=new de(n,{startRow:t,endRow:e-1});for(const s of o){const{row:r,cellHeight:a}=s,l=r+a-1;r<e&&e<=l&&i.push(s)}return i}function o0(n,e,t){const i=n.parent,o=i.parent,s=i.index,r=parseInt(n.getAttribute("rowspan")),a=e-s,l={},c=r-a;c>1&&(l.rowspan=c);const u=parseInt(n.getAttribute("colspan")||"1");u>1&&(l.colspan=u);const d=s,m=d+a,f=[...new de(o,{startRow:d,endRow:m,includeAllSlots:!0})];let g=null,p;for(const _ of f){const{row:v,column:E,cell:M}=_;M===n&&p===void 0&&(p=E),p!==void 0&&p===E&&v===m&&(g=In(t,_.getPositionBefore(),l))}return Re("rowspan",a,n,t),g}function s0(n,e){const t=[],i=new de(n);for(const o of i){const{column:s,cellWidth:r}=o,a=s+r-1;s<e&&e<=a&&t.push(o)}return t}function r0(n,e,t,i){const o=parseInt(n.getAttribute("colspan")),s=t-e,r={},a=o-s;a>1&&(r.colspan=a);const l=parseInt(n.getAttribute("rowspan")||"1");l>1&&(r.rowspan=l);const c=In(i,i.createPositionAfter(n),r);return Re("colspan",s,n,i),c}function a0(n,e,t,i,o,s){const r=parseInt(n.getAttribute("colspan")||"1"),a=parseInt(n.getAttribute("rowspan")||"1");if(t+r-1>o){const l=o-t+1;Re("colspan",l,n,s,1)}if(e+a-1>i){const l=i-e+1;Re("rowspan",l,n,s,1)}}function AR(n,e,t,i,o){const s=parseInt(e.getAttribute("headingRows")||"0");if(s>0){const a=s-t;Re("headingRows",a,n,o,0)}const r=parseInt(e.getAttribute("headingColumns")||"0");if(r>0){const a=r-i;Re("headingColumns",a,n,o,0)}}function _c(n,e){const t=e.getColumns(n),i=new Array(t).fill(0);for(const{column:s}of new de(n))i[s]++;const o=i.reduce((s,r,a)=>r?s:[...s,a],[]);if(o.length>0){const s=o[o.length-1];return e.removeColumns(n,{at:s}),!0}return!1}function vc(n,e){const t=[],i=e.getRows(n);for(let o=0;o<i;o++)n.getChild(o).isEmpty&&t.push(o);if(t.length>0){const o=t[t.length-1];return e.removeRows(n,{at:o}),!0}return!1}function Du(n,e){_c(n,e)||vc(n,e)}function l0(n,e){const t=Array.from(new de(n,{startColumn:e.firstColumn,endColumn:e.lastColumn,row:e.lastRow}));if(t.every(({cellHeight:o})=>o===1))return e.lastRow;const i=t[0].cellHeight-1;return e.lastRow+i}function c0(n,e){const t=Array.from(new de(n,{startRow:e.firstRow,endRow:e.lastRow,column:e.lastColumn}));if(t.every(({cellWidth:o})=>o===1))return e.lastColumn;const i=t[0].cellWidth-1;return e.lastColumn+i}class sr extends O{constructor(e,t){super(e),h(this,"direction"),h(this,"isHorizontal"),this.direction=t.direction,this.isHorizontal=this.direction=="right"||this.direction=="left"}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,i=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],o=this.value,s=this.direction;e.change(r=>{const a=s=="right"||s=="down",l=a?i:o,c=a?o:i,u=c.parent;ER(c,l,r);const d=this.isHorizontal?"colspan":"rowspan",m=parseInt(i.getAttribute(d)||"1"),f=parseInt(o.getAttribute(d)||"1");r.setAttribute(d,m+f,l),r.setSelection(r.createRangeIn(l));const g=this.editor.plugins.get("TableUtils"),p=u.findAncestor("table");Du(p,g)})}_getMergeableCell(){const e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),i=t.getTableCellsContainingSelection(e.selection)[0];if(!i)return;const o=this.isHorizontal?xR(i,this.direction,t):TR(i,this.direction,t);if(!o)return;const s=this.isHorizontal?"rowspan":"colspan",r=parseInt(i.getAttribute(s)||"1");if(parseInt(o.getAttribute(s)||"1")===r)return o}}function xR(n,e,t){const i=n.parent.parent,o=e=="right"?n.nextSibling:n.previousSibling,s=(i.getAttribute("headingColumns")||0)>0;if(!o)return;const r=e=="right"?n:o,a=e=="right"?o:n,{column:l}=t.getCellLocation(r),{column:c}=t.getCellLocation(a),u=parseInt(r.getAttribute("colspan")||"1"),d=bc(t,r),m=bc(t,a);return s&&d!=m?void 0:l+u===c?o:void 0}function TR(n,e,t){const i=n.parent,o=i.parent,s=o.getChildIndex(i);if(e=="down"&&s===t.getRows(o)-1||e=="up"&&s===0)return null;const r=parseInt(n.getAttribute("rowspan")||"1"),a=o.getAttribute("headingRows")||0,l=e=="down"&&s+r===a,c=e=="up"&&s===a;if(a&&(l||c))return null;const u=parseInt(n.getAttribute("rowspan")||"1"),d=e=="down"?s+u:s,m=[...new de(o,{endRow:d})],f=m.find(p=>p.cell===n).column,g=m.find(({row:p,cellHeight:_,column:v})=>v!==f?!1:e=="down"?p===d:d===p+_);return g&&g.cell?g.cell:null}function ER(n,e,t){Nf(n)||(Nf(e)&&t.remove(t.createRangeIn(e)),t.move(t.createRangeIn(n),t.createPositionAt(e,"end"))),t.remove(n)}function Nf(n){const e=n.getChild(0);return n.childCount==1&&e.is("element","paragraph")&&e.isEmpty}class SR extends O{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const o=i.findAncestor("table"),s=e.getRows(o)-1,r=e.getRowIndexes(t),a=r.first===0&&r.last===s;this.isEnabled=!a}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),o=t.getRowIndexes(i),s=i[0],r=s.findAncestor("table"),a=t.getCellLocation(s).column;e.change(l=>{const c=o.last-o.first+1;t.removeRows(r,{at:o.first,rows:c});const u=PR(r,o.first,a,t.getRows(r));l.setSelection(l.createPositionAt(u,0))})}}function PR(n,e,t,i){const o=n.getChild(Math.min(e,i-1));let s=o.getChild(0),r=0;for(const a of o.getChildren()){if(r>t)return s;s=a,r+=parseInt(a.getAttribute("colspan")||"1")}return s}class IR extends O{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const o=i.findAncestor("table"),s=e.getColumns(o),{first:r,last:a}=e.getColumnIndexes(t);this.isEnabled=a-r<s-1}else this.isEnabled=!1}execute(){const e=this.editor.plugins.get("TableUtils"),[t,i]=RR(this.editor.model.document.selection,e),o=t.parent.parent,s=[...new de(o)],r={first:s.find(l=>l.cell===t).column,last:s.find(l=>l.cell===i).column},a=VR(s,t,i,r);this.editor.model.change(l=>{const c=r.last-r.first+1;e.removeColumns(o,{at:r.first,columns:c}),l.setSelection(l.createPositionAt(a,0))})}}function VR(n,e,t,i){return parseInt(t.getAttribute("colspan")||"1")>1?t:e.previousSibling||t.nextSibling?t.nextSibling||e.previousSibling:i.first?n.reverse().find(({column:o})=>o<i.first).cell:n.reverse().find(({column:o})=>o>i.last).cell}function RR(n,e){const t=e.getSelectionAffectedTableCells(n),i=t[0],o=t.pop(),s=[i,o];return i.isBefore(o)?s:s.reverse()}class OR extends O{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection);if(i.length===0){this.isEnabled=!1,this.value=!1;return}const o=i[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(o,"headingRows"),this.value=i.every(s=>this._isInHeading(s,s.parent.parent))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,o=t.getSelectionAffectedTableCells(i.document.selection),s=o[0].findAncestor("table"),{first:r,last:a}=t.getRowIndexes(o),l=this.value?r:a+1,c=s.getAttribute("headingRows")||0;i.change(u=>{if(l){const d=l>c?c:0,m=n0(s,l,d);for(const{cell:f}of m)o0(f,l,u)}Re("headingRows",l,s,u,0)})}_isInHeading(e,t){const i=parseInt(t.getAttribute("headingRows")||"0");return!!i&&e.parent.index<i}}class BR extends O{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection);if(i.length===0){this.isEnabled=!1,this.value=!1;return}const o=i[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(o,"headingColumns"),this.value=i.every(s=>bc(e,s))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,o=t.getSelectionAffectedTableCells(i.document.selection),s=o[0].findAncestor("table"),{first:r,last:a}=t.getColumnIndexes(o),l=this.value?r:a+1;i.change(c=>{if(l){const u=s0(s,l);for(const{cell:d,column:m}of u)r0(d,m,l,c)}Re("headingColumns",l,s,c,0)})}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const MR=5,yc=40,LR=2,FR=3;function NR(n){const e=new Set;for(const t of n.document.differ.getChanges()){let i=null;switch(t.type){case"insert":i=["table","tableRow","tableCell"].includes(t.name)?t.position:null;break;case"remove":i=["tableRow","tableCell"].includes(t.name)?t.position:null;break;case"attribute":t.range.start.nodeAfter&&(i=["table","tableRow","tableCell"].includes(t.range.start.nodeAfter.name)?t.range.start:null);break}if(!i)continue;const o=i.nodeAfter&&i.nodeAfter.is("element","table")?i.nodeAfter:i.findAncestor("table");for(const s of n.createRangeOn(o).getItems())s.is("element","table")&&Rs(s)&&e.add(s)}return e}function DR(n,e){return yc*100/u0(n,e)}function u0(n,e){const t=Df(n,"tbody",e)||Df(n,"thead",e),i=e.editing.view.domConverter.mapViewToDom(t);return kc(i)}function Df(n,e,t){return[...[...t.editing.mapper.toViewElement(n).getChildren()].find(i=>i.is("element","table")).getChildren()].find(i=>i.is("element",e))}function kc(n){const e=I.window.getComputedStyle(n);return e.boxSizing==="border-box"?parseFloat(e.width)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth):parseFloat(e.width)}function zR(n,e){const t=e.getCellLocation(n).column,i=n.getAttribute("colspan")||1;return{leftEdge:t,rightEdge:t+i-1}}function ut(n){const e=Math.pow(10,LR),t=typeof n=="number"?n:parseFloat(n);return Math.round(t*e)/e}function HR(n,e,t){return n<=e?ut(e):n>=t?ut(t):ut(n)}function $R(n,e){return Array(n).fill(e)}function Ts(n){return n.map(e=>typeof e=="number"?e:parseFloat(e)).filter(e=>!Number.isNaN(e)).reduce((e,t)=>e+t,0)}function zu(n){const e=n.map(o=>o==="auto"?o:parseFloat(o.replace("%","")));let t=WR(e);const i=Ts(t);return i!==100&&(t=t.map(o=>ut(o*100/i)).map((o,s,r)=>{if(s!==r.length-1)return o;const a=Ts(r);return ut(o+100-a)})),t.map(o=>o+"%")}function WR(n){const e=n.filter(o=>o==="auto").length;if(e===0)return n.map(o=>ut(o));const t=Ts(n),i=Math.max((100-t)/e,MR);return n.map(o=>o==="auto"?i:o).map(o=>ut(o))}function jR(n){const e=I.window.getComputedStyle(n);return e.boxSizing==="border-box"?parseInt(e.width):parseFloat(e.width)+parseFloat(e.paddingLeft)+parseFloat(e.paddingRight)+parseFloat(e.borderWidth)}function h0(n,e,t,i){for(let o=0;o<Math.max(t.length,n.length);o++){const s=n[o],r=t[o];r?s?i.setAttribute("columnWidth",r,s):i.appendElement("tableColumn",{columnWidth:r},e):i.remove(s)}}function Rs(n){if(n.is("element","tableColumnGroup"))return n;const e=n.getChildren();return Array.from(e).find(t=>t.is("element","tableColumnGroup"))}function Os(n){const e=Rs(n);return e?Array.from(e.getChildren()):[]}function UR(n){return Os(n).map(e=>e.getAttribute("columnWidth"))}function qR(n,e){return Os(n).reduce((t,i)=>{const o=i.getAttribute("columnWidth"),s=i.getAttribute("colSpan");if(!s)return t.push(o),t;for(let r=0;r<s;r++)t.push(o);return e.removeAttribute("colSpan",i),t},[])}class We extends w{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,o=i.getChildIndex(t),s=new de(i,{row:o});for(const{cell:r,row:a,column:l}of s)if(r===e)return{row:a,column:l};/* istanbul ignore next -- @preserve */}createTable(e,t){const i=e.createElement("table"),o=t.rows||2,s=t.columns||2;return xl(e,i,0,o,s),t.headingRows&&Re("headingRows",Math.min(t.headingRows,o),i,e,0),t.headingColumns&&Re("headingColumns",Math.min(t.headingColumns,s),i,e,0),i}insertRows(e,t={}){const i=this.editor.model,o=t.at||0,s=t.rows||1,r=t.copyStructureFromAbove!==void 0,a=t.copyStructureFromAbove?o-1:o,l=this.getRows(e),c=this.getColumns(e);if(o>l)throw new b("tableutils-insertrows-insert-out-of-range",this,{options:t});i.change(u=>{const d=e.getAttribute("headingRows")||0;if(d>o&&Re("headingRows",d+s,e,u,0),!r&&(o===0||o===l)){xl(u,e,o,s,c);return}const m=r?Math.max(o,a):o,f=new de(e,{endRow:m}),g=new Array(c).fill(1);for(const{row:p,column:_,cellHeight:v,cellWidth:E,cell:M}of f){const G=p+v-1,X=p<o&&o<=G,T=p<=a&&a<=G;X?(u.setAttribute("rowspan",v+s,M),g[_]=-E):r&&T&&(g[_]=E)}for(let p=0;p<s;p++){const _=u.createElement("tableRow");u.insert(_,e,o);for(let v=0;v<g.length;v++){const E=g[v],M=u.createPositionAt(_,"end");E>0&&In(u,M,E>1?{colspan:E}:void 0),v+=Math.abs(E)-1}}})}insertColumns(e,t={}){const i=this.editor.model,o=t.at||0,s=t.columns||1;i.change(r=>{const a=e.getAttribute("headingColumns");o<a&&r.setAttribute("headingColumns",a+s,e);const l=this.getColumns(e);if(o===0||l===o){for(const u of e.getChildren())u.is("element","tableRow")&&Xn(s,r,r.createPositionAt(u,o?"end":0));return}const c=new de(e,{column:o,includeAllSlots:!0});for(const u of c){const{row:d,cell:m,cellAnchorColumn:f,cellAnchorRow:g,cellWidth:p,cellHeight:_}=u;if(f<o){r.setAttribute("colspan",p+s,m);const v=g+_-1;for(let E=d;E<=v;E++)c.skipRow(E)}else Xn(s,r,u.getPositionBefore())}})}removeRows(e,t){const i=this.editor.model,o=t.rows||1,s=this.getRows(e),r=t.at,a=r+o-1;if(a>s-1)throw new b("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});i.change(l=>{const c={first:r,last:a},{cellsToMove:u,cellsToTrim:d}=ZR(e,c);if(u.size){const m=a+1;JR(e,m,u,l)}for(let m=a;m>=r;m--)l.remove(e.getChild(m));for(const{rowspan:m,cell:f}of d)Re("rowspan",m,f,l);KR(e,c,l),_c(e,this)||vc(e,this)})}removeColumns(e,t){const i=this.editor.model,o=t.at,s=t.columns||1,r=t.at+s-1;i.change(a=>{GR(e,{first:o,last:r},a);const l=Os(e);for(let c=r;c>=o;c--){for(const{cell:u,column:d,cellWidth:m}of[...new de(e)])d<=c&&m>1&&d+m>c?Re("colspan",m-1,u,a):d===c&&a.remove(u);if(l[c]){const u=c===0?l[1]:l[c-1],d=parseFloat(l[c].getAttribute("columnWidth")),m=parseFloat(u.getAttribute("columnWidth"));a.remove(l[c]),a.setAttribute("columnWidth",d+m+"%",u)}}vc(e,this)||_c(e,this)})}splitCellVertically(e,t=2){const i=this.editor.model,o=e.parent.parent,s=parseInt(e.getAttribute("rowspan")||"1"),r=parseInt(e.getAttribute("colspan")||"1");i.change(a=>{if(r>1){const{newCellsSpan:l,updatedSpan:c}=zf(r,t);Re("colspan",c,e,a);const u={};l>1&&(u.colspan=l),s>1&&(u.rowspan=s);const d=r>t?t-1:r-1;Xn(d,a,a.createPositionAfter(e),u)}if(r<t){const l=t-r,c=[...new de(o)],{column:u}=c.find(({cell:g})=>g===e),d=c.filter(({cell:g,cellWidth:p,column:_})=>{const v=g!==e&&_===u,E=_<u&&_+p>u;return v||E});for(const{cell:g,cellWidth:p}of d)a.setAttribute("colspan",p+l,g);const m={};s>1&&(m.rowspan=s),Xn(l,a,a.createPositionAfter(e),m);const f=o.getAttribute("headingColumns")||0;f>u&&Re("headingColumns",f+l,o,a)}})}splitCellHorizontally(e,t=2){const i=this.editor.model,o=e.parent,s=o.parent,r=s.getChildIndex(o),a=parseInt(e.getAttribute("rowspan")||"1"),l=parseInt(e.getAttribute("colspan")||"1");i.change(c=>{if(a>1){const u=[...new de(s,{startRow:r,endRow:r+a-1,includeAllSlots:!0})],{newCellsSpan:d,updatedSpan:m}=zf(a,t);Re("rowspan",m,e,c);const{column:f}=u.find(({cell:_})=>_===e),g={};d>1&&(g.rowspan=d),l>1&&(g.colspan=l);let p=0;for(const _ of u){const{column:v,row:E}=_,M=E>=r+m,G=v===f;p>=d&&G&&(p=0),M&&G&&(p||Xn(1,c,_.getPositionBefore(),g),p++)}}if(a<t){const u=t-a,d=[...new de(s,{startRow:0,endRow:r})];for(const{cell:g,cellHeight:p,row:_}of d)if(g!==e&&_+p>r){const v=p+u;c.setAttribute("rowspan",v,g)}const m={};l>1&&(m.colspan=l),xl(c,s,r+1,u,1,m);const f=s.getAttribute("headingRows")||0;f>r&&Re("headingRows",f+u,s,c)}})}getColumns(e){return[...e.getChild(0).getChildren()].filter(t=>t.is("element","tableCell")).reduce((t,i)=>{const o=parseInt(i.getAttribute("colspan")||"1");return t+o},0)}getRows(e){return Array.from(e.getChildren()).reduce((t,i)=>i.is("element","tableRow")?t+1:t,0)}createTableWalker(e,t={}){return new de(e,t)}getSelectedTableCells(e){const t=[];for(const i of this.sortRanges(e.getRanges())){const o=i.getContainedElement();o&&o.is("element","tableCell")&&t.push(o)}return t}getTableCellsContainingSelection(e){const t=[];for(const i of e.getRanges()){const o=i.start.findAncestor("tableCell");o&&t.push(o)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map(i=>i.parent.index);return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),i=[...new de(t)].filter(o=>e.includes(o.cell)).map(o=>o.column);return this._getFirstLastIndexesObject(i)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,i=new Set;let o=0;for(const s of e){const{row:r,column:a}=this.getCellLocation(s),l=parseInt(s.getAttribute("rowspan"))||1,c=parseInt(s.getAttribute("colspan"))||1;t.add(r),i.add(a),l>1&&t.add(r+l-1),c>1&&i.add(a+c-1),o+=l*c}return YR(t,i)==o}sortRanges(e){return Array.from(e).sort(QR)}_getFirstLastIndexesObject(e){const t=e.sort((s,r)=>s-r),i=t[0],o=t[t.length-1];return{first:i,last:o}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),i=this.getRowIndexes(e),o=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(i,o))return!1;const s=this.getColumnIndexes(e),r=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(s,r)}_areIndexesInSameSection({first:e,last:t},i){const o=e<i,s=t<i;return o===s}}function xl(n,e,t,i,o,s={}){for(let r=0;r<i;r++){const a=n.createElement("tableRow");n.insert(a,e,t),Xn(o,n,n.createPositionAt(a,"end"),s)}}function Xn(n,e,t,i={}){for(let o=0;o<n;o++)In(e,t,i)}function zf(n,e){if(n<e)return{newCellsSpan:1,updatedSpan:1};const t=Math.floor(n/e),i=n-t*e+t;return{newCellsSpan:t,updatedSpan:i}}function GR(n,e,t){const i=n.getAttribute("headingColumns")||0;if(i&&e.first<i){const o=Math.min(i-1,e.last)-e.first+1;t.setAttribute("headingColumns",i-o,n)}}function KR(n,{first:e,last:t},i){const o=n.getAttribute("headingRows")||0;if(e<o){const s=t<o?o-(t-e+1):e;Re("headingRows",s,n,i,0)}}function ZR(n,{first:e,last:t}){const i=new Map,o=[];for(const{row:s,column:r,cellHeight:a,cell:l}of new de(n,{endRow:t})){const c=s+a-1;if(s>=e&&s<=t&&c>t){const u=t-s+1,d=a-u;i.set(r,{cell:l,rowspan:d})}if(s<e&&c>=e){let u;c>=t?u=t-e+1:u=c-e+1,o.push({cell:l,rowspan:a-u})}}return{cellsToMove:i,cellsToTrim:o}}function JR(n,e,t,i){const o=[...new de(n,{includeAllSlots:!0,row:e})],s=n.getChild(e);let r;for(const{column:a,cell:l,isAnchor:c}of o)if(t.has(a)){const{cell:u,rowspan:d}=t.get(a),m=r?i.createPositionAfter(r):i.createPositionAt(s,0);i.move(i.createRangeOn(u),m),Re("rowspan",d,u,i),r=u}else c&&(r=l)}function QR(n,e){const t=n.start,i=e.start;return t.isBefore(i)?-1:1}function YR(n,e){const t=Array.from(n.values()),i=Array.from(e.values()),o=Math.max(...t),s=Math.min(...t),r=Math.max(...i),a=Math.min(...i);return(o-s+1)*(r-a+1)}class XR extends O{refresh(){const e=this.editor.plugins.get(We),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(We);e.change(i=>{const o=t.getSelectedTableCells(e.document.selection),s=o.shift(),{mergeWidth:r,mergeHeight:a}=t8(s,o,t);Re("colspan",r,s,i),Re("rowspan",a,s,i);for(const c of o)e8(c,s,i);const l=s.findAncestor("table");Du(l,t),i.setSelection(s,"in")})}}function e8(n,e,t){Hf(n)||(Hf(e)&&t.remove(t.createRangeIn(e)),t.move(t.createRangeIn(n),t.createPositionAt(e,"end"))),t.remove(n)}function Hf(n){const e=n.getChild(0);return n.childCount==1&&e.is("element","paragraph")&&e.isEmpty}function t8(n,e,t){let i=0,o=0;for(const c of e){const{row:u,column:d}=t.getCellLocation(c);i=$f(c,d,i,"colspan"),o=$f(c,u,o,"rowspan")}const{row:s,column:r}=t.getCellLocation(n),a=i-r,l=o-s;return{mergeWidth:a,mergeHeight:l}}function $f(n,e,t,i){const o=parseInt(n.getAttribute(i)||"1");return Math.max(t,e+o)}class i8 extends O{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),o=t.getRowIndexes(i),s=i[0].findAncestor("table"),r=[];for(let a=o.first;a<=o.last;a++)for(const l of s.getChild(a).getChildren())r.push(e.createRangeOn(l));e.change(a=>{a.setSelection(r)})}}class n8 extends O{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),o=i[0],s=i.pop(),r=o.findAncestor("table"),a=e.getCellLocation(o),l=e.getCellLocation(s),c=Math.min(a.column,l.column),u=Math.max(a.column,l.column),d=[];for(const m of new de(r,{startColumn:c,endColumn:u}))d.push(t.createRangeOn(m.cell));t.change(m=>{m.setSelection(d)})}}function o8(n){n.document.registerPostFixer(e=>s8(e,n))}function s8(n,e){const t=e.document.differ.getChanges();let i=!1;const o=new Set;for(const s of t){let r=null;s.type=="insert"&&s.name=="table"&&(r=s.position.nodeAfter),(s.type=="insert"||s.type=="remove")&&(s.name=="tableRow"||s.name=="tableCell")&&(r=s.position.findAncestor("table")),u8(s)&&(r=s.range.start.findAncestor("table")),r&&!o.has(r)&&(i=r8(r,n)||i,i=a8(r,n)||i,o.add(r))}return i}function r8(n,e){let t=!1;const i=l8(n);if(i.length){t=!0;for(const o of i)Re("rowspan",o.rowspan,o.cell,e,1)}return t}function a8(n,e){let t=!1;const i=c8(n),o=[];for(const[a,l]of i.entries())!l&&n.getChild(a).is("element","tableRow")&&o.push(a);if(o.length){t=!0;for(const a of o.reverse())e.remove(n.getChild(a)),i.splice(a,1)}const s=i.filter((a,l)=>n.getChild(l).is("element","tableRow")),r=s[0];if(!s.every(a=>a===r)){const a=s.reduce((l,c)=>c>l?c:l,0);for(const[l,c]of s.entries()){const u=a-c;if(u){for(let d=0;d<u;d++)In(e,e.createPositionAt(n.getChild(l),"end"));t=!0}}}return t}function l8(n){const e=parseInt(n.getAttribute("headingRows")||"0"),t=Array.from(n.getChildren()).reduce((o,s)=>s.is("element","tableRow")?o+1:o,0),i=[];for(const{row:o,cell:s,cellHeight:r}of new de(n)){if(r<2)continue;const a=o<e?e:t;if(o+r>a){const l=a-o;i.push({cell:s,rowspan:l})}}return i}function c8(n){const e=new Array(n.childCount).fill(0);for(const{rowIndex:t}of new de(n,{includeAllSlots:!0}))e[t]++;return e}function u8(n){if(n.type!=="attribute")return!1;const e=n.attributeKey;return e==="headingRows"||e==="colspan"||e==="rowspan"}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function h8(n){n.document.registerPostFixer(e=>d8(e,n))}function d8(n,e){const t=e.document.differ.getChanges();let i=!1;for(const o of t)o.type=="insert"&&o.name=="table"&&(i=m8(o.position.nodeAfter,n)||i),o.type=="insert"&&o.name=="tableRow"&&(i=d0(o.position.nodeAfter,n)||i),o.type=="insert"&&o.name=="tableCell"&&(i=Cc(o.position.nodeAfter,n)||i),(o.type=="remove"||o.type=="insert")&&f8(o)&&(i=Cc(o.position.parent,n)||i);return i}function m8(n,e){let t=!1;for(const i of n.getChildren())i.is("element","tableRow")&&(t=d0(i,e)||t);return t}function d0(n,e){let t=!1;for(const i of n.getChildren())t=Cc(i,e)||t;return t}function Cc(n,e){if(n.childCount==0)return e.insertElement("paragraph",n),!0;const t=Array.from(n.getChildren()).filter(i=>i.is("$text"));for(const i of t)e.wrap(e.createRangeOn(i),"paragraph");return!!t.length}function f8(n){return n.position.parent.is("element","tableCell")?n.type=="insert"&&n.name=="$text"||n.type=="remove":!1}function g8(n,e){const t=n.document.differ;for(const i of t.getChanges()){let o,s=!1;if(i.type=="attribute"){const c=i.range.start.nodeAfter;if(!c||!c.is("element","table")||i.attributeKey!="headingRows"&&i.attributeKey!="headingColumns")continue;o=c,s=i.attributeKey=="headingRows"}else(i.name=="tableRow"||i.name=="tableCell")&&(o=i.position.findAncestor("table"),s=i.name=="tableRow");if(!o)continue;const r=o.getAttribute("headingRows")||0,a=o.getAttribute("headingColumns")||0,l=new de(o);for(const c of l){const u=c.row<r||c.column<a?"th":"td",d=e.mapper.toViewElement(c.cell);d&&d.is("element")&&d.name!=u&&e.reconvertItem(s?c.cell.parent:c.cell)}}}function p8(n,e){const t=n.document.differ,i=new Set;for(const o of t.getChanges()){const s=o.type=="attribute"?o.range.start.parent:o.position.parent;s.is("element","tableCell")&&i.add(s)}for(const o of i.values()){const s=Array.from(o.getChildren()).filter(r=>w8(r,e.mapper));for(const r of s)e.reconvertItem(r)}}function w8(n,e){if(!n.is("element","paragraph"))return!1;const t=e.toViewElement(n);return t?t0(n)!==t.is("element","span"):!1}class Bs extends w{constructor(e){super(e),h(this,"_additionalSlots"),this._additionalSlots=[]}static get pluginName(){return"TableEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[We]}init(){const e=this.editor,t=e.model,i=t.schema,o=e.conversion,s=e.plugins.get(We);i.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),i.register("tableRow",{allowIn:"table",isLimit:!0}),i.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),o.for("upcast").add(dR()),o.for("upcast").add(mR()),o.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Rf(s,{asWidget:!0,additionalSlots:this._additionalSlots})}),o.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Rf(s,{additionalSlots:this._additionalSlots})}),o.for("upcast").elementToElement({model:"tableRow",view:"tr"}),o.for("upcast").add(fR()),o.for("downcast").elementToElement({model:"tableRow",view:_R()}),o.for("upcast").elementToElement({model:"tableCell",view:"td"}),o.for("upcast").elementToElement({model:"tableCell",view:"th"}),o.for("upcast").add(Vf("td")),o.for("upcast").add(Vf("th")),o.for("editingDowncast").elementToElement({model:"tableCell",view:Of({asWidget:!0})}),o.for("dataDowncast").elementToElement({model:"tableCell",view:Of()}),o.for("editingDowncast").elementToElement({model:"paragraph",view:Bf({asWidget:!0}),converterPriority:"high"}),o.for("dataDowncast").elementToElement({model:"paragraph",view:Bf(),converterPriority:"high"}),o.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),o.for("upcast").attributeToAttribute({model:{key:"colspan",value:Wf("colspan")},view:"colspan"}),o.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),o.for("upcast").attributeToAttribute({model:{key:"rowspan",value:Wf("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new kR(e)),e.commands.add("insertTableRowAbove",new Mf(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Mf(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new Lf(e,{order:"left"})),e.commands.add("insertTableColumnRight",new Lf(e,{order:"right"})),e.commands.add("removeTableRow",new SR(e)),e.commands.add("removeTableColumn",new IR(e)),e.commands.add("splitTableCellVertically",new Ff(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Ff(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new XR(e)),e.commands.add("mergeTableCellRight",new sr(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new sr(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new sr(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new sr(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new BR(e)),e.commands.add("setTableRowHeader",new OR(e)),e.commands.add("selectTableRow",new i8(e)),e.commands.add("selectTableColumn",new n8(e)),o8(t),h8(t),this.listenTo(t.document,"change:data",()=>{g8(t,e.editing),p8(t,e.editing)})}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function Wf(n){return e=>{const t=parseInt(e.getAttribute(n));return Number.isNaN(t)||t<=0?null:t}}class jf extends A{constructor(e){super(e),h(this,"items"),h(this,"keystrokes"),h(this,"focusTracker");const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new te,this.focusTracker=new ee,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(i,o)=>`${o} × ${i}`),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(i=>{i.preventDefault()}),click:t.to(()=>{this.fire("execute")})}}),this.on("boxover",(i,o)=>{const{row:s,column:r}=o.target.dataset;this.items.get((parseInt(s,10)-1)*10+(parseInt(r,10)-1)).focus()}),this.focusTracker.on("change:focusedElement",(i,o,s)=>{if(!s)return;const{row:r,column:a}=s.dataset;this.set({rows:parseInt(r),columns:parseInt(a)})}),this.on("change:columns",()=>this._highlightGridBoxes()),this.on("change:rows",()=>this._highlightGridBoxes())}render(){super.render(),vo({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,o)=>{const s=Math.floor(o/10),r=o%10,a=s<e&&r<t;i.set("isOn",a)})}_createGridButton(e,t,i,o){const s=new P(e);return s.set({label:o,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),o=t%10,s=`${i+1} × ${o+1}`;e.push(this._createGridButton(this.locale,i+1,o+1,s))}return this.createCollection(e)}}class b8 extends w{static get pluginName(){return"TableUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t,i=e.locale.contentLanguageDirection==="ltr";e.ui.componentFactory.add("insertTable",o=>{const s=e.commands.get("insertTable"),r=Ee(o);r.bind("isEnabled").to(s),r.buttonView.set({icon:vd,label:t("Insert table"),tooltip:!0});let a;return r.on("change:isOpen",()=>{a||(a=new jf(o),r.panelView.children.add(a),a.delegate("execute").to(r),r.on("execute",()=>{e.execute("insertTable",{rows:a.rows,columns:a.columns}),e.editing.view.focus()}))}),r}),e.ui.componentFactory.add("menuBar:insertTable",o=>{const s=e.commands.get("insertTable"),r=new Tt(o),a=new jf(o);return a.delegate("execute").to(r),r.on("change:isOpen",(l,c,u)=>{u||a.reset()}),a.on("execute",()=>{e.execute("insertTable",{rows:a.rows,columns:a.columns}),e.editing.view.focus()}),r.buttonView.set({label:t("Table"),icon:vd}),r.panelView.children.add(a),r.bind("isEnabled").to(s),r}),e.ui.componentFactory.add("tableColumn",o=>{const s=[{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"),fA,s,o)}),e.ui.componentFactory.add("tableRow",o=>{const s=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),wA,s,o)}),e.ui.componentFactory.add("mergeTableCells",o=>{const s=[{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"),gA,s,o)})}_prepareDropdown(e,t,i,o){const s=this.editor,r=Ee(o),a=this._fillDropdownWithListOptions(r,i);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(a,"isEnabled",(...l)=>l.some(c=>c)),this.listenTo(r,"execute",l=>{s.execute(l.source.commandName),l.source instanceof Ji||s.editing.view.focus()}),r}_prepareMergeSplitButtonDropdown(e,t,i,o){const s=this.editor,r=Ee(o,Xi),a="mergeTableCells",l=s.commands.get(a),c=this._fillDropdownWithListOptions(r,i);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([l,...c],"isEnabled",(...u)=>u.some(d=>d)),this.listenTo(r.buttonView,"execute",()=>{s.execute(a),s.editing.view.focus()}),this.listenTo(r,"execute",u=>{s.execute(u.source.commandName),s.editing.view.focus()}),r}_fillDropdownWithListOptions(e,t){const i=this.editor,o=[],s=new _e;for(const r of t)_8(r,i,o,s);return wt(e,s),o}}function _8(n,e,t,i){if(n.type==="button"||n.type==="switchbutton"){const o=n.model=new et(n.model),{commandName:s,bindIsOn:r}=n.model,a=e.commands.get(s);t.push(a),o.set({commandName:s}),o.bind("isEnabled").to(a),r&&o.bind("isOn").to(a,"value"),o.set({withText:!0})}i.add(n)}class Ai extends w{static get pluginName(){return"TableSelection"}static get isOfficialPlugin(){return!0}static get requires(){return[We,We]}init(){const e=this.editor,t=e.model,i=e.editing.view;this.listenTo(t,"deleteContent",(o,s)=>this._handleDeleteContent(o,s),{priority:"high"}),this.listenTo(i.document,"insertText",(o,s)=>this._handleInsertTextEvent(o,s),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(We),t=this.editor.model.document.selection,i=e.getSelectedTableCells(t);return i.length==0?null:i}getSelectionAsFragment(){const e=this.editor.plugins.get(We),t=this.getSelectedTableCells();return t?this.editor.model.change(i=>{const o=i.createDocumentFragment(),{first:s,last:r}=e.getColumnIndexes(t),{first:a,last:l}=e.getRowIndexes(t),c=t[0].findAncestor("table");let u=l,d=r;if(e.isSelectionRectangular(t)){const f={firstColumn:s,lastColumn:r,firstRow:a,lastRow:l};u=l0(c,f),d=c0(c,f)}const m=i0(c,{startRow:a,startColumn:s,endRow:u,endColumn:d},i);return i.insert(m,o,0),o}):null}setCellSelection(e,t){const i=this._getCellsToSelect(e,t);this.editor.model.change(o=>{o.setSelection(i.cells.map(s=>o.createRangeOn(s)),{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=this.editor.model.document.selection,t=ae(e.getRanges()).getContainedElement();return t&&t.is("element","tableCell")?t:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add(o=>o.on("selection",(s,r,a)=>{const l=a.writer;i(l);const c=this.getSelectedTableCells();if(!c)return;for(const d of c){const m=a.mapper.toViewElement(d);l.addClass("ck-editor__editable_selected",m),t.add(m)}const u=a.mapper.toViewElement(c[c.length-1]);l.setSelection(u,0)},{priority:"lowest"}));function i(o){for(const s of t)o.removeClass("ck-editor__editable_selected",s);t.clear()}}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change(i=>{const o=i.createPositionAt(t[0],0),s=e.model.schema.getNearestSelectionRange(o);i.setSelection(s)})}})}_handleDeleteContent(e,t){const i=this.editor.plugins.get(We),o=t[0],s=t[1],r=this.editor.model,a=!s||s.direction=="backward",l=i.getSelectedTableCells(o);l.length&&(e.stop(),r.change(c=>{const u=l[a?l.length-1:0];r.change(m=>{for(const f of l)r.deleteContent(m.createSelection(f,"in"))});const d=r.schema.getNearestSelectionRange(c.createPositionAt(u,0));o.is("documentSelection")?c.setSelection(d):o.setTo(d)}))}_handleInsertTextEvent(e,t){const i=this.editor,o=this.getSelectedTableCells();if(!o)return;const s=i.editing.view,r=i.editing.mapper,a=o.map(l=>s.createRangeOn(r.toViewElement(l)));t.selection=s.createSelection(a),t.preventDefault()}_getCellsToSelect(e,t){const i=this.editor.plugins.get("TableUtils"),o=i.getCellLocation(e),s=i.getCellLocation(t),r=Math.min(o.row,s.row),a=Math.max(o.row,s.row),l=Math.min(o.column,s.column),c=parseInt(t.getAttribute("colspan")||"1")-1,u=Math.max(o.column,s.column+c),d=new Array(a-r+1).fill(null).map(()=>[]),m={startRow:r,endRow:a,startColumn:l,endColumn:u};for(const{row:p,cell:_}of new de(e.findAncestor("table"),m))d[p-r].push(_);const f=s.row<o.row,g=s.column<o.column;return f&&d.reverse(),g&&d.forEach(p=>p.reverse()),{cells:d.flat(),backward:f||g}}}class v8 extends w{static get pluginName(){return"TableClipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[os,pt,Ai,We]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"copy",(t,i)=>this._onCopyCut(t,i)),this.listenTo(e,"cut",(t,i)=>this._onCopyCut(t,i)),this._listenToContentInsertion(),this.decorate("_replaceTableSlotCell")}_listenToContentInsertion(){const{editor:e}=this,t=e.plugins.get(pt),i=e.plugins.get(Ai);let o=!1;t.on("contentInsertion",(s,r)=>{o=r.method==="paste"}),this.listenTo(e.model,"insertContent",(s,[r,a])=>{(o||i.getSelectedTableCells()!==null)&&this._onInsertContent(s,r,a)},{priority:"high"}),t.on("contentInsertion",()=>{o=!1},{priority:"lowest"})}_onCopyCut(e,t){const i=this.editor.editing.view,o=this.editor.plugins.get(Ai),s=this.editor.plugins.get(os);o.getSelectedTableCells()&&(e.name=="cut"&&!this.editor.model.canEditAt(this.editor.model.document.selection)||(t.preventDefault(),e.stop(),this.editor.model.enqueueChange({isUndoable:e.name==="cut"},()=>{const r=s._copySelectedFragmentWithMarkers(e.name,this.editor.model.document.selection,()=>o.getSelectionAsFragment());i.document.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:this.editor.data.toView(r),method:e.name})})))}_onInsertContent(e,t,i){if(i&&!i.is("documentSelection"))return;const o=this.editor.model,s=this.editor.plugins.get(We),r=this.editor.plugins.get(os),a=this.getTableIfOnlyTableInContent(t,o);if(!a)return;const l=s.getSelectionAffectedTableCells(o.document.selection);if(!l.length){Du(a,s);return}e.stop(),t.is("documentFragment")?r._pasteMarkersIntoTransformedElement(t.markers,c=>this._replaceSelectedCells(a,l,c)):this.editor.model.change(c=>{this._replaceSelectedCells(a,l,c)})}_replaceSelectedCells(e,t,i){const o=this.editor.plugins.get(We),s={width:o.getColumns(e),height:o.getRows(e)},r=y8(t,s,i,o),a=r.lastRow-r.firstRow+1,l=r.lastColumn-r.firstColumn+1,c={startRow:0,startColumn:0,endRow:Math.min(a,s.height)-1,endColumn:Math.min(l,s.width)-1};e=i0(e,c,i);const u=t[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(e,s,u,r,i);if(this.editor.plugins.get("TableSelection").isEnabled){const m=o.sortRanges(d.map(f=>i.createRangeOn(f)));i.setSelection(m)}else i.setSelection(d[0],0);return u}_replaceSelectedCellsWithPasted(e,t,i,o,s){const{width:r,height:a}=t,l=C8(e,r,a),c=[...new de(i,{startRow:o.firstRow,endRow:o.lastRow,startColumn:o.firstColumn,endColumn:o.lastColumn,includeAllSlots:!0})],u=[];let d;for(const _ of c){const{row:v,column:E}=_;E===o.firstColumn&&(d=_.getPositionBefore());const M=v-o.firstRow,G=E-o.firstColumn,X=l[M%a][G%r],T=X?s.cloneElement(X):null,F=this._replaceTableSlotCell(_,T,d,s);F&&(a0(F,v,E,o.lastRow,o.lastColumn,s),u.push(F),d=s.createPositionAfter(F))}const m=parseInt(i.getAttribute("headingRows")||"0"),f=parseInt(i.getAttribute("headingColumns")||"0"),g=o.firstRow<m&&m<=o.lastRow,p=o.firstColumn<f&&f<=o.lastColumn;if(g){const _={first:o.firstColumn,last:o.lastColumn},v=Ac(i,m,_,s,o.firstRow);u.push(...v)}if(p){const _={first:o.firstRow,last:o.lastRow},v=xc(i,f,_,s);u.push(...v)}return u}_replaceTableSlotCell(e,t,i,o){const{cell:s,isAnchor:r}=e;return r&&o.remove(s),t?(o.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(e.childCount==1&&e.getChild(0).is("element","table"))return e.getChild(0);const i=t.createRangeIn(e);for(const o of i.getItems())if(o.is("element","table")){const s=t.createRange(i.start,t.createPositionBefore(o));if(t.hasContent(s,{ignoreWhitespaces:!0}))return null;const r=t.createRange(t.createPositionAfter(o),i.end);return t.hasContent(r,{ignoreWhitespaces:!0})?null:o}return null}}function y8(n,e,t,i){const o=n[0].findAncestor("table"),s=i.getColumnIndexes(n),r=i.getRowIndexes(n),a={firstColumn:s.first,lastColumn:s.last,firstRow:r.first,lastRow:r.last},l=n.length===1;return l&&(a.lastRow+=e.height-1,a.lastColumn+=e.width-1,k8(o,a.lastRow+1,a.lastColumn+1,i)),l||!i.isSelectionRectangular(n)?A8(o,a,t):(a.lastRow=l0(o,a),a.lastColumn=c0(o,a)),a}function k8(n,e,t,i){const o=i.getColumns(n),s=i.getRows(n);t>o&&i.insertColumns(n,{at:o,columns:t-o}),e>s&&i.insertRows(n,{at:s,rows:e-s})}function C8(n,e,t){const i=new Array(t).fill(null).map(()=>new Array(e).fill(null));for(const{column:o,row:s,cell:r}of new de(n))i[s][o]=r;return i}function A8(n,e,t){const{firstRow:i,lastRow:o,firstColumn:s,lastColumn:r}=e,a={first:i,last:o},l={first:s,last:r};xc(n,s,a,t),xc(n,r+1,a,t),Ac(n,i,l,t),Ac(n,o+1,l,t,i)}function Ac(n,e,t,i,o=0){return e<1?void 0:n0(n,e,o).filter(({column:s,cellWidth:r})=>m0(s,r,t)).map(({cell:s})=>o0(s,e,i))}function xc(n,e,t,i){return e<1?void 0:s0(n,e).filter(({row:o,cellHeight:s})=>m0(o,s,t)).map(({cell:o,column:s})=>r0(o,s,e,i))}function m0(n,e,t){const i=n+e-1,{first:o,last:s}=t,r=n>=o&&n<=s,a=n<o&&i>=o;return r||a}class x8 extends w{static get pluginName(){return"TableKeyboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Ai,We]}init(){const e=this.editor,t=e.editing.view.document,i=e.t;this.listenTo(t,"arrowKey",(...o)=>this._onArrowKey(...o),{context:"table"}),this.listenTo(t,"tab",(...o)=>this._handleTabOnSelectedTable(...o),{context:"figure"}),this.listenTo(t,"tab",(...o)=>this._handleTab(...o),{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,o=i.model.document.selection.getSelectedElement();!o||!o.is("element","table")||(t.preventDefault(),t.stopPropagation(),e.stop(),i.model.change(s=>{s.setSelection(s.createRangeIn(o.getChild(0).getChild(0)))}))}_handleTab(e,t){const i=this.editor,o=this.editor.plugins.get(We),s=this.editor.plugins.get("TableSelection"),r=i.model.document.selection,a=!t.shiftKey;let l=o.getTableCellsContainingSelection(r)[0];if(l||(l=s.getFocusCell()),!l)return;t.preventDefault(),t.stopPropagation(),e.stop();const c=l.parent,u=c.parent,d=u.getChildIndex(c),m=c.getChildIndex(l),f=m===0;if(!a&&f&&d===0){i.model.change(v=>{v.setSelection(v.createRangeOn(u))});return}const g=m===c.childCount-1,p=d===o.getRows(u)-1;if(a&&p&&g&&(i.execute("insertTableRowBelow"),d===o.getRows(u)-1)){i.model.change(v=>{v.setSelection(v.createRangeOn(u))});return}let _;if(a&&g)_=u.getChild(d+1).getChild(0);else if(!a&&f){const v=u.getChild(d-1);_=v.getChild(v.childCount-1)}else _=c.getChild(m+(a?1:-1));i.model.change(v=>{v.setSelection(v.createRangeIn(_))})}_onArrowKey(e,t){const i=this.editor,o=t.keyCode,s=oa(o,i.locale.contentLanguageDirection);this._handleArrowKeys(s,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const i=this.editor.plugins.get(We),o=this.editor.plugins.get("TableSelection"),s=this.editor.model,r=s.document.selection,a=["right","down"].includes(e),l=i.getSelectedTableCells(r);if(l.length){let u;return t?u=o.getFocusCell():u=a?l[l.length-1]:l[0],this._navigateFromCellInDirection(u,e,t),!0}const c=r.focus.findAncestor("tableCell");/* istanbul ignore if: paranoid check -- @preserve */if(!c)return!1;if(!r.isCollapsed)if(t){if(r.isBackward==a&&!r.containsEntireContent(c))return!1}else{const u=r.getSelectedElement();if(!u||!s.schema.isObject(u))return!1}return this._isSelectionAtCellEdge(r,c,a)?(this._navigateFromCellInDirection(c,e,t),!0):!1}_isSelectionAtCellEdge(e,t,i){const o=this.editor.model,s=this.editor.model.schema,r=i?e.getLastPosition():e.getFirstPosition();if(!s.getLimitElement(r).is("element","tableCell"))return o.createPositionAt(t,i?"end":0).isTouching(r);const a=o.createSelection(r);return o.modifySelection(a,{direction:i?"forward":"backward"}),r.isEqual(a.focus)}_navigateFromCellInDirection(e,t,i=!1){const o=this.editor.model,s=e.findAncestor("table"),r=[...new de(s,{includeAllSlots:!0})],{row:a,column:l}=r[r.length-1],c=r.find(({cell:E})=>E==e);let{row:u,column:d}=c;switch(t){case"left":d--;break;case"up":u--;break;case"right":d+=c.cellWidth;break;case"down":u+=c.cellHeight;break}const m=u<0||u>a,f=d<0&&u<=0,g=d>l&&u>=a;if(m||f||g){o.change(E=>{E.setSelection(E.createRangeOn(s))});return}d<0?(d=i?0:l,u--):d>l&&(d=i?l:0,u++);const p=r.find(E=>E.row==u&&E.column==d).cell,_=["right","down"].includes(t),v=this.editor.plugins.get("TableSelection");if(i&&v.isEnabled){const E=v.getAnchorCell()||e;v.setCellSelection(E,p)}else{const E=o.createPositionAt(p,_?0:"end");o.change(M=>{M.setSelection(E)})}}}class f0 extends ui{constructor(){super(...arguments),h(this,"domEventType",["mousemove","mouseleave"])}onDomEvent(e){this.fire(e.type,e)}}class T8 extends w{static get pluginName(){return"TableMouse"}static get isOfficialPlugin(){return!0}static get requires(){return[Ai,We]}init(){this.editor.editing.view.addObserver(f0),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(We);let i=!1;const o=e.plugins.get(Ai);this.listenTo(e.editing.view.document,"mousedown",(s,r)=>{const a=e.model.document.selection;if(!this.isEnabled||!o.isEnabled||!r.domEvent.shiftKey)return;const l=o.getAnchorCell()||t.getTableCellsContainingSelection(a)[0];if(!l)return;const c=this._getModelTableCellFromDomEvent(r);c&&Uf(l,c)&&(i=!0,o.setCellSelection(l,c),r.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{i=!1}),this.listenTo(e.editing.view.document,"selectionChange",s=>{i&&s.stop()},{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,i,o=!1,s=!1;const r=e.plugins.get(Ai);this.listenTo(e.editing.view.document,"mousedown",(a,l)=>{!this.isEnabled||!r.isEnabled||l.domEvent.shiftKey||l.domEvent.ctrlKey||l.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(l))}),this.listenTo(e.editing.view.document,"mousemove",(a,l)=>{if(!l.domEvent.buttons||!t)return;const c=this._getModelTableCellFromDomEvent(l);c&&Uf(t,c)&&(i=c,!o&&i!=t&&(o=!0)),o&&(s=!0,r.setCellSelection(t,i),l.preventDefault())}),this.listenTo(e.editing.view.document,"mouseup",()=>{o=!1,s=!1,t=null,i=null}),this.listenTo(e.editing.view.document,"selectionChange",a=>{s&&a.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 Uf(n,e){return n.parent.parent==e.parent.parent}class E8 extends w{static get requires(){return[Bs,b8,Ai,T8,x8,v8,Vt]}static get pluginName(){return"Table"}static get isOfficialPlugin(){return!0}}function Gr(n){return g0(n)||ka(n)}function g0(n){const e=n.getSelectedElement();return e&&p0(e)?e:null}function ka(n){const e=n.getFirstPosition();if(!e)return null;let t=e.parent;for(;t;){if(t.is("element")&&p0(t))return t;t=t.parent}return null}function p0(n){return!!n.getCustomProperty("table")&&Se(n)}class S8 extends w{static get requires(){return[ci]}static get pluginName(){return"TableToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(ci),o=e.config.get("table.contentToolbar"),s=e.config.get("table.tableToolbar");o&&i.register("tableContent",{ariaLabel:t("Table toolbar"),items:o,getRelatedElement:ka}),s&&i.register("table",{ariaLabel:t("Table toolbar"),items:s,getRelatedElement:g0})}}class P8 extends A{constructor(e,t){super(e),h(this,"options"),h(this,"focusTracker"),h(this,"focusCycler"),h(this,"_focusables"),h(this,"dropdownView"),h(this,"inputView"),h(this,"keystrokes"),h(this,"_stillTyping"),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new ee,this._focusables=new Ie,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new te,this._stillTyping=!1,this.focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",(i,o,s)=>this._setInputValue(s))}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){e===-1?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,o=this._createColorSelector(e),s=Ee(e),r=new A;return r.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",a=>a!="")]}}]}),s.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),s.buttonView.children.add(r),s.buttonView.label=t("Color picker"),s.buttonView.tooltip=!0,s.panelPosition=e.uiLanguageDirection==="rtl"?"se":"sw",s.panelView.children.add(o),s.bind("isEnabled").to(this,"isReadOnly",a=>!a),s.on("change:isOpen",(a,l,c)=>{c&&(o.updateSelectedColors(),o.showColorGridsFragment())}),s}_createInputTextView(){const e=this.locale,t=new Zw(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 i=t.element.value,o=this.options.colorDefinitions.find(s=>i===s.label);this._stillTyping=!0,this.value=o&&o.color||i}),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||"",o=t(i?"Restore default":"Remove color"),s=new wu(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:o,colorPickerLabel:t("Color picker"),colorPickerViewConfig:this.options.colorPickerConfig===!1?!1:{...this.options.colorPickerConfig,hideInput:!0}});s.appendUI(),s.on("execute",(a,l)=>{if(l.source==="colorPickerSaveButton"){this.dropdownView.isOpen=!1;return}this.value=l.value||i,this.fire("input"),l.source!=="colorPicker"&&(this.dropdownView.isOpen=!1)});let r=this.value;return s.on("colorPicker:cancel",()=>{this.value=r,this.fire("input"),this.dropdownView.isOpen=!1}),s.colorGridsFragmentView.colorPickerButtonView.on("execute",()=>{r=this.value}),s.bind("selectedColor").to(this,"value"),s}_setInputValue(e){if(!this._stillTyping){const t=qf(e),i=this.options.colorDefinitions.find(o=>t===qf(o.color));i?this.inputView.value=i.label:this.inputView.value=e||""}}}function qf(n){return n.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const Hu=n=>n==="";function $u(n){return{none:n("None"),solid:n("Solid"),dotted:n("Dotted"),dashed:n("Dashed"),double:n("Double"),groove:n("Groove"),ridge:n("Ridge"),inset:n("Inset"),outset:n("Outset")}}function w0(n){return n('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function b0(n){return n('The value is invalid. Try "10px" or "2em" or simply "2".')}function Kr(n){return n=n.trim().toLowerCase(),Hu(n)||tw(n)}function rs(n){return n=n.trim(),Hu(n)||y0(n)||ha(n)||iw(n)}function _0(n){return n=n.trim(),Hu(n)||y0(n)||ha(n)}function v0(n,e){const t=new _e,i=$u(n.t);for(const o in i){const s={type:"button",model:new et({_borderStyleValue:o,label:i[o],role:"menuitemradio",withText:!0})};o==="none"?s.model.bind("isOn").to(n,"borderStyle",r=>e==="none"?!r:r===o):s.model.bind("isOn").to(n,"borderStyle",r=>r===o),t.add(s)}return t}function Tc(n){const{view:e,icons:t,toolbar:i,labels:o,propertyName:s,nameToValue:r,defaultValue:a}=n;for(const l in o){const c=new P(e.locale);c.set({role:"radio",isToggleable:!0,label:o[l],icon:t[l],tooltip:o[l]});const u=r?r(l):l;c.bind("isOn").to(e,s,d=>{let m=d;return d===""&&a&&(m=a),u===m}),c.on("execute",()=>{!a&&u&&e[s]===u?e[s]=void 0:e[s]=u}),i.items.add(c)}}const Zr=[{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 Jr(n){return(e,t,i)=>{const o=new P8(e.locale,{colorDefinitions:I8(n.colorConfig),columns:n.columns,defaultColorValue:n.defaultColorValue,colorPickerConfig:n.colorPickerConfig});return o.inputView.set({id:t,ariaDescribedById:i}),o.bind("isReadOnly").to(e,"isEnabled",s=>!s),o.bind("hasError").to(e,"errorText",s=>!!s),o.on("input",()=>{e.errorText=null}),e.bind("isEmpty","isFocused").to(o),o}}function y0(n){const e=parseFloat(n);return!Number.isNaN(e)&&n===String(e)}function I8(n){return n.map(e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}}))}class V8 extends A{constructor(e,t){super(e),h(this,"options"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"children"),h(this,"borderStyleDropdown"),h(this,"borderWidthInput"),h(this,"borderColorInput"),h(this,"backgroundInput"),h(this,"paddingInput"),h(this,"widthInput"),h(this,"heightInput"),h(this,"horizontalAlignmentToolbar"),h(this,"verticalAlignmentToolbar"),h(this,"saveButtonView"),h(this,"cancelButtonView"),h(this,"_focusables"),h(this,"_focusCycler"),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:o,borderColorInput:s,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:a,backgroundInput:l}=this._createBackgroundFields(),{widthInput:c,operatorLabel:u,heightInput:d,dimensionsLabel:m}=this._createDimensionFields(),{horizontalAlignmentToolbar:f,verticalAlignmentToolbar:g,alignmentLabel:p}=this._createAlignmentFields();this.focusTracker=new ee,this.keystrokes=new te,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=o,this.borderColorInput=s,this.backgroundInput=l,this.paddingInput=this._createPaddingField(),this.widthInput=c,this.heightInput=d,this.horizontalAlignmentToolbar=f,this.verticalAlignmentToolbar=g;const{saveButtonView:_,cancelButtonView:v}=this._createActionButtons();this.saveButtonView=_,this.cancelButtonView=v,this._focusables=new Ie,this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Jt(e,{label:this.t("Cell properties")})),this.children.add(new $e(e,{labelView:r,children:[r,i,s,o],class:"ck-table-form__border-row"})),this.children.add(new $e(e,{labelView:a,children:[a,l],class:"ck-table-form__background-row"})),this.children.add(new $e(e,{children:[new $e(e,{labelView:m,children:[m,c,u,d],class:"ck-table-form__dimensions-row"}),new $e(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new $e(e,{labelView:p,children:[p,f,g],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new $e(e,{children:[this.saveButtonView,this.cancelButtonView],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(),Ri({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].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=Jr({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),o=this.locale,s=this.t,r=s("Style"),a=new xt(o);a.text=s("Border");const l=$u(s),c=new Te(o,pu);c.set({label:r,class:"ck-table-form__border-style"}),c.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),c.fieldView.buttonView.bind("label").to(this,"borderStyle",m=>l[m||"none"]),c.fieldView.on("execute",m=>{this.borderStyle=m.source._borderStyleValue}),c.bind("isEmpty").to(this,"borderStyle",m=>!m),wt(c.fieldView,v0(this,t.style),{role:"menu",ariaLabel:r});const u=new Te(o,nt);u.set({label:s("Width"),class:"ck-table-form__border-width"}),u.fieldView.bind("value").to(this,"borderWidth"),u.bind("isEnabled").to(this,"borderStyle",rr),u.fieldView.on("input",()=>{this.borderWidth=u.fieldView.element.value});const d=new Te(o,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",rr),d.fieldView.on("input",()=>{this.borderColor=d.fieldView.value}),this.on("change:borderStyle",(m,f,g,p)=>{rr(g)||(this.borderColor="",this.borderWidth=""),rr(p)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:a,borderStyleDropdown:c,borderColorInput:d,borderWidthInput:u}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new xt(e);i.text=t("Background");const o=Jr({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),s=new Te(e,o);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}}_createDimensionFields(){const e=this.locale,t=this.t,i=new xt(e);i.text=t("Dimensions");const o=new Te(e,nt);o.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",()=>{this.width=o.fieldView.element.value});const s=new A(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new Te(e,nt);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",()=>{this.height=r.fieldView.element.value}),{dimensionsLabel:i,widthInput:o,operatorLabel:s,heightInput:r}}_createPaddingField(){const e=this.locale,t=this.t,i=new Te(e,nt);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 xt(e),o={left:nu,center:dw,right:fw,justify:mw,top:hC,middle:uC,bottom:cC};i.text=t("Table cell text alignment");const s=new Ei(e),r=e.contentLanguageDirection==="rtl";s.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Horizontal text alignment toolbar")}),Tc({view:this,icons:o,toolbar:s,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:l=>{if(r){if(l==="left")return"right";if(l==="right")return"left"}return l},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const a=new Ei(e);return a.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Vertical text alignment toolbar")}),Tc({view:this,icons:o,toolbar:a,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:s,verticalAlignmentToolbar:a,alignmentLabel:i}}_createActionButtons(){const e=this.locale,t=this.t,i=new P(e),o=new P(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return i.set({label:t("Save"),icon:Es,class:"ck-button-save",type:"submit",withText:!0}),i.bind("isEnabled").toMany(s,"errorText",(...r)=>r.every(a=>!a)),o.set({label:t("Cancel"),icon:_o,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:o}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,i=t("Align cell text to the left"),o=t("Align cell text to the center"),s=t("Align cell text to the right"),r=t("Justify cell text");return e.uiLanguageDirection==="rtl"?{right:s,center:o,left:i,justify:r}:{left:i,center:o,right:s,justify:r}}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")}}}function rr(n){return n!=="none"}const Ec=[Ne.defaultPositions.northArrowSouth,Ne.defaultPositions.northArrowSouthWest,Ne.defaultPositions.northArrowSouthEast,Ne.defaultPositions.southArrowNorth,Ne.defaultPositions.southArrowNorthWest,Ne.defaultPositions.southArrowNorthEast,Ne.defaultPositions.viewportStickyNorth];function k0(n,e){const t=n.plugins.get("ContextualBalloon"),i=n.editing.view.document.selection;let o;e==="cell"?ka(i)&&(o=A0(n)):Gr(i)&&(o=C0(n)),o&&t.updatePosition(o)}function C0(n){const e=n.model.document.selection,t=Gi(e),i=n.editing.mapper.toViewElement(t);return{target:n.editing.view.domConverter.mapViewToDom(i),positions:Ec}}function A0(n){const e=n.editing.mapper,t=n.editing.view.domConverter,i=n.model.document.selection;if(i.rangeCount>1)return{target:()=>R8(i.getRanges(),n),positions:Ec};const o=x0(i.getFirstPosition()),s=e.toViewElement(o);return{target:t.mapViewToDom(s),positions:Ec}}function x0(n){return n.nodeAfter&&n.nodeAfter.is("element","tableCell")?n.nodeAfter:n.findAncestor("tableCell")}function R8(n,e){const t=e.editing.mapper,i=e.editing.view.domConverter,o=Array.from(n).map(s=>{const r=x0(s.start),a=t.toViewElement(r);return new z(i.mapViewToDom(a))});return z.getBoundingRect(o)}function Vn(n){if(!n||!Et(n))return n;const{top:e,right:t,bottom:i,left:o}=n;if(e==t&&t==i&&i==o)return e}function Rn(n,e){const t=parseFloat(n);return Number.isNaN(t)||String(t)!==String(n)?n:`${t}${e}`}function Ca(n,e={}){const t={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...n};return e.includeAlignmentProperty&&!t.alignment&&(t.alignment="center"),e.includePaddingProperty&&!t.padding&&(t.padding=""),e.includeVerticalAlignmentProperty&&!t.verticalAlignment&&(t.verticalAlignment="middle"),e.includeHorizontalAlignmentProperty&&!t.horizontalAlignment&&(t.horizontalAlignment=e.isRightToLeftContent?"right":"left"),t}function T0(n,e){return Ca({borderStyle:"double",borderColor:"hsl(0, 0%, 70%)",borderWidth:"1px",...n},e)}function Wu(n,e){return Ca({borderStyle:"solid",borderColor:"hsl(0, 0%, 75%)",borderWidth:"1px",...n},e)}const O8=500,Gf={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class B8 extends w{constructor(e){super(e),h(this,"_defaultContentTableCellProperties"),h(this,"_defaultLayoutTableCellProperties"),h(this,"_balloon"),h(this,"view"),h(this,"_viewWithContentTableDefaults"),h(this,"_viewWithLayoutTableDefaults"),h(this,"_undoStepBatch"),h(this,"_isReady"),e.config.define("table.tableCellProperties",{borderColors:Zr,backgroundColors:Zr})}static get requires(){return[Ue]}static get pluginName(){return"TableCellPropertiesUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;this._defaultContentTableCellProperties=Wu(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"}),this._defaultLayoutTableCellProperties=Ca(void 0,{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"}),this._balloon=e.plugins.get(Ue),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",i=>{const o=new P(i);o.set({label:t("Cell properties"),icon:mA,tooltip:!0}),this.listenTo(o,"execute",()=>this._showView());const s=Object.values(Gf).map(r=>e.commands.get(r));return o.bind("isEnabled").toMany(s,"isEnabled",(...r)=>r.some(a=>a)),o})}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,i=t.config.get("table.tableCellProperties"),o=ws(i.borderColors),s=ps(t.locale,o),r=ws(i.backgroundColors),a=ps(t.locale,r),l=i.colorPicker!==!1,c=new V8(t.locale,{borderColors:s,backgroundColors:a,defaultTableCellProperties:e,colorPickerConfig:l?i.colorPicker||{}:!1}),u=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",(f,g)=>{this._hideView(),g()}),$t({emitter:c,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const d=w0(u),m=b0(u);return c.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),c.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:c.borderColorInput,commandName:"tableCellBorderColor",errorText:d,validator:Kr})),c.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:c.borderWidthInput,commandName:"tableCellBorderWidth",errorText:m,validator:_0})),c.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:c.paddingInput,commandName:"tableCellPadding",errorText:m,validator:rs})),c.on("change:width",this._getValidatedPropertyChangeCallback({viewField:c.widthInput,commandName:"tableCellWidth",errorText:m,validator:rs})),c.on("change:height",this._getValidatedPropertyChangeCallback({viewField:c.heightInput,commandName:"tableCellHeight",errorText:m,validator:rs})),c.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:c.backgroundInput,commandName:"tableCellBackgroundColor",errorText:d,validator:Kr})),c.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),c.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),c}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(Gf).map(([i,o])=>{const s=i,r=this.view===this._viewWithContentTableDefaults?this._defaultContentTableCellProperties[s]||"":this._defaultLayoutTableCellProperties[s]||"";return[i,e.get(o).value||r]}).forEach(([i,o])=>{(i==="borderColor"||i==="borderWidth")&&t.value==="none"||this.view.set(i,o)}),this._isReady=!0}_showView(){const e=this.editor,t=Gr(e.editing.view.document.selection),i=t&&e.editing.mapper.toModelElement(t),o=!i||i.getAttribute("tableType")!=="layout";o&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableCellProperties):!o&&!this._viewWithLayoutTableDefaults&&(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableCellProperties)),this.view=o?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:A0(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,t=e.editing.view.document;ka(t.selection)?this._isViewVisible&&k0(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,o)=>{this._isReady&&this.editor.execute(e,{value:o,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:i,validator:o,errorText:s}=e,r=St(()=>{i.errorText=s},O8);return(a,l,c)=>{r.cancel(),this._isReady&&(o(c)?(this.editor.execute(t,{value:c,batch:this._undoStepBatch}),i.errorText=null):r())}}}class Bi extends O{constructor(e,t,i){switch(super(e),h(this,"attributeName"),h(this,"_defaultValue"),h(this,"_defaultContentTableValue"),h(this,"_defaultLayoutTableValue"),this.attributeName=t,this._defaultContentTableValue=i,t){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=Gi(e);this._defaultValue=!i||i.getAttribute("tableType")!=="layout"?this._defaultContentTableValue:this._defaultLayoutTableValue,this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(e={}){const{value:t,batch:i}=e,o=this.editor.model,s=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(o.document.selection),r=this._getValueToSet(t);o.enqueueChange(i,a=>{r?s.forEach(l=>a.setAttribute(this.attributeName,r,l)):s.forEach(l=>a.removeAttribute(this.attributeName,l))})}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);if(t!==this._defaultValue)return t}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every(i=>this._getAttribute(i)===t)?t:void 0}}class M8 extends Bi{constructor(e,t){super(e,"tableCellWidth",t)}_getValueToSet(e){if(e=Rn(e,"px"),e!==this._defaultValue)return e}}class E0 extends w{static get pluginName(){return"TableCellWidthEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Bs]}init(){const e=this.editor,t=Wu(e.config.get("table.tableCellProperties.defaultProperties"));yr(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",defaultValue:t.width}),e.commands.add("tableCellWidth",new M8(e,t.width))}}class L8 extends Bi{constructor(e,t){super(e,"tableCellPadding",t)}_getAttribute(e){if(!e)return;const t=Vn(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=Rn(e,"px");if(t!==this._defaultValue)return t}}class F8 extends Bi{constructor(e,t){super(e,"tableCellHeight",t)}_getValueToSet(e){const t=Rn(e,"px");if(t!==this._defaultValue)return t}}class N8 extends Bi{constructor(e,t){super(e,"tableCellBackgroundColor",t)}}class D8 extends Bi{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}}class z8 extends Bi{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}}class H8 extends Bi{constructor(e,t){super(e,"tableCellBorderStyle",t)}_getAttribute(e){if(!e)return;const t=Vn(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class $8 extends Bi{constructor(e,t){super(e,"tableCellBorderColor",t)}_getAttribute(e){if(!e)return;const t=Vn(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class W8 extends Bi{constructor(e,t){super(e,"tableCellBorderWidth",t)}_getAttribute(e){if(!e)return;const t=Vn(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=Rn(e,"px");if(t!==this._defaultValue)return t}}const Kf=/^(top|middle|bottom)$/,Zf=/^(left|center|right|justify)$/;class j8 extends w{static get pluginName(){return"TableCellPropertiesEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Bs,E0]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const o=Wu(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:e.locale.contentLanguageDirection==="rtl"});e.data.addStyleProcessorRules(ow),U8(t,i,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),e.commands.add("tableCellBorderStyle",new H8(e,o.borderStyle)),e.commands.add("tableCellBorderColor",new $8(e,o.borderColor)),e.commands.add("tableCellBorderWidth",new W8(e,o.borderWidth)),yr(t,i,{modelAttribute:"tableCellHeight",styleName:"height",defaultValue:o.height}),e.commands.add("tableCellHeight",new F8(e,o.height)),e.data.addStyleProcessorRules(F5),yr(t,i,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:o.padding}),e.commands.add("tableCellPadding",new L8(e,o.padding)),e.data.addStyleProcessorRules(iu),yr(t,i,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",defaultValue:o.backgroundColor}),e.commands.add("tableCellBackgroundColor",new N8(e,o.backgroundColor)),q8(t,i,o.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new z8(e,o.horizontalAlignment)),G8(t,i,o.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new D8(e,o.verticalAlignment))}}function U8(n,e,t){const i={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};n.extend("tableCell",{allowAttributes:Object.values(i)}),wc(e,"td",i,t),wc(e,"th",i,t),ss(e,{modelElement:"tableCell",modelAttribute:i.style,styleName:"border-style"}),ss(e,{modelElement:"tableCell",modelAttribute:i.color,styleName:"border-color"}),ss(e,{modelElement:"tableCell",modelAttribute:i.width,styleName:"border-width"})}function q8(n,e,t){n.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:i=>({key:"style",value:{"text-align":i}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":Zf}},model:{key:"tableCellHorizontalAlignment",value:(i,o,s)=>{const r=qi(t,"left",s),a=i.getStyle("text-align");return a===r?null:a}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:Zf}},model:{key:"tableCellHorizontalAlignment",value:(i,o,s)=>{const r=qi(t,"left",s),a=i.getAttribute("align");return a===r?null:a}}})}function G8(n,e,t){n.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:i=>({key:"style",value:{"vertical-align":i}})}),e.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":Kf}},model:{key:"tableCellVerticalAlignment",value:(i,o,s)=>{const r=qi(t,"middle",s),a=i.getStyle("vertical-align");return a===r?null:a}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:Kf}},model:{key:"tableCellVerticalAlignment",value:(i,o,s)=>{const r=qi(t,"middle",s),a=i.getAttribute("valign");return a===r?null:a}}})}class K8 extends w{static get pluginName(){return"TableCellProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[j8,B8]}}class Z8 extends O{refresh(){this.isEnabled=!0}execute(e={}){const{model:t,plugins:i}=this.editor;let{table:o=t.document.selection.getSelectedElement(),columnWidths:s,tableWidth:r}=e;s&&(s=Array.isArray(s)?s:s.split(",")),t.change(a=>{r?a.setAttribute("tableWidth",r,o):a.removeAttribute("tableWidth",o);const l=i.get("TableColumnResizeEditing").getColumnGroupElement(o);if(!s&&!l)return;if(!s)return a.remove(l);const c=zu(s);if(l)Array.from(l.getChildren()).forEach((u,d)=>a.setAttribute("columnWidth",c[d],u));else{const u=a.createElement("tableColumnGroup");c.forEach(d=>a.appendElement("tableColumn",{columnWidth:d},u)),a.append(u,o)}})}}function J8(n){return e=>e.on("element:colgroup",(t,i,o)=>{const s=i.modelCursor.findAncestor("table"),r=Rs(s);if(!r)return;const a=Os(r),l=n.getColumns(s);let c=qR(r,o.writer);c=Array.from({length:l},(u,d)=>c[d]||"auto"),(c.length!=a.length||c.includes("auto"))&&h0(a,r,zu(c),o.writer)},{priority:"low"})}function Q8(){return n=>n.on("insert:table",(e,t,i)=>{const o=i.writer,s=t.item,r=i.mapper.toViewElement(s),a=r.is("element","table")?r:Array.from(r.getChildren()).find(l=>l.is("element","table"));Rs(s)?o.addClass("ck-table-resized",a):o.removeClass("ck-table-resized",a)},{priority:"low"})}const Jf=Vi("px");class Y8 extends w{constructor(e){super(e),h(this,"_isResizingActive"),h(this,"_resizingData"),h(this,"_domEmitter"),h(this,"_tableUtilsPlugin"),h(this,"_initialMouseEventData",null),this._isResizingActive=!1,this.set("_isResizingAllowed",!0),this._resizingData=null,this._domEmitter=new(st()),this._tableUtilsPlugin=e.plugins.get("TableUtils"),this.on("change:_isResizingAllowed",(t,i,o)=>{const s=o?"removeClass":"addClass";e.editing.view.change(r=>{for(const a of e.editing.view.document.roots)r[s]("ck-column-resize_disabled",e.editing.view.document.getRoot(a.rootName))})})}static get requires(){return[Bs,We]}static get pluginName(){return"TableColumnResizeEditing"}static get isOfficialPlugin(){return!0}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:o=>o.is("element","tableColumnGroup"),positionOffset:0});const i=new Z8(e);e.commands.add("resizeTableWidth",i),e.commands.add("resizeColumnWidths",i),this.bind("_isResizingAllowed").to(e,"isReadOnly",t,"isEnabled",i,"isEnabled",(o,s,r)=>!o&&s&&r)}destroy(){this._domEmitter.stopListening(),super.destroy()}getColumnGroupElement(e){return Rs(e)}getTableColumnElements(e){return Os(e)}getTableColumnsWidths(e){return UR(e)}_extendSchema(){this.editor.model.schema.extend("table",{allowAttributes:["tableWidth"]}),this.editor.model.schema.register("tableColumnGroup",{allowIn:"table",isLimit:!0}),this.editor.model.schema.register("tableColumn",{allowIn:"tableColumnGroup",allowAttributes:["columnWidth","colSpan"],isLimit:!0})}_registerPostFixer(){const e=this.editor.model;e.document.registerPostFixer(o=>{let s=!1;for(const r of NR(e)){const a=this.getColumnGroupElement(r),l=this.getTableColumnElements(a),c=this.getTableColumnsWidths(a);let u=zu(c);u=t(u,r,this),!lo(c,u)&&(h0(l,a,u,o),s=!0)}return s});function t(o,s,r){const a=r._tableUtilsPlugin.getColumns(s);if(a-o.length===0)return o;const l=o.map(u=>Number(u.replace("%",""))),c=i(r.editor.model.document.differ,s);for(const u of c){const d=a-l.length;if(d===0)continue;const m=d>0,f=r._tableUtilsPlugin.getCellLocation(u).column;if(m){const g=DR(s,r.editor),p=$R(d,g);l.splice(f,0,...p)}else{const g=l.splice(f,Math.abs(d));l[f]+=Ts(g)}}return l.map(u=>u+"%")}function i(o,s){const r=new Set;for(const a of o.getChanges())if(a.type=="insert"&&a.position.nodeAfter&&a.position.nodeAfter.name=="tableCell"&&a.position.nodeAfter.getAncestors().includes(s))r.add(a.position.nodeAfter);else if(a.type=="remove"){const l=a.position.nodeBefore||a.position.nodeAfter;l.name=="tableCell"&&l.getAncestors().includes(s)&&r.add(l)}return r}}_registerConverters(){const e=this.editor.conversion;e.for("upcast").attributeToAttribute({view:{name:/^(figure|table)$/,styles:{width:/[\s\S]+/}},model:{name:"table",key:"tableWidth",value:t=>{if(!t.parent.is("element","figure"))return t.getStyle("width")}}}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableWidth"},view:t=>({name:"figure",key:"style",value:{width:t}})}),e.elementToElement({model:"tableColumnGroup",view:"colgroup"}),e.elementToElement({model:"tableColumn",view:"col"}),e.for("downcast").add(Q8()),e.for("upcast").add(J8(this._tableUtilsPlugin)),e.for("upcast").attributeToAttribute({view:{name:"col",styles:{width:/.*/}},model:{key:"columnWidth",value:t=>{const i=t.getStyle("width");return!i||!i.endsWith("%")&&!i.endsWith("pt")?"auto":i}}}),e.for("upcast").attributeToAttribute({view:{name:"col",key:"span"},model:"colSpan"}),e.for("downcast").attributeToAttribute({model:{name:"tableColumn",key:"columnWidth"},view:t=>({key:"style",value:{width:t}})})}_registerResizingListeners(){const e=this.editor.editing.view;e.addObserver(f0),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(I.window.document,"mousemove",co(this._onMouseMoveHandler.bind(this),50)),this._domEmitter.listenTo(I.window.document,"mouseup",this._onMouseUpHandler.bind(this))}_recalculateResizerElement(e){const t=this.editor,i=t.editing.view.domConverter,o=i.mapViewToDom(e.findAncestor("table")),s=i.mapViewToDom(e.findAncestor(u=>["td","th"].includes(u.name))),r=new z(o),a=new z(s),l=Jf(Number((r.top-a.top).toFixed(4))),c=Jf(Number((a.bottom-r.bottom).toFixed(4)));t.editing.view.change(u=>{u.setStyle("top",l,e),u.setStyle("bottom",c,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")||!this._isResizingAllowed)return;const o=this.editor,s=o.editing.mapper.toModelElement(i.findAncestor("figure"));o.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")),o=t.findAncestor("table"),s=r(i,this._tableUtilsPlugin,this.editor);Array.from(o.getChildren()).find(c=>c.is("element","colgroup"))||this.editor.editing.view.change(c=>{a(c,s,o)}),this._isResizingActive=!0,this._resizingData=this._getResizingData(e,s),this.editor.editing.view.change(c=>l(c,o,this._resizingData));function r(c,u,d){const m=Array(u.getColumns(c)),f=new de(c);for(const g of f){const p=d.editing.mapper.toViewElement(g.cell),_=d.editing.view.domConverter.mapViewToDom(p),v=jR(_);(!m[g.column]||v<m[g.column])&&(m[g.column]=ut(v))}return m}function a(c,u,d){const m=c.createContainerElement("colgroup");for(let f=0;f<u.length;f++){const g=c.createEmptyElement("col"),p=`${ut(u[f]/Ts(u)*100)}%`;c.setStyle("width",p,g),c.insert(c.createPositionAt(m,"end"),g)}c.insert(c.createPositionAt(d,0),m)}function l(c,u,d){const m=d.widths.viewFigureWidth/d.widths.viewFigureParentWidth;c.addClass("ck-table-resized",u),c.addClass("ck-table-column-resizer__active",d.elements.viewResizer),c.setStyle("width",`${ut(m*100)}%`,u.findAncestor("figure"))}}_onMouseMoveHandler(e,t){if(this._initialMouseEventData){const M=this._initialMouseEventData.domEvent;if(Math.abs(t.clientX-M.clientX)>=FR)this._startResizingAfterThreshold(),this._initialMouseEventData=null;else return}if(!this._isResizingActive)return;if(!this._isResizingAllowed){this._onMouseUpHandler();return}const{columnPosition:i,flags:{isRightEdge:o,isTableCentered:s,isLtrContent:r},elements:{viewFigure:a,viewLeftColumn:l,viewRightColumn:c,viewResizer:u},widths:{viewFigureParentWidth:d,tableWidth:m,leftColumnWidth:f,rightColumnWidth:g}}=this._resizingData,p=-f+yc,_=o?d-m:g-yc,v=(r?1:-1)*(o&&s?2:1),E=HR((t.clientX-i)*v,Math.min(p,0),Math.max(_,0));E!==0&&(this.editor.editing.view.change(M=>{const G=ut((f+E)*100/m);if(M.setStyle("width",`${G}%`,l),o){const X=ut((m+E)*100/d);M.setStyle("width",`${X}%`,a)}else{const X=ut((g-E)*100/m);M.setStyle("width",`${X}%`,c)}}),this._recalculateResizerElement(u))}_onMouseUpHandler(){if(this._initialMouseEventData=null,!this._isResizingActive)return;const{viewResizer:e,modelTable:t,viewFigure:i,viewColgroup:o}=this._resizingData.elements,s=this.editor,r=s.editing.view,a=this.getColumnGroupElement(t),l=Array.from(o.getChildren()).filter(p=>p.is("view:element")),c=a?this.getTableColumnsWidths(a):null,u=l.map(p=>p.getStyle("width")),d=!lo(c,u),m=t.getAttribute("tableWidth"),f=i.getStyle("width"),g=m!==f;(d||g)&&(this._isResizingAllowed?s.execute("resizeTableWidth",{table:t,tableWidth:`${ut(f)}%`,columnWidths:u}):r.change(p=>{if(c)for(const _ of l)p.setStyle("width",c.shift(),_);else p.remove(o);g&&(m?p.setStyle("width",m,i):p.removeStyle("width",i)),!c&&!m&&p.removeClass("ck-table-resized",[...i.getChildren()].find(_=>_.name==="table"))})),r.change(p=>{p.removeClass("ck-table-column-resizer__active",e)}),r.domConverter.mapViewToDom(e).matches(":hover")||this._resetResizerStyles(e),this._isResizingActive=!1,this._resizingData=null}_getResizingData(e,t){const i=this.editor,o=e.domEvent.clientX,s=e.target,r=s.findAncestor("td")||s.findAncestor("th"),a=i.editing.mapper.toModelElement(r),l=a.findAncestor("table"),c=zR(a,this._tableUtilsPlugin).rightEdge,u=this._tableUtilsPlugin.getColumns(l)-1,d=c===u,m=!l.hasAttribute("tableAlignment"),f=i.locale.contentLanguageDirection!=="rtl",g=r.findAncestor("table"),p=g.findAncestor("figure"),_=[...g.getChildren()].find(x=>x.is("element","colgroup")),v=_.getChild(c),E=d?void 0:_.getChild(c+1),M=kc(i.editing.view.domConverter.mapViewToDom(p.parent)),G=kc(i.editing.view.domConverter.mapViewToDom(p)),X=u0(l,i),T=t[c],F=d?void 0:t[c+1];return{columnPosition:o,flags:{isRightEdge:d,isTableCentered:m,isLtrContent:f},elements:{viewResizer:s,modelTable:l,viewFigure:p,viewColgroup:_,viewLeftColumn:v,viewRightColumn:E},widths:{viewFigureParentWidth:M,viewFigureWidth:G,tableWidth:X,leftColumnWidth:T,rightColumnWidth:F}}}_registerResizerInserter(){this.editor.conversion.for("editingDowncast").add(e=>{e.on("insert:tableCell",(t,i,o)=>{const s=i.item,r=o.mapper.toViewElement(s),a=o.writer;a.insert(a.createPositionAt(r,"end"),a.createUIElement("div",{class:"ck-table-column-resizer"}))},{priority:"lowest"})})}}class X8 extends w{static get requires(){return[Y8,E0]}static get pluginName(){return"TableColumnResize"}static get isOfficialPlugin(){return!0}}class On extends O{constructor(e,t,i){super(e),h(this,"attributeName"),h(this,"_defaultValue"),h(this,"_defaultContentTableValue"),h(this,"_defaultLayoutTableValue"),this.attributeName=t,this._defaultContentTableValue=i,this._defaultLayoutTableValue=t==="tableBorderStyle"?"none":void 0}refresh(){const e=this.editor.model.document.selection,t=Gi(e);this._defaultValue=!t||t.getAttribute("tableType")!=="layout"?this._defaultContentTableValue:this._defaultLayoutTableValue,this.isEnabled=!!t,this.value=this._getValue(t)}execute(e={}){const t=this.editor.model,i=t.document.selection,{value:o,batch:s}=e,r=Gi(i),a=this._getValueToSet(o);t.enqueueChange(s,l=>{a?l.setAttribute(this.attributeName,a,r):l.removeAttribute(this.attributeName,r)})}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);if(t!==this._defaultValue)return t}_getValueToSet(e){if(e!==this._defaultValue)return e}}class eO extends On{constructor(e,t){super(e,"tableBackgroundColor",t)}}class tO extends On{constructor(e,t){super(e,"tableBorderColor",t)}_getValue(e){if(!e)return;const t=Vn(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class iO extends On{constructor(e,t){super(e,"tableBorderStyle",t)}_getValue(e){if(!e)return;const t=Vn(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}}class nO extends On{constructor(e,t){super(e,"tableBorderWidth",t)}_getValue(e){if(!e)return;const t=Vn(e.getAttribute(this.attributeName));if(t!==this._defaultValue)return t}_getValueToSet(e){const t=Rn(e,"px");if(t!==this._defaultValue)return t}}class oO extends On{constructor(e,t){super(e,"tableWidth",t)}_getValueToSet(e){if(e=Rn(e,"px"),e!==this._defaultValue)return e}}class sO extends On{constructor(e,t){super(e,"tableHeight",t)}_getValueToSet(e){if(e=Rn(e,"px"),e!==this._defaultValue)return e}}class rO extends On{constructor(e,t){super(e,"tableAlignment",t)}}const aO=/^(left|center|right)$/,lO=/^(left|none|right)$/;class cO extends w{static get pluginName(){return"TablePropertiesEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Bs]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const o=T0(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0});e.data.addStyleProcessorRules(ow),uO(t,i,{color:o.borderColor,style:o.borderStyle,width:o.borderWidth}),e.commands.add("tableBorderColor",new tO(e,o.borderColor)),e.commands.add("tableBorderStyle",new iO(e,o.borderStyle)),e.commands.add("tableBorderWidth",new nO(e,o.borderWidth)),hO(t,i,o.alignment),e.commands.add("tableAlignment",new rO(e,o.alignment)),Qf(t,i,{modelAttribute:"tableWidth",styleName:"width",defaultValue:o.width}),e.commands.add("tableWidth",new oO(e,o.width)),Qf(t,i,{modelAttribute:"tableHeight",styleName:"height",defaultValue:o.height}),e.commands.add("tableHeight",new sO(e,o.height)),e.data.addStyleProcessorRules(iu),dO(t,i,{modelAttribute:"tableBackgroundColor",styleName:"background-color",defaultValue:o.backgroundColor}),e.commands.add("tableBackgroundColor",new eO(e,o.backgroundColor))}}function uO(n,e,t){const i={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};n.extend("table",{allowAttributes:Object.values(i)}),wc(e,"table",i,t),_r(e,{modelAttribute:i.color,styleName:"border-color"}),_r(e,{modelAttribute:i.style,styleName:"border-style"}),_r(e,{modelAttribute:i.width,styleName:"border-width"})}function hO(n,e,t){n.extend("table",{allowAttributes:["tableAlignment"]}),e.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right"]},view:{left:{key:"style",value:{float:"left"}},right:{key:"style",value:{float:"right"}},center:(i,o,s)=>({key:"style",value:s.item.getAttribute("tableType")!=="layout"?{float:"none"}:{"margin-left":"auto","margin-right":"auto"}})},converterPriority:"high"}),e.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:lO}},model:{key:"tableAlignment",value:(i,o,s)=>{const r=qi(t,"",s);let a=i.getStyle("float");return a==="none"&&(a="center"),a===r?null:a}}}).attributeToAttribute({view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},model:{key:"tableAlignment",value:(i,o,s)=>{const r=qi(t,"",s),a="center";return a===r?null:a}}}).attributeToAttribute({view:{attributes:{align:aO}},model:{name:"table",key:"tableAlignment",value:(i,o,s)=>{const r=qi(t,"",s),a=i.getAttribute("align");return a===r?null:a}}})}function dO(n,e,t){const{modelAttribute:i}=t;n.extend("table",{allowAttributes:[i]}),Nu(e,{viewElement:"table",...t}),_r(e,t)}function Qf(n,e,t){const{modelAttribute:i}=t;n.extend("table",{allowAttributes:[i]}),Nu(e,{viewElement:/^(table|figure)$/,shouldUpcast:o=>!(o.name=="table"&&o.parent.name=="figure"),...t}),ss(e,{modelElement:"table",...t})}class mO extends A{constructor(e,t){super(e),h(this,"options"),h(this,"focusTracker"),h(this,"keystrokes"),h(this,"children"),h(this,"borderStyleDropdown"),h(this,"borderWidthInput"),h(this,"borderColorInput"),h(this,"backgroundInput"),h(this,"widthInput"),h(this,"heightInput"),h(this,"alignmentToolbar"),h(this,"saveButtonView"),h(this,"cancelButtonView"),h(this,"_focusables"),h(this,"_focusCycler"),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:o,borderColorInput:s,borderRowLabel:r}=this._createBorderFields(),{backgroundRowLabel:a,backgroundInput:l}=this._createBackgroundFields(),{widthInput:c,operatorLabel:u,heightInput:d,dimensionsLabel:m}=this._createDimensionFields(),{alignmentToolbar:f,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new ee,this.keystrokes=new te,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=o,this.borderColorInput=s,this.backgroundInput=l,this.widthInput=c,this.heightInput=d,this.alignmentToolbar=f;const{saveButtonView:p,cancelButtonView:_}=this._createActionButtons();this.saveButtonView=p,this.cancelButtonView=_,this._focusables=new Ie,this._focusCycler=new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Jt(e,{label:this.t("Table properties")})),this.children.add(new $e(e,{labelView:r,children:[r,i,s,o],class:"ck-table-form__border-row"})),this.children.add(new $e(e,{labelView:a,children:[a,l],class:"ck-table-form__background-row"})),this.children.add(new $e(e,{children:[new $e(e,{labelView:m,children:[m,c,u,d],class:"ck-table-form__dimensions-row"}),new $e(e,{labelView:g,children:[g,f],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new $e(e,{children:[this.saveButtonView,this.cancelButtonView],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(),Ri({view:this}),[this.borderColorInput,this.backgroundInput].forEach(e=>{this._focusCycler.chain(e.fieldView.focusCycler)}),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].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=Jr({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),o=this.locale,s=this.t,r=s("Style"),a=new xt(o);a.text=s("Border");const l=$u(s),c=new Te(o,pu);c.set({label:r,class:"ck-table-form__border-style"}),c.fieldView.buttonView.set({ariaLabel:r,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:r}),c.fieldView.buttonView.bind("label").to(this,"borderStyle",m=>l[m||"none"]),c.fieldView.on("execute",m=>{this.borderStyle=m.source._borderStyleValue}),c.bind("isEmpty").to(this,"borderStyle",m=>!m),wt(c.fieldView,v0(this,t.style),{role:"menu",ariaLabel:r});const u=new Te(o,nt);u.set({label:s("Width"),class:"ck-table-form__border-width"}),u.fieldView.bind("value").to(this,"borderWidth"),u.bind("isEnabled").to(this,"borderStyle",ar),u.fieldView.on("input",()=>{this.borderWidth=u.fieldView.element.value});const d=new Te(o,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",ar),d.fieldView.on("input",()=>{this.borderColor=d.fieldView.value}),this.on("change:borderStyle",(m,f,g,p)=>{ar(g)||(this.borderColor="",this.borderWidth=""),ar(p)||(this.borderColor=t.color,this.borderWidth=t.width)}),{borderRowLabel:a,borderStyleDropdown:c,borderColorInput:d,borderWidthInput:u}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new xt(e);i.text=t("Background");const o=Jr({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),s=new Te(e,o);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 xt(e);i.text=t("Dimensions");const o=new Te(e,nt);o.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),o.fieldView.bind("value").to(this,"width"),o.fieldView.on("input",()=>{this.width=o.fieldView.element.value});const s=new A(e);s.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const r=new Te(e,nt);return r.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),r.fieldView.bind("value").to(this,"height"),r.fieldView.on("input",()=>{this.height=r.fieldView.element.value}),{dimensionsLabel:i,widthInput:o,operatorLabel:s,heightInput:r}}_createAlignmentFields(){const e=this.locale,t=this.t,i=new xt(e);i.text=t("Alignment");const o=new Ei(e);return o.set({role:"radiogroup",isCompact:!0,ariaLabel:t("Table alignment toolbar")}),Tc({view:this,icons:{left:ru,center:Mr,right:Lr},toolbar:o,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:i,alignmentToolbar:o}}_createActionButtons(){const e=this.locale,t=this.t,i=new P(e),o=new P(e),s=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return i.set({label:t("Save"),icon:Es,class:"ck-button-save",type:"submit",withText:!0}),i.bind("isEnabled").toMany(s,"errorText",(...r)=>r.every(a=>!a)),o.set({label:t("Cancel"),icon:_o,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:o}}get _alignmentLabels(){const e=this.locale,t=this.t,i=t("Align table to the left"),o=t("Center table"),s=t("Align table to the right");return e.uiLanguageDirection==="rtl"?{right:s,center:o,left:i}:{left:i,center:o,right:s}}}function ar(n){return n!=="none"}const fO=500,Yf={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class gO extends w{constructor(e){super(e),h(this,"_defaultContentTableProperties"),h(this,"_defaultLayoutTableProperties"),h(this,"_balloon"),h(this,"view",null),h(this,"_viewWithContentTableDefaults",null),h(this,"_viewWithLayoutTableDefaults",null),h(this,"_undoStepBatch"),h(this,"_isReady"),e.config.define("table.tableProperties",{borderColors:Zr,backgroundColors:Zr})}static get requires(){return[Ue]}static get pluginName(){return"TablePropertiesUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;this._defaultContentTableProperties=T0(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._defaultLayoutTableProperties=Ca(),this._balloon=e.plugins.get(Ue),e.ui.componentFactory.add("tableProperties",()=>this._createTablePropertiesButton())}_createTablePropertiesButton(){const e=this.editor,t=e.t,i=new P(e.locale);i.set({label:t("Table properties"),icon:pA,tooltip:!0}),this.listenTo(i,"execute",()=>this._showView());const o=Object.values(Yf).map(s=>e.commands.get(s));return i.bind("isEnabled").toMany(o,"isEnabled",(...s)=>s.some(r=>r)),i}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,i=t.config.get("table.tableProperties"),o=ws(i.borderColors),s=ps(t.locale,o),r=ws(i.backgroundColors),a=ps(t.locale,r),l=i.colorPicker!==!1,c=new mO(t.locale,{borderColors:s,backgroundColors:a,defaultTableProperties:e,colorPickerConfig:l?i.colorPicker||{}:!1}),u=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",(f,g)=>{this._hideView(),g()}),$t({emitter:c,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const d=w0(u),m=b0(u);return c.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),c.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:c.borderColorInput,commandName:"tableBorderColor",errorText:d,validator:Kr})),c.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:c.borderWidthInput,commandName:"tableBorderWidth",errorText:m,validator:_0})),c.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:c.backgroundInput,commandName:"tableBackgroundColor",errorText:d,validator:Kr})),c.on("change:width",this._getValidatedPropertyChangeCallback({viewField:c.widthInput,commandName:"tableWidth",errorText:m,validator:rs})),c.on("change:height",this._getValidatedPropertyChangeCallback({viewField:c.heightInput,commandName:"tableHeight",errorText:m,validator:rs})),c.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),c}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(Yf).map(([i,o])=>{const s=i,r=this.view===this._viewWithContentTableDefaults?this._defaultContentTableProperties[s]||"":this._defaultLayoutTableProperties[s]||"";return[s,e.get(o).value||r]}).forEach(([i,o])=>{(i==="borderColor"||i==="borderWidth")&&t.value==="none"||this.view.set(i,o)}),this._isReady=!0}_showView(){const e=this.editor,t=Gr(e.editing.view.document.selection),i=t&&e.editing.mapper.toModelElement(t),o=!i||i.getAttribute("tableType")!=="layout";o&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableProperties):!o&&!this._viewWithLayoutTableDefaults&&(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableProperties)),this.view=o?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",()=>{this._updateView()}),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:C0(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,t=e.editing.view.document;Gr(t.selection)?this._isViewVisible&&k0(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,o)=>{this._isReady&&this.editor.execute(e,{value:o,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:i,validator:o,errorText:s}=e,r=St(()=>{i.errorText=s},fO);return(a,l,c)=>{r.cancel(),this._isReady&&(o(c)?(this.editor.execute(t,{value:c,batch:this._undoStepBatch}),i.errorText=null):r())}}}class pO extends w{static get pluginName(){return"TableProperties"}static get isOfficialPlugin(){return!0}static get requires(){return[cO,gO]}}/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function wO(n){n.document.registerPostFixer(e=>bO(e,n))}function bO(n,e){const t=e.document.differ.getChanges();let i=!1;for(const o of t){if(o.type!="insert")continue;const s=o.position.parent;if(s.is("element","table")||o.name=="table"){const r=o.name=="table"?o.position.nodeAfter:s,a=Array.from(r.getChildren()).filter(c=>c.is("element","caption")),l=a.shift();if(!l)continue;for(const c of a)n.move(n.createRangeIn(c),l,"end"),n.remove(c);l.nextSibling&&(n.move(n.createRangeOn(l),r,"end"),i=!0),i=!!a.length||i}}return i}function Xf(n){return!!n&&n.is("element","table")}function Sc(n){for(const e of n.getChildren())if(e.is("element","caption"))return e;return null}function _O(n){const e=Gi(n);return e?Sc(e):null}function vO(n){const e=n.parent;return n.name=="figcaption"&&e&&e.is("element","figure")&&e.hasClass("table")?{name:!0}:n.name=="caption"&&e&&e.is("element","table")?{name:!0}:null}class yO extends O{refresh(){const e=this.editor,t=Gi(e.model.document.selection);this.isEnabled=!!t&&e.model.schema.checkChild(t,"caption"),this.isEnabled?this.value=!!Sc(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,o=Gi(i.document.selection),s=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(o)||e.createElement("caption");i.insertContent(s,o,"end"),t&&e.setSelection(s,"in")}_hideTableCaption(e){const t=this.editor.model,i=Gi(t.document.selection),o=this.editor.plugins.get("TableCaptionEditing"),s=Sc(i);o._saveCaption(i,s),t.deleteContent(e.createSelection(s,"on"))}}class kO extends w{constructor(e){super(e),h(this,"_savedCaptionsMap"),this._savedCaptionsMap=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,o=e.t;t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new yO(this.editor)),e.conversion.for("upcast").elementToElement({view:vO,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(s,{writer:r})=>Xf(s.parent)?r.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(s,{writer:r})=>{if(!Xf(s.parent))return null;const a=r.createEditableElement("figcaption");return r.setCustomProperty("tableCaption",!0,a),a.placeholder=o("Enter table caption"),sa({view:i,element:a,keepOnFocus:!0}),wa(a,r)}}),wO(e.model)}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?ne.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}}class CO extends w{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",o=>{const s=e.commands.get("toggleTableCaption"),r=new P(o);return r.set({icon:pw,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.bind("label").to(s,"value",a=>i(a?"Toggle caption off":"Toggle caption on")),this.listenTo(r,"execute",()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),s.value){const a=_O(e.model.document.selection),l=e.editing.mapper.toViewElement(a);if(!l)return;t.scrollToTheSelection(),t.change(c=>{c.addClass("table__caption_highlighted",l)})}e.editing.view.focus()}),r})}}class AO extends w{static get pluginName(){return"TableCaption"}static get isOfficialPlugin(){return!0}static get requires(){return[kO,CO]}}const xO=`<?xml version="1.0" encoding="utf-8"?>
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
<g><g><path d="M853.9,754.9c-26-45.4-66.5-76.2-109.1-87.8c-33.7-9.2-68.7-6.4-98.9,10.7l-90-157.3C611.6,409.5,736.5,160.5,759,121.2C788,70.4,736,10,736,10L500,422.8L264,10c0,0-52,60.4-22.9,111.2c22.5,39.3,147.5,288.3,203.1,399.3l-89.9,157.3c-30.2-17.1-65.3-19.9-98.9-10.7c-42.7,11.6-83.1,42.3-109.1,87.8c-46.8,81.7-28.9,179.7,39.7,219c30.4,17.5,65.7,20.3,99.6,11.1c42.6-11.6,83.1-42.4,109.1-87.7c11.4-20,18.9-41,22.8-61.8v0c0-0.2,0-0.3,0.2-0.5c0.2-1.7,0.5-3.5,0.7-5.4c19.3-129.5,55.8-195.7,81.6-227.8c25.9,32.1,62.4,98.3,81.7,227.8c0.2,1.9,0.5,3.6,0.7,5.4c0.1,0.2,0.1,0.3,0.2,0.5v0c3.9,20.8,11.4,41.8,22.7,61.8c26,45.3,66.5,76.1,109.2,87.7c34,9.2,69.2,6.4,99.7-11.1C882.8,934.5,900.6,836.5,853.9,754.9z M327.9,858.9c-14.8,25.8-38.1,45.2-62.5,51.8c-10.8,3-26.7,4.7-41.3-3.6c-31.1-17.8-36.2-70.1-11.1-114c15-26,37.8-45,62.5-51.8c10.7-2.9,26.7-4.7,41.3,3.6C347.9,762.7,353,814.9,327.9,858.9z M775.9,907.1c-14.6,8.4-30.4,6.6-41.3,3.6c-24.4-6.6-47.7-26-62.5-51.8c-25.1-44-20-96.2,11.1-114c14.7-8.3,30.6-6.5,41.3-3.6C749.3,748,772.1,767,787,793C812.1,837,807.1,889.3,775.9,907.1z"/><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g></g>
</svg>`;class TO extends w{constructor(){super(...arguments),h(this,"htmlDataProcessor")}init(){this.htmlDataProcessor=new jp(this.editor.editing.view.document),this.editor.ui.componentFactory.add("cutToNote",e=>{const t=new P(e);return t.set({label:"Cut & paste selection to sub-note",icon:xO,tooltip:!0}),t.on("execute",()=>{const i=this.editor.editing.view.getDomRoot();glob.getComponentByEl(i).triggerCommand("cutIntoNote")}),t}),this.editor.getSelectedHtml=()=>this.getSelectedHtml(),this.editor.removeSelection=()=>this.removeSelection()}getSelectedHtml(){const e=this.editor.model,t=e.document,i=this.editor.data.toView(e.getSelectedContent(t.selection));return this.htmlDataProcessor.toData(i)}async removeSelection(){const e=this.editor.model;e.deleteContent(e.document.selection),this.editor.execute("paragraph"),await this.getComponent().triggerCommand("saveNoteDetailNow")}getComponent(){const e=this.editor.editing.view.getDomRoot();return glob.getComponentByEl(e)}}class EO extends w{static get requires(){return[At]}static get pluginName(){return"UploadimagePlugin"}init(){this.editor.plugins.get("FileRepository").createUploadAdapter=e=>new SO(e)}}class SO{constructor(e){h(this,"loader"),h(this,"xhr"),this.loader=e}upload(){return this.loader.file.then(e=>new Promise((t,i)=>{this._initRequest().then(()=>{this._initListeners(t,i),this._sendRequest()})}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){return glob.getHeaders().then(e=>{const t=this.xhr=new XMLHttpRequest,{noteId:i}=glob.getActiveContextNote(),o=`api/notes/${i}/attachments/upload`;t.open("POST",o,!0),t.responseType="json";for(const s in e)t.setRequestHeader(s,e[s])})}async _initListeners(e,t){const i=this.xhr;if(!i){t("Missing XHR");return}const o=this.loader,s=await o.file;if(!s){t("Missing file");return}const r=`Cannot upload file: ${s.name}.`;i.addEventListener("error",()=>t(r)),i.addEventListener("abort",()=>t()),i.addEventListener("load",()=>{const a=i.response;if(!a||!a.uploaded)return t(a&&a.error&&a.error.message?a.error.message:r);e({default:a.url})}),i.upload&&i.upload.addEventListener("progress",a=>{a.lengthComputable&&(o.uploadTotal=a.total,o.uploaded=a.loaded)})}async _sendRequest(){var e;const t=new FormData,i=await this.loader.file;i&&(t.append("upload",i),(e=this.xhr)==null||e.send(t))}}class PO extends w{init(){this.editor.conversion.for("downcast").attributeToElement({model:"italic",view:"em",converterPriority:"high"})}}class IO extends w{init(){this.editor.conversion.for("downcast").attributeToElement({model:"strikethrough",view:"del",converterPriority:"high"})}}const VO=`<?xml version="1.0" encoding="UTF-8"?>
<svg enable-background="new 0 0 256 256" version="1.1" viewBox="0 0 256 256" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<path d="m232.6 27.598c-17.706 0.092041-40.298 3.7127-58.258 10.104-1.7959 0.63909-3.5465 1.3043-5.2402 1.998-3.1 1.2-6.0988 2.6016-8.7988 4.1016-2.2 1.2-4.3016 2.4988-6.1016 3.7988-21.6 15.5-27.9 44.2-28.6 65.4l14.9-10.5 14.301-10 51.199-35.9-49.1 39.301-14.1 11.299-14.801 11.801c20.4 6.5 52.4 9.7992 74.9-6.3008 3.1886-2.319 6.4708-5.1162 9.7559-8.459 0.14708-0.08175 0.29689-0.1571 0.44336-0.24023 2.3386-2.3386 4.7705-4.8714 7.0215-7.5898 0.02928-0.033868 0.05864-0.065681 0.08789-0.099609 0.0964-0.038723 0.1948-0.072111 0.29102-0.11133 14.544-16.737 27.833-39.152 32.252-55.658 0.67979-2.5395 1.1487-4.9387 1.3809-7.1562 0.11607-1.1088 0.17422-2.173 0.16797-3.1855-1.0438-0.3625-2.1849-0.68557-3.4121-0.9707-1.2272-0.28513-2.542-0.53096-3.9336-0.74024s-2.8595-0.38069-4.3965-0.51562c-3.0739-0.26987-6.4198-0.39341-9.9609-0.375zm-202.79 20.252c-11.737-0.05-22.113 1.4004-28.312 4.6504 0.9 5.6625 4.3309 13.419 9.3125 21.77v0.001953c3.3209 5.5664 7.332 11.395 11.74 17.043v0.001953c6.6127 8.4716 14.122 16.534 21.547 22.684 2.3 1.9 4.5008 3.5996 6.8008 5.0996 0.048555 0.0124 0.097907 0.019 0.14648 0.03125 1.7845 1.2837 3.569 2.2777 5.3535 3.1699 20.8 10.4 45.5 3.7984 62.1-4.1016l-14.301-7.2988-13.6-6.9004-48.127-24.607 49.928 21.707 14.5 6.3008 15.199 6.5996c-3.4-18.3-14.099-44-35.799-54.9-3.3-1.6-6.9004-3.1004-10.9-4.4004-2.9-0.9-5.8996-1.7-9.0996-2.5-11.65-2.75-24.751-4.2996-36.488-4.3496zm97.488 73.85 3.6992 13.9 3.5996 13.201 12.801 47.6-15.9-47-4.5-13.4-4.8008-14.199c-10.3 13.4-21.3 36.199-15.5 57.199 0.8747 3.11 2.1333 6.3182 3.6719 9.709 0.01066 0.06374 0.01836 0.12769 0.0293 0.19141 1.1 2.5 2.3988 5.0992 3.7988 7.6992 10.4 18.8 27.701 38.501 39.701 42.801 0.00763-0.00936 0.01581-0.01991 0.02344-0.0293 0.02502 0.00909 0.05119 0.02035 0.07617 0.0293 8.8-10.8 16.8-42.601 15.9-65.701-0.1-2.7-0.30117-5.2992-0.70117-7.6992-0.3-1.9-0.69922-3.8-1.1992-5.5-5.6-20.2-25.199-32.601-40.699-38.801z"/>
</svg>
`;class S0 extends w{static get requires(){return[OO]}}class RO extends O{execute({href:e}){if(!(e!=null&&e.trim()))return;const t=this.editor;glob.getReferenceLinkTitle(e).then(()=>{t.model.change(i=>{const o=i.createElement("reference",{href:e});t.model.insertContent(o),i.setSelection(o,"after")})})}refresh(){const e=this.editor.model,t=e.document.selection;this.isEnabled=t.focus!==null&&e.schema.checkChild(t.focus.parent,"reference")}}class OO extends w{static get requires(){return[Vt,ks]}init(){this._defineSchema(),this._defineConverters(),this.editor.commands.add("referenceLink",new RO(this.editor)),this.editor.editing.mapper.on("viewToModelPosition",Cu(this.editor.model,e=>e.hasClass("reference-link"))),this.editor.plugins.get("LinkEditing")._registerLinkOpener(()=>!0)}_defineSchema(){this.editor.model.schema.register("reference",{allowWhere:"$text",isInline:!0,isObject:!0,allowAttributes:["href","uploadId","uploadStatus"]})}_defineConverters(){const e=this.editor,t=e.conversion;t.for("upcast").elementToElement({view:{name:"a",classes:["reference-link"]},model:(i,{writer:o})=>{const s=i.getAttribute("href");return o.createElement("reference",{href:s})}}),t.for("editingDowncast").elementToElement({model:"reference",view:(i,{writer:o})=>{const s=i.getAttribute("href"),r=o.createContainerElement("a",{href:s,class:"reference-link"},{renderUnsafeAttributes:["href"]}),a=o.createUIElement("span",{},function(l){const c=this.toDomElement(l),u=e.editing.view.getDomRoot();return glob.getComponentByEl(u).loadReferenceLinkTitle($(c),s),c});return o.insert(o.createPositionAt(r,0),a),gt(r,o)}}),t.for("dataDowncast").elementToElement({model:"reference",view:(i,{writer:o})=>{const s=i.getAttribute("href"),r=o.createContainerElement("a",{href:s,class:"reference-link"}),a=glob.getReferenceLinkTitleSync(s),l=o.createText(a);return o.insert(o.createPositionAt(r,0),l),r}})}}class BO extends w{static get requires(){return[S0]}init(){const e=this.editor;e.ui.componentFactory.add("internalLink",t=>{const i=new P(t);return i.set({label:"Internal Trilium link (CTRL-L)",icon:VO,tooltip:!0}),i.bind("isEnabled").to(e,"isReadOnly",o=>!o),i.on("execute",()=>{const o=e.editing.view.getDomRoot();glob.getComponentByEl(o).triggerCommand("addLinkToText")}),i})}}const MO=`<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#000000" xmlns="http://www.w3.org/2000/svg"
width="800px" height="800px" viewBox="0 0 52 52" enable-background="new 0 0 52 52" xml:space="preserve">
<path d="M43.6,6.8h-4V5.2c0-1.8-1.4-3.2-3.2-3.2c-1.8,0-3.2,1.4-3.2,3.2v1.6H18.8V5.2c0-1.8-1.4-3.2-3.2-3.2
s-3.2,1.4-3.2,3.2v1.6h-4c-2.6,0-4.8,2.2-4.8,4.8v1.6c0,0.9,0.7,1.6,1.6,1.6h41.6c0.9,0,1.6-0.7,1.6-1.6v-1.6
C48.4,9,46.2,6.8,43.6,6.8z"/>
<path d="M46.8,19.6H5.2c-0.9,0-1.6,0.7-1.6,1.6v24c0,2.6,2.2,4.8,4.8,4.8h35.2c2.6,0,4.8-2.2,4.8-4.8v-24
C48.4,20.3,47.7,19.6,46.8,19.6z M26,46.7c-6.6,0-11.9-5.4-11.9-11.9c0-6.6,5.4-11.9,11.9-11.9s11.9,5.4,11.9,11.9
C37.9,41.4,32.6,46.7,26,46.7z"/>
<path d="M27.2,34.3v-5.1c0-0.4-0.4-0.8-0.8-0.8h-0.8c-0.4,0-0.8,0.4-0.8,0.8v5.6c0,0.3,0.1,0.6,0.4,0.8l3.8,3.8
c0.3,0.3,0.8,0.3,1.1,0l0.6-0.6c0.3-0.3,0.3-0.8,0-1.1L27.2,34.3z"/>
</svg>`;class LO extends w{init(){const e=this.editor;e.ui.componentFactory.add("dateTime",t=>{const i=new P(t);return i.set({label:"Date time",icon:MO,tooltip:!0}),i.bind("isEnabled").to(e,"isReadOnly",o=>!o),i.on("execute",()=>{const o=e.editing.view.getDomRoot();glob.getComponentByEl(o).triggerCommand("insertDateTimeToText"),e.editing.view.focus()}),i})}}class FO extends w{static get requires(){return[e0]}init(){this.editor.model.schema.setAttributeProperties("linkHref",{isFormatting:!0})}}class NO extends w{init(){this.editor.keystrokes.set("Tab",(e,t)=>{const i=this.editor.commands.get("indentBlock");i&&i.isEnabled&&!this.isInTable()&&(i.execute(),t())}),this.editor.keystrokes.set("Shift+Tab",(e,t)=>{const i=this.editor.commands.get("outdentBlock");i&&i.isEnabled&&!this.isInTable()&&(i.execute(),t())})}isInTable(){let e=this.editor.model.document.selection.getFirstPosition();for(;e;){if("name"in e&&e.name==="tableCell")return!0;e="parent"in e?e.parent:null}return!1}}const DO='<svg xmlns="http://www.w3.org/2000/svg" width="208" height="128" viewBox="0 0 208 128"><rect width="198" height="118" x="5" y="5" ry="10" stroke="currentColor" stroke-width="10" fill="none"/><path d="M30 98V30h20l20 25 20-25h20v68H90V59L70 84 50 59v39zm125 0l-30-33h20V30h20v35h20z"/></svg>';class zO extends w{init(){this.editor.ui.componentFactory.add("markdownImport",e=>{const t=new P(e);return t.set({label:"Markdown import from clipboard",icon:DO,tooltip:!0}),t.on("execute",()=>{glob.importMarkdownInline()}),t})}}class HO extends w{static get requires(){return[Y1]}afterInit(){const e=this.editor;e.commands.add("mention",new $O(e))}}class $O extends O{execute(e){const{model:t}=this.editor,{document:i}=t,{selection:o}=i,s=e.mention,r=e.range||o.getFirstRange();if(s.id.startsWith("#")||s.id.startsWith("~"))t.change(a=>{t.insertContent(a.createText(s.id,{}),r)});else if(s.action==="create-note"){const a=this.editor.editing.view.getDomRoot();glob.getComponentByEl(a).createNoteForReferenceLink(s.noteTitle).then(l=>{this.insertReference(r,l)})}else this.insertReference(r,s.notePath)}insertReference(e,t){const{model:i}=this.editor;i.change(o=>{i.insertContent(o.createText("",{}),e),this.editor.execute("referenceLink",{href:"#"+t})})}}const WO='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19,3H5C3.897,3,3,3.897,3,5v14c0,1.103,0.897,2,2,2h8c0.131,0,0.26-0.026,0.381-0.076s0.232-0.123,0.326-0.217l7-7 c0.086-0.086,0.147-0.187,0.196-0.293c0.014-0.03,0.022-0.061,0.033-0.093c0.028-0.084,0.046-0.17,0.051-0.259 C20.989,13.041,21,13.021,21,13V5C21,3.897,20.103,3,19,3z M5,5h14v7h-6c-0.553,0-1,0.448-1,1v6H5V5z M14,17.586V14h3.586 L14,17.586z"/></svg>';class jO extends w{static get requires(){return[qO,UO]}}class UO extends w{init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("includeNote",i=>{const o=e.commands.get("insertIncludeNote"),s=new P(i);return s.set({label:t("Include note"),icon:WO,tooltip:!0}),o&&s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",()=>e.execute("insertIncludeNote")),s})}}class qO extends w{static get requires(){return[Vt]}init(){this._defineSchema(),this._defineConverters(),this.editor.commands.add("insertIncludeNote",new GO(this.editor))}_defineSchema(){this.editor.model.schema.register("includeNote",{isObject:!0,allowAttributes:["noteId","boxSize"],allowWhere:"$block"})}_defineConverters(){const e=this.editor,t=e.conversion;t.for("upcast").elementToElement({model:(i,{writer:o})=>o.createElement("includeNote",{noteId:i.getAttribute("data-note-id"),boxSize:i.getAttribute("data-box-size")}),view:{name:"section",classes:"include-note"}}),t.for("dataDowncast").elementToElement({model:"includeNote",view:(i,{writer:o})=>o.createContainerElement("section",{class:"include-note","data-note-id":i.getAttribute("noteId"),"data-box-size":i.getAttribute("boxSize")})}),t.for("editingDowncast").elementToElement({model:"includeNote",view:(i,{writer:o})=>{const s=i.getAttribute("noteId"),r=i.getAttribute("boxSize"),a=o.createContainerElement("section",{class:"include-note box-size-"+r,"data-note-id":s,"data-box-size":r}),l=o.createUIElement("div",{class:"include-note-wrapper","data-cke-ignore-events":!0},function(c){const u=this.toDomElement(c),d=e.editing.view.getDomRoot();return glob.getComponentByEl(d).loadIncludedNote(s,$(u)),KO(u,e),u});return o.insert(o.createPositionAt(a,0),l),gt(a,o,{label:"include note widget"})}})}}class GO extends O{execute(){const e=this.editor.editing.view.getDomRoot();glob.getComponentByEl(e).triggerCommand("addIncludeNoteToText")}refresh(){const e=this.editor.model,t=e.document.selection.getFirstPosition(),i=t&&e.schema.findAllowedParent(t,"includeNote");this.isEnabled=i!==null}}function KO(n,e){n.addEventListener("mousedown",t,{capture:!0}),n.addEventListener("focus",t,{capture:!0}),n.addEventListener("keydown",t,{capture:!0});function t(i){i.stopPropagation(),e.editing.view._renderer.isFocused=!1}}class ZO extends O{refresh(){this.isEnabled=!0}execute(e){const t=this.editor,i=t.model,o=t.plugins.get(At);i.change(s=>{const r=e.file;for(const a of r)JO(s,i,o,a)})}}function JO(n,e,t,i){const o=t.createLoader(i);o&&QO(n,e,{href:"",uploadId:o.id})}function QO(n,e,t={},i){const o=n.createElement("reference",t);e.insertContent(o,e.document.selection),n.insertText(" ",o,"after")}class YO extends w{static get requires(){return[At,Nr,_s]}static get pluginName(){return"FileUploadEditing"}init(){const e=this.editor,t=e.model.document,i=e.conversion,o=e.plugins.get(At);e.commands.add("fileUpload",new ZO(e)),i.for("upcast").attributeToAttribute({view:{name:"a",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",(s,r)=>{if(nB(r.dataTransfer))return;const a=Array.from(r.dataTransfer.files);e.model.change(l=>{r.targetRanges&&l.setSelection(r.targetRanges.map(c=>e.editing.mapper.toModelRange(c))),a.length&&(s.stop(),e.model.enqueueChange(()=>{e.execute("fileUpload",{file:a})}))})}),this.listenTo(e.plugins.get(_s),"inputTransformation",(s,r)=>{const a=Array.from(e.editing.view.createRangeIn(r.content)).filter(c=>eB(c.item)&&!c.item.getAttribute("uploadProcessed")).map(c=>({promise:XO(c.item),fileElement:c}));if(!a.length)return;const l=new Ht(this.editor.editing.view.document);for(const c of a){l.setAttribute("uploadProcessed",!0,c.fileElement);const u=o.createLoader(c.promise);u&&(l.setAttribute("href","",c.fileElement),l.setAttribute("uploadId",u.id,c.fileElement))}}),e.editing.view.document.on("dragover",(s,r)=>{r.preventDefault()}),t.on("change",()=>{const s=t.differ.getChanges({includeChangesInGraveyard:!0});for(const r of s)if(r.type=="insert"){const a=r.position.nodeAfter;if(a){const l=r.position.root.rootName=="$graveyard";for(const c of oB(e,a)){const u=c.getAttribute("uploadId");if(!u)continue;const d=o.loaders.get(u);d&&(l?d.abort():d.status=="idle"&&this._readAndUpload(d,c))}}}})}_readAndUpload(e,t){const i=this.editor,o=i.model,s=i.locale.t,r=i.plugins.get(At),a=i.plugins.get(Nr);return o.enqueueChange(c=>{c.setAttribute("uploadStatus","reading",t)}),e.read().then(()=>{const c=e.upload();return o.enqueueChange(u=>{u.setAttribute("uploadStatus","uploading",t)}),c}).then(c=>(o.enqueueChange(u=>{u.setAttributes({uploadStatus:"complete",href:c.default},t)}),l(),new Promise(u=>setTimeout(u,100)))).then(()=>{i.setData(i.getData())}).catch(c=>{if(e.status!=="error"&&e.status!=="aborted")throw c;e.status=="error"&&c&&a.showWarning(c,{title:s("Upload failed"),namespace:"upload"}),l(),o.enqueueChange(u=>{u.remove(t)})});function l(){o.enqueueChange(c=>{c.removeAttribute("uploadId",t),c.removeAttribute("uploadStatus",t)}),r.destroyLoader(e)}}}function XO(n){return new Promise((e,t)=>{const i=n.getAttribute("href");fetch(i).then(o=>o.blob()).then(o=>{const s=tB(o,i)??"",r=`file.${s?.replace("file/","")}`,a=iB(o,r,s);a?e(a):t()}).catch(t)})}function eB(n){return!n.is("element","a")||!n.getAttribute("href")?!1:n.getAttribute("href")}function tB(n,e){var t;if(n.type)return n.type;if(e.match(/data:(image\/\w+);base64/))return(t=e.match(/data:(image\/\w+);base64/))==null?void 0:t[1].toLowerCase();throw new Error("Could not retrieve mime type for file.")}function iB(n,e,t){try{return new File([n],e,{type:t})}catch{return null}}function nB(n){return Array.from(n.types).includes("text/html")&&n.getData("text/html")!==""}function oB(n,e){return Array.from(n.model.createRangeOn(e)).filter(t=>t.item.hasAttribute("href")).map(t=>t.item)}class sB extends w{static get requires(){return[YO]}static get pluginName(){return"fileUploadPlugin"}}class rB extends w{constructor(){super(...arguments),h(this,"config"),h(this,"hljs")}async init(){const e=this.editor.config.get("syntaxHighlighting");!e||!e.enabled||(this.config=e,this.hljs=await e.loadHighlightJs(),this.initTextEditor(this.editor))}initTextEditor(e){Hi("initTextEditor");const t=e.model.document;e.conversion.for("editingDowncast").markerToHighlight({model:"hljs",view:({markerName:i})=>{Ye("markerName "+i);const[,o,s]=i.split(":");return{name:"span",classes:[o],attributes:{"data-syntax-result":s}}}}),t.registerPostFixer(i=>{var o,s,r;Hi("postFixer");const a=t.differ.getChanges();let l=new Set;function c(u){if("getChildren"in u)for(const d of u.getChildren())d.is("element","paragraph")||(d.is("element","codeBlock")?l.add(d):d.childCount>0&&c(d))}for(const u of a)if(Ye("change "+JSON.stringify(u)),"name"in u&&u.name!=="paragraph"&&u.name!=="codeBlock"&&(o=u?.position)!=null&&o.nodeAfter&&u.position.nodeAfter.childCount>0)c(u.position.nodeAfter);else if(u.type=="insert"&&u.name=="codeBlock"){const d=(s=u.position)==null?void 0:s.nodeAfter;d&&(Hi("dirtying inserted codeBlock "+JSON.stringify(d.toJSON())),l.add(d))}else if(u.type=="remove"&&u.name=="codeBlock"&&u.position)Hi("removing codeBlock at path "+JSON.stringify(u.position.toJSON()));else if((u.type=="remove"||u.type=="insert")&&(r=u?.position)!=null&&r.parent.is("element","codeBlock")){const d=u.position.parent;Hi("dirtying codeBlock "+JSON.stringify(d.toJSON())),l.add(d)}for(let u of l)this.highlightCodeBlock(u,i);return!1})}highlightCodeBlock(e,t){var i;Hi("highlighting codeblock "+JSON.stringify(e.toJSON()));const o=(i=e.root.document)==null?void 0:i.model;if(!o)return;const s=o.createRangeIn(e);for(const _ of o.markers.getMarkersIntersectingRange(s))Ye("removing marker "+_.name),t.removeMarker(_.name);const r=e.getAttribute("language");if(r=="text-plain"){Hi("not highlighting plaintext codeblock");return}if(e.childCount>=aB)return;let a="";for(let _=0;_<e.childCount;++_){let v=e.getChild(_);v&&(v.is("$text")?(Ye("child text "+v.data),a+=v.data):v.is("element")&&v.name=="softBreak"?(Ye("softBreak"),a+=`
`):Pc("Unkown child "+JSON.stringify(v.toJSON())))}let l;if(r===this.config.defaultMimeType?l=this.hljs.highlightAuto(a):l=this.hljs.highlight(a,{language:r}),!l)return;Ye(`text
`+a),Ye(`html
`+l.value);let c=0,u=l.value,d=[],m=-1,f="",g=null,p=0;for(;c<u.length;){if(p>=f.length)if(m++,m<e.childCount){if(Ye("Fetching child "+m),g=e.getChild(m),!g)continue;g.is("$text")?(Ye("child text "+g.data),f=g.data,p=0):g.is("element","softBreak")?(Ye("softBreak"),p=0,f=`
`):Pc("child unknown!!!")}else f="";if(u[c]=="<"&&u[c+1]!="/"){let _=u.indexOf('"',c+1),v=u.indexOf('"',_+1),E=u.slice(_+1,v),M=E.indexOf(" ");M>0&&(E=E.slice(0,M)),Ye("Found span start "+E),c=u.indexOf(">",c)+1;let G=t.createPositionAt(e,(g?.startOffset??0)+p);d.push({className:E,posStart:G})}else if(u[c]=="<"&&u[c+1]=="/"){c=u.indexOf(">",c+1)+1;let _=d.pop(),v=_?.posStart,E=_?.className,M=t.createPositionAt(e,(g?.startOffset??0)+p);if(v){let G=t.createRange(v,M),X="hljs:"+E+":"+Tl;Tl=Tl+1&16777215,Ye("Found span end "+E),Ye("Adding marker "+X+": "+JSON.stringify(G.toJSON())),t.addMarker(X,{range:G,usingOperation:!1})}}else{if(lB(m<e.childCount&&p<f.length,"Found text in html with no corresponding child text!!!!"),u[c]=="&"){let _=u.indexOf(";",c);Ye(u.slice(c,_)),c=_+1}else Ye(u[c]),c++;p++}}}}const aB=500,Aa="SyntaxHighlightWidget",xa=["error","warn","info","log","debug"],ju=xa.indexOf("warn");let Pc=function(...n){};ju>=xa.indexOf("warn")&&(Pc=console.warn.bind(console,Aa+": "));let Hi=function(...n){};ju>=xa.indexOf("log")&&(Hi=console.log.bind(console,Aa+": "));let Ye=function(...n){};ju>=xa.indexOf("debug")&&(Ye=console.debug.bind(console,Aa+": "));function lB(n,e){console.assert(n,Aa+": "+e)}let Tl=0;var cB=`<!-- Came from IceMoon's free package (https://icomoon.io/#preview-free) licensed under CC BY 4.0 -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 32">
<path d="M34 4h-32c-1.1 0-2 0.9-2 2v20c0 1.1 0.9 2 2 2h32c1.1 0 2-0.9 2-2v-20c0-1.1-0.9-2-2-2zM20 8h4v4h-4v-4zM26 14v4h-4v-4h4zM14 8h4v4h-4v-4zM20 14v4h-4v-4h4zM8 8h4v4h-4v-4zM14 14v4h-4v-4h4zM4 8h2v4h-2v-4zM4 14h4v4h-4v-4zM6 24h-2v-4h2v4zM24 24h-16v-4h16v4zM32 24h-6v-4h6v4zM32 18h-4v-4h4v4zM32 12h-6v-4h6v4z"></path>
</svg>`;const hn="kbd";class uB extends w{static get pluginName(){return"KbdEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:hn}),e.model.schema.setAttributeProperties(hn,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:hn,view:hn}),e.commands.add(hn,new tn(e,hn)),e.keystrokes.set("CTRL+ALT+K",hn)}}const El="kbd";class hB extends w{static get pluginName(){return"KbdUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(El,i=>{const o=e.commands.get(El),s=new P(i);return s.set({label:t("Keyboard shortcut"),icon:cB,keystroke:"CTRL+ALT+K",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",()=>{e.execute(El),e.editing.view.focus()}),s})}}class dB extends w{static get requires(){return[uB,hB]}static get pluginName(){return"Kbd"}}var mB=typeof global=="object"&&global&&global.Object===Object&&global,fB=typeof self=="object"&&self&&self.Object===Object&&self,P0=mB||fB||Function("return this")(),Qr=P0.Symbol,I0=Object.prototype,gB=I0.hasOwnProperty,pB=I0.toString,$o=Qr?Qr.toStringTag:void 0;function wB(n){var e=gB.call(n,$o),t=n[$o];try{n[$o]=void 0;var i=!0}catch{}var o=pB.call(n);return i&&(e?n[$o]=t:delete n[$o]),o}var bB=Object.prototype,_B=bB.toString;function vB(n){return _B.call(n)}var yB="[object Null]",kB="[object Undefined]",eg=Qr?Qr.toStringTag:void 0;function CB(n){return n==null?n===void 0?kB:yB:eg&&eg in Object(n)?wB(n):vB(n)}function AB(n){return n!=null&&typeof n=="object"}var xB="[object Symbol]";function TB(n){return typeof n=="symbol"||AB(n)&&CB(n)==xB}var EB=/\s/;function SB(n){for(var e=n.length;e--&&EB.test(n.charAt(e)););return e}var PB=/^\s+/;function IB(n){return n&&n.slice(0,SB(n)+1).replace(PB,"")}function Ic(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}var tg=NaN,VB=/^[-+]0x[0-9a-f]+$/i,RB=/^0b[01]+$/i,OB=/^0o[0-7]+$/i,BB=parseInt;function ig(n){if(typeof n=="number")return n;if(TB(n))return tg;if(Ic(n)){var e=typeof n.valueOf=="function"?n.valueOf():n;n=Ic(e)?e+"":e}if(typeof n!="string")return n===0?n:+n;n=IB(n);var t=RB.test(n);return t||OB.test(n)?BB(n.slice(2),t?2:8):VB.test(n)?tg:+n}var Sl=function(){return P0.Date.now()},MB="Expected a function",LB=Math.max,FB=Math.min;function NB(n,e,t){var i,o,s,r,a,l,c=0,u=!1,d=!1,m=!0;if(typeof n!="function")throw new TypeError(MB);e=ig(e)||0,Ic(t)&&(u=!!t.leading,d="maxWait"in t,s=d?LB(ig(t.maxWait)||0,e):s,m="trailing"in t?!!t.trailing:m);function f(T){var F=i,x=o;return i=o=void 0,c=T,r=n.apply(x,F),r}function g(T){return c=T,a=setTimeout(v,e),u?f(T):r}function p(T){var F=T-l,x=T-c,q=e-F;return d?FB(q,s-x):q}function _(T){var F=T-l,x=T-c;return l===void 0||F>=e||F<0||d&&x>=s}function v(){var T=Sl();if(_(T))return E(T);a=setTimeout(v,p(T))}function E(T){return a=void 0,m&&i?f(T):(i=o=void 0,r)}function M(){a!==void 0&&clearTimeout(a),c=0,i=l=o=a=void 0}function G(){return a===void 0?r:E(Sl())}function X(){var T=Sl(),F=_(T);if(i=arguments,o=this,l=T,F){if(a===void 0)return g(l);if(d)return clearTimeout(a),a=setTimeout(v,e),f(l)}return a===void 0&&(a=setTimeout(v,e)),r}return X.cancel=M,X.flush=G,X}/**
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/function Uu(n,e){var t;const i=n.model.document.selection,o=i.getSelectedElement()||((t=i.getLastPosition())==null?void 0:t.parent);return!!(o&&o.is("element","mermaid")&&o.getAttribute("displayMode")===e)}class DB extends O{refresh(){var e;const t=this.editor,i=t.model.document.selection,o=i.getSelectedElement();o&&o.name==="mermaid"||(e=i.getLastPosition())!=null&&e.findAncestor("mermaid")?this.isEnabled=!!o:this.isEnabled=!1,this.value=Uu(t,"preview")}execute(){var e;const t=this.editor.model,i=this.editor.model.document.selection,o=i.getSelectedElement()||((e=i.getLastPosition())==null?void 0:e.parent);o&&t.change(s=>{o.getAttribute("displayMode")!=="preview"&&s.setAttribute("displayMode","preview",o)})}}class zB extends O{refresh(){var e;const t=this.editor,i=t.model.document.selection,o=i.getSelectedElement();o&&o.name==="mermaid"||(e=i.getLastPosition())!=null&&e.findAncestor("mermaid")?this.isEnabled=!!o:this.isEnabled=!1,this.value=Uu(t,"source")}execute(){var e;const t=this.editor.model,i=this.editor.model.document.selection,o=i.getSelectedElement()||((e=i.getLastPosition())==null?void 0:e.parent);t.change(s=>{o.getAttribute("displayMode")!=="source"&&s.setAttribute("displayMode","source",o)})}}class HB extends O{refresh(){var e;const t=this.editor,i=t.model.document.selection,o=i.getSelectedElement();o&&o.name==="mermaid"||(e=i.getLastPosition())!=null&&e.findAncestor("mermaid")?this.isEnabled=!!o:this.isEnabled=!1,this.value=Uu(t,"split")}execute(){var e;const t=this.editor.model,i=this.editor.model.document.selection,o=i.getSelectedElement()||((e=i.getLastPosition())==null?void 0:e.parent);t.change(s=>{o.getAttribute("displayMode")!=="split"&&s.setAttribute("displayMode","split",o)})}}const $B=`flowchart TB
A --> B
B --> C`;class WB extends O{refresh(){const e=this.editor.model.document.selection.getSelectedElement();e&&e.name==="mermaid"?this.isEnabled=!1:this.isEnabled=!0}execute(){const e=this.editor.model;let t;return e.change(i=>{t=i.createElement("mermaid",{displayMode:"split",source:$B}),e.insertContent(t)}),t}}const jB=300;class UB extends w{constructor(){super(...arguments),h(this,"_config"),h(this,"mermaid")}static get pluginName(){return"MermaidEditing"}init(){this._registerCommands(),this._defineConverters(),this._config=this.editor.config.get("mermaid")}afterInit(){this.editor.model.schema.register("mermaid",{allowAttributes:["displayMode","source"],allowWhere:"$block",isObject:!0})}_registerCommands(){const e=this.editor;e.commands.add("mermaidPreviewCommand",new DB(e)),e.commands.add("mermaidSplitViewCommand",new HB(e)),e.commands.add("mermaidSourceViewCommand",new zB(e)),e.commands.add("insertMermaidCommand",new WB(e))}_defineConverters(){const e=this.editor;e.data.downcastDispatcher.on("insert:mermaid",this._mermaidDataDowncast.bind(this)),e.editing.downcastDispatcher.on("insert:mermaid",this._mermaidDowncast.bind(this)),e.editing.downcastDispatcher.on("attribute:source:mermaid",this._sourceAttributeDowncast.bind(this)),e.data.upcastDispatcher.on("element:code",this._mermaidUpcast.bind(this),{priority:"high"}),e.conversion.for("editingDowncast").attributeToAttribute({model:{name:"mermaid",key:"displayMode"},view:t=>({key:"class",value:"ck-mermaid__"+t+"-mode"})})}_mermaidDataDowncast(e,t,i){const o=this.editor.model,{writer:s,mapper:r}=i;if(!i.consumable.consume(t.item,"insert"))return;const a=r.toViewPosition(o.createPositionBefore(t.item)),l=s.createContainerElement("code",{class:"language-mermaid"}),c=s.createContainerElement("pre",{spellcheck:"false"}),u=s.createText(t.item.getAttribute("source"));s.insert(o.createPositionAt(l,"end"),u),s.insert(o.createPositionAt(c,"end"),l),s.insert(a,c),r.bindElements(t.item,l)}_mermaidDowncast(e,t,i){const{writer:o,mapper:s,consumable:r}=i,{editor:a}=this,{model:l,t:c}=a,u=this;if(!r.consume(t.item,"insert"))return;const d=s.toViewPosition(l.createPositionBefore(t.item)),m={class:["ck-mermaid__wrapper"]},f={class:["ck-mermaid__editing-view"],placeholder:c("Insert mermaid source code"),"data-cke-ignore-events":!0},g=o.createContainerElement("div",m),p=o.createUIElement("textarea",f,v),_=o.createUIElement("div",{class:["ck-mermaid__preview"]},E);return o.insert(o.createPositionAt(g,"start"),_),o.insert(o.createPositionAt(g,"start"),p),o.insert(d,g),s.bindElements(t.item,g),gt(g,o,{label:c("Mermaid widget"),hasSelectionHandle:!0});function v(M){const G=this.toDomElement(M);G.value=t.item.getAttribute("source");const X=NB(T=>{a.model.change(F=>{F.setAttribute("source",T.target.value,t.item)})},jB);return G.addEventListener("input",X),G.addEventListener("focus",()=>{const T=a.model;T.document.selection.getSelectedElement()!==t.item&&T.change(F=>F.setSelection(t.item,"on"))},!0),G}function E(M){const G=t.item.getAttribute("source"),X=this.toDomElement(M);return X.innerHTML=G,window.setTimeout(()=>{u._renderMermaid(X)},100),X}}_sourceAttributeDowncast(e,t,i){const o=t.attributeNewValue,s=this.editor.editing.view.domConverter;if(o){const r=i.mapper.toViewElement(t.item);if(!r)return;for(const a of r.getChildren()){const l=a;if(l.name==="textarea"&&l.hasClass("ck-mermaid__editing-view")){const c=s.viewToDom(l);c.value!=o&&(c.value=o)}else if(l.name==="div"&&l.hasClass("ck-mermaid__preview")){const c=s.viewToDom(l);c&&(c.innerHTML=o,c.removeAttribute("data-processed"),this._renderMermaid(c))}}}}_mermaidUpcast(e,t,i){const o=t.viewItem,s=!o.parent||!o.parent.is("element","pre"),r=t.modelCursor.findAncestor("code"),{consumable:a,writer:l}=i;if(!o.hasClass("language-mermaid")||s||r||!a.test(o,{name:!0}))return;const c=Array.from(o.getChildren()).filter(d=>d.is("$text")).map(d=>d.data).join(""),u=l.createElement("mermaid",{source:c,displayMode:"split"});i.safeInsert(u,t.modelCursor)&&(a.consume(o,{name:!0}),i.updateConversionResult(u,t))}async _renderMermaid(e){var t,i,o;!window.mermaid&&typeof((t=this._config)==null?void 0:t.lazyLoad)=="function"&&(this.mermaid=await this._config.lazyLoad()),(o=this.mermaid)==null||o.init(((i=this._config)==null?void 0:i.config)??{},e)}}class qB extends w{static get requires(){return[ci]}static get pluginName(){return"MermaidToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(ci),o=["mermaidSourceView","mermaidSplitView","mermaidPreview","|","mermaidInfo"];o&&i.register("mermaidToolbar",{ariaLabel:t("Mermaid toolbar"),items:o,getRelatedElement:s=>GB(s)})}}function GB(n){const e=n.getSelectedElement();return e&&e.hasClass("ck-mermaid__wrapper")?e:null}var KB=`<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m8 11.5 3.004-3.004 3.003 3.004-3.003 3.004L8 11.5Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M9.504 2.863v3h3v-3h-3Zm-1 4h5v-5h-5v5Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M11.004 14.504 8 11.5l2.504-2.504V6.07h1v2.926l2.503 2.504-3.003 3.004ZM9.414 11.5l1.59-1.59 1.59 1.59-1.59 1.59-1.59-1.59ZM6.837 4.999h2.625v-1h-2.57a2.5 2.5 0 1 0-2.974 2.814V9h-2v5h5V9h-2V6.813c.934-.19 1.68-.9 1.919-1.814Zm-3.919-.636a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Zm0 5.637v3h3v-3h-3Z"/></svg>
`,ZB=`<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M13.8 11.609V13.4a.4.4 0 0 1-.4.4H2.6a.4.4 0 0 1-.4-.4v-1.791H1V13.4A1.6 1.6 0 0 0 2.6 15h10.8a1.6 1.6 0 0 0 1.6-1.6v-1.791h-1.2ZM13.8 4.997H15V2.6A1.6 1.6 0 0 0 13.4 1H2.6A1.6 1.6 0 0 0 1 2.6v2.397h1.2V2.6c0-.22.18-.4.4-.4h10.8c.22 0 .4.18.4.4v2.397Z"/><path d="M8 11.095c-1.92 0-3.837-.919-5.749-2.757L2 8.095l.251-.242c3.815-3.677 7.683-3.677 11.498 0l.251.242-.251.243C11.84 10.176 9.925 11.095 8 11.096Zm-5.02-3c3.375 3.1 6.665 3.1 10.04 0-3.375-3.1-6.665-3.095-10.04 0Z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M13.514 8.095c-3.676 3.543-7.352 3.543-11.028 0 3.676-3.542 7.352-3.542 11.028 0Zm-3.586 0A1.926 1.926 0 0 1 8 10.02a1.926 1.926 0 0 1-1.928-1.924c0-1.062.863-1.924 1.928-1.924s1.928.862 1.928 1.924Z"/><path d="M8 8.861a.767.767 0 1 0 .002-1.533A.767.767 0 0 0 8 8.86Z"/></svg>
`,JB=`<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M13.8 3.076H8.588V13.8H13.4a.4.4 0 0 0 .4-.4V3.076Zm-6.412 0H2.2V13.4c0 .22.18.4.4.4h4.788V3.076ZM2.6 1A1.6 1.6 0 0 0 1 2.6v10.8A1.6 1.6 0 0 0 2.6 15h10.8a1.6 1.6 0 0 0 1.6-1.6V2.6A1.6 1.6 0 0 0 13.4 1H2.6Z"/></svg>
`,QB=`<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M11.609 2.2H13.4c.22 0 .4.18.4.4v10.8a.4.4 0 0 1-.4.4h-1.791V15H13.4a1.6 1.6 0 0 0 1.6-1.6V2.6A1.6 1.6 0 0 0 13.4 1h-1.791v1.2ZM4.997 2.2V1H2.6A1.6 1.6 0 0 0 1 2.6v10.8A1.6 1.6 0 0 0 2.6 15h2.397v-1.2H2.6a.4.4 0 0 1-.4-.4V2.6c0-.22.18-.4.4-.4h2.397Z"/><path d="M3.511 4.778a.75.75 0 0 1 .75-.75h3.697a.75.75 0 1 1 0 1.5H4.26a.75.75 0 0 1-.75-.75ZM6.595 7.629a.75.75 0 0 1 .75-.75h3.588a.75.75 0 0 1 0 1.5H7.345a.75.75 0 0 1-.75-.75ZM6.595 10.48a.75.75 0 0 1 .75-.75h1.143a.75.75 0 1 1 0 1.5H7.345a.75.75 0 0 1-.75-.75ZM3.511 7.629a.75.75 0 0 1 .75-.75h.983a.75.75 0 1 1 0 1.5h-.983a.75.75 0 0 1-.75-.75ZM3.511 10.48a.75.75 0 0 1 .75-.75h.983a.75.75 0 1 1 0 1.5h-.983a.75.75 0 0 1-.75-.75Z"/></svg>
`,YB=`<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M8 1.219C4.254 1.219 1.219 4.28 1.219 8A6.78 6.78 0 0 0 8 14.781c3.719 0 6.781-3.035 6.781-6.781 0-3.719-3.062-6.781-6.781-6.781Zm0 12.25A5.45 5.45 0 0 1 2.531 8 5.467 5.467 0 0 1 8 2.531c3.008 0 5.469 2.461 5.469 5.469A5.467 5.467 0 0 1 8 13.469Zm0-9.242c-.656 0-1.148.52-1.148 1.148 0 .656.492 1.148 1.148 1.148.629 0 1.148-.492 1.148-1.148 0-.629-.52-1.148-1.148-1.148Zm1.531 6.945v-.656a.353.353 0 0 0-.328-.329h-.328V7.454a.353.353 0 0 0-.328-.328h-1.75a.332.332 0 0 0-.328.328v.656c0 .192.136.329.328.329h.328v1.75h-.328a.333.333 0 0 0-.328.328v.656c0 .191.136.328.328.328h2.406a.332.332 0 0 0 .328-.328Z"/></svg>
`;class XB extends w{static get pluginName(){return"MermaidUI"}init(){this._addButtons()}_addButtons(){const e=this.editor;this._addInsertMermaidButton(),this._addMermaidInfoButton(),this._createToolbarButton(e,"mermaidPreview","Preview",ZB),this._createToolbarButton(e,"mermaidSourceView","Source view",QB),this._createToolbarButton(e,"mermaidSplitView","Split view",JB)}_addInsertMermaidButton(){const e=this.editor,t=e.t,i=e.editing.view;e.ui.componentFactory.add("mermaid",o=>{const s=new P(o),r=e.commands.get("insertMermaidCommand");if(!r)throw new Error("Missing command.");return s.set({label:t("Insert Mermaid diagram"),icon:KB,tooltip:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),r.listenTo(s,"execute",()=>{var a;const l=e.execute("insertMermaidCommand"),c=e.editing.mapper.toViewElement(l);if(i.scrollToTheSelection(),i.focus(),c){const u=i.domConverter.viewToDom(c);u&&((a=u.querySelector(".ck-mermaid__editing-view"))==null||a.focus())}}),s})}_addMermaidInfoButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("mermaidInfo",i=>{const o=new P(i),s="https://ckeditor.com/blog/basic-overview-of-creating-flowcharts-using-mermaid/";return o.set({label:t("Read more about Mermaid diagram syntax"),icon:YB,tooltip:!0}),o.on("execute",()=>{window.open(s,"_blank","noopener")}),o})}_createToolbarButton(e,t,i,o){const s=e.t;e.ui.componentFactory.add(t,r=>{const a=new P(r),l=e.commands.get(`${t}Command`);if(!l)throw new Error("Missing command.");return a.set({label:s(i),icon:o,tooltip:!0}),a.bind("isOn","isEnabled").to(l,"value","isEnabled"),l.listenTo(a,"execute",()=>{e.execute(`${t}Command`),e.editing.view.scrollToTheSelection(),e.editing.view.focus()}),a})}}class e9 extends w{static get requires(){return[UB,qB,XB]}static get pluginName(){return"Mermaid"}}var t9=`<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 511.936 511.936" style="enable-background:new 0 0 511.936 511.936;" xml:space="preserve">
<g>
<g>
<g>
<path d="M255.959,128c11.776,0,21.333-9.557,21.333-21.333s-9.557-21.333-21.333-21.333s-21.333,9.557-21.333,21.333
S244.183,128,255.959,128z"/>
<path d="M383.968,0h-256C80.907,0,42.635,38.272,42.635,85.333v213.333c0,47.061,38.272,85.333,85.333,85.333h64l0.085,92.075
c0,14.571,8.683,27.584,22.165,33.173c4.331,1.792,8.875,2.688,13.397,2.688c9.557,0,19.157-3.968,27.051-11.968L350.475,384
h33.493c47.061,0,85.333-38.272,85.333-85.333V85.333C469.301,38.272,431.029,0,383.968,0z M426.635,298.667
c0,23.531-19.157,42.667-42.667,42.667h-36.629c-9.621,0-18.645,3.755-26.752,12.011l-85.888,103.979l-0.064-80.085
c0-19.797-16.107-35.904-35.904-35.904h-70.763c-23.531,0-42.667-19.136-42.667-42.667V85.333
c0-23.531,19.136-42.667,42.667-42.667h256c23.509,0,42.667,19.136,42.667,42.667V298.667z"/>
<path d="M298.626,256h-21.333v-85.333c0-11.776-9.536-21.333-21.333-21.333h-21.333c-11.797,0-21.333,9.557-21.333,21.333
S222.829,192,234.626,192v64h-21.333c-11.797,0-21.333,9.557-21.333,21.333s9.536,21.333,21.333,21.333h85.333
c11.797,0,21.333-9.557,21.333-21.333S310.423,256,298.626,256z"/>
</g>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>
`;const qu=["note","tip","important","caution","warning"],ao="admonitionType",i9=qu[0];class n9 extends O{constructor(){super(...arguments),h(this,"_lastType")}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,o=t.document.selection,s=Array.from(o.getSelectedBlocks()),r=this._getType(e);t.change(a=>{if(!r)this._removeQuote(a,s.filter(lr));else{const l=s.filter(c=>lr(c)||og(i,c));this._applyQuote(a,l,r)}})}_getType(e){const t=e.forceValue===void 0?!this.value:e.forceValue;return t?typeof t=="string"?t:e.usePreviousChoice&&this._lastType?this._lastType:"note":!1}_getValue(){const e=this.editor.model.document.selection,t=ae(e.getSelectedBlocks());if(!t)return!1;const i=lr(t);return i!=null&&i.is("element")?i.getAttribute(ao):!1}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=ae(e.getSelectedBlocks());return i?og(t,i):!1}_removeQuote(e,t){ng(e,t).reverse().forEach(i=>{if(i.start.isAtStart&&i.end.isAtEnd){e.unwrap(i.start.parent);return}if(i.start.isAtStart){const s=e.createPositionBefore(i.start.parent);e.move(i,s);return}i.end.isAtEnd||e.split(i.end);const o=e.createPositionAfter(i.end.parent);e.move(i,o)})}_applyQuote(e,t,i){this._lastType=i;const o=[];ng(e,t).reverse().forEach(s=>{let r=lr(s.start);if(r)r.is("element")&&this.editor.model.change(a=>{a.setAttribute(ao,i,r)});else{const a={};a[ao]=i,r=e.createElement("aside",a),e.wrap(s,r)}o.push(r)}),o.reverse().reduce((s,r)=>s.nextSibling==r?(e.merge(e.createPositionAfter(s)),s):r)}}function lr(n){return n.parent.name=="aside"?n.parent:null}function ng(n,e){let t,i=0;const o=[];for(;i<e.length;){const s=e[i],r=e[i+1];t||(t=n.createPositionBefore(s)),(!r||s.nextSibling!=r)&&(o.push(n.createRange(t,n.createPositionAfter(s))),t=null),i++}return o}function og(n,e){const t=n.checkChild(e.parent,"aside"),i=n.checkChild(["$root","aside"],e);return t&&i}class o9 extends w{static get pluginName(){return"AdmonitionEditing"}static get requires(){return[Ao,en]}init(){const e=this.editor,t=e.model.schema;e.commands.add("admonition",new n9(e)),t.register("aside",{inheritAllFrom:"$container",allowAttributes:ao}),e.conversion.for("upcast").elementToElement({view:{name:"aside",classes:"admonition"},model:(r,{writer:a})=>{let l=i9;for(const u of r.getClassNames())u!=="admonition"&&qu.includes(u)&&(l=u);const c={};return c[ao]=l,a.createElement("aside",c)}}),e.conversion.for("downcast").elementToElement({model:"aside",view:"aside"}).attributeToAttribute({model:ao,view:r=>({key:"class",value:["admonition",r]})}),e.model.document.registerPostFixer(r=>{const a=e.model.document.differ.getChanges();for(const l of a)if(l.type=="insert"){const c=l.position.nodeAfter;if(!c)continue;if(c.is("element","aside")&&c.isEmpty)return r.remove(c),!0;if(c.is("element","aside")&&!t.checkChild(l.position,c))return r.unwrap(c),!0;if(c.is("element")){const u=r.createRangeIn(c);for(const d of u.getItems())if(d.is("element","aside")&&!t.checkChild(r.createPositionBefore(d),d))return r.unwrap(d),!0}}else if(l.type=="remove"){const c=l.position.parent;if(c.is("element","aside")&&c.isEmpty)return r.remove(c),!0}return!1});const i=this.editor.editing.view.document,o=e.model.document.selection,s=e.commands.get("admonition");s&&(this.listenTo(i,"enter",(r,a)=>{!o.isCollapsed||!s.value||o.getLastPosition().parent.isEmpty&&(e.execute("admonition"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"aside"}),this.listenTo(i,"delete",(r,a)=>{if(a.direction!="backward"||!o.isCollapsed||!s.value)return;const l=o.getLastPosition().parent;l.isEmpty&&!l.previousSibling&&(e.execute("admonition"),e.editing.view.scrollToTheSelection(),a.preventDefault(),r.stop())},{context:"aside"}))}}const s9={note:{title:"Note"},tip:{title:"Tip"},important:{title:"Important"},caution:{title:"Caution"},warning:{title:"Warning"}};class r9 extends w{static get pluginName(){return"AdmonitionUI"}init(){this.editor.ui.componentFactory.add("admonition",()=>this._createButton())}_createButton(){const e=this.editor,t=e.locale,i=e.commands.get("admonition"),o=Ee(t,Xi),s=o.buttonView,r=t.t;return wt(o,this._getDropdownItems()),s.set({label:r("Admonition"),icon:t9,isToggleable:!0,tooltip:!0}),s.on("execute",()=>{e.execute("admonition",{usePreviousChoice:!0}),e.editing.view.focus()}),s.bind("isOn").to(i,"value",a=>!!a),o.bind("isEnabled").to(i,"isEnabled"),o.on("execute",a=>{e.execute("admonition",{forceValue:a.source.commandParam}),e.editing.view.focus()}),o}_getDropdownItems(){const e=new _e,t=this.editor.commands.get("admonition");if(!t)return e;for(const[i,o]of Object.entries(s9)){const s={type:"button",model:new et({commandParam:i,label:o.title,class:`ck-tn-admonition-option ck-tn-admonition-${i}`,role:"menuitemradio",withText:!0})};s.model.bind("isOn").to(t,"value",r=>r===i),e.add(s)}return e}}function a9(n){if(n.length===2&&qu.includes(n[1]))return n[1]}class l9 extends w{static get requires(){return[yu]}afterInit(){if(!this.editor.commands.get("admonition"))return;const e=this;Wt(this.editor,e,/^\!\!\[*\! (.+) $/,({match:t})=>{const i=a9(t);i?this.editor.execute("admonition",{forceValue:i}):(this.editor.execute("admonition"),t.length>1&&this.editor.execute("insertText",{text:(t[1]??"")+" "}))})}}class c9 extends w{static get requires(){return[o9,r9,l9]}static get pluginName(){return"Admonition"}}var u9=`<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
<text x="2" y="15" font-family="Arial, sans-serif" font-size="14" fill="currentColor">ab</text>
<text x="17" y="10" font-family="Arial, sans-serif" font-size="8" fill="currentColor">1</text>
</svg>
`;const h9="footnote",U={footnoteItem:"footnoteItem",footnoteReference:"footnoteReference",footnoteSection:"footnoteSection",footnoteContent:"footnoteContent",footnoteBackLink:"footnoteBackLink"},Wi={footnoteContent:"footnote-content",footnoteItem:"footnote-item",footnoteReference:"footnote-reference",footnoteSection:"footnote-section",footnoteBackLink:"footnote-back-link",footnotes:"footnotes"},ji={insertFootnote:"InsertFootnote"},L={footnoteContent:"data-footnote-content",footnoteId:"data-footnote-id",footnoteIndex:"data-footnote-index",footnoteItem:"data-footnote-item",footnoteReference:"data-footnote-reference",footnoteSection:"data-footnote-section",footnoteBackLink:"data-footnote-back-link"},wn=(n,e,t=i=>!0)=>{const i=n.model.createRangeIn(e),o=[];for(const s of i.getItems())s instanceof ne&&t(s)&&o.push(s);return o},wo=(n,e,t=i=>!0)=>{const i=n.model.createRangeIn(e);for(const o of i.getItems())if(o instanceof ne&&t(o))return o;return null},d9=(n,e,t=i=>!0)=>{const i=n.editing.view.createRangeIn(e);for(const o of i.getItems())if(o instanceof ai&&t(o))return o;return null},m9=(n,e)=>{const t=n.model.document.selection.anchor,i=t&&(t.textNode||t.getShiftedBy(-1).textNode);if(!t||!i)return{remove:[],format:[]};const o=e.matchAll(/\[\^([0-9]+)\]/g);for(const s of o||[]){const r=e.indexOf(s[0]),a=r+s[0].length,l=t.parent.getChildStartOffset(i);if(l===null||t.offset!==l+a)continue;const c=r+2,u=c+s[1].length;return{remove:[[r,a]],format:[[c,u]]}}return{remove:[],format:[]}},f9=(n,e,t)=>{const i=e.commands.get(ji.insertFootnote);if(!i||!i.isEnabled)return;const o=[...n[0].getItems()][0];if(!(o instanceof Lt||o instanceof Ce))return!1;const s=o.data.match(/[0-9]+/);if(!s)return!1;const r=parseInt(s[0]),a=wo(e,t,c=>c.is("element",U.footnoteSection));if(!a){if(r!==1)return!1;e.execute(ji.insertFootnote);return}const l=wn(e,a,c=>c.is("element",U.footnoteItem)).length;if(r===l+1){e.execute(ji.insertFootnote);return}else if(r>=1&&r<=l){e.execute(ji.insertFootnote,{footnoteIndex:r});return}return!1},g9=(n,e)=>{if(n.plugins.has("Autoformat")){const t=n.plugins.get("Autoformat");mn(n,t,i=>m9(n,i),(i,o)=>f9(o,n,e))}},p9=n=>{const e=n.conversion;e.for("downcast").attributeToAttribute({model:L.footnoteId,view:L.footnoteId}),e.for("downcast").attributeToAttribute({model:L.footnoteIndex,view:L.footnoteIndex}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteSection]:!0}},model:U.footnoteSection,converterPriority:"high"}),e.for("dataDowncast").elementToElement({model:U.footnoteSection,view:{name:"ol",attributes:{[L.footnoteSection]:"",role:"doc-endnotes"},classes:[Wi.footnoteSection,Wi.footnotes]}}),e.for("editingDowncast").elementToElement({model:U.footnoteSection,view:(t,i)=>{const o=i.writer,s=o.createContainerElement("div",{[L.footnoteSection]:"",role:"doc-endnotes list",class:Wi.footnoteSection});return gt(s,o,{label:"footnote widget"})}}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteContent]:!0}},model:(t,i)=>i.writer.createElement(U.footnoteContent)}),e.for("dataDowncast").elementToElement({model:U.footnoteContent,view:{name:"div",attributes:{[L.footnoteContent]:""},classes:[Wi.footnoteContent]}}),e.for("editingDowncast").elementToElement({model:U.footnoteContent,view:(t,i)=>{const o=i.writer,s=o.createEditableElement("div",{[L.footnoteContent]:"",class:Wi.footnoteContent});return wa(s,o)}}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteItem]:!0}},model:(t,i)=>{const o=i.writer,s=t.getAttribute(L.footnoteId),r=t.getAttribute(L.footnoteIndex);return s===void 0||r===void 0?null:o.createElement(U.footnoteItem,{[L.footnoteIndex]:r,[L.footnoteId]:s})},converterPriority:"high"}),e.for("dataDowncast").elementToElement({model:U.footnoteItem,view:ag}),e.for("editingDowncast").elementToElement({model:U.footnoteItem,view:ag}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteReference]:!0}},model:(t,i)=>{const o=i.writer,s=t.getAttribute(L.footnoteIndex),r=t.getAttribute(L.footnoteId);return s===void 0||r===void 0?null:o.createElement(U.footnoteReference,{[L.footnoteIndex]:s,[L.footnoteId]:r})}}),e.for("editingDowncast").elementToElement({model:U.footnoteReference,view:(t,i)=>{const o=i.writer,s=rg(t,i);return gt(s,o)}}),e.for("dataDowncast").elementToElement({model:U.footnoteReference,view:rg}),e.for("editingDowncast").add(t=>{t.on(`attribute:${L.footnoteIndex}:${U.footnoteReference}`,(i,o,s)=>w9(o,s,n),{priority:"high"})}),e.for("upcast").elementToElement({view:{attributes:{[L.footnoteBackLink]:!0}},model:(t,i)=>{const o=i.writer,s=t.getAttribute(L.footnoteId);return s===void 0?null:o.createElement(U.footnoteBackLink,{[L.footnoteId]:s})}}),e.for("dataDowncast").elementToElement({model:U.footnoteBackLink,view:sg}),e.for("editingDowncast").elementToElement({model:U.footnoteBackLink,view:sg})};function sg(n,e){const t=e.writer,i=`${n.getAttribute(L.footnoteId)}`;if(i===void 0)throw new Error("Footnote return link has no provided Id.");const o=t.createContainerElement("span",{class:Wi.footnoteBackLink,[L.footnoteBackLink]:"",[L.footnoteId]:i}),s=t.createContainerElement("sup"),r=t.createContainerElement("strong"),a=t.createContainerElement("a",{href:`#fnref${i}`}),l=t.createText("^");return t.insert(t.createPositionAt(a,0),l),t.insert(t.createPositionAt(r,0),a),t.insert(t.createPositionAt(s,0),r),t.insert(t.createPositionAt(o,0),s),o}function rg(n,e){const t=e.writer,i=`${n.getAttribute(L.footnoteIndex)}`,o=`${n.getAttribute(L.footnoteId)}`;if(i==="undefined")throw new Error("Footnote reference has no provided index.");if(o==="undefined")throw new Error("Footnote reference has no provided id.");const s=t.createContainerElement("span",{class:Wi.footnoteReference,[L.footnoteReference]:"",[L.footnoteIndex]:i,[L.footnoteId]:o,role:"doc-noteref",id:`fnref${o}`}),r=t.createText(`[${i}]`),a=t.createContainerElement("a",{href:`#fn${o}`}),l=t.createContainerElement("sup");return t.insert(t.createPositionAt(a,0),r),t.insert(t.createPositionAt(l,0),a),t.insert(t.createPositionAt(s,0),l),s}function ag(n,e){const t=e.writer,i=n.getAttribute(L.footnoteIndex),o=n.getAttribute(L.footnoteId);if(!i)throw new Error("Footnote item has no provided index.");if(!o)throw new Error("Footnote item has no provided id.");return t.createContainerElement("li",{class:Wi.footnoteItem,[L.footnoteItem]:"",[L.footnoteIndex]:`${i}`,[L.footnoteId]:`${o}`,role:"doc-endnote",id:`fn${o}`})}function w9(n,e,t){const{item:i,attributeNewValue:o}=n;if(!(i instanceof ne)||!e.consumable.consume(i,`attribute:${L.footnoteIndex}:${U.footnoteReference}`))return;const s=e.mapper.toViewElement(i);if(!s)return;const r=e.writer,a=d9(t,s,u=>u.name==="a"),l=a?.getChild(0);if(!l||!a){r.remove(s);return}r.remove(l);const c=r.createText(`[${o}]`);r.insert(r.createPositionAt(a,0),c),r.setAttribute("href",`#fn${i.getAttribute(L.footnoteId)}`,a),r.setAttribute(L.footnoteIndex,o,s)}const b9=n=>{n.register(U.footnoteSection,{isObject:!0,allowWhere:"$block",allowIn:"$root",allowChildren:U.footnoteItem,allowAttributes:[L.footnoteSection]}),n.register(U.footnoteItem,{isBlock:!0,isObject:!0,allowContentOf:"$root",allowAttributes:[L.footnoteSection,L.footnoteId,L.footnoteIndex]}),n.register(U.footnoteContent,{allowIn:U.footnoteItem,allowContentOf:"$root",allowAttributes:[L.footnoteSection]}),n.register(U.footnoteReference,{allowWhere:"$text",isInline:!0,isObject:!0,allowAttributes:[L.footnoteReference,L.footnoteId,L.footnoteIndex]}),n.register(U.footnoteBackLink,{allowIn:U.footnoteItem,isInline:!0,isSelectable:!1,allowAttributes:[L.footnoteBackLink,L.footnoteId]}),n.addChildCheck((e,t)=>{if(e.endsWith(U.footnoteContent)&&t.name===U.footnoteSection||e.endsWith(U.footnoteContent)&&t.name==="listItem")return!1})};class _9 extends O{execute({footnoteIndex:e}={footnoteIndex:0}){this.editor.model.enqueueChange(t=>{const i=this.editor.model.document,o=i.getRoot();if(!o)return;const s=this._getFootnoteSection(t,o);let r,a;if(e===0)r=`${s.maxOffset+1}`,a=Math.random().toString(36).slice(2);else{r=`${e}`;const f=wo(this.editor,s,g=>g.is("element",U.footnoteItem)&&g.getAttribute(L.footnoteIndex)===r);f&&(a=f.getAttribute(L.footnoteId))}if(!a||!r)return;t.setSelection(i.selection.getLastPosition());const l=t.createElement(U.footnoteReference,{[L.footnoteId]:a,[L.footnoteIndex]:r});if(this.editor.model.insertContent(l),t.setSelection(l,"after"),e!==0)return;const c=t.createElement(U.footnoteContent),u=t.createElement(U.footnoteItem,{[L.footnoteId]:a,[L.footnoteIndex]:r}),d=t.createElement(U.footnoteBackLink,{[L.footnoteId]:a}),m=t.createElement("paragraph");t.append(m,c),t.append(c,u),t.insert(d,u,0),this.editor.model.insertContent(u,t.createPositionAt(s,s.maxOffset))})}refresh(){const e=this.editor.model,t=e.document.selection.getLastPosition(),i=t&&e.schema.findAllowedParent(t,U.footnoteReference);this.isEnabled=i!==null}_getFootnoteSection(e,t){const i=wo(this.editor,t,s=>s.is("element",U.footnoteSection));if(i)return i;const o=e.createElement(U.footnoteSection);return this.editor.model.insertContent(o,e.createPositionAt(t,t.maxOffset)),o}}class v9 extends w{static get pluginName(){return"FootnotesEditing"}static get requires(){return[Vt,yu]}get rootElement(){const e=this.editor.model.document.getRoot();if(!e)throw new Error("Document has no rootElement element.");return e}init(){b9(this.editor.model.schema),p9(this.editor),this.editor.commands.add(ji.insertFootnote,new _9(this.editor)),g9(this.editor,this.rootElement),this.editor.model.document.on("change:data",(e,t)=>{const i=[...e.source.differ.getChanges()];i.some(o=>o.type==="insert"&&o.name===U.footnoteReference)&&this._orderFootnotes(t),i.forEach(o=>{if(o.type==="attribute"&&o.attributeKey===L.footnoteIndex){const{attributeNewValue:s}=o,r=[...o.range.getItems()].find(l=>l.is("element",U.footnoteItem)),a=r instanceof ne&&r.getAttribute(L.footnoteId);if(!a)return;this._updateReferenceIndices(t,`${a}`,s)}})},{priority:"high"}),this._handleDelete(),this.editor.editing.mapper.on("viewToModelPosition",Cu(this.editor.model,e=>e.hasAttribute(L.footnoteReference)))}_handleDelete(){const e=this.editor.editing.view.document,t=this.editor;this.listenTo(e,"delete",(i,o)=>{const s=t.model.document,r=s.selection.getSelectedElement(),a=s.selection.getLastPosition(),l=s.selection.getFirstPosition();if(!a||!l)throw new Error("Selection must have at least one range to perform delete operation.");this.editor.model.change(c=>{r&&r.is("element",U.footnoteSection)&&this._removeReferences(c);const u=r&&r.is("element",U.footnoteItem),d=u?r:a.findAncestor(U.footnoteItem);if(!d)return;const m=a.findAncestor("paragraph"),f=l.findAncestor("paragraph"),g=a.findAncestor(U.footnoteContent);if(!g||!f||!m)return;const p=f.maxOffset===0&&g.childCount===1;(u||p)&&(this._removeFootnote(c,d),o.preventDefault(),i.stop())})},{priority:"high"})}_clearContents(e,t){const i=e.createRangeIn(t);e.appendElement("paragraph",t),e.remove(i)}_removeFootnote(e,t){if(!this.editor)return;const i=t.findAncestor(U.footnoteSection);if(!i){e.remove(t);return}const o=i.getChildIndex(t),s=t.getAttribute(L.footnoteId);if(this._removeReferences(e,`${s}`),e.remove(t),i.childCount===0)e.remove(i),this._removeReferences(e);else{if(o==null)throw new Error("Index is nullish");const a=o===0?i.getChild(o):i.getChild((o??0)-1);if(!(a instanceof ne))return;const l=wn(this.editor,a,c=>c.is("element","paragraph")).pop();l&&e.setSelection(l,"end")}if(o==null)throw new Error("Index is nullish");const r=[...i.getChildren()].slice(o??0);for(const[a,l]of r.entries())e.setAttribute(L.footnoteIndex,`${o??0+a+1}`,l)}_removeReferences(e,t=void 0){const i=[];if(!this.rootElement)throw new Error("Document has no root element.");wn(this.editor,this.rootElement,o=>o.is("element",U.footnoteReference)).forEach(o=>{const s=o.getAttribute(L.footnoteId);(!t||s===t)&&i.push(o)});for(const o of i)e.remove(o)}_updateReferenceIndices(e,t,i){const o=wn(this.editor,this.rootElement,s=>s.is("element",U.footnoteReference)&&s.getAttribute(L.footnoteId)===t);this.editor.model.enqueueChange(e,s=>{o.forEach(r=>{s.setAttribute(L.footnoteIndex,i,r)})})}_orderFootnotes(e){const t=wn(this.editor,this.rootElement,o=>o.is("element",U.footnoteReference)),i=[...new Set(t.map(o=>o.getAttribute(L.footnoteId)))].map(o=>wo(this.editor,this.rootElement,s=>s.is("element",U.footnoteItem)&&s.getAttribute(L.footnoteId)===o));this.editor.model.enqueueChange(e,o=>{const s=wo(this.editor,this.rootElement,r=>r.is("element",U.footnoteSection));if(s){for(const r of i.reverse())r&&o.move(o.createRangeOn(r),s,0);for(const r of wn(this.editor,s,a=>a.is("element",U.footnoteItem))){const a=`${(s?.getChildIndex(r)??-1)+1}`;r&&o.setAttribute(L.footnoteIndex,a,r);const l=r.getAttribute(L.footnoteId);l&&this._updateReferenceIndices(e,`${l}`,`${a}`)}}})}}class y9 extends w{static get pluginName(){return"FootnoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(h9,i=>{const o=Ee(i,Xi),s=o.buttonView,r=e.commands.get(ji.insertFootnote);if(!r)throw new Error("Command not found.");return s.set({label:t("Footnote"),icon:u9,tooltip:!0,isToggleable:!0}),s.bind("isOn").to(r,"value",a=>!!a),s.on("execute",()=>{e.execute(ji.insertFootnote,{footnoteIndex:0}),e.editing.view.focus()}),o.class="ck-code-block-dropdown",o.bind("isEnabled").to(r),o.on("change:isOpen",(a,l,c)=>{var u,d,m;if((u=o?.listView)==null||u.items.clear(),c)wt(o,this.getDropdownItemsDefinitions());else{(d=o?.listView)==null||d.items.clear();const f=(m=o?.listView)==null?void 0:m.element;f&&f.parentNode&&f.parentNode.removeChild(f)}}),this.listenTo(o,"execute",a=>{e.execute(ji.insertFootnote,{footnoteIndex:a.source.commandParam}),e.editing.view.focus()}),o})}getDropdownItemsDefinitions(){const e=new _e,t={type:"button",model:new et({commandParam:0,label:"New footnote",withText:!0})};e.add(t);const i=this.editor.model.document.getRoot();if(!i)throw new Error("Document has no root element.");return wo(this.editor,i,o=>o.is("element",U.footnoteSection))&&wn(this.editor,i,o=>o.is("element",U.footnoteItem)).forEach(o=>{const s=o.getAttribute(L.footnoteIndex),r={type:"button",model:new et({commandParam:s,label:`Insert footnote ${s}`,withText:!0})};e.add(r)}),e}}class k9 extends w{static get pluginName(){return"Footnotes"}static get requires(){return[v9,y9]}}var C9=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15.44 10.78" height="40.74" width="58.35"><path d="M8.15 0c-.06 0-.1.02-.11.03a.12.12 0 0 0-.02.01 6.81 6.81 0 0 0-2.32 4.9v.9a6.82 6.82 0 0 0 2.32 4.9.12.12 0 0 0 .02 0c.02.02.06.04.11.04.07 0 .12-.03.16-.07a.22.22 0 0 0 0-.32.12.12 0 0 0-.02-.02A4.4 4.4 0 0 1 7 8.44a7.62 7.62 0 0 1-.5-2.6v-.9c0-.82.19-1.76.5-2.6A4.4 4.4 0 0 1 8.3.42.12.12 0 0 0 8.3.39a.22.22 0 0 0 .08-.16.22.22 0 0 0-.07-.16.22.22 0 0 0-.16-.07zm4.83 0a.22.22 0 0 0-.16.07.22.22 0 0 0-.07.16c0 .08.05.13.08.16a.12.12 0 0 0 .01.02c.52.39.98 1.1 1.3 1.94.3.83.49 1.77.49 2.6v.88c0 .83-.18 1.78-.5 2.6a4.4 4.4 0 0 1-1.29 1.95.22.22 0 0 0-.01.33c.03.04.08.07.15.07.05 0 .09-.02.12-.03a.12.12 0 0 0 .02-.01 6.82 6.82 0 0 0 2.32-4.9v-.9a6.81 6.81 0 0 0-2.32-4.9.12.12 0 0 0-.02 0c-.03-.02-.06-.04-.12-.04zm-8.5.46c-.4 0-1.13.23-1.46 1.32-.06.2-.11.45-.33 1.58h-.64c-.1 0-.19-.01-.28.03a.25.25 0 0 0-.12.12.38.38 0 0 0-.03.17c0 .04 0 .1.04.14.03.04.07.07.11.08.09.03.16.02.26.02h.56l-.77 4.04c-.1.51-.19 1-.32 1.36-.06.18-.14.32-.22.4-.08.1-.16.13-.26.13-.03 0-.1 0-.2-.03.11-.05.2-.13.26-.2a.7.7 0 0 0 .13-.4.48.48 0 0 0-.16-.38.53.53 0 0 0-.35-.12c-.34 0-.7.3-.7.76 0 .27.14.5.34.64s.44.2.68.2c.33 0 .61-.17.83-.4.21-.21.37-.48.47-.69.18-.35.32-.84.43-1.25a14.17 14.17 0 0 0 .18-.8l.61-3.26h.81c.1 0 .2.01.3-.03.04-.03.09-.07.11-.13.02-.05.03-.1.03-.17 0-.05-.01-.1-.05-.14a.23.23 0 0 0-.11-.07c-.08-.03-.16-.02-.25-.02h-.73l.2-1.07a26.3 26.3 0 0 1 .24-1.07c.08-.17.22-.3.39-.3l.21.05a.7.7 0 0 0-.25.2.7.7 0 0 0-.13.4c0 .15.06.28.16.37.1.08.22.12.35.12.34 0 .7-.3.7-.76 0-.28-.15-.5-.35-.64-.2-.14-.45-.2-.7-.2zm5.4 2.78c-.6 0-1.06.37-1.36.76-.16.2-.27.4-.35.57-.07.18-.12.3-.12.42 0 .1.08.18.14.2.06.03.1.02.1.02.06 0 .12 0 .18-.04.05-.05.07-.1.08-.17v.02c.35-1.09 1-1.3 1.3-1.3.09 0 .2.01.29.09.09.07.17.2.17.5 0 .27-.18 1-.57 2.48a1.8 1.8 0 0 1-.37.75.7.7 0 0 1-.52.26c-.04 0-.13 0-.22-.03a.68.68 0 0 0 .3-.56.47.47 0 0 0-.18-.39.55.55 0 0 0-.32-.1c-.4 0-.7.33-.7.74 0 .28.16.5.38.63.21.13.48.18.73.18.39 0 .69-.2.89-.41.09-.1.15-.19.2-.27.2.36.59.68 1.16.68.6 0 1.05-.37 1.35-.76.15-.2.27-.4.34-.57.08-.18.12-.3.12-.42a.24.24 0 0 0-.11-.2c-.06-.03-.12-.02-.13-.02a.26.26 0 0 0-.18.06c-.05.05-.06.1-.07.14-.34 1.1-1.02 1.3-1.3 1.3-.17 0-.27-.06-.35-.17a.72.72 0 0 1-.11-.4c0-.22.06-.45.18-.91l.36-1.45c.03-.14.1-.44.25-.7.15-.25.36-.46.68-.46.03 0 .12 0 .22.03a.7.7 0 0 0-.32.56c0 .11.04.23.13.33.08.1.22.16.4.16.14 0 .3-.06.44-.18a.73.73 0 0 0 .24-.55c0-.32-.2-.54-.42-.66a1.52 1.52 0 0 0-.68-.16c-.34 0-.62.16-.82.34a1.8 1.8 0 0 0-.3.35 1.32 1.32 0 0 0-.5-.54 1.37 1.37 0 0 0-.63-.15z" style="line-height:1.25;-inkscape-font-specification:'Latin Modern Math'" font-weight="400" font-size="10.58" font-family="Latin Modern Math" letter-spacing="-1.06" word-spacing="0"/></svg>
`;function A9(n){const e=n.getSelectedElement();return e&&(e.is("element","mathtex-inline")||e.is("element","mathtex-display"))?e:null}function V0(n){return n!=null&&typeof n=="object"&&"version"in n&&typeof n.version=="string"&&n.version.split(".").length===3&&n.version.split(".")[0]==="3"}function R0(n){return n!=null&&typeof n=="object"&&"Hub"in n}function O0(n){return n.match(/^(\\\[.*?\\\]|\\\(.*?\\\))$/)}function x9(n){var e;return(e=n.match(/(\\\[|\\\]|\\\(|\\\))/g))==null?void 0:e.length}function Gu(n){n=n.trim();const e=n.includes("\\(")&&n.includes("\\)"),t=n.includes("\\[")&&n.includes("\\]");return(e||t)&&(n=n.substring(2,n.length-2).trim()),{equation:n,display:t}}async function Ku(n,e,t="katex",i,o=!1,s=!1,r="",a=[],l={}){if(t=="mathjax")V0(MathJax)?Pl(e,s,r,a,c=>{E9(n,c,o,()=>{s&&(c.style.visibility="visible")})}):Pl(e,s,r,a,c=>{window.setTimeout(()=>{S9(n,c,o),s&&R0(MathJax)&&MathJax.Hub.Queue(()=>{c.style.visibility="visible"})})});else if(t==="katex"&&window.katex!==void 0)Pl(e,s,r,a,c=>{katex&&katex.render(n,c,{throwOnError:!1,displayMode:o,...l}),s&&(c.style.visibility="visible")});else if(typeof t=="function")t(n,e,o);else if(i!=null)try{window.CKEDITOR_MATH_LAZY_LOAD??(window.CKEDITOR_MATH_LAZY_LOAD=i()),e.innerHTML=n,await window.CKEDITOR_MATH_LAZY_LOAD,await Ku(n,e,t,void 0,o,s,r,a,l)}catch(c){e.innerHTML=n,console.error(`math-tex-typesetting-lazy-load-failed: Lazy load failed: ${String(c)}`)}else e.innerHTML=n,console.warn(`math-tex-typesetting-missing: Missing the mathematical typesetting engine (${String(t)}) for tex.`)}function T9(n){const e=n.editing.view,t=Ne.defaultPositions,i=e.document.selection.getSelectedElement();if(i)return{target:e.domConverter.viewToDom(i),positions:[t.southArrowNorth,t.southArrowNorthWest,t.southArrowNorthEast]};{const o=e.document.selection.getFirstRange();if(!o)throw new b("math-missing-range");return{target:e.domConverter.viewRangeToDom(o),positions:[t.southArrowNorth,t.southArrowNorthWest,t.southArrowNorthEast]}}}function Pl(n,e,t,i,o){e?P9(n,t,i,s=>{o(s)}):o(n)}function E9(n,e,t,i){let o;V0(MathJax)&&(MathJax.tex2chtmlPromise?o=MathJax.tex2chtmlPromise:MathJax.tex2svgPromise&&(o=MathJax.tex2svgPromise),o?.(n,{display:t}).then(s=>{e.firstChild&&e.removeChild(e.firstChild),e.appendChild(s),i()}))}function S9(n,e,t){R0(MathJax)&&(t?e.innerHTML="\\["+n+"\\]":e.innerHTML="\\("+n+"\\)",MathJax.Hub.Queue(["Typeset",MathJax.Hub,e]))}function P9(n,e,t,i){const o=I9(n,e,t);i(o)}function I9(n,e,t){let i=document.getElementById(e);return i||(i=document.createElement("div"),i.setAttribute("id",e),i.classList.add(...t),i.style.visibility="hidden",n.appendChild(i)),i}class Yr extends O{constructor(){super(...arguments),h(this,"value",null),h(this,"display",!1)}execute(e,t,i="script",o){const s=this.editor.model,r=s.document.selection.getSelectedElement();s.change(a=>{let l;if(r&&(r.is("element","mathtex-inline")||r.is("element","mathtex-display"))){const c=r.getAttribute("type"),u=o?i:c||i;l=a.createElement(t?"mathtex-display":"mathtex-inline",{equation:e,type:u,display:t})}else l=a.createElement(t?"mathtex-display":"mathtex-inline",{equation:e,type:i,display:t});s.insertContent(l)})}refresh(){const e=this.editor.model.document.selection,t=e.getSelectedElement();this.isEnabled=t===null||t.is("element","mathtex-inline")||t.is("element","mathtex-display");const i=A9(e),o=i?.getAttribute("equation");this.value=typeof o=="string"?o:null;const s=i?.getAttribute("display");this.display=typeof s=="boolean"?s:!1}}class B0 extends w{static get requires(){return[Vt]}static get pluginName(){return"MathEditing"}constructor(e){super(e),e.config.define("math",{engine:"mathjax",outputType:"script",className:"math-tex",forceOutputType:!1,enablePreview:!0,previewClassName:[],popupClassName:[],katexRenderOptions:{}})}init(){const e=this.editor,t=e.data.processor,i=t.toView.bind(t),o=/<span class="math-tex">([\s\S]*?)<\/span>/g;t.toView=s=>{const r=s.replace(o,(a,l)=>`<span class="math-tex">${l.replace(/\n/g,"___MATH_TEX_LF___")}</span>`);return i(r)},e.commands.add("math",new Yr(e)),this._defineSchema(),this._defineConverters(),e.editing.mapper.on("viewToModelPosition",Cu(e.model,s=>s.hasClass("math")))}_defineSchema(){const e=this.editor.model.schema;e.register("mathtex-inline",{allowWhere:"$text",isInline:!0,isObject:!0,allowAttributes:["equation","type","display"]}),e.register("mathtex-display",{inheritAllFrom:"$blockObject",allowAttributes:["equation","type","display"]})}_defineConverters(){const e=this.editor.conversion,t=this.editor.config.get("math");e.for("upcast").elementToElement({view:{name:"script",attributes:{type:"math/tex"}},model:(s,{writer:r})=>{const a=s.getChild(0);if(a!=null&&a.is("$text")){const l=a.data.trim();return r.createElement("mathtex-inline",{equation:l,type:t.forceOutputType?t.outputType:"script",display:!1})}return null}}).elementToElement({view:{name:"script",attributes:{type:"math/tex; mode=display"}},model:(s,{writer:r})=>{const a=s.getChild(0);if(a!=null&&a.is("$text")){const l=a.data.trim();return r.createElement("mathtex-display",{equation:l,type:t.forceOutputType?t.outputType:"script",display:!0})}return null}}).elementToElement({view:{name:"span",classes:[t.className]},model:(s,{writer:r})=>{const a=s.getChild(0);if(a!=null&&a.is("$text")){const l=a.data.trim().replace(/___MATH_TEX_LF___/g,`
`),c=Object.assign(Gu(l),{type:t.forceOutputType?t.outputType:"span"});return r.createElement(c.display?"mathtex-display":"mathtex-inline",c)}return null}}).elementToElement({view:{name:"span",classes:["ql-formula"]},model:(s,{writer:r})=>{const a=s.getAttribute("data-value");if(a==null)throw new b("missing-equation",{pluginName:"math"});return r.createElement("mathtex-inline",{equation:a.trim(),type:t.forceOutputType?t.outputType:"script",display:!1})}}),e.for("editingDowncast").elementToElement({model:"mathtex-inline",view:(s,{writer:r})=>{const a=i(s,r);return gt(a,r)}}).elementToElement({model:"mathtex-display",view:(s,{writer:r})=>{const a=i(s,r);return gt(a,r)}}),e.for("dataDowncast").elementToElement({model:"mathtex-inline",view:o}).elementToElement({model:"mathtex-display",view:o});function i(s,r){const a=String(s.getAttribute("equation")),l=!!s.getAttribute("display"),c="user-select: none; "+(l?"":"display: inline-block;"),u="ck-math-tex "+(l?"ck-math-tex-display":"ck-math-tex-inline"),d=r.createContainerElement(l?"div":"span",{style:c,class:u}),m=r.createUIElement("div",null,function(f){const g=this.toDomElement(f);return Ku(a,g,t.engine,t.lazyLoad,l,!1,`math-editing-${ze()}`,t.previewClassName,t.katexRenderOptions),g});return r.insert(r.createPositionAt(d,0),m),d}function o(s,{writer:r}){const a=s.getAttribute("equation");if(typeof a!="string")throw new b("missing-equation",{pluginName:"math"});const l=s.getAttribute("type"),c=s.getAttribute("display");if(l==="span"){const u=r.createContainerElement("span",{class:t.className});return c?r.insert(r.createPositionAt(u,0),r.createText("\\["+a+"\\]")):r.insert(r.createPositionAt(u,0),r.createText("\\("+a+"\\)")),u}else{const u=r.createContainerElement("script",{type:c?"math/tex; mode=display":"math/tex"});return r.insert(r.createPositionAt(u,0),r.createText(a)),u}}}}class V9 extends A{constructor(e,t,i,o,s,r){super(i),h(this,"previewUid"),h(this,"previewClassName"),h(this,"katexRenderOptions"),h(this,"engine"),h(this,"lazyLoad"),this.engine=e,this.lazyLoad=t,this.previewUid=o,this.katexRenderOptions=r,this.previewClassName=s,this.set("value",""),this.set("display",!1),this.on("change",()=>{this.isRendered&&this.updateMath()}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-math-preview","ck-reset_all-excluded"]}})}updateMath(){this.element&&Ku(this.value,this.element,this.engine,this.lazyLoad,this.display,!0,this.previewUid,this.previewClassName,this.katexRenderOptions)}render(){super.render(),this.updateMath()}}class R9 extends Te{constructor(e){super(e,Ix),h(this,"value",null),h(this,"isReadOnly",!1)}}class O9 extends A{constructor(e,t,i,o=!1,s,r,a,l){super(e),h(this,"saveButtonView"),h(this,"mathInputView"),h(this,"displayButtonView"),h(this,"cancelButtonView"),h(this,"previewEnabled"),h(this,"previewLabel"),h(this,"mathView"),h(this,"locale",new lp),h(this,"lazyLoad"),h(this,"focusTracker",new ee),h(this,"keystrokes",new te),h(this,"_focusables",new Ie),h(this,"_focusCycler",new Ae({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}));const c=e.t;this.saveButtonView=this._createButton(c("Save"),Es,"ck-button-save",null),this.saveButtonView.type="submit",this.mathInputView=this._createMathInput(),this.displayButtonView=this._createDisplayButton(),this.cancelButtonView=this._createButton(c("Cancel"),_o,"ck-button-cancel","cancel"),this.previewEnabled=o;let u=[];this.previewEnabled?(this.previewLabel=new xt(e),this.previewLabel.text=c("Equation preview"),this.mathView=new V9(t,i,e,s,r,l),this.mathView.bind("display").to(this.displayButtonView,"isOn"),u=[this.mathInputView,this.displayButtonView,this.previewLabel,this.mathView]):u=[this.mathInputView,this.displayButtonView],this.setTemplate({tag:"form",attributes:{class:["ck","ck-math-form",...a],tabindex:"-1",spellcheck:"false"},children:[{tag:"div",attributes:{class:["ck-math-view"]},children:u},this.saveButtonView,this.cancelButtonView]})}render(){super.render(),Ri({view:this}),[this.mathInputView,this.displayButtonView,this.saveButtonView,this.cancelButtonView].forEach(e=>{e.element&&(this._focusables.add(e),this.focusTracker.add(e.element))}),this.element&&this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}get equation(){var e;return((e=this.mathInputView.fieldView.element)==null?void 0:e.value)??""}set equation(e){this.mathInputView.fieldView.element&&(this.mathInputView.fieldView.element.value=e),this.previewEnabled&&this.mathView&&(this.mathView.value=e)}_createMathInput(){const e=this.locale.t,t=new R9(this.locale),i=t.fieldView;t.infoText=e("Insert equation in TeX format.");const o=()=>{if(i.element!=null){let s=i.element.value.trim();if(O0(s)){const r=Gu(s);i.element.value=r.equation,s=r.equation,this.displayButtonView.isOn=r.display}this.previewEnabled&&this.mathView&&(this.mathView.value=s),this.saveButtonView.isEnabled=!!s}};return i.on("render",o),i.on("input",o),t}_createButton(e,t,i,o){const s=new P(this.locale);return s.set({label:e,icon:t,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),o&&s.delegate("execute").to(this,o),s}_createDisplayButton(){const e=this.locale.t,t=new Ji(this.locale);return t.set({label:e("Display mode"),withText:!0}),t.extendTemplate({attributes:{class:"ck-button-display-toggle"}}),t.on("execute",()=>{t.isOn=!t.isOn,this.previewEnabled&&this.mathView&&(this.mathView.display=t.isOn)}),t}}const lg="Ctrl+M";class M0 extends w{constructor(){super(...arguments),h(this,"_previewUid",`math-preview-${ze()}`),h(this,"_balloon",this.editor.plugins.get(Ue)),h(this,"formView",null)}static get requires(){return[Ue,B0]}static get pluginName(){return"MathUI"}init(){this.editor.editing.view.addObserver(ew),this._createToolbarMathButton(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}destroy(){var e,t;super.destroy(),(e=this.formView)==null||e.destroy();const i=document.getElementById(this._previewUid);i&&((t=i.parentNode)==null||t.removeChild(i))}_showUI(){const e=this.editor.commands.get("math");e!=null&&e.isEnabled&&(this._addFormView(),this._balloon.showStack("main"),requestAnimationFrame(()=>{var t,i;(i=(t=this.formView)==null?void 0:t.mathInputView.fieldView.element)==null||i.focus()}))}_createFormView(){const e=this.editor,t=e.commands.get("math");if(!(t instanceof Yr))throw new b("math-command");const i=e.config.get("math"),o=new O9(e.locale,i.engine,i.lazyLoad,i.enablePreview,this._previewUid,i.previewClassName,i.popupClassName,i.katexRenderOptions);return o.mathInputView.bind("value").to(t,"value"),o.displayButtonView.bind("isOn").to(t,"display"),o.mathInputView.bind("isReadOnly").to(t,"isEnabled",s=>!s),o.saveButtonView.bind("isEnabled").to(t),o.displayButtonView.bind("isEnabled").to(t),this.listenTo(o,"submit",()=>{e.execute("math",o.equation,o.displayButtonView.isOn,i.outputType,i.forceOutputType),this._closeFormView()}),this.listenTo(o,"cancel",()=>{this._closeFormView()}),o.keystrokes.set("esc",(s,r)=>{this._closeFormView(),r()}),o.keystrokes.set("enter",(s,r)=>{s.shiftKey||(o.fire("submit"),r())}),o.mathInputView.fieldView.once("render",()=>{const s=o.mathInputView.fieldView.element;s&&Object.assign(s.style,{resize:"both",height:"100px",width:"400px",minWidth:"100%"})}),o}_addFormView(){var e,t;if(this._isFormInPanel)return;const i=this.editor,o=i.commands.get("math");if(!(o instanceof Yr))throw new b("plugin-load",{pluginName:"math"});this.formView!=null&&(this._balloon.add({view:this.formView,position:T9(i)}),this._balloon.visibleView===this.formView&&((e=this.formView.mathInputView.fieldView.element)==null||e.select()),document.getElementById(this._previewUid)&&this.formView.previewEnabled&&((t=this.formView.mathView)==null||t.updateMath()),this.formView.equation=o.value??"",this.formView.displayButtonView.isOn=o.display||!1)}_hideUI(){if(!this._isFormInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView()}_closeFormView(){const e=this.editor.commands.get("math");e?.value!=null?this._removeFormView():this._hideUI()}_removeFormView(){if(this._isFormInPanel&&this.formView){this.formView.saveButtonView.focus(),this._balloon.remove(this.formView);const e=document.getElementById(this._previewUid);e&&(e.style.visibility="hidden"),this.editor.editing.view.focus()}}_createToolbarMathButton(){const e=this.editor,t=e.commands.get("math");if(!t)throw new b("plugin-load",{pluginName:"math"});const i=e.t;e.keystrokes.set(lg,(o,s)=>{s(),t.isEnabled&&this._showUI()}),this.editor.ui.componentFactory.add("math",o=>{const s=new P(o);return s.isEnabled=!0,s.label=i("Insert math"),s.icon=C9,s.keystroke=lg,s.tooltip=!0,s.isToggleable=!0,s.bind("isEnabled").to(t,"isEnabled"),this.listenTo(s,"execute",()=>{this._showUI()}),s})}_enableUserBalloonInteractions(){const e=this.editor,t=this.editor.editing.view.document;if(this.listenTo(t,"click",()=>{const i=e.commands.get("math");i!=null&&i.isEnabled&&i.value&&this._showUI()}),e.keystrokes.set("Esc",(i,o)=>{this._isUIVisible&&(this._hideUI(),o())}),this.formView)$t({emitter:this.formView,activator:()=>!!this._isFormInPanel,contextElements:this._balloon.view.element?[this._balloon.view.element]:[],callback:()=>{this._hideUI()}});else throw new Error("missing form view")}get _isUIVisible(){return this._balloon.visibleView==this.formView}get _isFormInPanel(){return this.formView&&this._balloon.hasView(this.formView)}}class B9 extends w{constructor(e){super(e),h(this,"_timeoutId"),h(this,"_positionToInsert"),this._timeoutId=null,this._positionToInsert=null}static get requires(){return[_s,Ub]}static get pluginName(){return"AutoMath"}init(){var e;const t=this.editor,i=t.model.document;this.listenTo(t.plugins.get(_s),"inputTransformation",()=>{const o=i.selection.getFirstRange();if(!o)return;const s=Me.fromPosition(o.start);s.stickiness="toPrevious";const r=Me.fromPosition(o.end);r.stickiness="toNext",i.once("change:data",()=>{this._mathBetweenPositions(s,r),s.detach(),r.detach()},{priority:"high"})}),(e=t.commands.get("undo"))==null||e.on("execute",()=>{var o;this._timeoutId&&(window.clearTimeout(this._timeoutId),(o=this._positionToInsert)==null||o.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_mathBetweenPositions(e,t){const i=this.editor,o=this.editor.config.get("math"),s=new ht(e,t),r=s.getWalker({ignoreElementEnd:!0});let a="";for(const c of r)c.item.is("$textProxy")&&(a+=c.item.data);if(a=a.trim(),!O0(a)||x9(a)!==2)return;const l=i.commands.get("math");l!=null&&l.isEnabled&&(this._positionToInsert=Me.fromPosition(e),this._timeoutId=window.setTimeout(()=>{i.model.change(c=>{var u,d;this._timeoutId=null,c.remove(s);let m;((u=this._positionToInsert)==null?void 0:u.root.rootName)!=="$graveyard"&&(m=this._positionToInsert),i.model.change(f=>{const g=Object.assign(Gu(a),{type:o?.outputType}),p=f.createElement(g.display?"mathtex-display":"mathtex-inline",g);i.model.insertContent(p,m),f.setSelection(p,"on")}),(d=this._positionToInsert)==null||d.detach(),this._positionToInsert=null})},100))}}let L0=class extends w{static get requires(){return[B0,M0,B9,Vt]}static get pluginName(){return"Math"}};class M9 extends w{static get requires(){return[L0,"Autoformat"]}init(){const e=this.editor;e.plugins.has("Math")||J("autoformat-math-feature-missing",e)}afterInit(){const e=this.editor,t=e.commands.get("math");if(t instanceof Yr){const i=()=>{if(!t.isEnabled)return!1;t.display=!0,window.setTimeout(()=>{const o=e.plugins.get("MathUI");o instanceof M0&&o._showUI()},50)};Wt(e,this,/^\$\$$/,i),Wt(e,this,/^\\\[$/,i)}}static get pluginName(){return"AutoformatMath"}}class F0 extends w{static get requires(){return[Tu]}init(){const e=this.editor,t=e.ui.componentFactory,i=this._getNormalizedAndLocalizedLanguageDefinitions(e),o=this._getLanguageListItemDefinitions(i),s=e.commands.get("codeBlock");t.add("codeBlockDropdown",r=>{const a=Ee(this.editor.locale,fu);return a.buttonView.set({withText:!0}),a.bind("isEnabled").to(s,"value",l=>!!l),a.buttonView.bind("label").to(s,"value",l=>{const c=i.find(u=>u.language===l);return c?.label}),a.on("execute",l=>{e.execute("codeBlock",{language:l.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()}),wt(a,o),a})}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new _e;for(const o of e){const s={type:"button",model:new et({_codeBlockLanguage:o.language,label:o.label,role:"menuitemradio",withText:!0})};s.model.bind("isOn").to(t,"value",r=>r===s.model._codeBlockLanguage),i.add(s)}return i}_getNormalizedAndLocalizedLanguageDefinitions(e){const t=e.config.get("codeBlock.languages");for(const i of t)i.class===void 0&&(i.class=`language-${i.language}`);return t}}const L9='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" style="fill: rgba(0, 0, 0, 1);transform: ;msFilter:;"><path d="M20 2H10c-1.103 0-2 .897-2 2v4H4c-1.103 0-2 .897-2 2v10c0 1.103.897 2 2 2h10c1.103 0 2-.897 2-2v-4h4c1.103 0 2-.897 2-2V4c0-1.103-.897-2-2-2zM4 20V10h10l.002 10H4zm16-6h-4v-4c0-1.103-.897-2-2-2h-4V4h10v10z"></path></svg>';class F9 extends w{init(){const e=this.editor;e.commands.add("copyToClipboard",new N9(this.editor)),e.ui.componentFactory.add("copyToClipboard",t=>{const i=new P(t);return i.set({tooltip:"Copy to clipboard",icon:L9}),this.listenTo(i,"execute",()=>{e.execute("copyToClipboard")}),i})}}class N9 extends O{constructor(){super(...arguments),h(this,"executeCallback")}execute(...e){var t,i;const o=this.editor.model.document.selection;this.executeCallback||(this.executeCallback=(t=this.editor.config.get("clipboard"))==null?void 0:t.copy);const s=(i=o.getFirstPosition())==null?void 0:i.findAncestor("codeBlock");if(!s){console.warn("Unable to find code block element to copy from.");return}const r=Array.from(s.getChildren()).map(a=>"data"in a?a.data:`
`).join("");r?this.executeCallback?this.executeCallback(r):navigator.clipboard.writeText(r).then(()=>{console.log("Code block copied to clipboard")}).catch(a=>{console.error("Failed to copy code block",a)}):console.warn("No code block selected or found.")}}class D9 extends w{static get requires(){return[ci,Tu,F0,F9]}afterInit(){const e=this.editor;e.plugins.get(ci).register("codeblock",{items:["codeBlockDropdown","|","copyToClipboard"],balloonClassName:"ck-toolbar-container codeblock-language-list",getRelatedElement(t){const i=t.getFirstPosition();if(!i)return null;let o=i.parent;for(;o;){if(o.is("element","pre"))return o;o=o.parent}return null}}),e.plugins.has("BalloonToolbar")&&e.listenTo(e.plugins.get("BalloonToolbar"),"show",t=>{const i=e.model.document.selection.getFirstPosition();i?.findAncestor("codeBlock")&&t.stop()},{priority:"high"})}}class z9 extends w{init(){const e=this.editor;e.commands.add("moveBlockUp",new H9(e)),e.commands.add("moveBlockDown",new $9(e)),this.bindMoveBlockShortcuts(e)}bindMoveBlockShortcuts(e){e.editing.view.once("render",()=>{const t=e.editing.view.getDomRoot();if(!t)return;const i=o=>{const s={ArrowUp:"moveBlockUp",ArrowDown:"moveBlockDown"}[o.key],r=o.ctrlKey||o.metaKey,a=(r||o.altKey)&&!(r&&o.altKey);s&&a&&(o.preventDefault(),o.stopImmediatePropagation(),e.execute(s))};t.addEventListener("keydown",i,{capture:!0})})}}class N0 extends O{execute(){var e,t;const i=this.editor.model,o=i.document.selection,s=this.getSelectedBlocks(o);if(!(s.length>0&&s.every(d=>!!this.getSibling(d))))return;const r=this.offset==="before"?s:[...s].reverse(),a=s[0],l=s[s.length-1],c=((e=i.document.selection.getFirstPosition())==null?void 0:e.offset)??0,u=((t=i.document.selection.getLastPosition())==null?void 0:t.offset)??0;i.change(d=>{for(const p of r){const _=this.getSibling(p);if(_){const v=i.createRangeOn(p);d.move(v,_,this.offset)}}let m;const f=a.maxOffset??c,g=l.maxOffset??u;if(c<=f&&u<=g){const p=Math.min(c,f),_=Math.min(u,g);m=d.createRange(d.createPositionAt(a,p),d.createPositionAt(l,_))}else m=d.createRange(d.createPositionBefore(a),d.createPositionAfter(l));d.setSelection(m),this.editor.editing.view.focus(),this.scrollToSelection()})}getSelectedBlocks(e){const t=[...e.getSelectedBlocks()],i=[];if(!t.length){const o=e.getSelectedElement();if(o)return[o]}for(const o of t){let s=o;for(;s.parent&&s.parent.name!=="$root";)s=s.parent;i.push(s)}return i.filter((o,s)=>s===0||o!==i[s-1])}scrollToSelection(){requestAnimationFrame(()=>{this.editor.editing.view.scrollToTheSelection()})}}class H9 extends N0{getSibling(e){return e.previousSibling}get offset(){return"before"}}class $9 extends N0{getSibling(e){return e.nextSibling}get offset(){return"after"}}class W9 extends w{init(){var e,t;const i=this.editor,o=()=>{requestAnimationFrame(()=>{i.editing.view.scrollToTheSelection()})};(e=i.commands.get("undo"))==null||e.on("execute",o),(t=i.commands.get("redo"))==null||t.on("execute",o)}}const j9=[EO,TO,PO,IO,BO,LO,FO,NO,zO,jO,sB,rB,F0,D9,z9,W9],U9=[dB,e9,c9,k9,L0,M9],D0=[_s,Ao,Wb,Tb,pa,Ub,Su,Y1,HO,S0],z0=[...D0,aC,yu,iE,cE,yE,dE,rE,bE,gE,IE,AP,F4,H4,EI,SI,sI,pI,f1,yV,V1,qV,n7,f7,O6,II,E8,S8,pO,K8,Ai,AO,X8,BT,OI,MI,vP,TP,GT,wP,e1,t1,Tu,Wb,OP,e0,$6,K6,jS,$7,w4,zI,hR,C3,yS,...j9,...U9],q9=[...z0,yT];class G9 extends Nb{static get builtinPlugins(){return D0}}class K9 extends X3{static get builtinPlugins(){return z0}}class Z9 extends Nb{static get builtinPlugins(){return q9}}export{G9 as AttributeEditor,K9 as ClassicEditor,lw as EditorWatchdog,Z9 as PopupEditor};