!function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=60)}([function(t,e,i){"use strict";i.d(e,"b",(function(){return s})),i.d(e,"a",(function(){return o}));
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const n="https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html";class s extends Error{constructor(t,e,i){t=o(t),i&&(t+=" "+JSON.stringify(i)),super(t),this.name="CKEditorError",this.context=e,this.data=i}is(t){return"CKEditorError"===t}}function o(t){const e=t.match(/^([^:]+):/);return e?t+` Read more: ${n}#error-${e[1]}\n`:t}},,function(t,e,i){"use strict";var n=i(6),s="object"==typeof self&&self&&self.Object===Object&&self,o=n.a||s||Function("return this")();e.a=o},function(t,e,i){"use strict";(function(t){var n=i(6),s="object"==typeof exports&&exports&&!exports.nodeType&&exports,o=s&&"object"==typeof t&&t&&!t.nodeType&&t,r=o&&o.exports===s&&n.a.process,a=function(){try{var t=o&&o.require&&o.require("util").types;return t||r&&r.binding&&r.binding("util")}catch(t){}}();e.a=a}).call(this,i(7)(t))},function(t,e,i){"use strict";(function(t){var n=i(2),s=i(11),o="object"==typeof exports&&exports&&!exports.nodeType&&exports,r=o&&"object"==typeof t&&t&&!t.nodeType&&t,a=r&&r.exports===o?n.a.Buffer:void 0,l=(a?a.isBuffer:void 0)||s.a;e.a=l}).call(this,i(7)(t))},function(t,e,i){"use strict";(function(t){var e=i(13),n=i(0);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const s="object"==typeof window?window:t;if(s.CKEDITOR_VERSION)throw new n.b("ckeditor-duplicated-modules: Some CKEditor 5 modules are duplicated.",null);s.CKEDITOR_VERSION=e.a}).call(this,i(8))},function(t,e,i){"use strict";(function(t){var i="object"==typeof t&&t&&t.Object===Object&&t;e.a=i}).call(this,i(8))},function(t,e){t.exports=function(t){if(!t.webpackPolyfill){var e=Object.create(t);e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),Object.defineProperty(e,"exports",{enumerable:!0}),e.webpackPolyfill=1}return e}},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){},function(t,e,i){},function(t,e,i){"use strict";e.a=function(){return!1}},function(t,e,i){"use strict";(function(t){var n=i(2),s="object"==typeof exports&&exports&&!exports.nodeType&&exports,o=s&&"object"==typeof t&&t&&!t.nodeType&&t,r=o&&o.exports===s?n.a.Buffer:void 0,a=r?r.allocUnsafe:void 0;e.a=function(t,e){if(e)return t.slice();var i=t.length,n=a?a(i):new t.constructor(i);return t.copy(n),n}}).call(this,i(7)(t))},function(t){t.exports=JSON.parse('{"a":"12.4.0"}')},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){},function(t,e,i){"use strict";i.r(e);var n=i(2),s=n.a.Symbol,o=Object.prototype,r=o.hasOwnProperty,a=o.toString,l=s?s.toStringTag:void 0;var c=function(t){var e=r.call(t,l),i=t[l];try{t[l]=void 0;var n=!0}catch(t){}var s=a.call(t);return n&&(e?t[l]=i:delete t[l]),s},h=Object.prototype.toString;var d=function(t){return h.call(t)},u="[object Null]",f="[object Undefined]",m=s?s.toStringTag:void 0;var g=function(t){return null==t?void 0===t?f:u:m&&m in Object(t)?c(t):d(t)};var p=function(t,e){return function(i){return t(e(i))}},w=p(Object.getPrototypeOf,Object);var b=function(t){return null!=t&&"object"==typeof t},_="[object Object]",v=Function.prototype,y=Object.prototype,k=v.toString,A=y.hasOwnProperty,C=k.call(Object);var x=function(t){if(!b(t)||g(t)!=_)return!1;var e=w(t);if(null===e)return!0;var i=A.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&k.call(i)==C};var P=function(){this.__data__=[],this.size=0};var T=function(t,e){return t===e||t!=t&&e!=e};var E=function(t,e){for(var i=t.length;i--;)if(T(t[i][0],e))return i;return-1},S=Array.prototype.splice;var R=function(t){var e=this.__data__,i=E(e,t);return!(i<0)&&(i==e.length-1?e.pop():S.call(e,i,1),--this.size,!0)};var O=function(t){var e=this.__data__,i=E(e,t);return i<0?void 0:e[i][1]};var I=function(t){return E(this.__data__,t)>-1};var M=function(t,e){var i=this.__data__,n=E(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this};function V(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}V.prototype.clear=P,V.prototype.delete=R,V.prototype.get=O,V.prototype.has=I,V.prototype.set=M;var N=V;var B=function(){this.__data__=new N,this.size=0};var F=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var D=function(t){return this.__data__.get(t)};var L=function(t){return this.__data__.has(t)};var z=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},H="[object AsyncFunction]",j="[object Function]",q="[object GeneratorFunction]",W="[object Proxy]";var U,$=function(t){if(!z(t))return!1;var e=g(t);return e==j||e==q||e==H||e==W},G=n.a["__core-js_shared__"],K=(U=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+U:"";var J=function(t){return!!K&&K in t},Y=Function.prototype.toString;var Q=function(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""},X=/^\[object .+?Constructor\]$/,Z=Function.prototype,tt=Object.prototype,et=Z.toString,it=tt.hasOwnProperty,nt=RegExp("^"+et.call(it).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var st=function(t){return!(!z(t)||J(t))&&($(t)?nt:X).test(Q(t))};var ot=function(t,e){return null==t?void 0:t[e]};var rt=function(t,e){var i=ot(t,e);return st(i)?i:void 0},at=rt(n.a,"Map"),lt=rt(Object,"create");var ct=function(){this.__data__=lt?lt(null):{},this.size=0};var ht=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},dt="__lodash_hash_undefined__",ut=Object.prototype.hasOwnProperty;var ft=function(t){var e=this.__data__;if(lt){var i=e[t];return i===dt?void 0:i}return ut.call(e,t)?e[t]:void 0},mt=Object.prototype.hasOwnProperty;var gt=function(t){var e=this.__data__;return lt?void 0!==e[t]:mt.call(e,t)},pt="__lodash_hash_undefined__";var wt=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=lt&&void 0===e?pt:e,this};function bt(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}bt.prototype.clear=ct,bt.prototype.delete=ht,bt.prototype.get=ft,bt.prototype.has=gt,bt.prototype.set=wt;var _t=bt;var vt=function(){this.size=0,this.__data__={hash:new _t,map:new(at||N),string:new _t}};var yt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var kt=function(t,e){var i=t.__data__;return yt(e)?i["string"==typeof e?"string":"hash"]:i.map};var At=function(t){var e=kt(this,t).delete(t);return this.size-=e?1:0,e};var Ct=function(t){return kt(this,t).get(t)};var xt=function(t){return kt(this,t).has(t)};var Pt=function(t,e){var i=kt(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function Tt(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Tt.prototype.clear=vt,Tt.prototype.delete=At,Tt.prototype.get=Ct,Tt.prototype.has=xt,Tt.prototype.set=Pt;var Et=Tt,St=200;var Rt=function(t,e){var i=this.__data__;if(i instanceof N){var n=i.__data__;if(!at||n.length<St-1)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new Et(n)}return i.set(t,e),this.size=i.size,this};function Ot(t){var e=this.__data__=new N(t);this.size=e.size}Ot.prototype.clear=B,Ot.prototype.delete=F,Ot.prototype.get=D,Ot.prototype.has=L,Ot.prototype.set=Rt;var It=Ot;var Mt=function(t,e){for(var i=-1,n=null==t?0:t.length;++i<n&&!1!==e(t[i],i,t););return t},Vt=function(){try{var t=rt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var Nt=function(t,e,i){"__proto__"==e&&Vt?Vt(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i},Bt=Object.prototype.hasOwnProperty;var Ft=function(t,e,i){var n=t[e];Bt.call(t,e)&&T(n,i)&&(void 0!==i||e in t)||Nt(t,e,i)};var Dt=function(t,e,i,n){var s=!i;i||(i={});for(var o=-1,r=e.length;++o<r;){var a=e[o],l=n?n(i[a],t[a],a,i,t):void 0;void 0===l&&(l=t[a]),s?Nt(i,a,l):Ft(i,a,l)}return i};var Lt=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},zt="[object Arguments]";var Ht=function(t){return b(t)&&g(t)==zt},jt=Object.prototype,qt=jt.hasOwnProperty,Wt=jt.propertyIsEnumerable,Ut=Ht(function(){return arguments}())?Ht:function(t){return b(t)&&qt.call(t,"callee")&&!Wt.call(t,"callee")},$t=Array.isArray,Gt=i(4),Kt=9007199254740991,Jt=/^(?:0|[1-9]\d*)$/;var Yt=function(t,e){var i=typeof t;return!!(e=null==e?Kt:e)&&("number"==i||"symbol"!=i&&Jt.test(t))&&t>-1&&t%1==0&&t<e},Qt=9007199254740991;var Xt=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=Qt},Zt={};Zt["[object Float32Array]"]=Zt["[object Float64Array]"]=Zt["[object Int8Array]"]=Zt["[object Int16Array]"]=Zt["[object Int32Array]"]=Zt["[object Uint8Array]"]=Zt["[object Uint8ClampedArray]"]=Zt["[object Uint16Array]"]=Zt["[object Uint32Array]"]=!0,Zt["[object Arguments]"]=Zt["[object Array]"]=Zt["[object ArrayBuffer]"]=Zt["[object Boolean]"]=Zt["[object DataView]"]=Zt["[object Date]"]=Zt["[object Error]"]=Zt["[object Function]"]=Zt["[object Map]"]=Zt["[object Number]"]=Zt["[object Object]"]=Zt["[object RegExp]"]=Zt["[object Set]"]=Zt["[object String]"]=Zt["[object WeakMap]"]=!1;var te=function(t){return b(t)&&Xt(t.length)&&!!Zt[g(t)]};var ee=function(t){return function(e){return t(e)}},ie=i(3),ne=ie.a&&ie.a.isTypedArray,se=ne?ee(ne):te,oe=Object.prototype.hasOwnProperty;var re=function(t,e){var i=$t(t),n=!i&&Ut(t),s=!i&&!n&&Object(Gt.a)(t),o=!i&&!n&&!s&&se(t),r=i||n||s||o,a=r?Lt(t.length,String):[],l=a.length;for(var c in t)!e&&!oe.call(t,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Yt(c,l))||a.push(c);return a},ae=Object.prototype;var le=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ae)},ce=p(Object.keys,Object),he=Object.prototype.hasOwnProperty;var de=function(t){if(!le(t))return ce(t);var e=[];for(var i in Object(t))he.call(t,i)&&"constructor"!=i&&e.push(i);return e};var ue=function(t){return null!=t&&Xt(t.length)&&!$(t)};var fe=function(t){return ue(t)?re(t):de(t)};var me=function(t,e){return t&&Dt(e,fe(e),t)};var ge=function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e},pe=Object.prototype.hasOwnProperty;var we=function(t){if(!z(t))return ge(t);var e=le(t),i=[];for(var n in t)("constructor"!=n||!e&&pe.call(t,n))&&i.push(n);return i};var be=function(t){return ue(t)?re(t,!0):we(t)};var _e=function(t,e){return t&&Dt(e,be(e),t)},ve=i(12);var ye=function(t,e){var i=-1,n=t.length;for(e||(e=Array(n));++i<n;)e[i]=t[i];return e};var ke=function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,o=[];++i<n;){var r=t[i];e(r,i,t)&&(o[s++]=r)}return o};var Ae=function(){return[]},Ce=Object.prototype.propertyIsEnumerable,xe=Object.getOwnPropertySymbols,Pe=xe?function(t){return null==t?[]:(t=Object(t),ke(xe(t),(function(e){return Ce.call(t,e)})))}:Ae;var Te=function(t,e){return Dt(t,Pe(t),e)};var Ee=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},Se=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Ee(e,Pe(t)),t=w(t);return e}:Ae;var Re=function(t,e){return Dt(t,Se(t),e)};var Oe=function(t,e,i){var n=e(t);return $t(t)?n:Ee(n,i(t))};var Ie=function(t){return Oe(t,fe,Pe)};var Me=function(t){return Oe(t,be,Se)},Ve=rt(n.a,"DataView"),Ne=rt(n.a,"Promise"),Be=rt(n.a,"Set"),Fe=rt(n.a,"WeakMap"),De=Q(Ve),Le=Q(at),ze=Q(Ne),He=Q(Be),je=Q(Fe),qe=g;(Ve&&"[object DataView]"!=qe(new Ve(new ArrayBuffer(1)))||at&&"[object Map]"!=qe(new at)||Ne&&"[object Promise]"!=qe(Ne.resolve())||Be&&"[object Set]"!=qe(new Be)||Fe&&"[object WeakMap]"!=qe(new Fe))&&(qe=function(t){var e=g(t),i="[object Object]"==e?t.constructor:void 0,n=i?Q(i):"";if(n)switch(n){case De:return"[object DataView]";case Le:return"[object Map]";case ze:return"[object Promise]";case He:return"[object Set]";case je:return"[object WeakMap]"}return e});var We=qe,Ue=Object.prototype.hasOwnProperty;var $e=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&Ue.call(t,"index")&&(i.index=t.index,i.input=t.input),i},Ge=n.a.Uint8Array;var Ke=function(t){var e=new t.constructor(t.byteLength);return new Ge(e).set(new Ge(t)),e};var Je=function(t,e){var i=e?Ke(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)},Ye=/\w*$/;var Qe=function(t){var e=new t.constructor(t.source,Ye.exec(t));return e.lastIndex=t.lastIndex,e},Xe=s?s.prototype:void 0,Ze=Xe?Xe.valueOf:void 0;var ti=function(t){return Ze?Object(Ze.call(t)):{}};var ei=function(t,e){var i=e?Ke(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)},ii="[object Boolean]",ni="[object Date]",si="[object Map]",oi="[object Number]",ri="[object RegExp]",ai="[object Set]",li="[object String]",ci="[object Symbol]",hi="[object ArrayBuffer]",di="[object DataView]",ui="[object Float32Array]",fi="[object Float64Array]",mi="[object Int8Array]",gi="[object Int16Array]",pi="[object Int32Array]",wi="[object Uint8Array]",bi="[object Uint8ClampedArray]",_i="[object Uint16Array]",vi="[object Uint32Array]";var yi=function(t,e,i){var n=t.constructor;switch(e){case hi:return Ke(t);case ii:case ni:return new n(+t);case di:return Je(t,i);case ui:case fi:case mi:case gi:case pi:case wi:case bi:case _i:case vi:return ei(t,i);case si:return new n;case oi:case li:return new n(t);case ri:return Qe(t);case ai:return new n;case ci:return ti(t)}},ki=Object.create,Ai=function(){function t(){}return function(e){if(!z(e))return{};if(ki)return ki(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();var Ci=function(t){return"function"!=typeof t.constructor||le(t)?{}:Ai(w(t))},xi="[object Map]";var Pi=function(t){return b(t)&&We(t)==xi},Ti=ie.a&&ie.a.isMap,Ei=Ti?ee(Ti):Pi,Si="[object Set]";var Ri=function(t){return b(t)&&We(t)==Si},Oi=ie.a&&ie.a.isSet,Ii=Oi?ee(Oi):Ri,Mi=1,Vi=2,Ni=4,Bi="[object Arguments]",Fi="[object Function]",Di="[object GeneratorFunction]",Li="[object Object]",zi={};zi[Bi]=zi["[object Array]"]=zi["[object ArrayBuffer]"]=zi["[object DataView]"]=zi["[object Boolean]"]=zi["[object Date]"]=zi["[object Float32Array]"]=zi["[object Float64Array]"]=zi["[object Int8Array]"]=zi["[object Int16Array]"]=zi["[object Int32Array]"]=zi["[object Map]"]=zi["[object Number]"]=zi[Li]=zi["[object RegExp]"]=zi["[object Set]"]=zi["[object String]"]=zi["[object Symbol]"]=zi["[object Uint8Array]"]=zi["[object Uint8ClampedArray]"]=zi["[object Uint16Array]"]=zi["[object Uint32Array]"]=!0,zi["[object Error]"]=zi[Fi]=zi["[object WeakMap]"]=!1;var Hi=function t(e,i,n,s,o,r){var a,l=i&Mi,c=i&Vi,h=i&Ni;if(n&&(a=o?n(e,s,o,r):n(e)),void 0!==a)return a;if(!z(e))return e;var d=$t(e);if(d){if(a=$e(e),!l)return ye(e,a)}else{var u=We(e),f=u==Fi||u==Di;if(Object(Gt.a)(e))return Object(ve.a)(e,l);if(u==Li||u==Bi||f&&!o){if(a=c||f?{}:Ci(e),!l)return c?Re(e,_e(a,e)):Te(e,me(a,e))}else{if(!zi[u])return o?e:{};a=yi(e,u,l)}}r||(r=new It);var m=r.get(e);if(m)return m;r.set(e,a),Ii(e)?e.forEach((function(s){a.add(t(s,i,n,s,e,r))})):Ei(e)&&e.forEach((function(s,o){a.set(o,t(s,i,n,o,e,r))}));var g=h?c?Me:Ie:c?keysIn:fe,p=d?void 0:g(e);return Mt(p||e,(function(s,o){p&&(s=e[o=s]),Ft(a,o,t(s,i,n,o,e,r))})),a},ji=1,qi=4;var Wi=function(t,e){return Hi(t,ji|qi,e="function"==typeof e?e:void 0)};var Ui=function(t){return b(t)&&1===t.nodeType&&!x(t)};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $i{constructor(t,e){this._config={},e&&this.define(e),t&&this._setObjectToTarget(this._config,t)}set(t,e){this._setToTarget(this._config,t,e)}define(t,e){this._setToTarget(this._config,t,e,!0)}get(t){return this._getFromSource(this._config,t)}_setToTarget(t,e,i,n=!1){if(x(e))return void this._setObjectToTarget(t,e,n);const s=e.split(".");e=s.pop();for(const e of s)x(t[e])||(t[e]={}),t=t[e];if(x(i))return x(t[e])||(t[e]={}),t=t[e],void this._setObjectToTarget(t,i,n);n&&void 0!==t[e]||(t[e]=i)}_getFromSource(t,e){const i=e.split(".");e=i.pop();for(const e of i){if(!x(t[e])){t=null;break}t=t[e]}return t?function(t){return Wi(t,Gi)}(t[e]):void 0}_setObjectToTarget(t,e,i){Object.keys(e).forEach(n=>{this._setToTarget(t,n,e[n],i)})}}function Gi(t){return Ui(t)?t:void 0}var Ki=i(0);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */var Ji=function(){return function t(){t.called=!0}};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Yi{constructor(t,e){this.source=t,this.name=e,this.path=[],this.stop=Ji(),this.off=Ji()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Qi(){let t="e";for(let e=0;e<8;e++)t+=Math.floor(65536*(1+Math.random())).toString(16).substring(1);return t}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */var Xi={get(t){return"number"!=typeof t?this[t]||this.normal:t},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};i(5);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Zi=Symbol("listeningTo"),tn=Symbol("emitterId");var en={on(t,e,i={}){this.listenTo(this,t,e,i)},once(t,e,i){let n=!1;this.listenTo(this,t,(function(t,...i){n||(n=!0,t.off(),e.call(this,t,...i))}),i)},off(t,e){this.stopListening(this,t,e)},listenTo(t,e,i,n={}){let s,o;this[Zi]||(this[Zi]={});const r=this[Zi];sn(t)||nn(t);const a=sn(t);(s=r[a])||(s=r[a]={emitter:t,callbacks:{}}),(o=s.callbacks[e])||(o=s.callbacks[e]=[]),o.push(i),function(t,e){const i=on(t);if(i[e])return;let n=e,s=null;const o=[];for(;""!==n&&!i[n];)i[n]={callbacks:[],childEvents:[]},o.push(i[n]),s&&i[n].childEvents.push(s),s=n,n=n.substr(0,n.lastIndexOf(":"));if(""!==n){for(const t of o)t.callbacks=i[n].callbacks.slice();i[n].childEvents.push(s)}}(t,e);const l=rn(t,e),c=Xi.get(n.priority),h={callback:i,priority:c};for(const t of l){let e=!1;for(let i=0;i<t.length;i++)if(t[i].priority<c){t.splice(i,0,h),e=!0;break}e||t.push(h)}},stopListening(t,e,i){const n=this[Zi];let s=t&&sn(t);const o=n&&s&&n[s],r=o&&e&&o.callbacks[e];if(!(!n||t&&!o||e&&!r))if(i)ln(t,e,i);else if(r){for(;i=r.pop();)ln(t,e,i);delete o.callbacks[e]}else if(o){for(e in o.callbacks)this.stopListening(t,e);delete n[s]}else{for(s in n)this.stopListening(n[s].emitter);delete this[Zi]}},fire(t,...e){const i=t instanceof Yi?t:new Yi(this,t),n=i.name;let s=function t(e,i){let n;if(!e._events||!(n=e._events[i])||!n.callbacks.length)return i.indexOf(":")>-1?t(e,i.substr(0,i.lastIndexOf(":"))):null;return n.callbacks}(this,n);if(i.path.push(this),s){const t=[i,...e];s=Array.from(s);for(let e=0;e<s.length&&(s[e].callback.apply(this,t),i.off.called&&(delete i.off.called,ln(this,n,s[e].callback)),!i.stop.called);e++);}if(this._delegations){const t=this._delegations.get(n),s=this._delegations.get("*");t&&an(t,i,e),s&&an(s,i,e)}return i.return},delegate(...t){return{to:(e,i)=>{this._delegations||(this._delegations=new Map),t.forEach(t=>{const n=this._delegations.get(t);n?n.set(e,i):this._delegations.set(t,new Map([[e,i]]))})}}},stopDelegating(t,e){if(this._delegations)if(t)if(e){const i=this._delegations.get(t);i&&i.delete(e)}else this._delegations.delete(t);else this._delegations.clear()}};function nn(t,e){t[tn]||(t[tn]=e||Qi())}function sn(t){return t[tn]}function on(t){return t._events||Object.defineProperty(t,"_events",{value:{}}),t._events}function rn(t,e){const i=on(t)[e];if(!i)return[];let n=[i.callbacks];for(let e=0;e<i.childEvents.length;e++){const s=rn(t,i.childEvents[e]);n=n.concat(s)}return n}function an(t,e,i){for(let[n,s]of t){s?"function"==typeof s&&(s=s(e.name)):s=e.name;const t=new Yi(e.source,s);t.path=[...e.path],n.fire(t,...i)}}function ln(t,e,i){const n=rn(t,e);for(const t of n)for(let e=0;e<t.length;e++)t[e].callback==i&&(t.splice(e,1),e--)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function cn(t,...e){e.forEach(e=>{Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e)).forEach(i=>{if(i in t.prototype)return;const n=Object.getOwnPropertyDescriptor(e,i);n.enumerable=!1,Object.defineProperty(t.prototype,i,n)})})}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function hn(t,e){const i=Math.min(t.length,e.length);for(let n=0;n<i;n++)if(t[n]!=e[n])return n;return t.length==e.length?"same":t.length<e.length?"prefix":"extension"}var dn=4;var un=function(t){return Hi(t,dn)};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fn{constructor(){this.parent=null}get index(){let t;if(!this.parent)return null;if(-1==(t=this.parent.getChildIndex(this)))throw new Ki.b("view-node-not-found-in-parent: The node's parent does not contain this node.",this);return t}get nextSibling(){const t=this.index;return null!==t&&this.parent.getChild(t+1)||null}get previousSibling(){const t=this.index;return null!==t&&this.parent.getChild(t-1)||null}get root(){let t=this;for(;t.parent;)t=t.parent;return t}get document(){return this.parent instanceof fn?this.parent.document:null}getPath(){const t=[];let e=this;for(;e.parent;)t.unshift(e.index),e=e.parent;return t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let i=t.includeSelf?this:this.parent;for(;i;)e[t.parentFirst?"push":"unshift"](i),i=i.parent;return e}getCommonAncestor(t,e={}){const i=this.getAncestors(e),n=t.getAncestors(e);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(t){if(this==t)return!1;if(this.root!==t.root)return!1;const e=this.getPath(),i=t.getPath(),n=hn(e,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return e[n]<i[n]}}isAfter(t){return this!=t&&(this.root===t.root&&!this.isBefore(t))}_remove(){this.parent._removeChildren(this.index)}_fireChange(t,e){this.fire("change:"+t,e),this.parent&&this.parent._fireChange(t,e)}toJSON(){const t=un(this);return delete t.parent,t}is(t){return"node"==t||"view:node"==t}}cn(fn,en);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class mn extends fn{constructor(t){super(),this._textData=t}is(t){return"text"==t||"view:text"==t||super.is(t)}get data(){return this._textData}get _data(){return this.data}set _data(t){this._fireChange("text",this),this._textData=t}isSimilar(t){return t instanceof mn&&(this===t||this.data===t.data)}_clone(){return new mn(this.data)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class gn{constructor(t,e,i){if(this.textNode=t,e<0||e>t.data.length)throw new Ki.b("view-textproxy-wrong-offsetintext: Given offsetInText value is incorrect.",this);if(i<0||e+i>t.data.length)throw new Ki.b("view-textproxy-wrong-length: Given length value is incorrect.",this);this.data=t.data.substring(e,e+i),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}is(t){return"textProxy"==t||"view:textProxy"==t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let i=t.includeSelf?this.textNode:this.parent;for(;null!==i;)e[t.parentFirst?"push":"unshift"](i),i=i.parent;return e}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function pn(t){const e=new Map;for(const i in t)e.set(i,t[i]);return e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function wn(t){return!(!t||!t[Symbol.iterator])}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bn{constructor(...t){this._patterns=[],this.add(...t)}add(...t){for(let e of t)("string"==typeof e||e instanceof RegExp)&&(e={name:e}),e.classes&&("string"==typeof e.classes||e.classes instanceof RegExp)&&(e.classes=[e.classes]),this._patterns.push(e)}match(...t){for(const e of t)for(const t of this._patterns){const i=_n(e,t);if(i)return{element:e,pattern:t,match:i}}return null}matchAll(...t){const e=[];for(const i of t)for(const t of this._patterns){const n=_n(i,t);n&&e.push({element:i,pattern:t,match:n})}return e.length>0?e:null}getElementName(){if(1!==this._patterns.length)return null;const t=this._patterns[0],e=t.name;return"function"==typeof t||!e||e instanceof RegExp?null:e}}function _n(t,e){if("function"==typeof e)return e(t);const i={};return e.name&&(i.name=function(t,e){if(t instanceof RegExp)return t.test(e);return t===e}(e.name,t.name),!i.name)?null:e.attributes&&(i.attributes=function(t,e){const i=[];for(const n in t){const s=t[n];if(!e.hasAttribute(n))return null;{const t=e.getAttribute(n);if(!0===s)i.push(n);else if(s instanceof RegExp){if(!s.test(t))return null;i.push(n)}else{if(t!==s)return null;i.push(n)}}}return i}(e.attributes,t),!i.attributes)?null:!(e.classes&&(i.classes=function(t,e){const i=[];for(const n of t)if(n instanceof RegExp){const t=e.getClassNames();for(const e of t)n.test(e)&&i.push(e);if(0===i.length)return null}else{if(!e.hasClass(n))return null;i.push(n)}return i}(e.classes,t),!i.classes))&&(!(e.styles&&(i.styles=function(t,e){const i=[];for(const n in t){const s=t[n];if(!e.hasStyle(n))return null;{const t=e.getStyle(n);if(s instanceof RegExp){if(!s.test(t))return null;i.push(n)}else{if(t!==s)return null;i.push(n)}}}return i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e.styles,t),!i.styles))&&i)}class vn extends fn{constructor(t,e,i){if(super(),this.name=t,this._attrs=function(t){t=x(t)?pn(t):new Map(t);for(const[e,i]of t)null===i?t.delete(e):"string"!=typeof i&&t.set(e,String(i));return t}(e),this._children=[],i&&this._insertChild(0,i),this._classes=new Set,this._attrs.has("class")){const t=this._attrs.get("class");kn(this._classes,t),this._attrs.delete("class")}this._styles=new Map,this._attrs.has("style")&&(yn(this._styles,this._attrs.get("style")),this._attrs.delete("style")),this._customProperties=new Map}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}is(t,e=null){const i=t.replace(/^view:/,"");return e?"element"==i&&e==this.name:"element"==i||i==this.name||super.is(t)}getChild(t){return this._children[t]}getChildIndex(t){return this._children.indexOf(t)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes.size>0&&(yield"class"),this._styles.size>0&&(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.size>0&&(yield["style",this.getAttribute("style")])}getAttribute(t){if("class"==t)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"!=t)return this._attrs.get(t);if(this._styles.size>0){let t="";for(const[e,i]of this._styles)t+=`${e}:${i};`;return t}}hasAttribute(t){return"class"==t?this._classes.size>0:"style"==t?this._styles.size>0:this._attrs.has(t)}isSimilar(t){if(!(t instanceof vn))return!1;if(this===t)return!0;if(this.name!=t.name)return!1;if(this._attrs.size!==t._attrs.size||this._classes.size!==t._classes.size||this._styles.size!==t._styles.size)return!1;for(const[e,i]of this._attrs)if(!t._attrs.has(e)||t._attrs.get(e)!==i)return!1;for(const e of this._classes)if(!t._classes.has(e))return!1;for(const[e,i]of this._styles)if(!t._styles.has(e)||t._styles.get(e)!==i)return!1;return!0}hasClass(...t){for(const e of t)if(!this._classes.has(e))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(t){return this._styles.get(t)}getStyleNames(){return this._styles.keys()}hasStyle(...t){for(const e of t)if(!this._styles.has(e))return!1;return!0}findAncestor(...t){const e=new bn(...t);let i=this.parent;for(;i;){if(e.match(i))return i;i=i.parent}return null}getCustomProperty(t){return this._customProperties.get(t)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const t=Array.from(this._classes).sort().join(","),e=Array.from(this._styles).map(t=>`${t[0]}:${t[1]}`).sort().join(";"),i=Array.from(this._attrs).map(t=>`${t[0]}="${t[1]}"`).sort().join(" ");return this.name+(""==t?"":` class="${t}"`)+(""==e?"":` style="${e}"`)+(""==i?"":` ${i}`)}_clone(t=!1){const e=[];if(t)for(const i of this.getChildren())e.push(i._clone(t));const i=new this.constructor(this.name,this._attrs,e);return i._classes=new Set(this._classes),i._styles=new Map(this._styles),i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i}_appendChild(t){return this._insertChild(this.childCount,t)}_insertChild(t,e){this._fireChange("children",this);let i=0;const n=function(t){if("string"==typeof t)return[new mn(t)];wn(t)||(t=[t]);return Array.from(t).map(t=>"string"==typeof t?new mn(t):t instanceof gn?new mn(t.data):t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);for(const e of n)null!==e.parent&&e._remove(),e.parent=this,this._children.splice(t,0,e),t++,i++;return i}_removeChildren(t,e=1){this._fireChange("children",this);for(let i=t;i<t+e;i++)this._children[i].parent=null;return this._children.splice(t,e)}_setAttribute(t,e){e=String(e),this._fireChange("attributes",this),"class"==t?kn(this._classes,e):"style"==t?yn(this._styles,e):this._attrs.set(t,e)}_removeAttribute(t){return this._fireChange("attributes",this),"class"==t?this._classes.size>0&&(this._classes.clear(),!0):"style"==t?this._styles.size>0&&(this._styles.clear(),!0):this._attrs.delete(t)}_addClass(t){this._fireChange("attributes",this),(t=Array.isArray(t)?t:[t]).forEach(t=>this._classes.add(t))}_removeClass(t){this._fireChange("attributes",this),(t=Array.isArray(t)?t:[t]).forEach(t=>this._classes.delete(t))}_setStyle(t,e){if(this._fireChange("attributes",this),x(t)){const e=Object.keys(t);for(const i of e)this._styles.set(i,t[i])}else this._styles.set(t,e)}_removeStyle(t){this._fireChange("attributes",this),(t=Array.isArray(t)?t:[t]).forEach(t=>this._styles.delete(t))}_setCustomProperty(t,e){this._customProperties.set(t,e)}_removeCustomProperty(t){return this._customProperties.delete(t)}}function yn(t,e){let i=null,n=0,s=0,o=null;if(t.clear(),""!==e){";"!=e.charAt(e.length-1)&&(e+=";");for(let r=0;r<e.length;r++){const a=e.charAt(r);if(null===i)switch(a){case":":o||(o=e.substr(n,r-n),s=r+1);break;case'"':case"'":i=a;break;case";":{const i=e.substr(s,r-s);o&&t.set(o.trim(),i.trim()),o=null,n=r+1;break}}else a===i&&(i=null)}}}function kn(t,e){const i=e.split(/\s+/);t.clear(),i.forEach(e=>t.add(e))}class An extends vn{constructor(t,e,i){super(t,e,i),this.getFillerOffset=Cn}is(t,e=null){const i=t&&t.replace(/^view:/,"");return e?"containerElement"==i&&e==this.name||super.is(t,e):"containerElement"==i||super.is(t)}}function Cn(){const t=[...this.getChildren()],e=t[this.childCount-1];if(e&&e.is("element","br"))return this.childCount;for(const e of t)if(!e.is("uiElement"))return null;return this.childCount}var xn=function(t){return t};var Pn=function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)},Tn=Math.max;var En=function(t,e,i){return e=Tn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,s=-1,o=Tn(n.length-e,0),r=Array(o);++s<o;)r[s]=n[e+s];s=-1;for(var a=Array(e+1);++s<e;)a[s]=n[s];return a[e]=i(r),Pn(t,this,a)}};var Sn=function(t){return function(){return t}},Rn=Vt?function(t,e){return Vt(t,"toString",{configurable:!0,enumerable:!1,value:Sn(e),writable:!0})}:xn,On=800,In=16,Mn=Date.now;var Vn=function(t){var e=0,i=0;return function(){var n=Mn(),s=In-(n-i);if(i=n,s>0){if(++e>=On)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Rn);var Nn=function(t,e){return Vn(En(t,e,xn),t+"")};var Bn=function(t,e,i){if(!z(i))return!1;var n=typeof e;return!!("number"==n?ue(i)&&Yt(e,i.length):"string"==n&&e in i)&&T(i[e],t)};var Fn=function(t){return Nn((function(e,i){var n=-1,s=i.length,o=s>1?i[s-1]:void 0,r=s>2?i[2]:void 0;for(o=t.length>3&&"function"==typeof o?(s--,o):void 0,r&&Bn(i[0],i[1],r)&&(o=s<3?void 0:o,s=1),e=Object(e);++n<s;){var a=i[n];a&&t(e,a,n,o)}return e}))}((function(t,e){Dt(e,be(e),t)}));
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Dn=Symbol("observableProperties"),Ln=Symbol("boundObservables"),zn=Symbol("boundProperties"),Hn={set(t,e){if(z(t))return void Object.keys(t).forEach(e=>{this.set(e,t[e])},this);qn(this);const i=this[Dn];if(t in this&&!i.has(t))throw new Ki.b("observable-set-cannot-override: Cannot override an existing property.",this);Object.defineProperty(this,t,{enumerable:!0,configurable:!0,get:()=>i.get(t),set(e){const n=i.get(t);let s=this.fire("set:"+t,t,e,n);void 0===s&&(s=e),n===s&&i.has(t)||(i.set(t,s),this.fire("change:"+t,t,s,n))}}),this[t]=e},bind(...t){if(!t.length||!$n(t))throw new Ki.b("observable-bind-wrong-properties: All properties must be strings.",this);if(new Set(t).size!==t.length)throw new Ki.b("observable-bind-duplicate-properties: Properties must be unique.",this);qn(this);const e=this[zn];t.forEach(t=>{if(e.has(t))throw new Ki.b("observable-bind-rebind: Cannot bind the same property more that once.",this)});const i=new Map;return t.forEach(t=>{const n={property:t,to:[]};e.set(t,n),i.set(t,n)}),{to:Wn,toMany:Un,_observable:this,_bindProperties:t,_to:[],_bindings:i}},unbind(...t){if(!(Dn in this))return;const e=this[zn],i=this[Ln];if(t.length){if(!$n(t))throw new Ki.b("observable-unbind-wrong-properties: Properties must be strings.",this);t.forEach(t=>{const n=e.get(t);if(!n)return;let s,o,r,a;n.to.forEach(t=>{s=t[0],o=t[1],r=i.get(s),(a=r[o]).delete(n),a.size||delete r[o],Object.keys(r).length||(i.delete(s),this.stopListening(s,"change"))}),e.delete(t)})}else i.forEach((t,e)=>{this.stopListening(e,"change")}),i.clear(),e.clear()},decorate(t){const e=this[t];if(!e)throw new Ki.b("observablemixin-cannot-decorate-undefined: Cannot decorate an undefined method.",this,{object:this,methodName:t});this.on(t,(t,i)=>{t.return=e.apply(this,i)}),this[t]=function(...e){return this.fire(t,e)}}};Fn(Hn,en);var jn=Hn;function qn(t){Dn in t||(Object.defineProperty(t,Dn,{value:new Map}),Object.defineProperty(t,Ln,{value:new Map}),Object.defineProperty(t,zn,{value:new Map}))}function Wn(...t){const e=function(...t){if(!t.length)throw new Ki.b("observable-bind-to-parse-error: Invalid argument syntax in `to()`.",null);const e={to:[]};let i;"function"==typeof t[t.length-1]&&(e.callback=t.pop());return t.forEach(t=>{if("string"==typeof t)i.properties.push(t);else{if("object"!=typeof t)throw new Ki.b("observable-bind-to-parse-error: Invalid argument syntax in `to()`.",null);i={observable:t,properties:[]},e.to.push(i)}}),e}(...t),i=Array.from(this._bindings.keys()),n=i.length;if(!e.callback&&e.to.length>1)throw new Ki.b("observable-bind-to-no-callback: Binding multiple observables only possible with callback.",this);if(n>1&&e.callback)throw new Ki.b("observable-bind-to-extra-callback: Cannot bind multiple properties and use a callback in one binding.",this);var s;
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */e.to.forEach(t=>{if(t.properties.length&&t.properties.length!==n)throw new Ki.b("observable-bind-to-properties-length: The number of properties must match.",this);t.properties.length||(t.properties=this._bindProperties)}),this._to=e.to,e.callback&&(this._bindings.get(i[0]).callback=e.callback),s=this._observable,this._to.forEach(t=>{const e=s[Ln];let i;e.get(t.observable)||s.listenTo(t.observable,"change",(n,o)=>{(i=e.get(t.observable)[o])&&i.forEach(t=>{Gn(s,t.property)})})}),function(t){let e;t._bindings.forEach((i,n)=>{t._to.forEach(s=>{e=s.properties[i.callback?0:t._bindProperties.indexOf(n)],i.to.push([s.observable,e]),function(t,e,i,n){const s=t[Ln],o=s.get(i),r=o||{};r[n]||(r[n]=new Set);r[n].add(e),o||s.set(i,r)}(t._observable,i,s.observable,e)})})}(this),this._bindProperties.forEach(t=>{Gn(this._observable,t)})}function Un(t,e,i){if(this._bindings.size>1)throw new Ki.b("observable-bind-to-many-not-one-binding: Cannot bind multiple properties with toMany().",this);this.to(...function(t,e){const i=t.map(t=>[t,e]);return Array.prototype.concat.apply([],i)}(t,e),i)}function $n(t){return t.every(t=>"string"==typeof t)}function Gn(t,e){const i=t[zn].get(e);let n;n=i.callback?i.callback.apply(t,i.to.map(t=>t[0][t[1]])):(n=i.to[0])[0][n[1]],t.hasOwnProperty(e)?t[e]=n:t.set(e,n)}const Kn=Symbol("document");class Jn extends An{constructor(t,e,i){super(t,e,i),this.set("isReadOnly",!1),this.set("isFocused",!1)}is(t,e=null){const i=t&&t.replace(/^view:/,"");return e?"editableElement"==i&&e==this.name||super.is(t,e):"editableElement"==i||super.is(t)}destroy(){this.stopListening()}get document(){return this.getCustomProperty(Kn)}set _document(t){if(this.getCustomProperty(Kn))throw new Ki.b("view-editableelement-document-already-set: View document is already set.",this);this._setCustomProperty(Kn,t),this.bind("isReadOnly").to(t),this.bind("isFocused").to(t,"isFocused",e=>e&&t.selection.editableElement==this),this.listenTo(t.selection,"change",()=>{this.isFocused=t.isFocused&&t.selection.editableElement==this})}}cn(Jn,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Yn=Symbol("rootName");class Qn extends Jn{constructor(t){super(t),this.rootName="main"}is(t,e=null){const i=t.replace(/^view:/,"");return e?"rootElement"==i&&e==this.name||super.is(t,e):"rootElement"==i||super.is(t)}get rootName(){return this.getCustomProperty(Yn)}set rootName(t){this._setCustomProperty(Yn,t)}set _name(t){this.name=t}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xn{constructor(t={}){if(!t.boundaries&&!t.startPosition)throw new Ki.b("view-tree-walker-no-start-position: Neither boundaries nor starting position have been defined.",null);if(t.direction&&"forward"!=t.direction&&"backward"!=t.direction)throw new Ki.b("view-tree-walker-unknown-direction: Only `backward` and `forward` direction allowed.",t.startPosition,{direction:t.direction});this.boundaries=t.boundaries||null,t.startPosition?this.position=Zn._createAt(t.startPosition):this.position=Zn._createAt(t.boundaries["backward"==t.direction?"end":"start"]),this.direction=t.direction||"forward",this.singleCharacters=!!t.singleCharacters,this.shallow=!!t.shallow,this.ignoreElementEnd=!!t.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}skip(t){let e,i,n;do{n=this.position,({done:e,value:i}=this.next())}while(!e&&t(i));e||(this.position=n)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let t=this.position.clone();const e=this.position,i=t.parent;if(null===i.parent&&t.offset===i.childCount)return{done:!0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0};let n;if(i instanceof mn){if(t.isAtEnd)return this.position=Zn._createAfter(i),this._next();n=i.data[t.offset]}else n=i.getChild(t.offset);if(n instanceof vn)return this.shallow?t.offset++:t=new Zn(n,0),this.position=t,this._formatReturnValue("elementStart",n,e,t,1);if(n instanceof mn){if(this.singleCharacters)return t=new Zn(n,0),this.position=t,this._next();{let i,s=n.data.length;return n==this._boundaryEndParent?(s=this.boundaries.end.offset,i=new gn(n,0,s),t=Zn._createAfter(i)):(i=new gn(n,0,n.data.length),t.offset++),this.position=t,this._formatReturnValue("text",i,e,t,s)}}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{n=(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-t.offset}const s=new gn(i,t.offset,n);return t.offset+=n,this.position=t,this._formatReturnValue("text",s,e,t,n)}return t=Zn._createAfter(i),this.position=t,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,e,t)}_previous(){let t=this.position.clone();const e=this.position,i=t.parent;if(null===i.parent&&0===t.offset)return{done:!0};if(i==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0};let n;if(i instanceof mn){if(t.isAtStart)return this.position=Zn._createBefore(i),this._previous();n=i.data[t.offset-1]}else n=i.getChild(t.offset-1);if(n instanceof vn)return this.shallow?(t.offset--,this.position=t,this._formatReturnValue("elementStart",n,e,t,1)):(t=new Zn(n,n.childCount),this.position=t,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,e,t));if(n instanceof mn){if(this.singleCharacters)return t=new Zn(n,n.data.length),this.position=t,this._previous();{let i,s=n.data.length;if(n==this._boundaryStartParent){const e=this.boundaries.start.offset;s=(i=new gn(n,e,n.data.length-e)).data.length,t=Zn._createBefore(i)}else i=new gn(n,0,n.data.length),t.offset--;return this.position=t,this._formatReturnValue("text",i,e,t,s)}}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const e=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=t.offset-e}t.offset-=n;const s=new gn(i,t.offset,n);return this.position=t,this._formatReturnValue("text",s,e,t,n)}return t=Zn._createBefore(i),this.position=t,this._formatReturnValue("elementStart",i,e,t,1)}_formatReturnValue(t,e,i,n,s){return e instanceof gn&&(e.offsetInText+e.data.length==e.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Zn._createAfter(e.textNode):(n=Zn._createAfter(e.textNode),this.position=n)),0===e.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Zn._createBefore(e.textNode):(n=Zn._createBefore(e.textNode),this.position=n))),{done:!1,value:{type:t,item:e,previousPosition:i,nextPosition:n,length:s}}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zn{constructor(t,e){this.parent=t,this.offset=e}get nodeAfter(){return this.parent.is("text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return 0===this.offset}get isAtEnd(){const t=this.parent.is("text")?this.parent.data.length:this.parent.childCount;return this.offset===t}get root(){return this.parent.root}get editableElement(){let t=this.parent;for(;!(t instanceof Jn);){if(!t.parent)return null;t=t.parent}return t}getShiftedBy(t){const e=Zn._createAt(this),i=e.offset+t;return e.offset=i<0?0:i,e}getLastMatchingPosition(t,e={}){e.startPosition=this;const i=new Xn(e);return i.skip(t),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(t){const e=this.getAncestors(),i=t.getAncestors();let n=0;for(;e[n]==i[n]&&e[n];)n++;return 0===n?null:e[n-1]}is(t){return"position"==t||"view:position"==t}isEqual(t){return this.parent==t.parent&&this.offset==t.offset}isBefore(t){return"before"==this.compareWith(t)}isAfter(t){return"after"==this.compareWith(t)}compareWith(t){if(this.root!==t.root)return"different";if(this.isEqual(t))return"same";const e=this.parent.is("node")?this.parent.getPath():[],i=t.parent.is("node")?t.parent.getPath():[];e.push(this.offset),i.push(t.offset);const n=hn(e,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return e[n]<i[n]?"before":"after"}}getWalker(t={}){return t.startPosition=this,new Xn(t)}clone(){return new Zn(this.parent,this.offset)}static _createAt(t,e){if(t instanceof Zn)return new this(t.parent,t.offset);{const i=t;if("end"==e)e=i.is("text")?i.data.length:i.childCount;else{if("before"==e)return this._createBefore(i);if("after"==e)return this._createAfter(i);if(0!==e&&!e)throw new Ki.b("view-createPositionAt-offset-required: View#createPositionAt() requires the offset when the first parameter is a view item.",i)}return new Zn(i,e)}}static _createAfter(t){if(t.is("textProxy"))return new Zn(t.textNode,t.offsetInText+t.data.length);if(!t.parent)throw new Ki.b("view-position-after-root: You can not make position after root.",t,{root:t});return new Zn(t.parent,t.index+1)}static _createBefore(t){if(t.is("textProxy"))return new Zn(t.textNode,t.offsetInText);if(!t.parent)throw new Ki.b("view-position-before-root: You can not make position before root.",t,{root:t});return new Zn(t.parent,t.index)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ts{constructor(t,e=null){this.start=t.clone(),this.end=e?e.clone():t.clone()}*[Symbol.iterator](){yield*new Xn({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 t=this.start.getLastMatchingPosition(es,{direction:"backward"}),e=this.end.getLastMatchingPosition(es);return t.parent.is("text")&&t.isAtStart&&(t=Zn._createBefore(t.parent)),e.parent.is("text")&&e.isAtEnd&&(e=Zn._createAfter(e.parent)),new ts(t,e)}getTrimmed(){let t=this.start.getLastMatchingPosition(es);if(t.isAfter(this.end)||t.isEqual(this.end))return new ts(t,t);let e=this.end.getLastMatchingPosition(es,{direction:"backward"});const i=t.nodeAfter,n=e.nodeBefore;return i&&i.is("text")&&(t=new Zn(i,0)),n&&n.is("text")&&(e=new Zn(n,n.data.length)),new ts(t,e)}isEqual(t){return this==t||this.start.isEqual(t.start)&&this.end.isEqual(t.end)}containsPosition(t){return t.isAfter(this.start)&&t.isBefore(this.end)}containsRange(t,e=!1){t.isCollapsed&&(e=!1);const i=this.containsPosition(t.start)||e&&this.start.isEqual(t.start),n=this.containsPosition(t.end)||e&&this.end.isEqual(t.end);return i&&n}getDifference(t){const e=[];return this.isIntersecting(t)?(this.containsPosition(t.start)&&e.push(new ts(this.start,t.start)),this.containsPosition(t.end)&&e.push(new ts(t.end,this.end))):e.push(this.clone()),e}getIntersection(t){if(this.isIntersecting(t)){let e=this.start,i=this.end;return this.containsPosition(t.start)&&(e=t.start),this.containsPosition(t.end)&&(i=t.end),new ts(e,i)}return null}getWalker(t={}){return t.boundaries=this,new Xn(t)}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}clone(){return new ts(this.start,this.end)}*getItems(t={}){t.boundaries=this,t.ignoreElementEnd=!0;const e=new Xn(t);for(const t of e)yield t.item}*getPositions(t={}){t.boundaries=this;const e=new Xn(t);yield e.position;for(const t of e)yield t.nextPosition}is(t){return"range"==t||"view:range"==t}isIntersecting(t){return this.start.isBefore(t.end)&&this.end.isAfter(t.start)}static _createFromParentsAndOffsets(t,e,i,n){return new this(new Zn(t,e),new Zn(i,n))}static _createFromPositionAndShift(t,e){const i=t,n=t.getShiftedBy(e);return e>0?new this(i,n):new this(n,i)}static _createIn(t){return this._createFromParentsAndOffsets(t,0,t,t.childCount)}static _createOn(t){const e=t.is("textProxy")?t.offsetSize:1;return this._createFromPositionAndShift(Zn._createBefore(t),e)}}function es(t){return!(!t.item.is("attributeElement")&&!t.item.is("uiElement"))}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function is(t){let e=0;for(const i of t)e++;return e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ns{constructor(t=null,e,i){this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",this.setTo(t,e,i)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const t=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?t.end:t.start).clone()}get focus(){if(!this._ranges.length)return null;const t=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?t.start:t.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const t of this._ranges)yield t.clone()}getFirstRange(){let t=null;for(const e of this._ranges)t&&!e.start.isBefore(t.start)||(t=e);return t?t.clone():null}getLastRange(){let t=null;for(const e of this._ranges)t&&!e.end.isAfter(t.end)||(t=e);return t?t.clone():null}getFirstPosition(){const t=this.getFirstRange();return t?t.start.clone():null}getLastPosition(){const t=this.getLastRange();return t?t.end.clone():null}isEqual(t){if(this.isFake!=t.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=t.fakeSelectionLabel)return!1;if(this.rangeCount!=t.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(t.anchor)||!this.focus.isEqual(t.focus))return!1;for(const e of this._ranges){let i=!1;for(const n of t._ranges)if(e.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(t){if(this.isBackward!=t.isBackward)return!1;const e=is(this.getRanges());if(e!=is(t.getRanges()))return!1;if(0==e)return!0;for(let e of this.getRanges()){e=e.getTrimmed();let i=!1;for(let n of t.getRanges())if(n=n.getTrimmed(),e.start.isEqual(n.start)&&e.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){if(1!==this.rangeCount)return null;const t=this.getFirstRange();let e=t.start.nodeAfter,i=t.end.nodeBefore;return t.start.parent.is("text")&&t.start.isAtEnd&&t.start.parent.nextSibling&&(e=t.start.parent.nextSibling),t.end.parent.is("text")&&t.end.isAtStart&&t.end.parent.previousSibling&&(i=t.end.parent.previousSibling),e instanceof vn&&e==i?e:null}setTo(t,e,i){if(null===t)this._setRanges([]),this._setFakeOptions(e);else if(t instanceof ns||t instanceof ss)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof ts)this._setRanges([t],e&&e.backward),this._setFakeOptions(e);else if(t instanceof Zn)this._setRanges([new ts(t)]),this._setFakeOptions(e);else if(t instanceof fn){const n=!!i&&!!i.backward;let s;if(void 0===e)throw new Ki.b("view-selection-setTo-required-second-parameter: selection.setTo requires the second parameter when the first parameter is a node.",this);s="in"==e?ts._createIn(t):"on"==e?ts._createOn(t):new ts(Zn._createAt(t,e)),this._setRanges([s],n),this._setFakeOptions(i)}else{if(!wn(t))throw new Ki.b("view-selection-setTo-not-selectable: Cannot set selection to given place.",this);this._setRanges(t,e&&e.backward),this._setFakeOptions(e)}this.fire("change")}setFocus(t,e){if(null===this.anchor)throw new Ki.b("view-selection-setFocus-no-ranges: Cannot set selection focus if there are no ranges in selection.",this);const i=Zn._createAt(t,e);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new ts(i,n),!0):this._addRange(new ts(n,i)),this.fire("change")}is(t){return"selection"==t||"view:selection"==t}_setRanges(t,e=!1){t=Array.from(t),this._ranges=[];for(const e of t)this._addRange(e);this._lastRangeBackward=!!e}_setFakeOptions(t={}){this._isFake=!!t.fake,this._fakeSelectionLabel=t.fake&&t.label||""}_addRange(t,e=!1){if(!(t instanceof ts))throw new Ki.b("view-selection-add-range-not-range: Selection range set to an object that is not an instance of view.Range",this);this._pushRange(t),this._lastRangeBackward=!!e}_pushRange(t){for(const e of this._ranges)if(t.isIntersecting(e))throw new Ki.b("view-selection-range-intersects: Trying to add a range that intersects with another range from selection.",this,{addedRange:t,intersectingRange:e});this._ranges.push(new ts(t.start,t.end))}}cn(ns,en);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ss{constructor(t=null,e,i){this._selection=new ns,this._selection.delegate("change").to(this),this._selection.setTo(t,e,i)}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(t){return this._selection.isEqual(t)}isSimilar(t){return this._selection.isSimilar(t)}is(t){return"selection"==t||"documentSelection"==t||"view:selection"==t||"view:documentSelection"==t}_setTo(t,e,i){this._selection.setTo(t,e,i)}_setFocus(t,e){this._selection.setFocus(t,e)}}cn(ss,en);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class os{constructor(t={}){this._items=[],this._itemMap=new Map,this._idProperty=t.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[]}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(t,e){let i;const n=this._idProperty;if(n in t){if("string"!=typeof(i=t[n]))throw new Ki.b("collection-add-invalid-id",this);if(this.get(i))throw new Ki.b("collection-add-item-already-exists",this)}else t[n]=i=Qi();if(void 0===e)e=this._items.length;else if(e>this._items.length||e<0)throw new Ki.b("collection-add-item-invalid-index",this);return this._items.splice(e,0,t),this._itemMap.set(i,t),this.fire("add",t,e),this}get(t){let e;if("string"==typeof t)e=this._itemMap.get(t);else{if("number"!=typeof t)throw new Ki.b("collection-get-invalid-arg: Index or id must be given.",this);e=this._items[t]}return e||null}has(t){if("string"==typeof t)return this._itemMap.has(t);{const e=t[this._idProperty];return this._itemMap.has(e)}}getIndex(t){let e;return e="string"==typeof t?this._itemMap.get(t):t,this._items.indexOf(e)}remove(t){let e,i,n,s=!1;const o=this._idProperty;if("string"==typeof t?(i=t,s=!(n=this._itemMap.get(i)),n&&(e=this._items.indexOf(n))):"number"==typeof t?(e=t,s=!(n=this._items[e]),n&&(i=n[o])):(i=(n=t)[o],s=-1==(e=this._items.indexOf(n))||!this._itemMap.get(i)),s)throw new Ki.b("collection-remove-404: Item not found.",this);this._items.splice(e,1),this._itemMap.delete(i);const r=this._bindToInternalToExternalMap.get(n);return this._bindToInternalToExternalMap.delete(n),this._bindToExternalToInternalMap.delete(r),this.fire("remove",n,e),n}map(t,e){return this._items.map(t,e)}find(t,e){return this._items.find(t,e)}filter(t,e){return this._items.filter(t,e)}clear(){for(this._bindToCollection&&(this.stopListening(this._bindToCollection),this._bindToCollection=null);this.length;)this.remove(0)}bindTo(t){if(this._bindToCollection)throw new Ki.b("collection-bind-to-rebind: The collection cannot be bound more than once.",this);return this._bindToCollection=t,{as:t=>{this._setUpBindToBinding(e=>new t(e))},using:t=>{"function"==typeof t?this._setUpBindToBinding(e=>t(e)):this._setUpBindToBinding(e=>e[t])}}}_setUpBindToBinding(t){const e=this._bindToCollection,i=(i,n,s)=>{const o=e._bindToCollection==this,r=e._bindToInternalToExternalMap.get(n);if(o&&r)this._bindToExternalToInternalMap.set(n,r),this._bindToInternalToExternalMap.set(r,n);else{const i=t(n);if(!i)return void this._skippedIndexesFromExternal.push(s);let o=s;for(const t of this._skippedIndexesFromExternal)s>t&&o--;for(const t of e._skippedIndexesFromExternal)o>=t&&o++;this._bindToExternalToInternalMap.set(n,i),this._bindToInternalToExternalMap.set(i,n),this.add(i,o);for(let t=0;t<e._skippedIndexesFromExternal.length;t++)o<=e._skippedIndexesFromExternal[t]&&e._skippedIndexesFromExternal[t]++}};for(const t of e)i(0,t,e.getIndex(t));this.listenTo(e,"add",i),this.listenTo(e,"remove",(t,e,i)=>{const n=this._bindToExternalToInternalMap.get(e);n&&this.remove(n),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce((t,e)=>(i<e&&t.push(e-1),i>e&&t.push(e),t),[])})}[Symbol.iterator](){return this._items[Symbol.iterator]()}}cn(os,en);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class rs{constructor(){this.selection=new ss,this.roots=new os({idProperty:"rootName"}),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isComposing",!1),this._postFixers=new Set}getRoot(t="main"){return this.roots.get(t)}registerPostFixer(t){this._postFixers.add(t)}destroy(){this.roots.map(t=>t.destroy()),this.stopListening()}_callPostFixers(t){let e=!1;do{for(const i of this._postFixers)if(e=i(t))break}while(e)}}cn(rs,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const as=10;class ls extends vn{constructor(t,e,i){super(t,e,i),this.getFillerOffset=cs,this._priority=as,this._id=null,this._clonesGroup=null}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new Ki.b("attribute-element-get-elements-with-same-id-no-id: Cannot get elements with the same id for an attribute element without id.",this);return new Set(this._clonesGroup)}is(t,e=null){const i=t&&t.replace(/^view:/,"");return e?"attributeElement"==i&&e==this.name||super.is(t,e):"attributeElement"==i||super.is(t)}isSimilar(t){return null!==this.id||null!==t.id?this.id===t.id:super.isSimilar(t)&&this.priority==t.priority}_clone(t){const e=super._clone(t);return e._priority=this._priority,e._id=this._id,e}}function cs(){if(hs(this))return null;let t=this.parent;for(;t&&t.is("attributeElement");){if(hs(t)>1)return null;t=t.parent}return!t||hs(t)>1?null:this.childCount}function hs(t){return Array.from(t.getChildren()).filter(t=>!t.is("uiElement")).length}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */ls.DEFAULT_PRIORITY=as;class ds extends vn{constructor(t,e,i){super(t,e,i),this.getFillerOffset=us}is(t,e=null){const i=t.replace(/^view:/,"");return e?"emptyElement"==i&&e==this.name||super.is(t,e):"emptyElement"==i||super.is(t)}_insertChild(t,e){if(e&&(e instanceof fn||Array.from(e).length>0))throw new Ki.b("view-emptyelement-cannot-add: Cannot add child nodes to EmptyElement instance.",[this,e])}}function us(){return null}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const fs=navigator.userAgent.toLowerCase();var ms={isMac:function(t){return t.indexOf("macintosh")>-1}(fs),isEdge:function(t){return!!t.match(/edge\/(\d+.?\d*)/)}(fs),isGecko:function(t){return!!t.match(/gecko\/\d+/)}(fs),isSafari:function(t){return t.indexOf(" applewebkit/")>-1&&-1===t.indexOf("chrome")}(fs),isAndroid:function(t){return t.indexOf("android")>-1}(fs),features:{isRegExpUnicodePropertySupported:function(){let t=!1;try{t=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(t){}return t}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */()}};const gs={"⌘":"ctrl","⇧":"shift","⌥":"alt"},ps={ctrl:"⌘",shift:"⇧",alt:"⌥"},ws=function(){const t={arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,cmd:1114112,shift:2228224,alt:4456448};for(let e=65;e<=90;e++){const i=String.fromCharCode(e);t[i.toLowerCase()]=e}for(let e=48;e<=57;e++)t[e-48]=e;for(let e=112;e<=123;e++)t["f"+(e-111)]=e;return t}();function bs(t){let e;if("string"==typeof t){if(!(e=ws[t.toLowerCase()]))throw new Ki.b("keyboard-unknown-key: Unknown key name.",null,{key:t})}else e=t.keyCode+(t.altKey?ws.alt:0)+(t.ctrlKey?ws.ctrl:0)+(t.shiftKey?ws.shift:0);return e}function _s(t){return"string"==typeof t&&(t=vs(t)),t.map(t=>"string"==typeof t?bs(t):t).reduce((t,e)=>e+t,0)}function vs(t){return t.split(/\s*\+\s*/)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ys extends vn{constructor(t,e,i){super(t,e,i),this.getFillerOffset=As}is(t,e=null){const i=t.replace(/^view:/,"");return e?"uiElement"==i&&e==this.name||super.is(t,e):"uiElement"==i||super.is(t)}_insertChild(t,e){if(e&&(e instanceof fn||Array.from(e).length>0))throw new Ki.b("view-uielement-cannot-add: Cannot add child nodes to UIElement instance.",this)}render(t){return this.toDomElement(t)}toDomElement(t){const e=t.createElement(this.name);for(const t of this.getAttributeKeys())e.setAttribute(t,this.getAttribute(t));return e}}function ks(t){t.document.on("keydown",(e,i)=>(function(t,e,i){if(e.keyCode==ws.arrowright){const t=e.domTarget.ownerDocument.defaultView.getSelection(),n=1==t.rangeCount&&t.getRangeAt(0).collapsed;if(n||e.shiftKey){const e=t.focusNode,s=t.focusOffset,o=i.domPositionToView(e,s);if(null===o)return;let r=!1;const a=o.getLastMatchingPosition(t=>(t.item.is("uiElement")&&(r=!0),!(!t.item.is("uiElement")&&!t.item.is("attributeElement"))));if(r){const e=i.viewPositionToDom(a);n?t.collapse(e.parent,e.offset):t.extend(e.parent,e.offset)}}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */)(0,i,t.domConverter))}function As(){return null}class Cs{constructor(t){this._children=[],t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}is(t){return"documentFragment"==t||"view:documentFragment"==t}_appendChild(t){return this._insertChild(this.childCount,t)}getChild(t){return this._children[t]}getChildIndex(t){return this._children.indexOf(t)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(t,e){this._fireChange("children",this);let i=0;const n=function(t){if("string"==typeof t)return[new mn(t)];wn(t)||(t=[t]);return Array.from(t).map(t=>"string"==typeof t?new mn(t):t instanceof gn?new mn(t.data):t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);for(const e of n)null!==e.parent&&e._remove(),e.parent=this,this._children.splice(t,0,e),t++,i++;return i}_removeChildren(t,e=1){this._fireChange("children",this);for(let i=t;i<t+e;i++)this._children[i].parent=null;return this._children.splice(t,e)}_fireChange(t,e){this.fire("change:"+t,e)}}cn(Cs,en);class xs{constructor(t){this.document=t,this._cloneGroups=new Map}setSelection(t,e,i){this.document.selection._setTo(t,e,i)}setSelectionFocus(t,e){this.document.selection._setFocus(t,e)}createText(t){return new mn(t)}createAttributeElement(t,e,i={}){const n=new ls(t,e);return i.priority&&(n._priority=i.priority),i.id&&(n._id=i.id),n}createContainerElement(t,e){return new An(t,e)}createEditableElement(t,e){const i=new Jn(t,e);return i._document=this.document,i}createEmptyElement(t,e){return new ds(t,e)}createUIElement(t,e,i){const n=new ys(t,e);return i&&(n.render=i),n}setAttribute(t,e,i){i._setAttribute(t,e)}removeAttribute(t,e){e._removeAttribute(t)}addClass(t,e){e._addClass(t)}removeClass(t,e){e._removeClass(t)}setStyle(t,e,i){x(t)&&void 0===i&&(i=e),i._setStyle(t,e)}removeStyle(t,e){e._removeStyle(t)}setCustomProperty(t,e,i){i._setCustomProperty(t,e)}removeCustomProperty(t,e){return e._removeCustomProperty(t)}breakAttributes(t){return t instanceof Zn?this._breakAttributes(t):this._breakAttributesRange(t)}breakContainer(t){const e=t.parent;if(!e.is("containerElement"))throw new Ki.b("view-writer-break-non-container-element: Trying to break an element which is not a container element.",this.document);if(!e.parent)throw new Ki.b("view-writer-break-root: Trying to break root element.",this.document);if(t.isAtStart)return Zn._createBefore(e);if(!t.isAtEnd){const i=e._clone(!1);this.insert(Zn._createAfter(e),i);const n=new ts(t,Zn._createAt(e,"end")),s=new Zn(i,0);this.move(n,s)}return Zn._createAfter(e)}mergeAttributes(t){const e=t.offset,i=t.parent;if(i.is("text"))return t;if(i.is("attributeElement")&&0===i.childCount){const t=i.parent,e=i.index;return i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new Zn(t,e))}const n=i.getChild(e-1),s=i.getChild(e);if(!n||!s)return t;if(n.is("text")&&s.is("text"))return Rs(n,s);if(n.is("attributeElement")&&s.is("attributeElement")&&n.isSimilar(s)){const t=n.childCount;return n._appendChild(s.getChildren()),s._remove(),this._removeFromClonedElementsGroup(s),this.mergeAttributes(new Zn(n,t))}return t}mergeContainers(t){const e=t.nodeBefore,i=t.nodeAfter;if(!(e&&i&&e.is("containerElement")&&i.is("containerElement")))throw new Ki.b("view-writer-merge-containers-invalid-position: Element before and after given position cannot be merged.",this.document);const n=e.getChild(e.childCount-1),s=n instanceof mn?Zn._createAt(n,"end"):Zn._createAt(e,"end");return this.move(ts._createIn(i),Zn._createAt(e,"end")),this.remove(ts._createOn(i)),s}insert(t,e){(function t(e,i){for(const n of e){if(!Os.some(t=>n instanceof t))throw new Ki.b("view-writer-insert-invalid-node",i);n.is("text")||t(n.getChildren(),i)}})(e=wn(e)?[...e]:[e],this.document);const i=Ps(t);if(!i)throw new Ki.b("view-writer-invalid-position-container",this.document);const n=this._breakAttributes(t,!0),s=i._insertChild(n.offset,e);for(const t of e)this._addToClonedElementsGroup(t);const o=n.getShiftedBy(s),r=this.mergeAttributes(n);if(0===s)return new ts(r,r);{r.isEqual(n)||o.offset--;const t=this.mergeAttributes(o);return new ts(r,t)}}remove(t){const e=t instanceof ts?t:ts._createOn(t);if(Ms(e,this.document),e.isCollapsed)return new Cs;const{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=n.offset-i.offset,r=s._removeChildren(i.offset,o);for(const t of r)this._removeFromClonedElementsGroup(t);const a=this.mergeAttributes(i);return e.start=a,e.end=a.clone(),new Cs(r)}clear(t,e){Ms(t,this.document);const i=t.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let s;if(i.is("element")&&e.isSimilar(i))s=ts._createOn(i);else if(!n.nextPosition.isAfter(t.start)&&i.is("textProxy")){const t=i.getAncestors().find(t=>t.is("element")&&e.isSimilar(t));t&&(s=ts._createIn(t))}s&&(s.end.isAfter(t.end)&&(s.end=t.end),s.start.isBefore(t.start)&&(s.start=t.start),this.remove(s))}}move(t,e){let i;if(e.isAfter(t.end)){const n=(e=this._breakAttributes(e,!0)).parent,s=n.childCount;t=this._breakAttributesRange(t,!0),i=this.remove(t),e.offset+=n.childCount-s}else i=this.remove(t);return this.insert(e,i)}wrap(t,e){if(!(e instanceof ls))throw new Ki.b("view-writer-wrap-invalid-attribute",this.document);if(Ms(t,this.document),t.isCollapsed){let n=t.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some(t=>!t.is("uiElement")))&&(n=n.getLastMatchingPosition(t=>t.item.is("uiElement"))),n=this._wrapPosition(n,e);const s=this.document.selection;return s.isCollapsed&&s.getFirstPosition().isEqual(t.start)&&this.setSelection(n),new ts(n)}return this._wrapRange(t,e);var i}unwrap(t,e){if(!(e instanceof ls))throw new Ki.b("view-writer-unwrap-invalid-attribute",this.document);if(Ms(t,this.document),t.isCollapsed)return t;const{start:i,end:n}=this._breakAttributesRange(t,!0),s=i.parent,o=this._unwrapChildren(s,i.offset,n.offset,e),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new ts(r,a)}rename(t,e){const i=new An(t,e.getAttributes());return this.insert(Zn._createAfter(e),i),this.move(ts._createIn(e),Zn._createAt(i,0)),this.remove(ts._createOn(e)),i}clearClonedElementsGroup(t){this._cloneGroups.delete(t)}createPositionAt(t,e){return Zn._createAt(t,e)}createPositionAfter(t){return Zn._createAfter(t)}createPositionBefore(t){return Zn._createBefore(t)}createRange(t,e){return new ts(t,e)}createRangeOn(t){return ts._createOn(t)}createRangeIn(t){return ts._createIn(t)}createSelection(t,e,i){return new ns(t,e,i)}_wrapChildren(t,e,i,n){let s=e;const o=[];for(;s<i;){const e=t.getChild(s),i=e.is("text"),r=e.is("attributeElement"),a=e.is("emptyElement"),l=e.is("uiElement");if(r&&this._wrapAttributeElement(n,e))o.push(new Zn(t,s));else if(i||a||l||r&&Ts(n,e)){const i=n._clone();e._remove(),i._appendChild(e),t._insertChild(s,i),this._addToClonedElementsGroup(i),o.push(new Zn(t,s))}else r&&this._wrapChildren(e,0,e.childCount,n);s++}let r=0;for(const t of o){if(t.offset-=r,t.offset==e)continue;this.mergeAttributes(t).isEqual(t)||(r++,i--)}return ts._createFromParentsAndOffsets(t,e,t,i)}_unwrapChildren(t,e,i,n){let s=e;const o=[];for(;s<i;){const e=t.getChild(s);if(e.is("attributeElement"))if(e.isSimilar(n)){const n=e.getChildren(),r=e.childCount;e._remove(),t._insertChild(s,n),this._removeFromClonedElementsGroup(e),o.push(new Zn(t,s),new Zn(t,s+r)),s+=r,i+=r-1}else this._unwrapAttributeElement(n,e)?(o.push(new Zn(t,s),new Zn(t,s+1)),s++):(this._unwrapChildren(e,0,e.childCount,n),s++);else s++}let r=0;for(const t of o){if(t.offset-=r,t.offset==e||t.offset==i)continue;this.mergeAttributes(t).isEqual(t)||(r++,i--)}return ts._createFromParentsAndOffsets(t,e,t,i)}_wrapRange(t,e){const{start:i,end:n}=this._breakAttributesRange(t,!0),s=i.parent,o=this._wrapChildren(s,i.offset,n.offset,e),r=this.mergeAttributes(o.start);r.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new ts(r,a)}_wrapPosition(t,e){if(e.isSimilar(t.parent))return Es(t.clone());t.parent.is("text")&&(t=Ss(t));const i=this.createAttributeElement();i._priority=Number.POSITIVE_INFINITY,i.isSimilar=()=>!1,t.parent._insertChild(t.offset,i);const n=new ts(t,t.getShiftedBy(1));this.wrap(n,e);const s=new Zn(i.parent,i.index);i._remove();const o=s.nodeBefore,r=s.nodeAfter;return o instanceof mn&&r instanceof mn?Rs(o,r):Es(s)}_wrapAttributeElement(t,e){if(!Vs(t,e))return!1;if(t.name!==e.name||t.priority!==e.priority)return!1;for(const i of t.getAttributeKeys())if("class"!==i&&"style"!==i&&e.hasAttribute(i)&&e.getAttribute(i)!==t.getAttribute(i))return!1;for(const i of t.getStyleNames())if(e.hasStyle(i)&&e.getStyle(i)!==t.getStyle(i))return!1;for(const i of t.getAttributeKeys())"class"!==i&&"style"!==i&&(e.hasAttribute(i)||this.setAttribute(i,t.getAttribute(i),e));for(const i of t.getStyleNames())e.hasStyle(i)||this.setStyle(i,t.getStyle(i),e);for(const i of t.getClassNames())e.hasClass(i)||this.addClass(i,e);return!0}_unwrapAttributeElement(t,e){if(!Vs(t,e))return!1;if(t.name!==e.name||t.priority!==e.priority)return!1;for(const i of t.getAttributeKeys())if("class"!==i&&"style"!==i&&(!e.hasAttribute(i)||e.getAttribute(i)!==t.getAttribute(i)))return!1;if(!e.hasClass(...t.getClassNames()))return!1;for(const i of t.getStyleNames())if(!e.hasStyle(i)||e.getStyle(i)!==t.getStyle(i))return!1;for(const i of t.getAttributeKeys())"class"!==i&&"style"!==i&&this.removeAttribute(i,e);return this.removeClass(Array.from(t.getClassNames()),e),this.removeStyle(Array.from(t.getStyleNames()),e),!0}_breakAttributesRange(t,e=!1){const i=t.start,n=t.end;if(Ms(t,this.document),t.isCollapsed){const i=this._breakAttributes(t.start,e);return new ts(i,i)}const s=this._breakAttributes(n,e),o=s.parent.childCount,r=this._breakAttributes(i,e);return s.offset+=s.parent.childCount-o,new ts(r,s)}_breakAttributes(t,e=!1){const i=t.offset,n=t.parent;if(t.parent.is("emptyElement"))throw new Ki.b("view-writer-cannot-break-empty-element",this.document);if(t.parent.is("uiElement"))throw new Ki.b("view-writer-cannot-break-ui-element",this.document);if(!e&&n.is("text")&&Is(n.parent))return t.clone();if(Is(n))return t.clone();if(n.is("text"))return this._breakAttributes(Ss(t),e);if(i==n.childCount){const t=new Zn(n.parent,n.index+1);return this._breakAttributes(t,e)}if(0===i){const t=new Zn(n.parent,n.index);return this._breakAttributes(t,e)}{const t=n.index+1,s=n._clone();n.parent._insertChild(t,s),this._addToClonedElementsGroup(s);const o=n.childCount-i,r=n._removeChildren(i,o);s._appendChild(r);const a=new Zn(n.parent,t);return this._breakAttributes(a,e)}}_addToClonedElementsGroup(t){if(!t.root.is("rootElement"))return;if(t.is("element"))for(const e of t.getChildren())this._addToClonedElementsGroup(e);const e=t.id;if(!e)return;let i=this._cloneGroups.get(e);i||(i=new Set,this._cloneGroups.set(e,i)),i.add(t),t._clonesGroup=i}_removeFromClonedElementsGroup(t){if(t.is("element"))for(const e of t.getChildren())this._removeFromClonedElementsGroup(e);const e=t.id;if(!e)return;const i=this._cloneGroups.get(e);i&&i.delete(t)}}function Ps(t){let e=t.parent;for(;!Is(e);){if(!e)return;e=e.parent}return e}function Ts(t,e){return t.priority<e.priority||!(t.priority>e.priority)&&t.getIdentity()<e.getIdentity()}function Es(t){const e=t.nodeBefore;if(e&&e.is("text"))return new Zn(e,e.data.length);const i=t.nodeAfter;return i&&i.is("text")?new Zn(i,0):t}function Ss(t){if(t.offset==t.parent.data.length)return new Zn(t.parent.parent,t.parent.index+1);if(0===t.offset)return new Zn(t.parent.parent,t.parent.index);const e=t.parent.data.slice(t.offset);return t.parent._data=t.parent.data.slice(0,t.offset),t.parent.parent._insertChild(t.parent.index+1,new mn(e)),new Zn(t.parent.parent,t.parent.index+1)}function Rs(t,e){const i=t.data.length;return t._data+=e.data,e._remove(),new Zn(t,i)}const Os=[mn,ls,An,ds,ys];function Is(t){return t&&(t.is("containerElement")||t.is("documentFragment"))}function Ms(t,e){const i=Ps(t.start),n=Ps(t.end);if(!i||!n||i!==n)throw new Ki.b("view-writer-invalid-range-container",e)}function Vs(t,e){return null===t.id&&null===e.id}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ns(t){return"[object Text]"==Object.prototype.toString.call(t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Bs=t=>{const e=t.createElement("br");return e.dataset.ckeFiller=!0,e},Fs=t=>t.createTextNode(" "),Ds=7;let Ls="";for(let t=0;t<Ds;t++)Ls+="​";function zs(t){return Ns(t)&&t.data.substr(0,Ds)===Ls}function Hs(t){return t.data.length==Ds&&zs(t)}function js(t){return zs(t)?t.data.slice(Ds):t.data}const qs=new WeakMap;function Ws(t,e){let i=qs.get(e);return i||(i=e(window.document),qs.set(e,i)),t.isEqualNode(i)}function Us(t,e){if(e.keyCode==ws.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(1==t.rangeCount&&t.getRangeAt(0).collapsed){const e=t.getRangeAt(0).startContainer,i=t.getRangeAt(0).startOffset;zs(e)&&i<=Ds&&t.collapse(e,0)}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function $s(t,e,i,n=!1){i=i||function(t,e){return t===e},Array.isArray(t)||(t=Array.from(t)),Array.isArray(e)||(e=Array.from(e));const s=function(t,e,i){const n=Gs(t,e,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const s=Ks(t,n),o=Ks(e,n),r=Gs(s,o,i),a=t.length-r,l=e.length-r;return{firstIndex:n,lastIndexOld:a,lastIndexNew:l}}(t,e,i);return n?function(t,e){const{firstIndex:i,lastIndexOld:n,lastIndexNew:s}=t;if(-1===i)return Array(e).fill("equal");let o=[];i>0&&(o=o.concat(Array(i).fill("equal")));s-i>0&&(o=o.concat(Array(s-i).fill("insert")));n-i>0&&(o=o.concat(Array(n-i).fill("delete")));s<e&&(o=o.concat(Array(e-s).fill("equal")));return o}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(s,e.length):function(t,e){const i=[],{firstIndex:n,lastIndexOld:s,lastIndexNew:o}=e;o-n>0&&i.push({index:n,type:"insert",values:t.slice(n,o)});s-n>0&&i.push({index:n+(o-n),type:"delete",howMany:s-n});return i}(e,s)}function Gs(t,e,i){for(let n=0;n<Math.max(t.length,e.length);n++)if(void 0===t[n]||void 0===e[n]||!i(t[n],e[n]))return n;return-1}function Ks(t,e){return t.slice(e).reverse()}function Js(t,e,i){i=i||function(t,e){return t===e};const n=t.length,s=e.length;if(n>200||s>200||n+s>300)return Js.fastDiff(t,e,i,!0);let o,r;if(s<n){const i=t;t=e,e=i,o="delete",r="insert"}else o="insert",r="delete";const a=t.length,l=e.length,c=l-a,h={},d={};function u(n){const s=(void 0!==d[n-1]?d[n-1]:-1)+1,c=void 0!==d[n+1]?d[n+1]:-1,u=s>c?-1:1;h[n+u]&&(h[n]=h[n+u].slice(0)),h[n]||(h[n]=[]),h[n].push(s>c?o:r);let f=Math.max(s,c),m=f-n;for(;m<a&&f<l&&i(t[m],e[f]);)m++,f++,h[n].push("equal");return f}let f,m=0;do{for(f=-m;f<c;f++)d[f]=u(f);for(f=c+m;f>c;f--)d[f]=u(f);d[c]=u(c),m++}while(d[c]!==l);return h[c].slice(1)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Ys(t,e,i){t.insertBefore(i,t.childNodes[e]||null)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Qs(t){const e=t.parentNode;e&&e.removeChild(t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Xs(t){if(t){if(t.defaultView)return t instanceof t.defaultView.Document;if(t.ownerDocument&&t.ownerDocument.defaultView)return t instanceof t.ownerDocument.defaultView.Node}return!1}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Js.fastDiff=$s;class Zs{constructor(t,e){this.domDocuments=new Set,this.domConverter=t,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this.selection=e,this.isFocused=!1,this._inlineFiller=null,this._fakeSelectionContainer=null}markToSync(t,e){if("text"===t)this.domConverter.mapViewToDom(e.parent)&&this.markedTexts.add(e);else{if(!this.domConverter.mapViewToDom(e))return;if("attributes"===t)this.markedAttributes.add(e);else{if("children"!==t)throw new Ki.b("view-renderer-unknown-type: Unknown type passed to Renderer.markToSync.",this);this.markedChildren.add(e)}}}render(){let t;for(const t of this.markedChildren)this._updateChildrenMappings(t);this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?t=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(t=this.selection.getFirstPosition(),this.markedChildren.add(t.parent));for(const t of this.markedAttributes)this._updateAttrs(t);for(const e of this.markedChildren)this._updateChildren(e,{inlineFillerPosition:t});for(const e of this.markedTexts)!this.markedChildren.has(e.parent)&&this.domConverter.mapViewToDom(e.parent)&&this._updateText(e,{inlineFillerPosition:t});if(t){const e=this.domConverter.viewPositionToDom(t),i=e.parent.ownerDocument;zs(e.parent)?this._inlineFiller=e.parent:this._inlineFiller=to(i,e.parent,e.offset)}else this._inlineFiller=null;this._updateSelection(),this._updateFocus(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(t){const e=this.domConverter.mapViewToDom(t);if(!e)return;const i=this.domConverter.mapViewToDom(t).childNodes,n=Array.from(this.domConverter.viewChildrenToDom(t,e.ownerDocument,{withChildren:!1})),s=this._diffNodeLists(i,n),o=this._findReplaceActions(s,i,n);if(-1!==o.indexOf("replace")){const e={equal:0,insert:0,delete:0};for(const s of o)if("replace"===s){const s=e.equal+e.insert,o=e.equal+e.delete,r=t.getChild(s);r&&!r.is("uiElement")&&this._updateElementMappings(r,i[o]),Qs(n[s]),e.equal++}else e[s]++}}_updateElementMappings(t,e){this.domConverter.unbindDomElement(e),this.domConverter.bindElements(e,t),this.markedChildren.add(t),this.markedAttributes.add(t)}_getInlineFillerPosition(){const t=this.selection.getFirstPosition();return t.parent.is("text")?Zn._createBefore(this.selection.getFirstPosition().parent):t}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const t=this.selection.getFirstPosition(),e=this.domConverter.viewPositionToDom(t);return!!(e&&Ns(e.parent)&&zs(e.parent))}_removeInlineFiller(){const t=this._inlineFiller;if(!zs(t))throw new Ki.b("view-renderer-filler-was-lost: The inline filler node was lost.",this);Hs(t)?t.parentNode.removeChild(t):t.data=t.data.substr(Ds),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const t=this.selection.getFirstPosition(),e=t.parent,i=t.offset;if(!this.domConverter.mapViewToDom(e.root))return!1;if(!e.is("element"))return!1;if(!function(t){if("false"==t.getAttribute("contenteditable"))return!1;const e=t.findAncestor(t=>t.hasAttribute("contenteditable"));return!e||"true"==e.getAttribute("contenteditable")}(e))return!1;if(i===e.getFillerOffset())return!1;const n=t.nodeBefore,s=t.nodeAfter;return!(n instanceof mn||s instanceof mn)}_updateText(t,e){const i=this.domConverter.findCorrespondingDomText(t),n=this.domConverter.viewToDom(t,i.ownerDocument),s=i.data;let o=n.data;const r=e.inlineFillerPosition;if(r&&r.parent==t.parent&&r.offset==t.index&&(o=Ls+o),s!=o){const t=$s(s,o);for(const e of t)"insert"===e.type?i.insertData(e.index,e.values.join("")):i.deleteData(e.index,e.howMany)}}_updateAttrs(t){const e=this.domConverter.mapViewToDom(t);if(!e)return;const i=Array.from(e.attributes).map(t=>t.name),n=t.getAttributeKeys();for(const i of n)e.setAttribute(i,t.getAttribute(i));for(const n of i)t.hasAttribute(n)||e.removeAttribute(n)}_updateChildren(t,e){const i=this.domConverter.mapViewToDom(t);if(!i)return;const n=e.inlineFillerPosition,s=this.domConverter.mapViewToDom(t).childNodes,o=Array.from(this.domConverter.viewChildrenToDom(t,i.ownerDocument,{bind:!0,inlineFillerPosition:n}));n&&n.parent===t&&to(i.ownerDocument,o,n.offset);const r=this._diffNodeLists(s,o);let a=0;const l=new Set;for(const t of r)"insert"===t?(Ys(i,a,o[a]),a++):"delete"===t?(l.add(s[a]),Qs(s[a])):(this._markDescendantTextToSync(this.domConverter.domToView(o[a])),a++);for(const t of l)t.parentNode||this.domConverter.unbindDomElement(t)}_diffNodeLists(t,e){return Js(t=function(t,e){const i=Array.from(t);if(0==i.length||!e)return i;i[i.length-1]==e&&i.pop();return i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t,this._fakeSelectionContainer),e,io.bind(null,this.domConverter.blockFiller))}_findReplaceActions(t,e,i){if(-1===t.indexOf("insert")||-1===t.indexOf("delete"))return t;let n=[],s=[],o=[];const r={equal:0,insert:0,delete:0};for(const a of t)"insert"===a?o.push(i[r.equal+r.insert]):"delete"===a?s.push(e[r.equal+r.delete]):((n=n.concat(Js(s,o,eo).map(t=>"equal"===t?"replace":t))).push("equal"),s=[],o=[]),r[a]++;return n.concat(Js(s,o,eo).map(t=>"equal"===t?"replace":t))}_markDescendantTextToSync(t){if(t)if(t.is("text"))this.markedTexts.add(t);else if(t.is("element"))for(const e of t.getChildren())this._markDescendantTextToSync(e)}_updateSelection(){if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const t=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&t&&(this.selection.isFake?this._updateFakeSelection(t):(this._removeFakeSelection(),this._updateDomSelection(t)))}_updateFakeSelection(t){const e=t.ownerDocument;let i=this._fakeSelectionContainer;i||(this._fakeSelectionContainer=i=e.createElement("div"),Object.assign(i.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),i.textContent=" "),i.parentElement&&i.parentElement==t||t.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const n=e.getSelection(),s=e.createRange();n.removeAllRanges(),s.selectNodeContents(i),n.addRange(s),this.domConverter.bindFakeSelection(i,this.selection)}_updateDomSelection(t){const e=t.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(e))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.focus(),e.collapse(i.parent,i.offset),e.extend(n.parent,n.offset),ms.isGecko&&function(t,e){const i=t.parent;if(i.nodeType!=Node.ELEMENT_NODE||t.offset!=i.childNodes.length-1)return;const n=i.childNodes[t.offset];n&&"BR"==n.tagName&&e.addRange(e.getRangeAt(0))}(n,e)}_domSelectionNeedsUpdate(t){if(!this.domConverter.isDomSelectionCorrect(t))return!0;const e=t&&this.domConverter.domSelectionToView(t);return(!e||!this.selection.isEqual(e))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(e))}_removeDomSelection(){for(const t of this.domDocuments){if(t.getSelection().rangeCount){const e=t.activeElement,i=this.domConverter.mapDomToView(e);e&&i&&t.getSelection().removeAllRanges()}}}_removeFakeSelection(){const t=this._fakeSelectionContainer;t&&t.remove()}_updateFocus(){if(this.isFocused){const t=this.selection.editableElement;t&&this.domConverter.focus(t)}}}function to(t,e,i){const n=e instanceof Array?e:e.childNodes,s=n[i];if(Ns(s))return s.data=Ls+s.data,s;{const s=t.createTextNode(Ls);return Array.isArray(e)?n.splice(i,0,s):Ys(e,i,s),s}}function eo(t,e){return Xs(t)&&Xs(e)&&!Ns(t)&&!Ns(e)&&t.tagName.toLowerCase()===e.tagName.toLowerCase()}function io(t,e,i){return e===i||(Ns(e)&&Ns(i)?e.data===i.data:!(!Ws(e,t)||!Ws(i,t)))}cn(Zs,jn);var no={window:window,document:document};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function so(t){let e=0;for(;t.previousSibling;)t=t.previousSibling,e++;return e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function oo(t){const e=[];for(;t&&t.nodeType!=Node.DOCUMENT_NODE;)e.unshift(t),t=t.parentNode;return e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ro{constructor(t={}){this.blockFiller=t.blockFiller||Bs,this.preElements=["pre"],this.blockElements=["p","div","h1","h2","h3","h4","h5","h6"],this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap}bindFakeSelection(t,e){this._fakeSelectionMapping.set(t,new ns(e))}fakeSelectionToView(t){return this._fakeSelectionMapping.get(t)}bindElements(t,e){this._domToViewMapping.set(t,e),this._viewToDomMapping.set(e,t)}unbindDomElement(t){const e=this._domToViewMapping.get(t);if(e){this._domToViewMapping.delete(t),this._viewToDomMapping.delete(e);for(const e of Array.from(t.childNodes))this.unbindDomElement(e)}}bindDocumentFragments(t,e){this._domToViewMapping.set(t,e),this._viewToDomMapping.set(e,t)}viewToDom(t,e,i={}){if(t.is("text")){const i=this._processDataFromViewText(t);return e.createTextNode(i)}{if(this.mapViewToDom(t))return this.mapViewToDom(t);let n;if(t.is("documentFragment"))n=e.createDocumentFragment(),i.bind&&this.bindDocumentFragments(n,t);else{if(t.is("uiElement"))return n=t.render(e),i.bind&&this.bindElements(n,t),n;n=e.createElement(t.name),i.bind&&this.bindElements(n,t);for(const e of t.getAttributeKeys())n.setAttribute(e,t.getAttribute(e))}if(i.withChildren||void 0===i.withChildren)for(const s of this.viewChildrenToDom(t,e,i))n.appendChild(s);return n}}*viewChildrenToDom(t,e,i={}){const n=t.getFillerOffset&&t.getFillerOffset();let s=0;for(const o of t.getChildren())n===s&&(yield this.blockFiller(e)),yield this.viewToDom(o,e,i),s++;n===s&&(yield this.blockFiller(e))}viewRangeToDom(t){const e=this.viewPositionToDom(t.start),i=this.viewPositionToDom(t.end),n=document.createRange();return n.setStart(e.parent,e.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(t){const e=t.parent;if(e.is("text")){const i=this.findCorrespondingDomText(e);if(!i)return null;let n=t.offset;return zs(i)&&(n+=Ds),{parent:i,offset:n}}{let i,n,s;if(0===t.offset){if(!(i=this.mapViewToDom(e)))return null;s=i.childNodes[0]}else{const e=t.nodeBefore;if(!(n=e.is("text")?this.findCorrespondingDomText(e):this.mapViewToDom(t.nodeBefore)))return null;i=n.parentNode,s=n.nextSibling}if(Ns(s)&&zs(s))return{parent:s,offset:Ds};return{parent:i,offset:n?so(n)+1:0}}}domToView(t,e={}){if(Ws(t,this.blockFiller))return null;const i=this.getParentUIElement(t,this._domToViewMapping);if(i)return i;if(Ns(t)){if(Hs(t))return null;{const e=this._processDataFromDomText(t);return""===e?null:new mn(e)}}if(this.isComment(t))return null;{if(this.mapDomToView(t))return this.mapDomToView(t);let i;if(this.isDocumentFragment(t))i=new Cs,e.bind&&this.bindDocumentFragments(t,i);else{const n=e.keepOriginalCase?t.tagName:t.tagName.toLowerCase();i=new vn(n),e.bind&&this.bindElements(t,i);const s=t.attributes;for(let t=s.length-1;t>=0;t--)i._setAttribute(s[t].name,s[t].value)}if(e.withChildren||void 0===e.withChildren)for(const n of this.domChildrenToView(t,e))i._appendChild(n);return i}}*domChildrenToView(t,e={}){for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i],s=this.domToView(n,e);null!==s&&(yield s)}}domSelectionToView(t){if(1===t.rangeCount){let e=t.getRangeAt(0).startContainer;Ns(e)&&(e=e.parentNode);const i=this.fakeSelectionToView(e);if(i)return i}const e=this.isDomSelectionBackward(t),i=[];for(let e=0;e<t.rangeCount;e++){const n=t.getRangeAt(e),s=this.domRangeToView(n);s&&i.push(s)}return new ns(i,{backward:e})}domRangeToView(t){const e=this.domPositionToView(t.startContainer,t.startOffset),i=this.domPositionToView(t.endContainer,t.endOffset);return e&&i?new ts(e,i):null}domPositionToView(t,e){if(Ws(t,this.blockFiller))return this.domPositionToView(t.parentNode,so(t));const i=this.mapDomToView(t);if(i&&i.is("uiElement"))return Zn._createBefore(i);if(Ns(t)){if(Hs(t))return this.domPositionToView(t.parentNode,so(t));const i=this.findCorrespondingViewText(t);let n=e;return i?(zs(t)&&(n=(n-=Ds)<0?0:n),new Zn(i,n)):null}if(0===e){const e=this.mapDomToView(t);if(e)return new Zn(e,0)}else{const i=t.childNodes[e-1],n=Ns(i)?this.findCorrespondingViewText(i):this.mapDomToView(i);if(n&&n.parent)return new Zn(n.parent,n.index+1)}return null}mapDomToView(t){return this.getParentUIElement(t)||this._domToViewMapping.get(t)}findCorrespondingViewText(t){if(Hs(t))return null;const e=this.getParentUIElement(t);if(e)return e;const i=t.previousSibling;if(i){if(!this.isElement(i))return null;const t=this.mapDomToView(i);if(t){return t.nextSibling instanceof mn?t.nextSibling:null}}else{const e=this.mapDomToView(t.parentNode);if(e){const t=e.getChild(0);return t instanceof mn?t:null}}return null}mapViewToDom(t){return this._viewToDomMapping.get(t)}findCorrespondingDomText(t){const e=t.previousSibling;return e&&this.mapViewToDom(e)?this.mapViewToDom(e).nextSibling:!e&&t.parent&&this.mapViewToDom(t.parent)?this.mapViewToDom(t.parent).childNodes[0]:null}focus(t){const e=this.mapViewToDom(t);if(e&&e.ownerDocument.activeElement!==e){const{scrollX:t,scrollY:i}=no.window,n=[];lo(e,t=>{const{scrollLeft:e,scrollTop:i}=t;n.push([e,i])}),e.focus(),lo(e,t=>{const[e,i]=n.shift();t.scrollLeft=e,t.scrollTop=i}),no.window.scrollTo(t,i)}}isElement(t){return t&&t.nodeType==Node.ELEMENT_NODE}isDocumentFragment(t){return t&&t.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isComment(t){return t&&t.nodeType==Node.COMMENT_NODE}isDomSelectionBackward(t){if(t.isCollapsed)return!1;const e=document.createRange();e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset);const i=e.collapsed;return e.detach(),i}getParentUIElement(t){const e=oo(t);for(e.pop();e.length;){const t=e.pop(),i=this._domToViewMapping.get(t);if(i&&i.is("uiElement"))return i}return null}isDomSelectionCorrect(t){return this._isDomSelectionPositionCorrect(t.anchorNode,t.anchorOffset)&&this._isDomSelectionPositionCorrect(t.focusNode,t.focusOffset)}_isDomSelectionPositionCorrect(t,e){if(Ns(t)&&zs(t)&&e<Ds)return!1;if(this.isElement(t)&&zs(t.childNodes[e]))return!1;const i=this.mapDomToView(t);return!i||!i.is("uiElement")}_processDataFromViewText(t){let e=t.data;if(t.getAncestors().some(t=>this.preElements.includes(t.name)))return e;if(" "==e.charAt(0)){const i=this._getTouchingViewTextNode(t,!1);!(i&&this._nodeEndsWithSpace(i))&&i||(e=" "+e.substr(1))}if(" "==e.charAt(e.length-1)){const i=this._getTouchingViewTextNode(t,!0);" "!=e.charAt(e.length-2)&&i&&" "!=i.data.charAt(0)||(e=e.substr(0,e.length-1)+" ")}return e.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(t){if(t.getAncestors().some(t=>this.preElements.includes(t.name)))return!1;const e=this._processDataFromViewText(t);return" "==e.charAt(e.length-1)}_processDataFromDomText(t){let e=t.data;if(ao(t,this.preElements))return js(t);e=e.replace(/[ \n\t\r]{1,}/g," ");const i=this._getTouchingInlineDomNode(t,!1),n=this._getTouchingInlineDomNode(t,!0),s=this._checkShouldLeftTrimDomText(i),o=this._checkShouldRightTrimDomText(t,n);return s&&(e=e.replace(/^ /,"")),o&&(e=e.replace(/ $/,"")),e=(e=js(new Text(e))).replace(/ \u00A0/g,"  "),(/( |\u00A0)\u00A0$/.test(e)||!n||n.data&&" "==n.data.charAt(0))&&(e=e.replace(/\u00A0$/," ")),s&&(e=e.replace(/^\u00A0/," ")),e}_checkShouldLeftTrimDomText(t){return!t||(!!Ui(t)||/[^\S\u00A0]/.test(t.data.charAt(t.data.length-1)))}_checkShouldRightTrimDomText(t,e){return!e&&!zs(t)}_getTouchingViewTextNode(t,e){const i=new Xn({startPosition:e?Zn._createAfter(t):Zn._createBefore(t),direction:e?"forward":"backward"});for(const t of i){if(t.item.is("containerElement"))return null;if(t.item.is("br"))return null;if(t.item.is("textProxy"))return t.item}return null}_getTouchingInlineDomNode(t,e){if(!t.parentNode)return null;const i=e?"nextNode":"previousNode",n=t.ownerDocument,s=oo(t)[0],o=n.createTreeWalker(s,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:t=>Ns(t)?NodeFilter.FILTER_ACCEPT:"BR"==t.tagName?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});o.currentNode=t;const r=o[i]();if(null!==r){const e=function(t,e){const i=oo(t),n=oo(e);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}(t,r);if(e&&!ao(t,this.blockElements,e)&&!ao(r,this.blockElements,e))return r}return null}}function ao(t,e,i){let n=oo(t);return i&&(n=n.slice(n.indexOf(i)+1)),n.some(t=>t.tagName&&e.includes(t.tagName.toLowerCase()))}function lo(t,e){for(;t&&t!=no.document;)e(t),t=t.parentNode}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function co(t){const e=Object.prototype.toString.apply(t);return"[object Window]"==e||"[object global]"==e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */var ho=Fn({},en,{listenTo(t,...e){if(Xs(t)||co(t)){const i=this._getProxyEmitter(t)||new uo(t);i.attach(...e),t=i}en.listenTo.call(this,t,...e)},stopListening(t,e,i){if(Xs(t)||co(t)){const e=this._getProxyEmitter(t);if(!e)return;t=e}en.stopListening.call(this,t,e,i),t instanceof uo&&t.detach(e)},_getProxyEmitter(t){return e=this,i=fo(t),e[Zi]&&e[Zi][i]?e[Zi][i].emitter:null;var e,i}});class uo{constructor(t){nn(this,fo(t)),this._domNode=t}}function fo(t){return t["data-ck-expando"]||(t["data-ck-expando"]=Qi())}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Fn(uo.prototype,en,{attach(t,e,i={}){if(this._domListeners&&this._domListeners[t])return;const n=this._createDomListener(t,!!i.useCapture);this._domNode.addEventListener(t,n,!!i.useCapture),this._domListeners||(this._domListeners={}),this._domListeners[t]=n},detach(t){let e;!this._domListeners[t]||(e=this._events[t])&&e.callbacks.length||this._domListeners[t].removeListener()},_createDomListener(t,e){const i=e=>{this.fire(t,e)};return i.removeListener=()=>{this._domNode.removeEventListener(t,i,e),delete this._domListeners[t]},i}});class mo{constructor(t){this.view=t,this.document=t.document,this.isEnabled=!1}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}destroy(){this.disable(),this.stopListening()}}cn(mo,ho);var go="__lodash_hash_undefined__";var po=function(t){return this.__data__.set(t,go),this};var wo=function(t){return this.__data__.has(t)};function bo(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Et;++e<i;)this.add(t[e])}bo.prototype.add=bo.prototype.push=po,bo.prototype.has=wo;var _o=bo;var vo=function(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1};var yo=function(t,e){return t.has(e)},ko=1,Ao=2;var Co=function(t,e,i,n,s,o){var r=i&ko,a=t.length,l=e.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(t);if(c&&o.get(e))return c==e;var h=-1,d=!0,u=i&Ao?new _o:void 0;for(o.set(t,e),o.set(e,t);++h<a;){var f=t[h],m=e[h];if(n)var g=r?n(m,f,h,e,t,o):n(f,m,h,t,e,o);if(void 0!==g){if(g)continue;d=!1;break}if(u){if(!vo(e,(function(t,e){if(!yo(u,e)&&(f===t||s(f,t,i,n,o)))return u.push(e)}))){d=!1;break}}else if(f!==m&&!s(f,m,i,n,o)){d=!1;break}}return o.delete(t),o.delete(e),d};var xo=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var Po=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},To=1,Eo=2,So="[object Boolean]",Ro="[object Date]",Oo="[object Error]",Io="[object Map]",Mo="[object Number]",Vo="[object RegExp]",No="[object Set]",Bo="[object String]",Fo="[object Symbol]",Do="[object ArrayBuffer]",Lo="[object DataView]",zo=s?s.prototype:void 0,Ho=zo?zo.valueOf:void 0;var jo=function(t,e,i,n,s,o,r){switch(i){case Lo:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Do:return!(t.byteLength!=e.byteLength||!o(new Ge(t),new Ge(e)));case So:case Ro:case Mo:return T(+t,+e);case Oo:return t.name==e.name&&t.message==e.message;case Vo:case Bo:return t==e+"";case Io:var a=xo;case No:var l=n&To;if(a||(a=Po),t.size!=e.size&&!l)return!1;var c=r.get(t);if(c)return c==e;n|=Eo,r.set(t,e);var h=Co(a(t),a(e),n,s,o,r);return r.delete(t),h;case Fo:if(Ho)return Ho.call(t)==Ho.call(e)}return!1},qo=1,Wo=Object.prototype.hasOwnProperty;var Uo=function(t,e,i,n,s,o){var r=i&qo,a=Ie(t),l=a.length;if(l!=Ie(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:Wo.call(e,h)))return!1}var d=o.get(t);if(d&&o.get(e))return d==e;var u=!0;o.set(t,e),o.set(e,t);for(var f=r;++c<l;){var m=t[h=a[c]],g=e[h];if(n)var p=r?n(g,m,h,e,t,o):n(m,g,h,t,e,o);if(!(void 0===p?m===g||s(m,g,i,n,o):p)){u=!1;break}f||(f="constructor"==h)}if(u&&!f){var w=t.constructor,b=e.constructor;w!=b&&"constructor"in t&&"constructor"in e&&!("function"==typeof w&&w instanceof w&&"function"==typeof b&&b instanceof b)&&(u=!1)}return o.delete(t),o.delete(e),u},$o=1,Go="[object Arguments]",Ko="[object Array]",Jo="[object Object]",Yo=Object.prototype.hasOwnProperty;var Qo=function(t,e,i,n,s,o){var r=$t(t),a=$t(e),l=r?Ko:We(t),c=a?Ko:We(e),h=(l=l==Go?Jo:l)==Jo,d=(c=c==Go?Jo:c)==Jo,u=l==c;if(u&&Object(Gt.a)(t)){if(!Object(Gt.a)(e))return!1;r=!0,h=!1}if(u&&!h)return o||(o=new It),r||se(t)?Co(t,e,i,n,s,o):jo(t,e,l,i,n,s,o);if(!(i&$o)){var f=h&&Yo.call(t,"__wrapped__"),m=d&&Yo.call(e,"__wrapped__");if(f||m){var g=f?t.value():t,p=m?e.value():e;return o||(o=new It),s(g,p,i,n,o)}}return!!u&&(o||(o=new It),Uo(t,e,i,n,s,o))};var Xo=function t(e,i,n,s,o){return e===i||(null==e||null==i||!b(e)&&!b(i)?e!=e&&i!=i:Qo(e,i,n,s,t,o))};var Zo=function(t,e,i){var n=(i="function"==typeof i?i:void 0)?i(t,e):void 0;return void 0===n?Xo(t,e,void 0,i):!!n};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tr extends mo{constructor(t){super(t),this._config={childList:!0,characterData:!0,characterDataOldValue:!0,subtree:!0},this.domConverter=t.domConverter,this.renderer=t._renderer,this._domElements=[],this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(t){this._domElements.push(t),this.isEnabled&&this._mutationObserver.observe(t,this._config)}enable(){super.enable();for(const t of this._domElements)this._mutationObserver.observe(t,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(t){if(0===t.length)return;const e=this.domConverter,i=new Map,n=new Set;for(const i of t)if("childList"===i.type){const t=e.mapDomToView(i.target);if(t&&t.is("uiElement"))continue;t&&!this._isBogusBrMutation(i)&&n.add(t)}for(const s of t){const t=e.mapDomToView(s.target);if((!t||!t.is("uiElement"))&&"characterData"===s.type){const t=e.findCorrespondingViewText(s.target);t&&!n.has(t.parent)?i.set(t,{type:"text",oldText:t.data,newText:js(s.target),node:t}):!t&&zs(s.target)&&n.add(e.mapDomToView(s.target.parentNode))}}const s=[];for(const t of i.values())this.renderer.markToSync("text",t.node),s.push(t);for(const t of n){const i=e.mapViewToDom(t),n=Array.from(t.getChildren()),o=Array.from(e.domChildrenToView(i,{withChildren:!1}));Zo(n,o,a)||(this.renderer.markToSync("children",t),s.push({type:"children",oldChildren:n,newChildren:o,node:t}))}const o=t[0].target.ownerDocument.getSelection();let r=null;if(o&&o.anchorNode){const t=e.domPositionToView(o.anchorNode,o.anchorOffset),i=e.domPositionToView(o.focusNode,o.focusOffset);t&&i&&(r=new ns(t)).setFocus(i)}function a(t,e){if(!Array.isArray(t))return t===e||!(!t.is("text")||!e.is("text"))&&t.data===e.data}this.document.fire("mutations",s,r),this.view.forceRender()}_isBogusBrMutation(t){let e=null;return null===t.nextSibling&&0===t.removedNodes.length&&1==t.addedNodes.length&&(e=this.domConverter.domToView(t.addedNodes[0],{withChildren:!1})),e&&e.is("element","br")}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class er{constructor(t,e,i){this.view=t,this.document=t.document,this.domEvent=e,this.domTarget=e.target,Fn(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ir extends mo{constructor(t){super(t),this.useCapture=!1}observe(t){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach(e=>{this.listenTo(t,e,(t,e)=>{this.isEnabled&&this.onDomEvent(e)},{useCapture:this.useCapture})})}fire(t,e,i){this.isEnabled&&this.document.fire(t,new er(this.view,e,i))}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class nr extends ir{constructor(t){super(t),this.domEventType=["keydown","keyup"]}onDomEvent(t){this.fire(t.type,t,{keyCode:t.keyCode,altKey:t.altKey,ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey,get keystroke(){return bs(this)}})}}var sr=function(){return n.a.Date.now()},or="[object Symbol]";var rr=function(t){return"symbol"==typeof t||b(t)&&g(t)==or},ar=NaN,lr=/^\s+|\s+$/g,cr=/^[-+]0x[0-9a-f]+$/i,hr=/^0b[01]+$/i,dr=/^0o[0-7]+$/i,ur=parseInt;var fr=function(t){if("number"==typeof t)return t;if(rr(t))return ar;if(z(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=z(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(lr,"");var i=hr.test(t);return i||dr.test(t)?ur(t.slice(2),i?2:8):cr.test(t)?ar:+t},mr="Expected a function",gr=Math.max,pr=Math.min;var wr=function(t,e,i){var n,s,o,r,a,l,c=0,h=!1,d=!1,u=!0;if("function"!=typeof t)throw new TypeError(mr);function f(e){var i=n,o=s;return n=s=void 0,c=e,r=t.apply(o,i)}function m(t){var i=t-l;return void 0===l||i>=e||i<0||d&&t-c>=o}function g(){var t=sr();if(m(t))return p(t);a=setTimeout(g,function(t){var i=e-(t-l);return d?pr(i,o-(t-c)):i}(t))}function p(t){return a=void 0,u&&n?f(t):(n=s=void 0,r)}function w(){var t=sr(),i=m(t);if(n=arguments,s=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(g,e),h?f(t):r}(l);if(d)return clearTimeout(a),a=setTimeout(g,e),f(l)}return void 0===a&&(a=setTimeout(g,e)),r}return e=fr(e)||0,z(i)&&(h=!!i.leading,o=(d="maxWait"in i)?gr(fr(i.maxWait)||0,e):o,u="trailing"in i?!!i.trailing:u),w.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},w.flush=function(){return void 0===a?r:p(sr())},w};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class br extends mo{constructor(t){super(t),this._fireSelectionChangeDoneDebounced=wr(t=>this.document.fire("selectionChangeDone",t),200)}observe(){const t=this.document;t.on("keydown",(e,i)=>{t.selection.isFake&&function(t){return t==ws.arrowright||t==ws.arrowleft||t==ws.arrowup||t==ws.arrowdown}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(i.keyCode)&&this.isEnabled&&(i.preventDefault(),this._handleSelectionMove(i.keyCode))},{priority:"lowest"})}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(t){const e=this.document.selection,i=new ns(e.getRanges(),{backward:e.isBackward,fake:!1});t!=ws.arrowleft&&t!=ws.arrowup||i.setTo(i.getFirstPosition()),t!=ws.arrowright&&t!=ws.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:e,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}class _r extends mo{constructor(t){super(t),this.mutationObserver=t.getObserver(tr),this.selection=this.document.selection,this.domConverter=t.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=wr(t=>this.document.fire("selectionChangeDone",t),200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._loopbackCounter=0}observe(t){const e=t.ownerDocument;this._documents.has(e)||(this.listenTo(e,"selectionchange",()=>{this._handleSelectionChange(e)}),this._documents.add(e))}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionChange(t){if(!this.isEnabled||!this.document.isFocused&&!this.document.isReadOnly)return;this.mutationObserver.flush();const e=t.defaultView.getSelection(),i=this.domConverter.domSelectionToView(e);if(!(this.selection.isEqual(i)&&this.domConverter.isDomSelectionCorrect(e)||++this._loopbackCounter>60))if(this.selection.isSimilar(i))this.view.forceRender();else{const t={oldSelection:this.selection,newSelection:i,domSelection:e};this.document.fire("selectionChange",t),this._fireSelectionChangeDoneDebounced(t)}}_clearInfiniteLoop(){this._loopbackCounter=0}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vr extends ir{constructor(t){super(t),this.domEventType=["focus","blur"],this.useCapture=!0;const e=this.document;e.on("focus",()=>{e.isFocused=!0,this._renderTimeoutId=setTimeout(()=>t.forceRender(),50)}),e.on("blur",(i,n)=>{const s=e.selection.editableElement;null!==s&&s!==n.target||(e.isFocused=!1,t.forceRender())})}onDomEvent(t){this.fire(t.type,t)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yr extends ir{constructor(t){super(t),this.domEventType=["compositionstart","compositionupdate","compositionend"];const e=this.document;e.on("compositionstart",()=>{e.isComposing=!0}),e.on("compositionend",()=>{e.isComposing=!1})}onDomEvent(t){this.fire(t.type,t)}}
/**
 * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */class kr extends ir{constructor(t){super(t),this.domEventType=["beforeinput"]}onDomEvent(t){this.fire(t.type,t)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ar(t){return"[object Range]"==Object.prototype.toString.apply(t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Cr(t){const e=t.ownerDocument.defaultView.getComputedStyle(t);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-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const xr=["top","right","bottom","left","width","height"];class Pr{constructor(t){const e=Ar(t);if(Object.defineProperty(this,"_source",{value:t._source||t,writable:!0,enumerable:!1}),Ui(t)||e)Tr(this,e?Pr.getDomRangeRects(t)[0]:t.getBoundingClientRect());else if(co(t)){const{innerWidth:e,innerHeight:i}=t;Tr(this,{top:0,right:e,bottom:i,left:0,width:e,height:i})}else Tr(this,t)}clone(){return new Pr(this)}moveTo(t,e){return this.top=e,this.right=t+this.width,this.bottom=e+this.height,this.left=t,this}moveBy(t,e){return this.top+=e,this.right+=t,this.left+=t,this.bottom+=e,this}getIntersection(t){const e={top:Math.max(this.top,t.top),right:Math.min(this.right,t.right),bottom:Math.min(this.bottom,t.bottom),left:Math.max(this.left,t.left)};return e.width=e.right-e.left,e.height=e.bottom-e.top,e.width<0||e.height<0?null:new Pr(e)}getIntersectionArea(t){const e=this.getIntersection(t);return e?e.getArea():0}getArea(){return this.width*this.height}getVisible(){const t=this._source;let e=this.clone();if(!Er(t)){let i=t.parentNode||t.commonAncestorContainer;for(;i&&!Er(i);){const t=new Pr(i),n=e.getIntersection(t);if(!n)return null;n.getArea()<e.getArea()&&(e=n),i=i.parentNode}}return e}isEqual(t){for(const e of xr)if(this[e]!==t[e])return!1;return!0}contains(t){const e=this.getIntersection(t);return!(!e||!e.isEqual(t))}excludeScrollbarsAndBorders(){const t=this._source;let e,i;if(co(t))e=t.innerWidth-t.document.documentElement.clientWidth,i=t.innerHeight-t.document.documentElement.clientHeight;else{const n=Cr(this._source);e=t.offsetWidth-t.clientWidth,i=t.offsetHeight-t.clientHeight,this.moveBy(n.left,n.top)}return this.width-=e,this.right-=e,this.height-=i,this.bottom-=i,this}static getDomRangeRects(t){const e=[],i=Array.from(t.getClientRects());if(i.length)for(const t of i)e.push(new Pr(t));else{let i=t.startContainer;Ns(i)&&(i=i.parentNode);const n=new Pr(i.getBoundingClientRect());n.right=n.left,n.width=0,e.push(n)}return e}}function Tr(t,e){for(const i of xr)t[i]=e[i]}function Er(t){return!!Ui(t)&&t===t.ownerDocument.body}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Sr({target:t,viewportOffset:e=0}){const i=Br(t);let n=i,s=null;for(;n;){let o;Or(o=Fr(n==i?t:s),()=>Dr(t,n));const r=Dr(t,n);if(Rr(n,r,e),n.parent!=n){if(s=n.frameElement,n=n.parent,!s)return}else n=null}}function Rr(t,e,i){const n=e.clone().moveBy(0,i),s=e.clone().moveBy(0,-i),o=new Pr(t).excludeScrollbarsAndBorders();if(![s,n].every(t=>o.contains(t))){let{scrollX:r,scrollY:a}=t;Mr(s,o)?a-=o.top-e.top+i:Ir(n,o)&&(a+=e.bottom-o.bottom+i),Vr(e,o)?r-=o.left-e.left+i:Nr(e,o)&&(r+=e.right-o.right+i),t.scrollTo(r,a)}}function Or(t,e){const i=Br(t);let n,s;for(;t!=i.document.body;)s=e(),(n=new Pr(t).excludeScrollbarsAndBorders()).contains(s)||(Mr(s,n)?t.scrollTop-=n.top-s.top:Ir(s,n)&&(t.scrollTop+=s.bottom-n.bottom),Vr(s,n)?t.scrollLeft-=n.left-s.left:Nr(s,n)&&(t.scrollLeft+=s.right-n.right)),t=t.parentNode}function Ir(t,e){return t.bottom>e.bottom}function Mr(t,e){return t.top<e.top}function Vr(t,e){return t.left<e.left}function Nr(t,e){return t.right>e.right}function Br(t){return Ar(t)?t.startContainer.ownerDocument.defaultView:t.ownerDocument.defaultView}function Fr(t){if(Ar(t)){let e=t.commonAncestorContainer;return Ns(e)&&(e=e.parentNode),e}return t.parentNode}function Dr(t,e){const i=Br(t),n=new Pr(t);if(i===e)return n;{let t=i;for(;t!=e;){const e=t.frameElement,i=new Pr(e).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),t=t.parent}}return n}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Object.assign({},{scrollViewportToShowTarget:Sr,scrollAncestorsToShowTarget:function(t){Or(Fr(t),()=>new Pr(t))}});class Lr{constructor(){this.document=new rs,this.domConverter=new ro,this.domRoots=new Map,this.set("isRenderingInProgress",!1),this._renderer=new Zs(this.domConverter,this.document.selection),this._renderer.bind("isFocused").to(this.document),this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this._writer=new xs(this.document),this.addObserver(tr),this.addObserver(_r),this.addObserver(vr),this.addObserver(nr),this.addObserver(br),this.addObserver(yr),ms.isAndroid&&this.addObserver(kr),this.document.on("keydown",Us),ks(this),this.on("render",()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1}),this.listenTo(this.document.selection,"change",()=>{this._hasChangedSinceTheLastRendering=!0})}attachDomRoot(t,e="main"){const i=this.document.getRoot(e);i._name=t.tagName.toLowerCase();const n={};for(const{name:e,value:s}of Array.from(t.attributes))n[e]=s,"class"===e?this._writer.addClass(s.split(" "),i):this._writer.setAttribute(e,s,i);this._initialDomRootAttributes.set(t,n);const s=()=>{this._writer.setAttribute("contenteditable",!i.isReadOnly,i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};s(),this.domRoots.set(e,t),this.domConverter.bindElements(t,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(t.ownerDocument),i.on("change:children",(t,e)=>this._renderer.markToSync("children",e)),i.on("change:attributes",(t,e)=>this._renderer.markToSync("attributes",e)),i.on("change:text",(t,e)=>this._renderer.markToSync("text",e)),i.on("change:isReadOnly",()=>this.change(s)),i.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const i of this._observers.values())i.observe(t,e)}detachDomRoot(t){const e=this.domRoots.get(t);Array.from(e.attributes).forEach(({name:t})=>e.removeAttribute(t));const i=this._initialDomRootAttributes.get(e);for(const t in i)e.setAttribute(t,i[t]);this.domRoots.delete(t),this.domConverter.unbindDomElement(e)}getDomRoot(t="main"){return this.domRoots.get(t)}addObserver(t){let e=this._observers.get(t);if(e)return e;e=new t(this),this._observers.set(t,e);for(const[t,i]of this.domRoots)e.observe(i,t);return e.enable(),e}getObserver(t){return this._observers.get(t)}disableObservers(){for(const t of this._observers.values())t.disable()}enableObservers(){for(const t of this._observers.values())t.enable()}scrollToTheSelection(){const t=this.document.selection.getFirstRange();t&&Sr({target:this.domConverter.viewRangeToDom(t),viewportOffset:20})}focus(){if(!this.document.isFocused){const t=this.document.selection.editableElement;t&&(this.domConverter.focus(t),this.forceRender())}}change(t){if(this.isRenderingInProgress||this._postFixersInProgress)throw new Ki.b("cannot-change-view-tree: Attempting to make changes to the view when it is in an incorrect state: rendering or post-fixers are in progress. This may cause some unexpected behavior and inconsistency between the DOM and the view.",this);if(this._ongoingChange)return t(this._writer);this._ongoingChange=!0;const e=t(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}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.change(()=>{})}destroy(){for(const t of this._observers.values())t.destroy();this.document.destroy(),this.stopListening()}createPositionAt(t,e){return Zn._createAt(t,e)}createPositionAfter(t){return Zn._createAfter(t)}createPositionBefore(t){return Zn._createBefore(t)}createRange(t,e){return new ts(t,e)}createRangeOn(t){return ts._createOn(t)}createRangeIn(t){return ts._createIn(t)}createSelection(t,e,i){return new ns(t,e,i)}_disableRendering(t){this._renderingDisabled=t,0==t&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function zr(t){return x(t)?pn(t):new Map(t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */cn(Lr,jn);class Hr{constructor(t){this.parent=null,this._attrs=zr(t)}get index(){let t;if(!this.parent)return null;if(null===(t=this.parent.getChildIndex(this)))throw new Ki.b("model-node-not-found-in-parent: The node's parent does not contain this node.",this);return t}get startOffset(){let t;if(!this.parent)return null;if(null===(t=this.parent.getChildStartOffset(this)))throw new Ki.b("model-node-not-found-in-parent: The node's parent does not contain this node.",this);return t}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const t=this.index;return null!==t&&this.parent.getChild(t+1)||null}get previousSibling(){const t=this.index;return null!==t&&this.parent.getChild(t-1)||null}get root(){let t=this;for(;t.parent;)t=t.parent;return t}get document(){return this.root==this?null:this.root.document||null}getPath(){const t=[];let e=this;for(;e.parent;)t.unshift(e.startOffset),e=e.parent;return t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let i=t.includeSelf?this:this.parent;for(;i;)e[t.parentFirst?"push":"unshift"](i),i=i.parent;return e}getCommonAncestor(t,e={}){const i=this.getAncestors(e),n=t.getAncestors(e);let s=0;for(;i[s]==n[s]&&i[s];)s++;return 0===s?null:i[s-1]}isBefore(t){if(this==t)return!1;if(this.root!==t.root)return!1;const e=this.getPath(),i=t.getPath(),n=hn(e,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return e[n]<i[n]}}isAfter(t){return this!=t&&(this.root===t.root&&!this.isBefore(t))}hasAttribute(t){return this._attrs.has(t)}getAttribute(t){return this._attrs.get(t)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){const t={};return this._attrs.size&&(t.attributes=Array.from(this._attrs).reduce((t,e)=>(t[e[0]]=e[1],t),{})),t}is(t){return"node"==t||"model:node"==t}_clone(){return new Hr(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(t,e){this._attrs.set(t,e)}_setAttributesTo(t){this._attrs=zr(t)}_removeAttribute(t){return this._attrs.delete(t)}_clearAttributes(){this._attrs.clear()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jr extends Hr{constructor(t,e){super(e),this._data=t||""}get offsetSize(){return this.data.length}get data(){return this._data}is(t){return"text"==t||"model:text"==t||super.is(t)}toJSON(){const t=super.toJSON();return t.data=this.data,t}_clone(){return new jr(this.data,this.getAttributes())}static fromJSON(t){return new jr(t.data,t.attributes)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qr{constructor(t,e,i){if(this.textNode=t,e<0||e>t.offsetSize)throw new Ki.b("model-textproxy-wrong-offsetintext: Given offsetInText value is incorrect.",this);if(i<0||e+i>t.offsetSize)throw new Ki.b("model-textproxy-wrong-length: Given length value is incorrect.",this);this.data=t.data.substring(e,e+i),this.offsetInText=e}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}is(t){return"textProxy"==t||"model:textProxy"==t}getPath(){const t=this.textNode.getPath();return t.length>0&&(t[t.length-1]+=this.offsetInText),t}getAncestors(t={includeSelf:!1,parentFirst:!1}){const e=[];let i=t.includeSelf?this:this.parent;for(;i;)e[t.parentFirst?"push":"unshift"](i),i=i.parent;return e}hasAttribute(t){return this.textNode.hasAttribute(t)}getAttribute(t){return this.textNode.getAttribute(t)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wr{constructor(t){this._nodes=[],t&&this._insertNodes(0,t)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._nodes.reduce((t,e)=>t+e.offsetSize,0)}getNode(t){return this._nodes[t]||null}getNodeIndex(t){const e=this._nodes.indexOf(t);return-1==e?null:e}getNodeStartOffset(t){const e=this.getNodeIndex(t);return null===e?null:this._nodes.slice(0,e).reduce((t,e)=>t+e.offsetSize,0)}indexToOffset(t){if(t==this._nodes.length)return this.maxOffset;const e=this._nodes[t];if(!e)throw new Ki.b("model-nodelist-index-out-of-bounds: Given index cannot be found in the node list.",this);return this.getNodeStartOffset(e)}offsetToIndex(t){let e=0;for(const i of this._nodes){if(t>=e&&t<e+i.offsetSize)return this.getNodeIndex(i);e+=i.offsetSize}if(e!=t)throw new Ki.b("model-nodelist-offset-out-of-bounds: Given offset cannot be found in the node list.",this,{offset:t,nodeList:this});return this.length}_insertNodes(t,e){for(const t of e)if(!(t instanceof Hr))throw new Ki.b("model-nodelist-insertNodes-not-node: Trying to insert an object which is not a Node instance.",this);this._nodes.splice(t,0,...e)}_removeNodes(t,e=1){return this._nodes.splice(t,e)}toJSON(){return this._nodes.map(t=>t.toJSON())}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ur extends Hr{constructor(t,e,i){super(e),this.name=t,this._children=new Wr,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}is(t,e=null){const i=t.replace(/^model:/,"");return e?"element"==i&&e==this.name:"element"==i||i==this.name||super.is(t)}getChild(t){return this._children.getNode(t)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(t){return this._children.getNodeIndex(t)}getChildStartOffset(t){return this._children.getNodeStartOffset(t)}offsetToIndex(t){return this._children.offsetToIndex(t)}getNodeByPath(t){let e=this;for(const i of t)e=e.getChild(e.offsetToIndex(i));return e}toJSON(){const t=super.toJSON();if(t.name=this.name,this._children.length>0){t.children=[];for(const e of this._children)t.children.push(e.toJSON())}return t}_clone(t=!1){const e=t?Array.from(this._children).map(t=>t._clone(!0)):null;return new Ur(this.name,this.getAttributes(),e)}_appendChild(t){this._insertChild(this.childCount,t)}_insertChild(t,e){const i=function(t){if("string"==typeof t)return[new jr(t)];wn(t)||(t=[t]);return Array.from(t).map(t=>"string"==typeof t?new jr(t):t instanceof qr?new jr(t.data,t.getAttributes()):t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);for(const t of i)null!==t.parent&&t._remove(),t.parent=this;this._children._insertNodes(t,i)}_removeChildren(t,e=1){const i=this._children._removeNodes(t,e);for(const t of i)t.parent=null;return i}static fromJSON(t){let e=null;if(t.children){e=[];for(const i of t.children)i.name?e.push(Ur.fromJSON(i)):e.push(jr.fromJSON(i))}return new Ur(t.name,t.attributes,e)}}class $r{constructor(t={}){if(!t.boundaries&&!t.startPosition)throw new Ki.b("model-tree-walker-no-start-position: Neither boundaries nor starting position have been defined.",null);const e=t.direction||"forward";if("forward"!=e&&"backward"!=e)throw new Ki.b("model-tree-walker-unknown-direction: Only `backward` and `forward` direction allowed.",t,{direction:e});this.direction=e,this.boundaries=t.boundaries||null,t.startPosition?this.position=t.startPosition.clone():this.position=Jr._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!t.singleCharacters,this.shallow=!!t.shallow,this.ignoreElementEnd=!!t.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}skip(t){let e,i,n,s;do{n=this.position,s=this._visitedParent,({done:e,value:i}=this.next())}while(!e&&t(i));e||(this.position=n,this._visitedParent=s)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const t=this.position,e=this.position.clone(),i=this._visitedParent;if(null===i.parent&&e.offset===i.maxOffset)return{done:!0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0};const n=e.textNode?e.textNode:e.nodeAfter;if(n instanceof Ur)return this.shallow?e.offset++:(e.path.push(0),this._visitedParent=n),this.position=e,Gr("elementStart",n,t,e,1);if(n instanceof jr){let s;if(this.singleCharacters)s=1;else{let t=n.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offset<t&&(t=this.boundaries.end.offset),s=t-e.offset}const o=e.offset-n.startOffset,r=new qr(n,o,s);return e.offset+=s,this.position=e,Gr("text",r,t,e,s)}return e.path.pop(),e.offset++,this.position=e,this._visitedParent=i.parent,this.ignoreElementEnd?this._next():Gr("elementEnd",i,t,e)}_previous(){const t=this.position,e=this.position.clone(),i=this._visitedParent;if(null===i.parent&&0===e.offset)return{done:!0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0};const n=e.textNode?e.textNode:e.nodeBefore;if(n instanceof Ur)return e.offset--,this.shallow?(this.position=e,Gr("elementStart",n,t,e,1)):(e.path.push(n.maxOffset),this.position=e,this._visitedParent=n,this.ignoreElementEnd?this._previous():Gr("elementEnd",n,t,e));if(n instanceof jr){let s;if(this.singleCharacters)s=1;else{let t=n.startOffset;this._boundaryStartParent==i&&this.boundaries.start.offset>t&&(t=this.boundaries.start.offset),s=e.offset-t}const o=e.offset-n.startOffset,r=new qr(n,o-s,s);return e.offset-=s,this.position=e,Gr("text",r,t,e,s)}return e.path.pop(),this.position=e,this._visitedParent=i.parent,Gr("elementStart",i,t,e,1)}}function Gr(t,e,i,n,s){return{done:!1,value:{type:t,item:e,previousPosition:i,nextPosition:n,length:s}}}var Kr=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jr{constructor(t,e,i="toNone"){if(!t.is("element")&&!t.is("documentFragment"))throw new Ki.b("model-position-root-invalid: Position root invalid.",t);if(!(e instanceof Array)||0===e.length)throw new Ki.b("model-position-path-incorrect-format: Position path must be an array with at least one item.",t,{path:e});e=t.getPath().concat(e),t=t.root,this.root=t,this.path=e,this.stickiness=i}get offset(){return Kr(this.path)}set offset(t){this.path[this.path.length-1]=t}get parent(){let t=this.root;for(let e=0;e<this.path.length-1;e++)if(!(t=t.getChild(t.offsetToIndex(this.path[e]))))throw new Ki.b("model-position-path-incorrect: The position's path is incorrect.",this,{position:this});if(t.is("text"))throw new Ki.b("model-position-path-incorrect: The position's path is incorrect.",this,{position:this});return t}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){const t=this.parent.getChild(this.index);return t instanceof jr&&t.startOffset<this.offset?t:null}get nodeAfter(){return null===this.textNode?this.parent.getChild(this.index):null}get nodeBefore(){return null===this.textNode?this.parent.getChild(this.index-1):null}get isAtStart(){return 0===this.offset}get isAtEnd(){return this.offset==this.parent.maxOffset}compareWith(t){if(this.root!=t.root)return"different";const e=hn(this.path,t.path);switch(e){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[e]<t.path[e]?"before":"after"}}getLastMatchingPosition(t,e={}){e.startPosition=this;const i=new $r(e);return i.skip(t),i.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonPath(t){if(this.root!=t.root)return[];const e=hn(this.path,t.path),i="string"==typeof e?Math.min(this.path.length,t.path.length):e;return this.path.slice(0,i)}getCommonAncestor(t){const e=this.getAncestors(),i=t.getAncestors();let n=0;for(;e[n]==i[n]&&e[n];)n++;return 0===n?null:e[n-1]}getShiftedBy(t){const e=this.clone(),i=e.offset+t;return e.offset=i<0?0:i,e}isAfter(t){return"after"==this.compareWith(t)}isBefore(t){return"before"==this.compareWith(t)}isEqual(t){return"same"==this.compareWith(t)}isTouching(t){let e=null,i=null;switch(this.compareWith(t)){case"same":return!0;case"before":e=Jr._createAt(this),i=Jr._createAt(t);break;case"after":e=Jr._createAt(t),i=Jr._createAt(this);break;default:return!1}let n=e.parent;for(;e.path.length+i.path.length;){if(e.isEqual(i))return!0;if(e.path.length>i.path.length){if(e.offset!==n.maxOffset)return!1;e.path=e.path.slice(0,-1),n=n.parent,e.offset++}else{if(0!==i.offset)return!1;i.path=i.path.slice(0,-1)}}}is(t){return"position"==t||"model:position"==t}hasSameParentAs(t){if(this.root!==t.root)return!1;return"same"==hn(this.getParentPath(),t.getParentPath())}getTransformedByOperation(t){let e;switch(t.type){case"insert":e=this._getTransformedByInsertOperation(t);break;case"move":case"remove":case"reinsert":e=this._getTransformedByMoveOperation(t);break;case"split":e=this._getTransformedBySplitOperation(t);break;case"merge":e=this._getTransformedByMergeOperation(t);break;default:e=Jr._createAt(this)}return e}_getTransformedByInsertOperation(t){return this._getTransformedByInsertion(t.position,t.howMany)}_getTransformedByMoveOperation(t){return this._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany)}_getTransformedBySplitOperation(t){const e=t.movedRange;return e.containsPosition(this)||e.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(t.splitPosition,t.moveTargetPosition):t.graveyardPosition?this._getTransformedByMove(t.graveyardPosition,t.insertionPosition,1):this._getTransformedByInsertion(t.insertionPosition,1)}_getTransformedByMergeOperation(t){const e=t.movedRange;let i;return e.containsPosition(this)||e.start.isEqual(this)?(i=this._getCombined(t.sourcePosition,t.targetPosition),t.sourcePosition.isBefore(t.targetPosition)&&(i=i._getTransformedByDeletion(t.deletionPosition,1))):i=this.isEqual(t.deletionPosition)?Jr._createAt(t.deletionPosition):this._getTransformedByMove(t.deletionPosition,t.graveyardPosition,1),i}_getTransformedByDeletion(t,e){const i=Jr._createAt(this);if(this.root!=t.root)return i;if("same"==hn(t.getParentPath(),this.getParentPath())){if(t.offset<this.offset){if(t.offset+e>this.offset)return null;i.offset-=e}}else if("prefix"==hn(t.getParentPath(),this.getParentPath())){const n=t.path.length-1;if(t.offset<=this.path[n]){if(t.offset+e>this.path[n])return null;i.path[n]-=e}}return i}_getTransformedByInsertion(t,e){const i=Jr._createAt(this);if(this.root!=t.root)return i;if("same"==hn(t.getParentPath(),this.getParentPath()))(t.offset<this.offset||t.offset==this.offset&&"toPrevious"!=this.stickiness)&&(i.offset+=e);else if("prefix"==hn(t.getParentPath(),this.getParentPath())){const n=t.path.length-1;t.offset<=this.path[n]&&(i.path[n]+=e)}return i}_getTransformedByMove(t,e,i){if(e=e._getTransformedByDeletion(t,i),t.isEqual(e))return Jr._createAt(this);const n=this._getTransformedByDeletion(t,i);return null===n||t.isEqual(this)&&"toNext"==this.stickiness||t.getShiftedBy(i).isEqual(this)&&"toPrevious"==this.stickiness?this._getCombined(t,e):n._getTransformedByInsertion(e,i)}_getCombined(t,e){const i=t.path.length-1,n=Jr._createAt(e);return n.stickiness=this.stickiness,n.offset=n.offset+this.path[i]-t.offset,n.path=n.path.concat(this.path.slice(i+1)),n}toJSON(){return{root:this.root.toJSON(),path:Array.from(this.path),stickiness:this.stickiness}}clone(){return new this.constructor(this.root,this.path,this.stickiness)}static _createAt(t,e,i="toNone"){if(t instanceof Jr)return new Jr(t.root,t.path,t.stickiness);{const n=t;if("end"==e)e=n.maxOffset;else{if("before"==e)return this._createBefore(n,i);if("after"==e)return this._createAfter(n,i);if(0!==e&&!e)throw new Ki.b("model-createPositionAt-offset-required: Model#createPositionAt() requires the offset when the first parameter is a model item.",[this,t])}if(!n.is("element")&&!n.is("documentFragment"))throw new Ki.b("model-position-parent-incorrect: Position parent have to be a element or document fragment.",[this,t]);const s=n.getPath();return s.push(e),new this(n.root,s,i)}}static _createAfter(t,e){if(!t.parent)throw new Ki.b("model-position-after-root: You cannot make a position after root.",[this,t],{root:t});return this._createAt(t.parent,t.endOffset,e)}static _createBefore(t,e){if(!t.parent)throw new Ki.b("model-position-before-root: You cannot make a position before root.",t,{root:t});return this._createAt(t.parent,t.startOffset,e)}static fromJSON(t,e){if("$graveyard"===t.root){const i=new Jr(e.graveyard,t.path);return i.stickiness=t.stickiness,i}if(!e.getRoot(t.root))throw new Ki.b("model-position-fromjson-no-root: Cannot create position for document. Root with specified name does not exist.",e,{rootName:t.root});return new Jr(e.getRoot(t.root),t.path,t.stickiness)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Yr{constructor(t,e=null){this.start=Jr._createAt(t),this.end=e?Jr._createAt(e):Jr._createAt(t),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new $r({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return"same"==hn(this.start.getParentPath(),this.end.getParentPath())}get root(){return this.start.root}containsPosition(t){return t.isAfter(this.start)&&t.isBefore(this.end)}containsRange(t,e=!1){t.isCollapsed&&(e=!1);const i=this.containsPosition(t.start)||e&&this.start.isEqual(t.start),n=this.containsPosition(t.end)||e&&this.end.isEqual(t.end);return i&&n}containsItem(t){const e=Jr._createBefore(t);return this.containsPosition(e)||this.start.isEqual(e)}is(t){return"range"==t||"model:range"==t}isEqual(t){return this.start.isEqual(t.start)&&this.end.isEqual(t.end)}isIntersecting(t){return this.start.isBefore(t.end)&&this.end.isAfter(t.start)}getDifference(t){const e=[];return this.isIntersecting(t)?(this.containsPosition(t.start)&&e.push(new Yr(this.start,t.start)),this.containsPosition(t.end)&&e.push(new Yr(t.end,this.end))):e.push(new Yr(this.start,this.end)),e}getIntersection(t){if(this.isIntersecting(t)){let e=this.start,i=this.end;return this.containsPosition(t.start)&&(e=t.start),this.containsPosition(t.end)&&(i=t.end),new Yr(e,i)}return null}getMinimalFlatRanges(){const t=[],e=this.start.getCommonPath(this.end).length,i=Jr._createAt(this.start);let n=i.parent;for(;i.path.length>e+1;){const e=n.maxOffset-i.offset;0!==e&&t.push(new Yr(i,i.getShiftedBy(e))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const e=this.end.path[i.path.length-1],n=e-i.offset;0!==n&&t.push(new Yr(i,i.getShiftedBy(n))),i.offset=e,i.path.push(0)}return t}getWalker(t={}){return t.boundaries=this,new $r(t)}*getItems(t={}){t.boundaries=this,t.ignoreElementEnd=!0;const e=new $r(t);for(const t of e)yield t.item}*getPositions(t={}){t.boundaries=this;const e=new $r(t);yield e.position;for(const t of e)yield t.nextPosition}getTransformedByOperation(t){switch(t.type){case"insert":return this._getTransformedByInsertOperation(t);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(t);case"split":return[this._getTransformedBySplitOperation(t)];case"merge":return[this._getTransformedByMergeOperation(t)]}return[new Yr(this.start,this.end)]}getTransformedByOperations(t){const e=[new Yr(this.start,this.end)];for(const i of t)for(let t=0;t<e.length;t++){const n=e[t].getTransformedByOperation(i);e.splice(t,1,...n),t+=n.length-1}for(let t=0;t<e.length;t++){const i=e[t];for(let n=t+1;n<e.length;n++){const t=e[n];(i.containsRange(t)||t.containsRange(i)||i.isEqual(t))&&e.splice(n,1)}}return e}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}clone(){return new this.constructor(this.start,this.end)}_getTransformedByInsertOperation(t,e=!1){return this._getTransformedByInsertion(t.position,t.howMany,e)}_getTransformedByMoveOperation(t,e=!1){const i=t.sourcePosition,n=t.howMany,s=t.targetPosition;return this._getTransformedByMove(i,s,n,e)}_getTransformedBySplitOperation(t){const e=this.start._getTransformedBySplitOperation(t);let i=this.end._getTransformedBySplitOperation(t);return this.end.isEqual(t.insertionPosition)&&(i=this.end.getShiftedBy(1)),e.root!=i.root&&(i=this.end.getShiftedBy(-1)),new Yr(e,i)}_getTransformedByMergeOperation(t){if(this.start.isEqual(t.targetPosition)&&this.end.isEqual(t.deletionPosition))return new Yr(this.start);let e=this.start._getTransformedByMergeOperation(t),i=this.end._getTransformedByMergeOperation(t);return e.root!=i.root&&(i=this.end.getShiftedBy(-1)),e.isAfter(i)?(t.sourcePosition.isBefore(t.targetPosition)?(e=Jr._createAt(i)).offset=0:(t.deletionPosition.isEqual(e)||(i=t.deletionPosition),e=t.targetPosition),new Yr(e,i)):new Yr(e,i)}_getTransformedByInsertion(t,e,i=!1){if(i&&this.containsPosition(t))return[new Yr(this.start,t),new Yr(t.getShiftedBy(e),this.end._getTransformedByInsertion(t,e))];{const i=new Yr(this.start,this.end);return i.start=i.start._getTransformedByInsertion(t,e),i.end=i.end._getTransformedByInsertion(t,e),[i]}}_getTransformedByMove(t,e,i,n=!1){if(this.isCollapsed){const n=this.start._getTransformedByMove(t,e,i);return[new Yr(n)]}const s=Yr._createFromPositionAndShift(t,i),o=e._getTransformedByDeletion(t,i);if(this.containsPosition(e)&&!n&&(s.containsPosition(this.start)||s.containsPosition(this.end))){const n=this.start._getTransformedByMove(t,e,i),s=this.end._getTransformedByMove(t,e,i);return[new Yr(n,s)]}let r;const a=this.getDifference(s);let l=null;const c=this.getIntersection(s);if(1==a.length?l=new Yr(a[0].start._getTransformedByDeletion(t,i),a[0].end._getTransformedByDeletion(t,i)):2==a.length&&(l=new Yr(this.start,this.end._getTransformedByDeletion(t,i))),r=l?l._getTransformedByInsertion(o,i,null!==c||n):[],c){const t=new Yr(c.start._getCombined(s.start,o),c.end._getCombined(s.start,o));2==r.length?r.splice(1,0,t):r.push(t)}return r}_getTransformedByDeletion(t,e){let i=this.start._getTransformedByDeletion(t,e),n=this.end._getTransformedByDeletion(t,e);return null==i&&null==n?null:(null==i&&(i=t),null==n&&(n=t),new Yr(i,n))}static _createFromPositionAndShift(t,e){const i=t,n=t.getShiftedBy(e);return e>0?new this(i,n):new this(n,i)}static _createIn(t){return new this(Jr._createAt(t,0),Jr._createAt(t,t.maxOffset))}static _createOn(t){return this._createFromPositionAndShift(Jr._createBefore(t),t.offsetSize)}static _createFromRanges(t){if(0===t.length)throw new Ki.b("range-create-from-ranges-empty-array: At least one range has to be passed.",null);if(1==t.length)return t[0].clone();const e=t[0];t.sort((t,e)=>t.start.isAfter(e.start)?1:-1);const i=t.indexOf(e),n=new this(e.start,e.end);if(i>0)for(let e=i-1;t[e].end.isEqual(n.start);e++)n.start=Jr._createAt(t[e].start);for(let e=i+1;e<t.length&&t[e].start.isEqual(n.end);e++)n.end=Jr._createAt(t[e].end);return n}static fromJSON(t,e){return new this(Jr.fromJSON(t.start,e),Jr.fromJSON(t.end,e))}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Qr{constructor(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._viewToModelLengthCallbacks=new Map,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this.on("modelToViewPosition",(t,e)=>{if(e.viewPosition)return;const i=this._modelToViewMapping.get(e.modelPosition.parent);e.viewPosition=this._findPositionIn(i,e.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(t,e)=>{if(e.modelPosition)return;const i=this.findMappedViewAncestor(e.viewPosition),n=this._viewToModelMapping.get(i),s=this._toModelOffset(e.viewPosition.parent,e.viewPosition.offset,i);e.modelPosition=Jr._createAt(n,s)},{priority:"low"})}bindElements(t,e){this._modelToViewMapping.set(t,e),this._viewToModelMapping.set(e,t)}unbindViewElement(t){const e=this.toModelElement(t);if(this._viewToModelMapping.delete(t),this._elementToMarkerNames.has(t))for(const e of this._elementToMarkerNames.get(t))this._unboundMarkerNames.add(e);this._modelToViewMapping.get(e)==t&&this._modelToViewMapping.delete(e)}unbindModelElement(t){const e=this.toViewElement(t);this._modelToViewMapping.delete(t),this._viewToModelMapping.get(e)==t&&this._viewToModelMapping.delete(e)}bindElementToMarker(t,e){const i=this._markerNameToElements.get(e)||new Set;i.add(t);const n=this._elementToMarkerNames.get(t)||new Set;n.add(e),this._markerNameToElements.set(e,i),this._elementToMarkerNames.set(t,n)}unbindElementFromMarkerName(t,e){const i=this._markerNameToElements.get(e);i&&(i.delete(t),0==i.size&&this._markerNameToElements.delete(e));const n=this._elementToMarkerNames.get(t);n&&(n.delete(e),0==n.size&&this._elementToMarkerNames.delete(t))}flushUnboundMarkerNames(){const t=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),t}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set}toModelElement(t){return this._viewToModelMapping.get(t)}toViewElement(t){return this._modelToViewMapping.get(t)}toModelRange(t){return new Yr(this.toModelPosition(t.start),this.toModelPosition(t.end))}toViewRange(t){return new ts(this.toViewPosition(t.start),this.toViewPosition(t.end))}toModelPosition(t){const e={viewPosition:t,mapper:this};return this.fire("viewToModelPosition",e),e.modelPosition}toViewPosition(t,e={isPhantom:!1}){const i={modelPosition:t,mapper:this,isPhantom:e.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(t){const e=this._markerNameToElements.get(t);if(!e)return null;const i=new Set;for(const t of e)if(t.is("attributeElement"))for(const e of t.getElementsWithSameId())i.add(e);else i.add(t);return i}registerViewToModelLength(t,e){this._viewToModelLengthCallbacks.set(t,e)}findMappedViewAncestor(t){let e=t.parent;for(;!this._viewToModelMapping.has(e);)e=e.parent;return e}_toModelOffset(t,e,i){if(i!=t){return this._toModelOffset(t.parent,t.index,i)+this._toModelOffset(t,e,t)}if(t.is("text"))return e;let n=0;for(let i=0;i<e;i++)n+=this.getModelLength(t.getChild(i));return n}getModelLength(t){if(this._viewToModelLengthCallbacks.get(t.name)){return this._viewToModelLengthCallbacks.get(t.name)(t)}if(this._viewToModelMapping.has(t))return 1;if(t.is("text"))return t.data.length;if(t.is("uiElement"))return 0;{let e=0;for(const i of t.getChildren())e+=this.getModelLength(i);return e}}_findPositionIn(t,e){let i,n=0,s=0,o=0;if(t.is("text"))return new Zn(t,e);for(;s<e;)i=t.getChild(o),s+=n=this.getModelLength(i),o++;return s==e?this._moveViewPositionToTextNode(new Zn(t,o)):this._findPositionIn(i,e-(s-n))}_moveViewPositionToTextNode(t){const e=t.nodeBefore,i=t.nodeAfter;return e instanceof mn?new Zn(e,e.data.length):i instanceof mn?new Zn(i,0):t}}cn(Qr,en);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Xr{constructor(){this._consumable=new Map,this._textProxyRegistry=new Map}add(t,e){e=Zr(e),t instanceof qr&&(t=this._getSymbolForTextProxy(t)),this._consumable.has(t)||this._consumable.set(t,new Map),this._consumable.get(t).set(e,!0)}consume(t,e){return e=Zr(e),t instanceof qr&&(t=this._getSymbolForTextProxy(t)),!!this.test(t,e)&&(this._consumable.get(t).set(e,!1),!0)}test(t,e){e=Zr(e),t instanceof qr&&(t=this._getSymbolForTextProxy(t));const i=this._consumable.get(t);if(void 0===i)return null;const n=i.get(e);return void 0===n?null:n}revert(t,e){e=Zr(e),t instanceof qr&&(t=this._getSymbolForTextProxy(t));const i=this.test(t,e);return!1===i?(this._consumable.get(t).set(e,!0),!0):!0!==i&&null}_getSymbolForTextProxy(t){let e=null;const i=this._textProxyRegistry.get(t.startOffset);if(i){const n=i.get(t.endOffset);n&&(e=n.get(t.parent))}return e||(e=this._addSymbolForTextProxy(t.startOffset,t.endOffset,t.parent)),e}_addSymbolForTextProxy(t,e,i){const n=Symbol("textProxySymbol");let s,o;return(s=this._textProxyRegistry.get(t))||(s=new Map,this._textProxyRegistry.set(t,s)),(o=s.get(e))||(o=new Map,s.set(e,o)),o.set(i,n),n}}function Zr(t){const e=t.split(":");return e.length>1?e[0]+":"+e[1]:e[0]}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ta{constructor(t){this.conversionApi=Fn({dispatcher:this},t)}convertChanges(t,e,i){for(const e of t.getMarkersToRemove())this.convertMarkerRemove(e.name,e.range,i);for(const e of t.getChanges())"insert"==e.type?this.convertInsert(Yr._createFromPositionAndShift(e.position,e.length),i):"remove"==e.type?this.convertRemove(e.position,e.length,e.name,i):this.convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,i);for(const t of this.conversionApi.mapper.flushUnboundMarkerNames()){const n=e.get(t).getRange();this.convertMarkerRemove(t,n,i),this.convertMarkerAdd(t,n,i)}for(const e of t.getMarkersToAdd())this.convertMarkerAdd(e.name,e.range,i)}convertInsert(t,e){this.conversionApi.writer=e,this.conversionApi.consumable=this._createInsertConsumable(t);for(const e of t){const t=e.item,i={item:t,range:Yr._createFromPositionAndShift(e.previousPosition,e.length)};this._testAndFire("insert",i);for(const e of t.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=t.getAttribute(e),this._testAndFire(`attribute:${e}`,i)}this._clearConversionApi()}convertRemove(t,e,i,n){this.conversionApi.writer=n,this.fire("remove:"+i,{position:t,length:e},this.conversionApi),this._clearConversionApi()}convertAttribute(t,e,i,n,s){this.conversionApi.writer=s,this.conversionApi.consumable=this._createConsumableForRange(t,`attribute:${e}`);for(const s of t){const t={item:s.item,range:Yr._createFromPositionAndShift(s.previousPosition,s.length),attributeKey:e,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${e}`,t)}this._clearConversionApi()}convertSelection(t,e,i){const n=Array.from(e.getMarkersAtPosition(t.getFirstPosition()));if(this.conversionApi.writer=i,this.conversionApi.consumable=this._createSelectionConsumable(t,n),this.fire("selection",{selection:t},this.conversionApi),t.isCollapsed){for(const e of n){const i=e.getRange();if(!ea(t.getFirstPosition(),e,this.conversionApi.mapper))continue;const n={item:t,markerName:e.name,markerRange:i};this.conversionApi.consumable.test(t,"addMarker:"+e.name)&&this.fire("addMarker:"+e.name,n,this.conversionApi)}for(const e of t.getAttributeKeys()){const i={item:t,range:t.getFirstRange(),attributeKey:e,attributeOldValue:null,attributeNewValue:t.getAttribute(e)};this.conversionApi.consumable.test(t,"attribute:"+i.attributeKey)&&this.fire("attribute:"+i.attributeKey+":$text",i,this.conversionApi)}this._clearConversionApi()}}convertMarkerAdd(t,e,i){if(!e.root.document||"$graveyard"==e.root.rootName)return;this.conversionApi.writer=i;const n="addMarker:"+t,s=new Xr;if(s.add(e,n),this.conversionApi.consumable=s,this.fire(n,{markerName:t,markerRange:e},this.conversionApi),s.test(e,n)){this.conversionApi.consumable=this._createConsumableForRange(e,n);for(const i of e.getItems()){if(!this.conversionApi.consumable.test(i,n))continue;const s={item:i,range:Yr._createOn(i),markerName:t,markerRange:e};this.fire(n,s,this.conversionApi)}this._clearConversionApi()}}convertMarkerRemove(t,e,i){e.root.document&&"$graveyard"!=e.root.rootName&&(this.conversionApi.writer=i,this.fire("removeMarker:"+t,{markerName:t,markerRange:e},this.conversionApi),this._clearConversionApi())}_createInsertConsumable(t){const e=new Xr;for(const i of t){const t=i.item;e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}return e}_createConsumableForRange(t,e){const i=new Xr;for(const n of t.getItems())i.add(n,e);return i}_createSelectionConsumable(t,e){const i=new Xr;i.add(t,"selection");for(const n of e)i.add(t,"addMarker:"+n.name);for(const e of t.getAttributeKeys())i.add(t,"attribute:"+e);return i}_testAndFire(t,e){if(!this.conversionApi.consumable.test(e.item,t))return;const i=e.item.name||"$text";this.fire(t+":"+i,e,this.conversionApi)}_clearConversionApi(){delete this.conversionApi.writer,delete this.conversionApi.consumable}}function ea(t,e,i){const n=e.getRange(),s=Array.from(t.getAncestors());return s.shift(),s.reverse(),!s.some(t=>{if(n.containsItem(t)){return!!i.toViewElement(t).getCustomProperty("addHighlight")}})}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */cn(ta,en);class ia{constructor(t,e,i){this._lastRangeBackward=!1,this._ranges=[],this._attrs=new Map,t&&this.setTo(t,e,i)}get anchor(){if(this._ranges.length>0){const t=this._ranges[this._ranges.length-1];return this._lastRangeBackward?t.end:t.start}return null}get focus(){if(this._ranges.length>0){const t=this._ranges[this._ranges.length-1];return this._lastRangeBackward?t.start:t.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(t){if(this.rangeCount!=t.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(t.anchor)||!this.focus.isEqual(t.focus))return!1;for(const e of this._ranges){let i=!1;for(const n of t._ranges)if(e.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const t of this._ranges)yield new Yr(t.start,t.end)}getFirstRange(){let t=null;for(const e of this._ranges)t&&!e.start.isBefore(t.start)||(t=e);return t?new Yr(t.start,t.end):null}getLastRange(){let t=null;for(const e of this._ranges)t&&!e.end.isAfter(t.end)||(t=e);return t?new Yr(t.start,t.end):null}getFirstPosition(){const t=this.getFirstRange();return t?t.start.clone():null}getLastPosition(){const t=this.getLastRange();return t?t.end.clone():null}setTo(t,e,i){if(null===t)this._setRanges([]);else if(t instanceof ia)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof Yr)this._setRanges([t],!!e&&!!e.backward);else if(t instanceof Jr)this._setRanges([new Yr(t)]);else if(t instanceof Hr){const n=!!i&&!!i.backward;let s;if("in"==e)s=Yr._createIn(t);else if("on"==e)s=Yr._createOn(t);else{if(void 0===e)throw new Ki.b("model-selection-setTo-required-second-parameter: selection.setTo requires the second parameter when the first parameter is a node.",[this,t]);s=new Yr(Jr._createAt(t,e))}this._setRanges([s],n)}else{if(!wn(t))throw new Ki.b("model-selection-setTo-not-selectable: Cannot set the selection to the given place.",[this,t]);this._setRanges(t,e&&!!e.backward)}}_setRanges(t,e=!1){const i=(t=Array.from(t)).some(e=>{if(!(e instanceof Yr))throw new Ki.b("model-selection-set-ranges-not-range: Selection range set to an object that is not an instance of model.Range.",[this,t]);return this._ranges.every(t=>!t.isEqual(e))});if(t.length!==this._ranges.length||i){this._removeAllRanges();for(const e of t)this._pushRange(e);this._lastRangeBackward=!!e,this.fire("change:range",{directChange:!0})}}setFocus(t,e){if(null===this.anchor)throw new Ki.b("model-selection-setFocus-no-ranges: Cannot set selection focus if there are no ranges in selection.",[this,t]);const i=Jr._createAt(t,e);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new Yr(i,n)),this._lastRangeBackward=!0):(this._pushRange(new Yr(n,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(t){return this._attrs.get(t)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(t){return this._attrs.has(t)}removeAttribute(t){this.hasAttribute(t)&&(this._attrs.delete(t),this.fire("change:attribute",{attributeKeys:[t],directChange:!0}))}setAttribute(t,e){this.getAttribute(t)!==e&&(this._attrs.set(t,e),this.fire("change:attribute",{attributeKeys:[t],directChange:!0}))}getSelectedElement(){if(1!==this.rangeCount)return null;const t=this.getFirstRange(),e=t.start.nodeAfter,i=t.end.nodeBefore;return e instanceof Ur&&e==i?e:null}is(t){return"selection"==t||"model:selection"==t}*getSelectedBlocks(){const t=new WeakSet;for(const e of this.getRanges()){const i=sa(e.start,t);i&&(yield i);for(const i of e.getWalker())"elementEnd"==i.type&&na(i.item,t)&&(yield i.item);const n=sa(e.end,t);n&&!e.end.isTouching(Jr._createAt(n,0))&&(yield n)}}*getTopMostBlocks(){const t=Array.from(this.getSelectedBlocks());for(const e of t){const i=oa(e);i&&t.includes(i)||(yield e)}}containsEntireContent(t=this.anchor.root){const e=Jr._createAt(t,0),i=Jr._createAt(t,"end");return e.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(t){this._checkRange(t),this._ranges.push(new Yr(t.start,t.end))}_checkRange(t){for(let e=0;e<this._ranges.length;e++)if(t.isIntersecting(this._ranges[e]))throw new Ki.b("model-selection-range-intersects: Trying to add a range that intersects with another range in the selection.",[this,t],{addedRange:t,intersectingRange:this._ranges[e]})}_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}function na(t,e){return!e.has(t)&&(e.add(t),t.document.model.schema.isBlock(t)&&t.parent)}function sa(t,e){const i=t.parent.document.model.schema,n=t.parent.getAncestors({parentFirst:!0,includeSelf:!0});let s=!1;const o=n.find(t=>!s&&(!(s=i.isLimit(t))&&na(t,e)));return n.forEach(t=>e.add(t)),o}function oa(t){const e=t.document.model.schema;let i=t.parent;for(;i;){if(e.isBlock(i))return i;i=i.parent}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */cn(ia,en);class ra extends Yr{constructor(t,e){super(t,e),aa.call(this)}detach(){this.stopListening()}is(t){return"liveRange"==t||"model:liveRange"==t||super.is(t)}toRange(){return new Yr(this.start,this.end)}static fromRange(t){return new ra(t.start,t.end)}}function aa(){this.listenTo(this.root.document.model,"applyOperation",(t,e)=>{const i=e[0];i.isDocumentOperation&&la.call(this,i)},{priority:"low"})}function la(t){const e=this.getTransformedByOperation(t),i=Yr._createFromRanges(e),n=!i.isEqual(this),s=function(t,e){switch(e.type){case"insert":return t.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return t.containsPosition(e.sourcePosition)||t.start.isEqual(e.sourcePosition)||t.containsPosition(e.targetPosition);case"split":return t.containsPosition(e.splitPosition)||t.containsPosition(e.insertionPosition)}return!1}(this,t);let o=null;if(n){"$graveyard"==i.root.rootName&&(o="remove"==t.type?t.sourcePosition:t.deletionPosition);const e=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",e,{deletionPosition:o})}else s&&this.fire("change:content",this.toRange(),{deletionPosition:o})}cn(ra,en);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const ca="selection:";class ha{constructor(t){this._selection=new da(t),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").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()}getTopMostBlocks(){return this._selection.getTopMostBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(t){return this._selection.containsEntireContent(t)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(t){return this._selection.getAttribute(t)}hasAttribute(t){return this._selection.hasAttribute(t)}refresh(){this._selection._updateMarkers(),this._selection._updateAttributes(!1)}is(t){return"selection"==t||"model:selection"==t||"documentSelection"==t||"model:documentSelection"==t}_setFocus(t,e){this._selection.setFocus(t,e)}_setTo(t,e,i){this._selection.setTo(t,e,i)}_setAttribute(t,e){this._selection.setAttribute(t,e)}_removeAttribute(t){this._selection.removeAttribute(t)}_getStoredAttributes(){return this._selection._getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(t){this._selection.restoreGravity(t)}static _getStoreAttributeKey(t){return ca+t}static _isStoreAttributeKey(t){return t.startsWith(ca)}}cn(ha,en);class da extends ia{constructor(t){super(),this.markers=new os({idProperty:"name"}),this._model=t.model,this._document=t,this._attributePriority=new Map,this._fixGraveyardRangesData=[],this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this.listenTo(this._model,"applyOperation",(t,e)=>{const i=e[0];if(i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type){for(;this._fixGraveyardRangesData.length;){const{liveRange:t,sourcePosition:e}=this._fixGraveyardRangesData.shift();this._fixGraveyardSelection(t,e)}this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1}))}},{priority:"lowest"}),this.on("change:range",()=>{for(const t of this.getRanges())if(!this._document._validateSelectionRange(t))throw new Ki.b("document-selection-wrong-position: Range from document selection starts or ends at incorrect position.",this,{range:t})}),this.listenTo(this._model.markers,"update",()=>this._updateMarkers()),this.listenTo(this._document,"change",(t,e)=>{!function(t,e){const i=t.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&t.enqueueChange(e,t=>{const e=Array.from(i.getAttributeKeys()).filter(t=>t.startsWith(ca));for(const n of e)t.removeAttribute(n,i)})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this._model,e)})}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let t=0;t<this._ranges.length;t++)this._ranges[t].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(t,e,i){super.setTo(t,e,i),this._updateAttributes(!0)}setFocus(t,e){super.setFocus(t,e),this._updateAttributes(!0)}setAttribute(t,e){if(this._setAttribute(t,e)){const e=[t];this.fire("change:attribute",{attributeKeys:e,directChange:!0})}}removeAttribute(t){if(this._removeAttribute(t)){const e=[t];this.fire("change:attribute",{attributeKeys:e,directChange:!0})}}overrideGravity(){const t=Qi();return this._overriddenGravityRegister.add(t),1===this._overriddenGravityRegister.size&&this._updateAttributes(!0),t}restoreGravity(t){if(!this._overriddenGravityRegister.has(t))throw new Ki.b("document-selection-gravity-wrong-restore: Attempting to restore the selection gravity for an unknown UID.",this,{uid:t});this._overriddenGravityRegister.delete(t),this.isGravityOverridden||this._updateAttributes(!0)}_popRange(){this._ranges.pop().detach()}_pushRange(t){const e=this._prepareRange(t);e&&this._ranges.push(e)}_prepareRange(t){if(this._checkRange(t),t.root==this._document.graveyard)return;const e=ra.fromRange(t);return e.on("change:range",(t,i,n)=>{this._hasChangedRange=!0,e.root==this._document.graveyard&&this._fixGraveyardRangesData.push({liveRange:e,sourcePosition:n.deletionPosition})}),e}_updateMarkers(){const t=[];for(const e of this._model.markers){const i=e.getRange();for(const n of this.getRanges())i.containsRange(n,!n.isCollapsed)&&t.push(e)}for(const e of t)this.markers.has(e)||this.markers.add(e);for(const e of Array.from(this.markers))t.includes(e)||this.markers.remove(e)}_updateAttributes(t){const e=zr(this._getSurroundingAttributes()),i=zr(this.getAttributes());if(t)this._attributePriority=new Map,this._attrs=new Map;else for(const[t,e]of this._attributePriority)"low"==e&&(this._attrs.delete(t),this._attributePriority.delete(t));this._setAttributesTo(e);const n=[];for(const[t,e]of this.getAttributes())i.has(t)&&i.get(t)===e||n.push(t);for(const[t]of i)this.hasAttribute(t)||n.push(t);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(t,e,i=!0){const n=i?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(t))&&(super.getAttribute(t)!==e&&(this._attrs.set(t,e),this._attributePriority.set(t,n),!0))}_removeAttribute(t,e=!0){const i=e?"normal":"low";return("low"!=i||"normal"!=this._attributePriority.get(t))&&(this._attributePriority.set(t,i),!!super.hasAttribute(t)&&(this._attrs.delete(t),!0))}_setAttributesTo(t){const e=new Set;for(const[e,i]of this.getAttributes())t.get(e)!==i&&this._removeAttribute(e,!1);for(const[i,n]of t){this._setAttribute(i,n,!1)&&e.add(i)}return e}*_getStoredAttributes(){const t=this.getFirstPosition().parent;if(this.isCollapsed&&t.isEmpty)for(const e of t.getAttributeKeys())if(e.startsWith(ca)){const i=e.substr(ca.length);yield[i,t.getAttribute(e)]}}_getSurroundingAttributes(){const t=this.getFirstPosition(),e=this._model.schema;let i=null;if(this.isCollapsed){const e=t.textNode?t.textNode:t.nodeBefore,n=t.textNode?t.textNode:t.nodeAfter;if(this.isGravityOverridden||(i=ua(e)),i||(i=ua(n)),!this.isGravityOverridden&&!i){let t=e;for(;t&&!i;)i=ua(t=t.previousSibling)}if(!i){let t=n;for(;t&&!i;)i=ua(t=t.nextSibling)}i||(i=this._getStoredAttributes())}else{const t=this.getFirstRange();for(const n of t){if(n.item.is("element")&&e.isObject(n.item))break;if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(t,e){const i=e.clone(),n=this._model.schema.getNearestSelectionRange(i),s=this._ranges.indexOf(t);if(this._ranges.splice(s,1),t.detach(),n){const t=this._prepareRange(n);this._ranges.splice(s,0,t)}}}function ua(t){return t instanceof qr||t instanceof jr?t.getAttributes():null}class fa{constructor(t){this._dispatchers=t}add(t){for(const e of this._dispatchers)t(e);return this}}var ma=1,ga=4;var pa=function(t){return Hi(t,ma|ga)};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class wa extends fa{elementToElement(t){return this.add(function(t){return(t=pa(t)).view=_a(t.view,"container"),e=>{e.on("insert:"+t.model,function(t){return(e,i,n)=>{const s=t(i.item,n.writer);if(!s)return;if(!n.consumable.consume(i.item,"insert"))return;const o=n.mapper.toViewPosition(i.range.start);n.mapper.bindElements(i.item,s),n.writer.insert(o,s)}}(t.view),{priority:t.converterPriority||"normal"})}}(t))}attributeToElement(t){return this.add(function(t){let e="attribute:"+((t=pa(t)).model.key?t.model.key:t.model);t.model.name&&(e+=":"+t.model.name);if(t.model.values)for(const e of t.model.values)t.view[e]=_a(t.view[e],"attribute");else t.view=_a(t.view,"attribute");const i=va(t);return n=>{n.on(e,function(t){return(e,i,n)=>{const s=t(i.attributeOldValue,n.writer),o=t(i.attributeNewValue,n.writer);if(!s&&!o)return;if(!n.consumable.consume(i.item,e.name))return;const r=n.writer,a=r.document.selection;if(i.item instanceof ia||i.item instanceof ha)r.wrap(a.getFirstRange(),o);else{let t=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&s&&(t=r.unwrap(t,s)),null!==i.attributeNewValue&&o&&r.wrap(t,o)}}}(i),{priority:t.converterPriority||"normal"})}}(t))}attributeToAttribute(t){return this.add(function(t){let e="attribute:"+((t=pa(t)).model.key?t.model.key:t.model);t.model.name&&(e+=":"+t.model.name);if(t.model.values)for(const e of t.model.values)t.view[e]=ya(t.view[e]);else t.view=ya(t.view);const i=va(t);return n=>{n.on(e,function(t){return(e,i,n)=>{const s=t(i.attributeOldValue,i),o=t(i.attributeNewValue,i);if(!s&&!o)return;if(!n.consumable.consume(i.item,e.name))return;const r=n.mapper.toViewElement(i.item),a=n.writer;if(!r)throw new Ki.b("conversion-attribute-to-attribute-on-text: Trying to convert text node's attribute with attribute-to-attribute converter.",[i,n]);if(null!==i.attributeOldValue&&s)if("class"==s.key){const t=Array.isArray(s.value)?s.value:[s.value];for(const e of t)a.removeClass(e,r)}else if("style"==s.key){const t=Object.keys(s.value);for(const e of t)a.removeStyle(e,r)}else a.removeAttribute(s.key,r);if(null!==i.attributeNewValue&&o)if("class"==o.key){const t=Array.isArray(o.value)?o.value:[o.value];for(const e of t)a.addClass(e,r)}else if("style"==o.key){const t=Object.keys(o.value);for(const e of t)a.setStyle(e,o.value[e],r)}else a.setAttribute(o.key,o.value,r)}}(i),{priority:t.converterPriority||"normal"})}}(t))}markerToElement(t){return this.add(function(t){return(t=pa(t)).view=_a(t.view,"ui"),e=>{e.on("addMarker:"+t.model,function(t){return(e,i,n)=>{i.isOpening=!0;const s=t(i,n.writer);i.isOpening=!1;const o=t(i,n.writer);if(!s||!o)return;const r=i.markerRange;if(r.isCollapsed&&!n.consumable.consume(r,e.name))return;for(const t of r)if(!n.consumable.consume(t.item,e.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(r.start),s),n.mapper.bindElementToMarker(s,i.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),o),n.mapper.bindElementToMarker(o,i.markerName)),e.stop()}}(t.view),{priority:t.converterPriority||"normal"}),e.on("removeMarker:"+t.model,(t.view,(t,e,i)=>{const n=i.mapper.markerNameToElements(e.markerName);if(n){for(const t of n)i.mapper.unbindElementFromMarkerName(t,e.markerName),i.writer.clear(i.writer.createRangeOn(t),t);i.writer.clearClonedElementsGroup(e.markerName),t.stop()}}),{priority:t.converterPriority||"normal"})}}(t))}markerToHighlight(t){return this.add(function(t){return e=>{e.on("addMarker:"+t.model,function(t){return(e,i,n)=>{if(!i.item)return;if(!(i.item instanceof ia||i.item instanceof ha||i.item.is("textProxy")))return;const s=ka(t,i,n);if(!s)return;if(!n.consumable.consume(i.item,e.name))return;const o=ba(s),r=n.writer,a=r.document.selection;if(i.item instanceof ia||i.item instanceof ha)r.wrap(a.getFirstRange(),o,a);else{const t=n.mapper.toViewRange(i.range),e=r.wrap(t,o);for(const t of e.getItems())if(t.is("attributeElement")&&t.isSimilar(o)){n.mapper.bindElementToMarker(t,i.markerName);break}}}}(t.view),{priority:t.converterPriority||"normal"}),e.on("addMarker:"+t.model,function(t){return(e,i,n)=>{if(!i.item)return;if(!(i.item instanceof Ur))return;const s=ka(t,i,n);if(!s)return;if(!n.consumable.test(i.item,e.name))return;const o=n.mapper.toViewElement(i.item);if(o&&o.getCustomProperty("addHighlight")){n.consumable.consume(i.item,e.name);for(const t of Yr._createIn(i.item))n.consumable.consume(t.item,e.name);o.getCustomProperty("addHighlight")(o,s,n.writer),n.mapper.bindElementToMarker(o,i.markerName)}}}(t.view),{priority:t.converterPriority||"normal"}),e.on("removeMarker:"+t.model,function(t){return(e,i,n)=>{if(i.markerRange.isCollapsed)return;const s=ka(t,i,n);if(!s)return;const o=ba(s),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const t of r)n.mapper.unbindElementFromMarkerName(t,i.markerName),t.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(t),o):t.getCustomProperty("removeHighlight")(t,s.id,n.writer);n.writer.clearClonedElementsGroup(i.markerName),e.stop()}}}(t.view),{priority:t.converterPriority||"normal"})}}(t))}}function ba(t){const e=new ls("span",t.attributes);return t.classes&&e._addClass(t.classes),t.priority&&(e._priority=t.priority),e._id=t.id,e}function _a(t,e){return"function"==typeof t?t:(i,n)=>(function(t,e,i){"string"==typeof t&&(t={name:t});let n;const s=Object.assign({},t.attributes);if("container"==i)n=e.createContainerElement(t.name,s);else if("attribute"==i){const i={priority:t.priority||ls.DEFAULT_PRIORITY};n=e.createAttributeElement(t.name,s,i)}else n=e.createUIElement(t.name,s);if(t.styles){const i=Object.keys(t.styles);for(const s of i)e.setStyle(s,t.styles[s],n)}if(t.classes){const i=t.classes;if("string"==typeof i)e.addClass(i,n);else for(const t of i)e.addClass(t,n)}return n})(t,n,e)}function va(t){return t.model.values?(e,i)=>{const n=t.view[e];return n?n(e,i):null}:t.view}function ya(t){return"string"==typeof t?e=>({key:t,value:e}):"object"==typeof t?t.value?()=>t:e=>({key:t.key,value:e}):t}function ka(t,e,i){const n="function"==typeof t?t(e,i):t;return n?(n.priority||(n.priority=10),n.id||(n.id=e.markerName),n):null}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Aa extends fa{elementToElement(t){return this.add(Ca(t))}elementToAttribute(t){return this.add(function(t){Pa(t=pa(t));const e=Ta(t,!1),i=xa(t),n=i?"element:"+i:"element";return i=>{i.on(n,e,{priority:t.converterPriority||"low"})}}(t))}attributeToAttribute(t){return this.add(function(t){t=pa(t);let e=null;("string"==typeof t.view||t.view.key)&&(e=function(t){"string"==typeof t.view&&(t.view={key:t.view});const e=t.view.key;let i;if("class"==e||"style"==e){i={["class"==e?"classes":"styles"]:t.view.value}}else{const n=void 0===t.view.value?/[\s\S]*/:t.view.value;i={attributes:{[e]:n}}}t.view.name&&(i.name=t.view.name);return t.view=i,e}(t));Pa(t,e);const i=Ta(t,!0);return e=>{e.on("element",i,{priority:t.converterPriority||"low"})}}(t))}elementToMarker(t){return this.add(function(t){return function(t){const e=t.model;t.model=(t,i)=>{const n="string"==typeof e?e:e(t);return i.createElement("$marker",{"data-name":n})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t=pa(t)),Ca(t)}(t))}}function Ca(t){const e=function(t){const e=t.view?new bn(t.view):null;return(i,n,s)=>{let o={};if(e){const t=e.match(n.viewItem);if(!t)return;o=t.match}o.name=!0;const r=function(t,e,i){return t instanceof Function?t(e,i):i.createElement(t)}(t.model,n.viewItem,s.writer);if(!r)return;if(!s.consumable.test(n.viewItem,o))return;const a=s.splitToAllowedParent(r,n.modelCursor);if(!a)return;s.writer.insert(r,a.position),s.convertChildren(n.viewItem,s.writer.createPositionAt(r,0)),s.consumable.consume(n.viewItem,o);const l=s.getSplitParts(r);n.modelRange=new Yr(s.writer.createPositionBefore(r),s.writer.createPositionAfter(l[l.length-1])),a.cursorParent?n.modelCursor=s.writer.createPositionAt(a.cursorParent,0):n.modelCursor=n.modelRange.end}}(t=pa(t)),i=xa(t),n=i?"element:"+i:"element";return i=>{i.on(n,e,{priority:t.converterPriority||"normal"})}}function xa(t){return"string"==typeof t.view?t.view:"object"==typeof t.view&&"string"==typeof t.view.name?t.view.name:null}function Pa(t,e=null){const i=null===e||(t=>t.getAttribute(e)),n="object"!=typeof t.model?t.model:t.model.key,s="object"!=typeof t.model||void 0===t.model.value?i:t.model.value;t.model={key:n,value:s}}function Ta(t,e){const i=new bn(t.view);return(n,s,o)=>{const r=i.match(s.viewItem);if(!r)return;const a=t.model.key,l="function"==typeof t.model.value?t.model.value(s.viewItem):t.model.value;null!==l&&(!function(t){if("object"==typeof t.view&&!xa(t))return!1;return!t.view.classes&&!t.view.attributes&&!t.view.styles}(t)?delete r.match.name:r.match.name=!0,o.consumable.test(s.viewItem,r.match)&&(s.modelRange||(s=Object.assign(s,o.convertChildren(s.viewItem,s.modelCursor))),function(t,e,i,n){let s=!1;for(const o of Array.from(t.getItems({shallow:i})))n.schema.checkAttribute(o,e.key)&&(n.writer.setAttribute(e.key,e.value,o),s=!0);return s}(s.modelRange,{key:a,value:l},e,o)&&o.consumable.consume(s.viewItem,r.match)))}}class Ea{constructor(t){this.model=t,this.view=new Lr,this.mapper=new Qr,this.downcastDispatcher=new ta({mapper:this.mapper});const e=this.model.document,i=e.selection,n=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(e,"change",()=>{this.view.change(t=>{this.downcastDispatcher.convertChanges(e.differ,n,t),this.downcastDispatcher.convertSelection(i,n,t)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(t,e){return(i,n)=>{const s=n.newSelection,o=new ia,r=[];for(const t of s.getRanges())r.push(e.toModelRange(t));o.setTo(r,{backward:s.isBackward}),o.isEqual(t.document.selection)||t.change(t=>{t.setSelection(o)})}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",(t,e,i)=>{if(!i.consumable.consume(e.item,"insert"))return;const n=i.writer,s=i.mapper.toViewPosition(e.range.start),o=n.createText(e.item.data);n.insert(s,o)},{priority:"lowest"}),this.downcastDispatcher.on("remove",(t,e,i)=>{const n=i.mapper.toViewPosition(e.position),s=e.position.getShiftedBy(e.length),o=i.mapper.toViewPosition(s,{isPhantom:!0}),r=i.writer.createRange(n,o),a=i.writer.remove(r.getTrimmed());for(const t of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(t)},{priority:"low"}),this.downcastDispatcher.on("selection",(t,e,i)=>{const n=i.writer,s=n.document.selection;for(const t of s.getRanges())t.isCollapsed&&t.end.parent.document&&i.writer.mergeAttributes(t.start);n.setSelection(null)},{priority:"low"}),this.downcastDispatcher.on("selection",(t,e,i)=>{const n=e.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=[];for(const t of n.getRanges()){const e=i.mapper.toViewRange(t);s.push(e)}i.writer.setSelection(s,{backward:n.isBackward})},{priority:"low"}),this.downcastDispatcher.on("selection",(t,e,i)=>{const n=e.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const s=i.writer,o=n.getFirstPosition(),r=i.mapper.toViewPosition(o),a=s.breakAttributes(r);s.setSelection(a)},{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(t=>{if("$graveyard"==t.rootName)return null;const e=new Qn(t.name);return e.rootName=t.rootName,e._document=this.view.document,this.mapper.bindElements(t,e),e})}destroy(){this.view.destroy(),this.stopListening()}}cn(Ea,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Sa{constructor(t,e=[]){this._editor=t,this._availablePlugins=new Map,this._plugins=new Map;for(const t of e)this._availablePlugins.set(t,t),t.pluginName&&this._availablePlugins.set(t.pluginName,t)}*[Symbol.iterator](){for(const t of this._plugins)"function"==typeof t[0]&&(yield t)}get(t){const e=this._plugins.get(t);if(!e){const e="plugincollection-plugin-not-loaded: The requested plugin is not loaded.";let i=t;throw"function"==typeof t&&(i=t.pluginName||t.name),new Ki.b(e,this._editor,{plugin:i})}return e}has(t){return this._plugins.has(t)}init(t,e=[]){const i=this,n=this._editor,s=new Set,o=[],r=u(t),a=u(e),l=function(t){const e=[];for(const i of t)d(i)||e.push(i);return e.length?e:null}(t);if(l){const t="plugincollection-plugin-not-found: Some plugins are not available and could not be loaded.";return console.error(Object(Ki.a)(t),{plugins:l}),Promise.reject(new Ki.b(t,this._editor,{plugins:l}))}return Promise.all(r.map(c)).then(()=>h(o,"init")).then(()=>h(o,"afterInit")).then(()=>o);function c(t){if(!a.includes(t)&&!i._plugins.has(t)&&!s.has(t))return function(t){return new Promise(r=>{s.add(t),t.requires&&t.requires.forEach(i=>{const s=d(i);if(e.includes(s))throw new Ki.b("plugincollection-required: Cannot load a plugin because one of its dependencies is listed inthe `removePlugins` option.",n,{plugin:s,requiredBy:t});c(s)});const a=new t(n);i._add(t,a),o.push(a),r()})}(t).catch(e=>{throw console.error(Object(Ki.a)("plugincollection-load: It was not possible to load the plugin."),{plugin:t}),e})}function h(t,e){return t.reduce((t,i)=>i[e]?t.then(i[e].bind(i)):t,Promise.resolve())}function d(t){return"function"==typeof t?t:i._availablePlugins.get(t)}function u(t){return t.map(t=>d(t)).filter(t=>!!t)}}destroy(){const t=Array.from(this).map(([,t])=>t).filter(t=>"function"==typeof t.destroy).map(t=>t.destroy());return Promise.all(t)}_add(t,e){this._plugins.set(t,e);const i=t.pluginName;if(i){if(this._plugins.has(i))throw new Ki.b("plugincollection-plugin-name-conflict: Two plugins with the same name were loaded.",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:t});this._plugins.set(i,e)}}}cn(Sa,en);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ra{constructor(){this._commands=new Map}add(t,e){this._commands.set(t,e)}get(t){return this._commands.get(t)}execute(t,...e){const i=this.get(t);if(!i)throw new Ki.b("commandcollection-command-not-found: Command does not exist.",this,{commandName:t});i.execute(...e)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const t of this.commands())t.destroy()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Oa(t,e){const i=Object.keys(window.CKEDITOR_TRANSLATIONS).length;return 1===i&&(t=Object.keys(window.CKEDITOR_TRANSLATIONS)[0]),0!==i&&function(t,e){return t in window.CKEDITOR_TRANSLATIONS&&e in window.CKEDITOR_TRANSLATIONS[t]}(t,e)?window.CKEDITOR_TRANSLATIONS[t][e].replace(/ \[context: [^\]]+\]$/,""):e.replace(/ \[context: [^\]]+\]$/,"")}window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={});
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Ia=["ar","fa","he","ku","ug"];class Ma{constructor(t={}){this.uiLanguage=t.uiLanguage||"en",this.contentLanguage=t.contentLanguage||this.uiLanguage,this.uiLanguageDirection=Va(this.uiLanguage),this.contentLanguageDirection=Va(this.contentLanguage),this.t=(...t)=>this._t(...t)}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(t,e){let i=Oa(this.uiLanguage,t);return e&&(i=i.replace(/%(\d+)/g,(t,i)=>i<e.length?e[i]:t)),i}}function Va(t){return Ia.includes(t)?"rtl":"ltr"}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Na{constructor(){this._consumables=new Map}add(t,e){let i;t.is("text")||t.is("documentFragment")?this._consumables.set(t,!0):(this._consumables.has(t)?i=this._consumables.get(t):(i=new Ba,this._consumables.set(t,i)),i.add(e))}test(t,e){const i=this._consumables.get(t);return void 0===i?null:t.is("text")||t.is("documentFragment")?i:i.test(e)}consume(t,e){return!!this.test(t,e)&&(t.is("text")||t.is("documentFragment")?this._consumables.set(t,!1):this._consumables.get(t).consume(e),!0)}revert(t,e){const i=this._consumables.get(t);void 0!==i&&(t.is("text")||t.is("documentFragment")?this._consumables.set(t,!0):i.revert(e))}static consumablesFromElement(t){const e={name:!0,attributes:[],classes:[],styles:[]},i=t.getAttributeKeys();for(const t of i)"style"!=t&&"class"!=t&&e.attributes.push(t);const n=t.getClassNames();for(const t of n)e.classes.push(t);const s=t.getStyleNames();for(const t of s)e.styles.push(t);return e}static createFrom(t,e){if(e||(e=new Na),t.is("text"))return e.add(t),e;t.is("element")&&e.add(t,Na.consumablesFromElement(t)),t.is("documentFragment")&&e.add(t);for(const i of t.getChildren())e=Na.createFrom(i,e);return e}}class Ba{constructor(){this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}add(t){t.name&&(this._canConsumeName=!0);for(const e in this._consumables)e in t&&this._add(e,t[e])}test(t){if(t.name&&!this._canConsumeName)return this._canConsumeName;for(const e in this._consumables)if(e in t){const i=this._test(e,t[e]);if(!0!==i)return i}return!0}consume(t){t.name&&(this._canConsumeName=!1);for(const e in this._consumables)e in t&&this._consume(e,t[e])}revert(t){t.name&&(this._canConsumeName=!0);for(const e in this._consumables)e in t&&this._revert(e,t[e])}_add(t,e){const i=$t(e)?e:[e],n=this._consumables[t];for(const e of i){if("attributes"===t&&("class"===e||"style"===e))throw new Ki.b("viewconsumable-invalid-attribute: Classes and styles should be handled separately.",this);n.set(e,!0)}}_test(t,e){const i=$t(e)?e:[e],n=this._consumables[t];for(const e of i)if("attributes"!==t||"class"!==e&&"style"!==e){const t=n.get(e);if(void 0===t)return null;if(!t)return!1}else{const t="class"==e?"classes":"styles",i=this._test(t,[...this._consumables[t].keys()]);if(!0!==i)return i}return!0}_consume(t,e){const i=$t(e)?e:[e],n=this._consumables[t];for(const e of i)if("attributes"!==t||"class"!==e&&"style"!==e)n.set(e,!1);else{const t="class"==e?"classes":"styles";this._consume(t,[...this._consumables[t].keys()])}}_revert(t,e){const i=$t(e)?e:[e],n=this._consumables[t];for(const e of i)if("attributes"!==t||"class"!==e&&"style"!==e){!1===n.get(e)&&n.set(e,!0)}else{const t="class"==e?"classes":"styles";this._revert(t,[...this._consumables[t].keys()])}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Fa{constructor(){this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(t,e)=>{e[0]=new Da(e[0])},{priority:"highest"}),this.on("checkChild",(t,e)=>{e[0]=new Da(e[0]),e[1]=this.getDefinition(e[1])},{priority:"highest"})}register(t,e){if(this._sourceDefinitions[t])throw new Ki.b("schema-cannot-register-item-twice: A single item cannot be registered twice in the schema.",this,{itemName:t});this._sourceDefinitions[t]=[Object.assign({},e)],this._clearCache()}extend(t,e){if(!this._sourceDefinitions[t])throw new Ki.b("schema-cannot-extend-missing-item: Cannot extend an item which was not registered yet.",this,{itemName:t});this._sourceDefinitions[t].push(Object.assign({},e)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(t){let e;return e="string"==typeof t?t:t.is&&(t.is("text")||t.is("textProxy"))?"$text":t.name,this.getDefinitions()[e]}isRegistered(t){return!!this.getDefinition(t)}isBlock(t){const e=this.getDefinition(t);return!(!e||!e.isBlock)}isLimit(t){const e=this.getDefinition(t);return!!e&&!(!e.isLimit&&!e.isObject)}isObject(t){const e=this.getDefinition(t);return!(!e||!e.isObject)}isInline(t){const e=this.getDefinition(t);return!(!e||!e.isInline)}checkChild(t,e){return!!e&&this._checkContextMatch(e,t)}checkAttribute(t,e){const i=this.getDefinition(t.last);return!!i&&i.allowAttributes.includes(e)}checkMerge(t,e=null){if(t instanceof Jr){const e=t.nodeBefore,i=t.nodeAfter;if(!(e instanceof Ur))throw new Ki.b("schema-check-merge-no-element-before: The node before the merge position must be an element.",this);if(!(i instanceof Ur))throw new Ki.b("schema-check-merge-no-element-after: The node after the merge position must be an element.",this);return this.checkMerge(e,i)}for(const i of e.getChildren())if(!this.checkChild(t,i))return!1;return!0}addChildCheck(t){this.on("checkChild",(e,[i,n])=>{if(!n)return;const s=t(i,n);"boolean"==typeof s&&(e.stop(),e.return=s)},{priority:"high"})}addAttributeCheck(t){this.on("checkAttribute",(e,[i,n])=>{const s=t(i,n);"boolean"==typeof s&&(e.stop(),e.return=s)},{priority:"high"})}setAttributeProperties(t,e){this._attributeProperties[t]=Object.assign(this.getAttributeProperties(t),e)}getAttributeProperties(t){return this._attributeProperties[t]||{}}getLimitElement(t){let e;if(t instanceof Jr)e=t.parent;else{e=(t instanceof Yr?[t]:Array.from(t.getRanges())).reduce((t,e)=>{const i=e.getCommonAncestor();return t?t.getCommonAncestor(i,{includeSelf:!0}):i},null)}for(;!this.isLimit(e)&&e.parent;)e=e.parent;return e}checkAttributeInSelection(t,e){if(t.isCollapsed){const i=[...t.getFirstPosition().getAncestors(),new jr("",t.getAttributes())];return this.checkAttribute(i,e)}{const i=t.getRanges();for(const t of i)for(const i of t)if(this.checkAttribute(i.item,e))return!0}return!1}*getValidRanges(t,e){t=function*(t){for(const e of t)yield*e.getMinimalFlatRanges()}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t);for(const i of t)yield*this._getValidRangesForRange(i,e)}getNearestSelectionRange(t,e="both"){if(this.checkChild(t,"$text"))return new Yr(t);let i,n;"both"!=e&&"backward"!=e||(i=new $r({startPosition:t,direction:"backward"})),"both"!=e&&"forward"!=e||(n=new $r({startPosition:t}));for(const t of function*(t,e){let i=!1;for(;!i;){if(i=!0,t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}if(e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}}}(i,n)){const e=t.walker==i?"elementEnd":"elementStart",n=t.value;if(n.type==e&&this.isObject(n.item))return Yr._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new Yr(n.nextPosition)}return null}findAllowedParent(t,e){let i=t.parent;for(;i;){if(this.checkChild(i,e))return i;if(this.isLimit(i))return null;i=i.parent}return null}removeDisallowedAttributes(t,e){for(const i of t){for(const t of i.getAttributeKeys())this.checkAttribute(i,t)||e.removeAttribute(t,i);i.is("element")&&this.removeDisallowedAttributes(i.getChildren(),e)}}createContext(t){return new Da(t)}_clearCache(){this._compiledDefinitions=null}_compile(){const t={},e=this._sourceDefinitions,i=Object.keys(e);for(const n of i)t[n]=La(e[n],n);for(const e of i)za(t,e);for(const e of i)Ha(t,e);for(const e of i)ja(t,e),qa(t,e);for(const e of i)Wa(t,e),Ua(t,e);this._compiledDefinitions=t}_checkContextMatch(t,e,i=e.length-1){const n=e.getItem(i);if(t.allowIn.includes(n.name)){if(0==i)return!0;{const t=this.getDefinition(n);return this._checkContextMatch(t,e,i-1)}}return!1}*_getValidRangesForRange(t,e){let i=t.start,n=t.start;for(const s of t.getItems({shallow:!0}))s.is("element")&&(yield*this._getValidRangesForRange(Yr._createIn(s),e)),this.checkAttribute(s,e)||(i.isEqual(n)||(yield new Yr(i,n)),i=Jr._createAfter(s)),n=Jr._createAfter(s);i.isEqual(n)||(yield new Yr(i,n))}}cn(Fa,jn);class Da{constructor(t){if(t instanceof Da)return t;"string"==typeof t?t=[t]:Array.isArray(t)||(t=t.getAncestors({includeSelf:!0})),t[0]&&"string"!=typeof t[0]&&t[0].is("documentFragment")&&t.shift(),this._items=t.map(Ka)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(t){const e=new Da([t]);return e._items=[...this._items,...e._items],e}getItem(t){return this._items[t]}*getNames(){yield*this._items.map(t=>t.name)}endsWith(t){return Array.from(this.getNames()).join(" ").endsWith(t)}}function La(t,e){const i={name:e,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],inheritTypesFrom:[]};return function(t,e){for(const i of t){const t=Object.keys(i).filter(t=>t.startsWith("is"));for(const n of t)e[n]=i[n]}}(t,i),$a(t,i,"allowIn"),$a(t,i,"allowContentOf"),$a(t,i,"allowWhere"),$a(t,i,"allowAttributes"),$a(t,i,"allowAttributesOf"),$a(t,i,"inheritTypesFrom"),function(t,e){for(const i of t){const t=i.inheritAllFrom;t&&(e.allowContentOf.push(t),e.allowWhere.push(t),e.allowAttributesOf.push(t),e.inheritTypesFrom.push(t))}}(t,i),i}function za(t,e){for(const i of t[e].allowContentOf)if(t[i]){Ga(t,i).forEach(t=>{t.allowIn.push(e)})}delete t[e].allowContentOf}function Ha(t,e){for(const i of t[e].allowWhere){const n=t[i];if(n){const i=n.allowIn;t[e].allowIn.push(...i)}}delete t[e].allowWhere}function ja(t,e){for(const i of t[e].allowAttributesOf){const n=t[i];if(n){const i=n.allowAttributes;t[e].allowAttributes.push(...i)}}delete t[e].allowAttributesOf}function qa(t,e){const i=t[e];for(const e of i.inheritTypesFrom){const n=t[e];if(n){const t=Object.keys(n).filter(t=>t.startsWith("is"));for(const e of t)e in i||(i[e]=n[e])}}delete i.inheritTypesFrom}function Wa(t,e){const i=t[e],n=i.allowIn.filter(e=>t[e]);i.allowIn=Array.from(new Set(n))}function Ua(t,e){const i=t[e];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function $a(t,e,i){for(const n of t)"string"==typeof n[i]?e[i].push(n[i]):Array.isArray(n[i])&&e[i].push(...n[i])}function Ga(t,e){const i=t[e];return(n=t,Object.keys(n).map(t=>n[t])).filter(t=>t.allowIn.includes(i.name));var n}function Ka(t){return"string"==typeof t?{name:t,*getAttributeKeys(){},getAttribute(){}}:{name:t.is("element")?t.name:"$text",*getAttributeKeys(){yield*t.getAttributeKeys()},getAttribute:e=>t.getAttribute(e)}}class Ja{constructor(t={}){this._splitParts=new Map,this._modelCursor=null,this.conversionApi=Object.assign({},t),this.conversionApi.convertItem=this._convertItem.bind(this),this.conversionApi.convertChildren=this._convertChildren.bind(this),this.conversionApi.splitToAllowedParent=this._splitToAllowedParent.bind(this),this.conversionApi.getSplitParts=this._getSplitParts.bind(this)}convert(t,e,i=["$root"]){this.fire("viewCleanup",t),this._modelCursor=function(t,e){let i;for(const n of new Da(t)){const t={};for(const e of n.getAttributeKeys())t[e]=n.getAttribute(e);const s=e.createElement(n.name,t);i&&e.append(s,i),i=Jr._createAt(s,0)}return i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(i,e),this.conversionApi.writer=e,this.conversionApi.consumable=Na.createFrom(t),this.conversionApi.store={};const{modelRange:n}=this._convertItem(t,this._modelCursor),s=e.createDocumentFragment();if(n){this._removeEmptyElements();for(const t of Array.from(this._modelCursor.parent.getChildren()))e.append(t,s);s.markers=function(t,e){const i=new Set,n=new Map,s=Yr._createIn(t).getItems();for(const t of s)"$marker"==t.name&&i.add(t);for(const t of i){const i=t.getAttribute("data-name"),s=e.createPositionBefore(t);n.has(i)?n.get(i).end=s.clone():n.set(i,new Yr(s.clone())),e.remove(t)}return n}(s,e)}return this._modelCursor=null,this._splitParts.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,s}_convertItem(t,e){const i=Object.assign({viewItem:t,modelCursor:e,modelRange:null});if(t.is("element")?this.fire("element:"+t.name,i,this.conversionApi):t.is("text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof Yr))throw new Ki.b("view-conversion-dispatcher-incorrect-result: Incorrect conversion result was dropped.",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(t,e){const i=new Yr(e);let n=e;for(const e of Array.from(t.getChildren())){const t=this._convertItem(e,n);t.modelRange instanceof Yr&&(i.end=t.modelRange.end,n=t.modelCursor)}return{modelRange:i,modelCursor:n}}_splitToAllowedParent(t,e){const i=this.conversionApi.schema.findAllowedParent(e,t);if(!i)return null;if(i===e.parent)return{position:e};if(this._modelCursor.parent.getAncestors().includes(i))return null;const n=this.conversionApi.writer.split(e,i),s=[];for(const t of n.range.getWalker())if("elementEnd"==t.type)s.push(t.item);else{const e=s.pop(),i=t.item;this._registerSplitPair(e,i)}return{position:n.position,cursorParent:n.range.end.parent}}_registerSplitPair(t,e){this._splitParts.has(t)||this._splitParts.set(t,[t]);const i=this._splitParts.get(t);this._splitParts.set(e,i),i.push(e)}_getSplitParts(t){let e;return e=this._splitParts.has(t)?this._splitParts.get(t):[t]}_removeEmptyElements(){let t=!1;for(const e of this._splitParts.keys())e.isEmpty&&(this.conversionApi.writer.remove(e),this._splitParts.delete(e),t=!0);t&&this._removeEmptyElements()}}cn(Ja,en);class Ya{constructor(t,e){this.model=t,this.processor=e,this.mapper=new Qr,this.downcastDispatcher=new ta({mapper:this.mapper}),this.downcastDispatcher.on("insert:$text",(t,e,i)=>{if(!i.consumable.consume(e.item,"insert"))return;const n=i.writer,s=i.mapper.toViewPosition(e.range.start),o=n.createText(e.item.data);n.insert(s,o)},{priority:"lowest"}),this.upcastDispatcher=new Ja({schema:t.schema}),this.upcastDispatcher.on("text",(t,e,i)=>{if(i.schema.checkChild(e.modelCursor,"$text")&&i.consumable.consume(e.viewItem)){const t=i.writer.createText(e.viewItem.data);i.writer.insert(t,e.modelCursor),e.modelRange=Yr._createFromPositionAndShift(e.modelCursor,t.offsetSize),e.modelCursor=e.modelRange.end}},{priority:"lowest"}),this.upcastDispatcher.on("element",(t,e,i)=>{if(!e.modelRange&&i.consumable.consume(e.viewItem,{name:!0})){const{modelRange:t,modelCursor:n}=i.convertChildren(e.viewItem,e.modelCursor);e.modelRange=t,e.modelCursor=n}},{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",(t,e,i)=>{if(!e.modelRange&&i.consumable.consume(e.viewItem,{name:!0})){const{modelRange:t,modelCursor:n}=i.convertChildren(e.viewItem,e.modelCursor);e.modelRange=t,e.modelCursor=n}},{priority:"lowest"}),this.decorate("init"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"})}get(t){const{rootName:e="main",trim:i="empty"}=t||{};if(!this._checkIfRootsExists([e]))throw new Ki.b("datacontroller-get-non-existent-root: Attempting to get data from a non-existing root.",this);const n=this.model.document.getRoot(e);return"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n):""}stringify(t){const e=this.toView(t);return this.processor.toData(e)}toView(t){this.mapper.clearBindings();const e=Yr._createIn(t),i=new Cs,n=new xs(new rs);if(this.mapper.bindElements(t,i),this.downcastDispatcher.convertInsert(e,n),!t.is("documentFragment")){const e=function(t){const e=[],i=t.root.document;if(!i)return[];const n=Yr._createIn(t);for(const t of i.model.markers){const i=n.getIntersection(t.getRange());i&&e.push([t.name,i])}return e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t);for(const[t,i]of e)this.downcastDispatcher.convertMarkerAdd(t,i,n)}return i}init(t){if(this.model.document.version)throw new Ki.b("datacontroller-init-document-not-empty: Trying to set initial data to not empty document.",this);let e={};if("string"==typeof t?e.main=t:e=t,!this._checkIfRootsExists(Object.keys(e)))throw new Ki.b("datacontroller-init-non-existent-root: Attempting to init data on a non-existing root.",this);return this.model.enqueueChange("transparent",t=>{for(const i of Object.keys(e)){const n=this.model.document.getRoot(i);t.insert(this.parse(e[i],n),n,0)}}),Promise.resolve()}set(t){let e={};if("string"==typeof t?e.main=t:e=t,!this._checkIfRootsExists(Object.keys(e)))throw new Ki.b("datacontroller-set-non-existent-root: Attempting to set data on a non-existing root.",this);this.model.enqueueChange("transparent",t=>{t.setSelection(null),t.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const i of Object.keys(e)){const n=this.model.document.getRoot(i);t.remove(t.createRangeIn(n)),t.insert(this.parse(e[i],n),n,0)}})}parse(t,e="$root"){const i=this.processor.toView(t);return this.toModel(i,e)}toModel(t,e="$root"){return this.model.change(i=>this.upcastDispatcher.convert(t,i,e))}destroy(){this.stopListening()}_checkIfRootsExists(t){for(const e of t)if(!this.model.document.getRootNames().includes(e))return!1;return!0}}cn(Ya,jn);class Qa{constructor(t,e){this._helpers=new Map,this._downcast=Array.isArray(t)?t:[t],this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=Array.isArray(e)?e:[e],this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(t,e){const i=this._downcast.includes(e);if(!this._upcast.includes(e)&&!i)throw new Ki.b("conversion-add-alias-dispatcher-not-registered: Trying to register and alias for a dispatcher that nas not been registered.",this);this._createConversionHelpers({name:t,dispatchers:[e],isDowncast:i})}for(t){if(!this._helpers.has(t))throw new Ki.b("conversion-for-unknown-group: Trying to add a converter to an unknown dispatchers group.",this);return this._helpers.get(t)}elementToElement(t){this.for("downcast").elementToElement(t);for(const{model:e,view:i}of Xa(t))this.for("upcast").elementToElement({model:e,view:i,converterPriority:t.converterPriority})}attributeToElement(t){this.for("downcast").attributeToElement(t);for(const{model:e,view:i}of Xa(t))this.for("upcast").elementToAttribute({view:i,model:e,converterPriority:t.converterPriority})}attributeToAttribute(t){this.for("downcast").attributeToAttribute(t);for(const{model:e,view:i}of Xa(t))this.for("upcast").attributeToAttribute({view:i,model:e})}_createConversionHelpers({name:t,dispatchers:e,isDowncast:i}){if(this._helpers.has(t))throw new Ki.b("conversion-group-exists: Trying to register a group name that has already been registered.",this);const n=i?new wa(e):new Aa(e);this._helpers.set(t,n)}}function*Xa(t){if(t.model.values)for(const e of t.model.values){const i={key:t.model.key,value:e},n=t.view[e],s=t.upcastAlso?t.upcastAlso[e]:void 0;yield*Za(i,n,s)}else yield*Za(t.model,t.view,t.upcastAlso)}function*Za(t,e,i){if(yield{model:t,view:e},i){i=Array.isArray(i)?i:[i];for(const e of i)yield{model:t,view:e}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tl{constructor(t="default"){this.operations=[],this.type=t}get baseVersion(){for(const t of this.operations)if(null!==t.baseVersion)return t.baseVersion;return null}addOperation(t){return t.batch=this,this.operations.push(t),t}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class el{constructor(t){this.baseVersion=t,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}_validate(){}toJSON(){const t=Object.assign({},this);return t.__className=this.constructor.className,delete t.batch,delete t.isDocumentOperation,t}static get className(){return"Operation"}static fromJSON(t){return new this(t.baseVersion)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class il{constructor(t){this.markers=new Map,this._children=new Wr,t&&this._insertChild(0,t)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}is(t){return"documentFragment"==t||"model:documentFragment"==t}getChild(t){return this._children.getNode(t)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(t){return this._children.getNodeIndex(t)}getChildStartOffset(t){return this._children.getNodeStartOffset(t)}getPath(){return[]}getNodeByPath(t){let e=this;for(const i of t)e=e.getChild(e.offsetToIndex(i));return e}offsetToIndex(t){return this._children.offsetToIndex(t)}toJSON(){const t=[];for(const e of this._children)t.push(e.toJSON());return t}static fromJSON(t){const e=[];for(const i of t)i.name?e.push(Ur.fromJSON(i)):e.push(jr.fromJSON(i));return new il(e)}_appendChild(t){this._insertChild(this.childCount,t)}_insertChild(t,e){const i=function(t){if("string"==typeof t)return[new jr(t)];wn(t)||(t=[t]);return Array.from(t).map(t=>"string"==typeof t?new jr(t):t instanceof qr?new jr(t.data,t.getAttributes()):t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);for(const t of i)null!==t.parent&&t._remove(),t.parent=this;this._children._insertNodes(t,i)}_removeChildren(t,e=1){const i=this._children._removeNodes(t,e);for(const t of i)t.parent=null;return i}}function nl(t,e){const i=(e=rl(e)).reduce((t,e)=>t+e.offsetSize,0),n=t.parent;ll(t);const s=t.index;return n._insertChild(s,e),al(n,s+e.length),al(n,s),new Yr(t,t.getShiftedBy(i))}function sl(t){if(!t.isFlat)throw new Ki.b("operation-utils-remove-range-not-flat: Trying to remove a range which starts and ends in different element.",this);const e=t.start.parent;ll(t.start),ll(t.end);const i=e._removeChildren(t.start.index,t.end.index-t.start.index);return al(e,t.start.index),i}function ol(t,e){if(!t.isFlat)throw new Ki.b("operation-utils-move-range-not-flat: Trying to move a range which starts and ends in different element.",this);const i=sl(t);return nl(e=e._getTransformedByDeletion(t.start,t.end.offset-t.start.offset),i)}function rl(t){const e=[];t instanceof Array||(t=[t]);for(let i=0;i<t.length;i++)if("string"==typeof t[i])e.push(new jr(t[i]));else if(t[i]instanceof qr)e.push(new jr(t[i].data,t[i].getAttributes()));else if(t[i]instanceof il||t[i]instanceof Wr)for(const n of t[i])e.push(n);else t[i]instanceof Hr&&e.push(t[i]);for(let t=1;t<e.length;t++){const i=e[t],n=e[t-1];i instanceof jr&&n instanceof jr&&cl(i,n)&&(e.splice(t-1,2,new jr(n.data+i.data,n.getAttributes())),t--)}return e}function al(t,e){const i=t.getChild(e-1),n=t.getChild(e);if(i&&n&&i.is("text")&&n.is("text")&&cl(i,n)){const s=new jr(i.data+n.data,i.getAttributes());t._removeChildren(e-1,2),t._insertChild(e-1,s)}}function ll(t){const e=t.textNode,i=t.parent;if(e){const n=t.offset-e.startOffset,s=e.index;i._removeChildren(s,1);const o=new jr(e.data.substr(0,n),e.getAttributes()),r=new jr(e.data.substr(n),e.getAttributes());i._insertChild(s,[o,r])}}function cl(t,e){const i=t.getAttributes(),n=e.getAttributes();for(const t of i){if(t[1]!==e.getAttribute(t[0]))return!1;n.next()}return n.next().done}var hl=function(t,e){return Xo(t,e)};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class dl extends el{constructor(t,e,i,n,s){super(s),this.range=t.clone(),this.key=e,this.oldValue=void 0===i?null:i,this.newValue=void 0===n?null:n}get type(){return null===this.oldValue?"addAttribute":null===this.newValue?"removeAttribute":"changeAttribute"}clone(){return new dl(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new dl(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const t=super.toJSON();return t.range=this.range.toJSON(),t}_validate(){if(!this.range.isFlat)throw new Ki.b("attribute-operation-range-not-flat: The range to change is not flat.",this);for(const t of this.range.getItems({shallow:!0})){if(null!==this.oldValue&&!hl(t.getAttribute(this.key),this.oldValue))throw new Ki.b("attribute-operation-wrong-old-value: Changed node has different attribute value than operation's old attribute value.",this,{item:t,key:this.key,value:this.oldValue});if(null===this.oldValue&&null!==this.newValue&&t.hasAttribute(this.key))throw new Ki.b("attribute-operation-attribute-exists: The attribute with given key already exists.",this,{node:t,key:this.key})}}_execute(){hl(this.oldValue,this.newValue)||function(t,e,i){ll(t.start),ll(t.end);for(const n of t.getItems({shallow:!0})){const t=n.is("textProxy")?n.textNode:n;null!==i?t._setAttribute(e,i):t._removeAttribute(e),al(t.parent,t.index)}al(t.end.parent,t.end.index)}(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(t,e){return new dl(Yr.fromJSON(t.range,e),t.key,t.oldValue,t.newValue,t.baseVersion)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ul extends el{constructor(t,e){super(null),this.sourcePosition=t.clone(),this.howMany=e}get type(){return"detach"}toJSON(){const t=super.toJSON();return t.sourcePosition=this.sourcePosition.toJSON(),t}_validate(){if(this.sourcePosition.root.document)throw new Ki.b("detach-operation-on-document-node: Cannot detach document node.",this)}_execute(){sl(Yr._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fl extends el{constructor(t,e,i,n){super(n),this.sourcePosition=t.clone(),this.sourcePosition.stickiness="toNext",this.howMany=e,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNone"}get type(){return"$graveyard"==this.targetPosition.root.rootName?"remove":"$graveyard"==this.sourcePosition.root.rootName?"reinsert":"move"}clone(){return new this.constructor(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){const t=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new this.constructor(this.getMovedRangeStart(),this.howMany,t,this.baseVersion+1)}_validate(){const t=this.sourcePosition.parent,e=this.targetPosition.parent,i=this.sourcePosition.offset,n=this.targetPosition.offset;if(i+this.howMany>t.maxOffset)throw new Ki.b("move-operation-nodes-do-not-exist: The nodes which should be moved do not exist.",this);if(t===e&&i<n&&n<i+this.howMany)throw new Ki.b("move-operation-range-into-itself: Trying to move a range of nodes to the inside of that range.",this);if(this.sourcePosition.root==this.targetPosition.root&&"prefix"==hn(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())){const t=this.sourcePosition.path.length-1;if(this.targetPosition.path[t]>=i&&this.targetPosition.path[t]<i+this.howMany)throw new Ki.b("move-operation-node-into-itself: Trying to move a range of nodes into one of nodes from that range.",this)}}_execute(){ol(Yr._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){const t=super.toJSON();return t.sourcePosition=this.sourcePosition.toJSON(),t.targetPosition=this.targetPosition.toJSON(),t}static get className(){return"MoveOperation"}static fromJSON(t,e){const i=Jr.fromJSON(t.sourcePosition,e),n=Jr.fromJSON(t.targetPosition,e);return new this(i,t.howMany,n,t.baseVersion)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ml extends el{constructor(t,e,i){super(i),this.position=t.clone(),this.position.stickiness="toNone",this.nodes=new Wr(rl(e)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}clone(){const t=new Wr([...this.nodes].map(t=>t._clone(!0))),e=new ml(this.position,t,this.baseVersion);return e.shouldReceiveAttributes=this.shouldReceiveAttributes,e}getReversed(){const t=this.position.root.document.graveyard,e=new Jr(t,[0]);return new fl(this.position,this.nodes.maxOffset,e,this.baseVersion+1)}_validate(){const t=this.position.parent;if(!t||t.maxOffset<this.position.offset)throw new Ki.b("insert-operation-position-invalid: Insertion position is invalid.",this)}_execute(){const t=this.nodes;this.nodes=new Wr([...t].map(t=>t._clone(!0))),nl(this.position,t)}toJSON(){const t=super.toJSON();return t.position=this.position.toJSON(),t.nodes=this.nodes.toJSON(),t}static get className(){return"InsertOperation"}static fromJSON(t,e){const i=[];for(const e of t.nodes)e.name?i.push(Ur.fromJSON(e)):i.push(jr.fromJSON(e));const n=new ml(Jr.fromJSON(t.position,e),i,t.baseVersion);return n.shouldReceiveAttributes=t.shouldReceiveAttributes,n}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class gl extends el{constructor(t,e,i,n,s,o){super(o),this.name=t,this.oldRange=e?e.clone():null,this.newRange=i?i.clone():null,this.affectsData=s,this._markers=n}get type(){return"marker"}clone(){return new gl(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new gl(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){const t=this.newRange?"_set":"_remove";this._markers[t](this.name,this.newRange,!0,this.affectsData)}toJSON(){const t=super.toJSON();return this.oldRange&&(t.oldRange=this.oldRange.toJSON()),this.newRange&&(t.newRange=this.newRange.toJSON()),delete t._markers,t}static get className(){return"MarkerOperation"}static fromJSON(t,e){return new gl(t.name,t.oldRange?Yr.fromJSON(t.oldRange,e):null,t.newRange?Yr.fromJSON(t.newRange,e):null,e.model.markers,t.affectsData,t.baseVersion)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class pl extends el{constructor(t,e,i,n){super(n),this.position=t,this.position.stickiness="toNext",this.oldName=e,this.newName=i}get type(){return"rename"}clone(){return new pl(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new pl(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const t=this.position.nodeAfter;if(!(t instanceof Ur))throw new Ki.b("rename-operation-wrong-position: Given position is invalid or node after it is not an instance of Element.",this);if(t.name!==this.oldName)throw new Ki.b("rename-operation-wrong-name: Element to change has different name than operation's old name.",this)}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const t=super.toJSON();return t.position=this.position.toJSON(),t}static get className(){return"RenameOperation"}static fromJSON(t,e){return new pl(Jr.fromJSON(t.position,e),t.oldName,t.newName,t.baseVersion)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class wl extends el{constructor(t,e,i,n,s){super(s),this.root=t,this.key=e,this.oldValue=i,this.newValue=n}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}clone(){return new wl(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new wl(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new Ki.b("rootattribute-operation-not-a-root: The element to change is not a root element.",this,{root:this.root,key:this.key});if(null!==this.oldValue&&this.root.getAttribute(this.key)!==this.oldValue)throw new Ki.b("rootattribute-operation-wrong-old-value: Changed node has different attribute value than operation's old attribute value.",this,{root:this.root,key:this.key});if(null===this.oldValue&&null!==this.newValue&&this.root.hasAttribute(this.key))throw new Ki.b("rootattribute-operation-attribute-exists: The attribute with given key already exists.",this,{root:this.root,key:this.key})}_execute(){null!==this.newValue?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const t=super.toJSON();return t.root=this.root.toJSON(),t}static get className(){return"RootAttributeOperation"}static fromJSON(t,e){if(!e.getRoot(t.root))throw new Ki.b("rootattribute-operation-fromjson-no-root: Cannot create RootAttributeOperation. Root with specified name does not exist.",this,{rootName:t.root});return new wl(e.getRoot(t.root),t.key,t.oldValue,t.newValue,t.baseVersion)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bl extends el{constructor(t,e,i,n,s){super(s),this.sourcePosition=t.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=e,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=n.clone()}get type(){return"merge"}get deletionPosition(){return new Jr(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const t=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new Yr(this.sourcePosition,t)}clone(){return new this.constructor(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const t=this.targetPosition._getTransformedByMergeOperation(this),e=this.sourcePosition.path.slice(0,-1),i=new Jr(this.sourcePosition.root,e)._getTransformedByMergeOperation(this),n=new _l(t,this.howMany,this.graveyardPosition,this.baseVersion+1);return n.insertionPosition=i,n}_validate(){const t=this.sourcePosition.parent,e=this.targetPosition.parent;if(!t.parent)throw new Ki.b("merge-operation-source-position-invalid: Merge source position is invalid.",this);if(!e.parent)throw new Ki.b("merge-operation-target-position-invalid: Merge target position is invalid.",this);if(this.howMany!=t.maxOffset)throw new Ki.b("merge-operation-how-many-invalid: Merge operation specifies wrong number of nodes to move.",this)}_execute(){const t=this.sourcePosition.parent;ol(Yr._createIn(t),this.targetPosition),ol(Yr._createOn(t),this.graveyardPosition)}toJSON(){const t=super.toJSON();return t.sourcePosition=t.sourcePosition.toJSON(),t.targetPosition=t.targetPosition.toJSON(),t.graveyardPosition=t.graveyardPosition.toJSON(),t}static get className(){return"MergeOperation"}static fromJSON(t,e){const i=Jr.fromJSON(t.sourcePosition,e),n=Jr.fromJSON(t.targetPosition,e),s=Jr.fromJSON(t.graveyardPosition,e);return new this(i,t.howMany,n,s,t.baseVersion)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _l extends el{constructor(t,e,i,n){super(n),this.splitPosition=t.clone(),this.splitPosition.stickiness="toNext",this.howMany=e,this.insertionPosition=_l.getInsertionPosition(t),this.insertionPosition.stickiness="toNone",this.graveyardPosition=i?i.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const t=this.insertionPosition.path.slice();return t.push(0),new Jr(this.insertionPosition.root,t)}get movedRange(){const t=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new Yr(this.splitPosition,t)}clone(){const t=new this.constructor(this.splitPosition,this.howMany,this.graveyardPosition,this.baseVersion);return t.insertionPosition=this.insertionPosition,t}getReversed(){const t=this.splitPosition.root.document.graveyard,e=new Jr(t,[0]);return new bl(this.moveTargetPosition,this.howMany,this.splitPosition,e,this.baseVersion+1)}_validate(){const t=this.splitPosition.parent,e=this.splitPosition.offset;if(!t||t.maxOffset<e)throw new Ki.b("split-operation-position-invalid: Split position is invalid.",this);if(!t.parent)throw new Ki.b("split-operation-split-in-root: Cannot split root element.",this);if(this.howMany!=t.maxOffset-this.splitPosition.offset)throw new Ki.b("split-operation-how-many-invalid: Split operation specifies wrong number of nodes to move.",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new Ki.b("split-operation-graveyard-position-invalid: Graveyard position invalid.",this)}_execute(){const t=this.splitPosition.parent;if(this.graveyardPosition)ol(Yr._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const e=t._clone();nl(this.insertionPosition,e)}ol(new Yr(Jr._createAt(t,this.splitPosition.offset),Jr._createAt(t,t.maxOffset)),this.moveTargetPosition)}toJSON(){const t=super.toJSON();return t.splitPosition=this.splitPosition.toJSON(),t.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(t.graveyardPosition=this.graveyardPosition.toJSON()),t}static get className(){return"SplitOperation"}static getInsertionPosition(t){const e=t.path.slice(0,-1);return e[e.length-1]++,new Jr(t.root,e)}static fromJSON(t,e){const i=Jr.fromJSON(t.splitPosition,e),n=Jr.fromJSON(t.insertionPosition,e),s=t.graveyardPosition?Jr.fromJSON(t.graveyardPosition,e):null,o=new this(i,t.howMany,s,t.baseVersion);return o.insertionPosition=n,o}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vl extends Ur{constructor(t,e,i="main"){super(e),this._doc=t,this.rootName=i}get document(){return this._doc}is(t,e){const i=t.replace("model:","");return e?"rootElement"==i&&e==this.name||super.is(t,e):"rootElement"==i||super.is(t)}toJSON(){return this.rootName}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yl{constructor(t,e){this.model=t,this.batch=e}createText(t,e){return new jr(t,e)}createElement(t,e){return new Ur(t,e)}createDocumentFragment(){return new il}insert(t,e,i=0){if(this._assertWriterUsedCorrectly(),t instanceof jr&&""==t.data)return;const n=Jr._createAt(e,i);if(t.parent){if(Pl(t.root,n.root))return void this.move(Yr._createOn(t),n);if(t.root.document)throw new Ki.b("model-writer-insert-forbidden-move: Cannot move a node from a document to a different tree. It is forbidden to move a node that was already in a document outside of it.",this);this.remove(t)}const s=n.root.document?n.root.document.version:null,o=new ml(n,t,s);if(t instanceof jr&&(o.shouldReceiveAttributes=!0),this.batch.addOperation(o),this.model.applyOperation(o),t instanceof il)for(const[e,i]of t.markers){const t=Jr._createAt(i.root,0),s={range:new Yr(i.start._getCombined(t,n),i.end._getCombined(t,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(e)?this.updateMarker(e,s):this.addMarker(e,s)}}insertText(t,e,i,n){e instanceof il||e instanceof Ur||e instanceof Jr?this.insert(this.createText(t),e,i):this.insert(this.createText(t,e),i,n)}insertElement(t,e,i,n){e instanceof il||e instanceof Ur||e instanceof Jr?this.insert(this.createElement(t),e,i):this.insert(this.createElement(t,e),i,n)}append(t,e){this.insert(t,e,"end")}appendText(t,e,i){e instanceof il||e instanceof Ur?this.insert(this.createText(t),e,"end"):this.insert(this.createText(t,e),i,"end")}appendElement(t,e,i){e instanceof il||e instanceof Ur?this.insert(this.createElement(t),e,"end"):this.insert(this.createElement(t,e),i,"end")}setAttribute(t,e,i){if(this._assertWriterUsedCorrectly(),i instanceof Yr){const n=i.getMinimalFlatRanges();for(const i of n)kl(this,t,e,i)}else Al(this,t,e,i)}setAttributes(t,e){for(const[i,n]of zr(t))this.setAttribute(i,n,e)}removeAttribute(t,e){if(this._assertWriterUsedCorrectly(),e instanceof Yr){const i=e.getMinimalFlatRanges();for(const e of i)kl(this,t,null,e)}else Al(this,t,null,e)}clearAttributes(t){this._assertWriterUsedCorrectly();const e=t=>{for(const e of t.getAttributeKeys())this.removeAttribute(e,t)};if(t instanceof Yr)for(const i of t.getItems())e(i);else e(t)}move(t,e,i){if(this._assertWriterUsedCorrectly(),!(t instanceof Yr))throw new Ki.b("writer-move-invalid-range: Invalid range to move.",this);if(!t.isFlat)throw new Ki.b("writer-move-range-not-flat: Range to move is not flat.",this);const n=Jr._createAt(e,i);if(n.isEqual(t.start))return;if(this._addOperationForAffectedMarkers("move",t),!Pl(t.root,n.root))throw new Ki.b("writer-move-different-document: Range is going to be moved between different documents.",this);const s=t.root.document?t.root.document.version:null,o=new fl(t.start,t.end.offset-t.start.offset,n,s);this.batch.addOperation(o),this.model.applyOperation(o)}remove(t){this._assertWriterUsedCorrectly();const e=(t instanceof Yr?t:Yr._createOn(t)).getMinimalFlatRanges().reverse();for(const t of e)this._addOperationForAffectedMarkers("move",t),xl(t.start,t.end.offset-t.start.offset,this.batch,this.model)}merge(t){this._assertWriterUsedCorrectly();const e=t.nodeBefore,i=t.nodeAfter;if(this._addOperationForAffectedMarkers("merge",t),!(e instanceof Ur))throw new Ki.b("writer-merge-no-element-before: Node before merge position must be an element.",this);if(!(i instanceof Ur))throw new Ki.b("writer-merge-no-element-after: Node after merge position must be an element.",this);t.root.document?this._merge(t):this._mergeDetached(t)}createPositionFromPath(t,e,i){return this.model.createPositionFromPath(t,e,i)}createPositionAt(t,e){return this.model.createPositionAt(t,e)}createPositionAfter(t){return this.model.createPositionAfter(t)}createPositionBefore(t){return this.model.createPositionBefore(t)}createRange(t,e){return this.model.createRange(t,e)}createRangeIn(t){return this.model.createRangeIn(t)}createRangeOn(t){return this.model.createRangeOn(t)}createSelection(t,e,i){return this.model.createSelection(t,e,i)}_mergeDetached(t){const e=t.nodeBefore,i=t.nodeAfter;this.move(Yr._createIn(i),Jr._createAt(e,"end")),this.remove(i)}_merge(t){const e=Jr._createAt(t.nodeBefore,"end"),i=Jr._createAt(t.nodeAfter,0),n=t.root.document.graveyard,s=new Jr(n,[0]),o=t.root.document.version,r=new bl(i,t.nodeAfter.maxOffset,e,s,o);this.batch.addOperation(r),this.model.applyOperation(r)}rename(t,e){if(this._assertWriterUsedCorrectly(),!(t instanceof Ur))throw new Ki.b("writer-rename-not-element-instance: Trying to rename an object which is not an instance of Element.",this);const i=t.root.document?t.root.document.version:null,n=new pl(Jr._createBefore(t),t.name,e,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(t,e){this._assertWriterUsedCorrectly();let i,n,s=t.parent;if(!s.parent)throw new Ki.b("writer-split-element-no-parent: Element with no parent can not be split.",this);if(e||(e=s.parent),!t.parent.getAncestors({includeSelf:!0}).includes(e))throw new Ki.b("writer-split-invalid-limit-element: Limit element is not a position ancestor.",this);do{const e=s.root.document?s.root.document.version:null,o=s.maxOffset-t.offset,r=new _l(t,o,null,e);this.batch.addOperation(r),this.model.applyOperation(r),i||n||(i=s,n=t.parent.nextSibling),s=(t=this.createPositionAfter(t.parent)).parent}while(s!==e);return{position:t,range:new Yr(Jr._createAt(i,"end"),Jr._createAt(n,0))}}wrap(t,e){if(this._assertWriterUsedCorrectly(),!t.isFlat)throw new Ki.b("writer-wrap-range-not-flat: Range to wrap is not flat.",this);const i=e instanceof Ur?e:new Ur(e);if(i.childCount>0)throw new Ki.b("writer-wrap-element-not-empty: Element to wrap with is not empty.",this);if(null!==i.parent)throw new Ki.b("writer-wrap-element-attached: Element to wrap with is already attached to tree model.",this);this.insert(i,t.start);const n=new Yr(t.start.getShiftedBy(1),t.end.getShiftedBy(1));this.move(n,Jr._createAt(i,0))}unwrap(t){if(this._assertWriterUsedCorrectly(),null===t.parent)throw new Ki.b("writer-unwrap-element-no-parent: Trying to unwrap an element which has no parent.",this);this.move(Yr._createIn(t),this.createPositionAfter(t)),this.remove(t)}addMarker(t,e){if(this._assertWriterUsedCorrectly(),!e||"boolean"!=typeof e.usingOperation)throw new Ki.b("writer-addMarker-no-usingOperation: The options.usingOperation parameter is required when adding a new marker.",this);const i=e.usingOperation,n=e.range,s=void 0!==e.affectsData&&e.affectsData;if(this.model.markers.has(t))throw new Ki.b("writer-addMarker-marker-exists: Marker with provided name already exists.",this);if(!n)throw new Ki.b("writer-addMarker-no-range: Range parameter is required when adding a new marker.",this);return i?(Cl(this,t,null,n,s),this.model.markers.get(t)):this.model.markers._set(t,n,i,s)}updateMarker(t,e){this._assertWriterUsedCorrectly();const i="string"==typeof t?t:t.name,n=this.model.markers.get(i);if(!n)throw new Ki.b("writer-updateMarker-marker-not-exists: Marker with provided name does not exists.",this);if(!e)return void this.model.markers._refresh(n);const s="boolean"==typeof e.usingOperation,o="boolean"==typeof e.affectsData,r=o?e.affectsData:n.affectsData;if(!s&&!e.range&&!o)throw new Ki.b("writer-updateMarker-wrong-options: One of the options is required - provide range, usingOperations or affectsData.",this);const a=n.getRange(),l=e.range?e.range:a;s&&e.usingOperation!==n.managedUsingOperations?e.usingOperation?Cl(this,i,null,l,r):(Cl(this,i,a,null,r),this.model.markers._set(i,l,void 0,r)):n.managedUsingOperations?Cl(this,i,a,l,r):this.model.markers._set(i,l,void 0,r)}removeMarker(t){this._assertWriterUsedCorrectly();const e="string"==typeof t?t:t.name;if(!this.model.markers.has(e))throw new Ki.b("writer-removeMarker-no-marker: Trying to remove marker which does not exist.",this);const i=this.model.markers.get(e);i.managedUsingOperations?Cl(this,e,i.getRange(),null,i.affectsData):this.model.markers._remove(e)}setSelection(t,e,i){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(t,e,i)}setSelectionFocus(t,e){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(t,e)}setSelectionAttribute(t,e){if(this._assertWriterUsedCorrectly(),"string"==typeof t)this._setSelectionAttribute(t,e);else for(const[e,i]of zr(t))this._setSelectionAttribute(e,i)}removeSelectionAttribute(t){if(this._assertWriterUsedCorrectly(),"string"==typeof t)this._removeSelectionAttribute(t);else for(const e of t)this._removeSelectionAttribute(e)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(t){this.model.document.selection._restoreGravity(t)}_setSelectionAttribute(t,e){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=ha._getStoreAttributeKey(t);this.setAttribute(n,e,i.anchor.parent)}i._setAttribute(t,e)}_removeSelectionAttribute(t){const e=this.model.document.selection;if(e.isCollapsed&&e.anchor.parent.isEmpty){const i=ha._getStoreAttributeKey(t);this.removeAttribute(i,e.anchor.parent)}e._removeAttribute(t)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new Ki.b("writer-incorrect-use: Trying to use a writer outside the change() block.",this)}_addOperationForAffectedMarkers(t,e){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let s=!1;if("move"==t)s=e.containsPosition(n.start)||e.start.isEqual(n.start)||e.containsPosition(n.end)||e.end.isEqual(n.end);else{const t=e.nodeBefore,i=e.nodeAfter,o=n.start.parent==t&&n.start.isAtEnd,r=n.end.parent==i&&0==n.end.offset,a=n.end.nodeAfter==i,l=n.start.nodeAfter==i;s=o||r||a||l}s&&this.updateMarker(i.name,{range:n})}}}function kl(t,e,i,n){const s=t.model,o=s.document;let r,a,l,c=n.start;for(const t of n.getWalker({shallow:!0}))l=t.item.getAttribute(e),r&&a!=l&&(a!=i&&h(),c=r),r=t.nextPosition,a=l;function h(){const n=new Yr(c,r),l=n.root.document?o.version:null,h=new dl(n,e,a,i,l);t.batch.addOperation(h),s.applyOperation(h)}r instanceof Jr&&r!=c&&a!=i&&h()}function Al(t,e,i,n){const s=t.model,o=s.document,r=n.getAttribute(e);let a,l;if(r!=i){if(n.root===n){const t=n.document?o.version:null;l=new wl(n,e,r,i,t)}else{const s=(a=new Yr(Jr._createBefore(n),t.createPositionAfter(n))).root.document?o.version:null;l=new dl(a,e,r,i,s)}t.batch.addOperation(l),s.applyOperation(l)}}function Cl(t,e,i,n,s){const o=t.model,r=o.document,a=new gl(e,i,n,o.markers,s,r.version);t.batch.addOperation(a),o.applyOperation(a)}function xl(t,e,i,n){let s;if(t.root.document){const i=n.document,o=new Jr(i.graveyard,[0]);s=new fl(t,e,o,i.version)}else s=new ul(t,e);i.addOperation(s),n.applyOperation(s)}function Pl(t,e){return t===e||t instanceof vl&&e instanceof vl}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tl{constructor(t){this._markerCollection=t,this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size}refreshItem(t){if(this._isInInsertedElement(t.parent))return;this._markRemove(t.parent,t.startOffset,t.offsetSize),this._markInsert(t.parent,t.startOffset,t.offsetSize);const e=Yr._createOn(t);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getRange();this.bufferMarkerChange(t.name,e,e,t.affectsData)}this._cachedChanges=null}bufferOperation(t){switch(t.type){case"insert":if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),i=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const e=Yr._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getRange();this.bufferMarkerChange(t.name,e,e,t.affectsData)}break}case"split":{const e=t.splitPosition.parent;this._isInInsertedElement(e)||this._markRemove(e,t.splitPosition.offset,t.howMany),this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1);break}case"merge":{const e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1);const n=t.targetPosition.parent;this._isInInsertedElement(n)||this._markInsert(n,t.targetPosition.offset,e.maxOffset);break}}this._cachedChanges=null}bufferMarkerChange(t,e,i,n){const s=this._changedMarkers.get(t);s?(s.newRange=i,s.affectsData=n,null==s.oldRange&&null==s.newRange&&this._changedMarkers.delete(t)):this._changedMarkers.set(t,{oldRange:e,newRange:i,affectsData:n})}getMarkersToRemove(){const t=[];for(const[e,i]of this._changedMarkers)null!=i.oldRange&&t.push({name:e,range:i.oldRange});return t}getMarkersToAdd(){const t=[];for(const[e,i]of this._changedMarkers)null!=i.newRange&&t.push({name:e,range:i.newRange});return t}getChangedMarkers(){return Array.from(this._changedMarkers).map(t=>({name:t[0],data:{oldRange:t[1].oldRange,newRange:t[1].newRange}}))}hasDataChanges(){for(const[,t]of this._changedMarkers)if(t.affectsData)return!0;return this._changesInElement.size>0}getChanges(t={includeChangesInGraveyard:!1}){if(this._cachedChanges)return t.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();const e=[];for(const t of this._changesInElement.keys()){const i=this._changesInElement.get(t).sort((t,e)=>t.offset===e.offset?t.type!=e.type?"remove"==t.type?-1:1:0:t.offset<e.offset?-1:1),n=this._elementSnapshots.get(t),s=El(t.getChildren()),o=Sl(n.length,i);let r=0,a=0;for(const i of o)if("i"===i)e.push(this._getInsertDiff(t,r,s[r].name)),r++;else if("r"===i)e.push(this._getRemoveDiff(t,r,n[a].name)),a++;else if("a"===i){const i=s[r].attributes,o=n[a].attributes;let l;if("$text"==s[r].name)l=new Yr(Jr._createAt(t,r),Jr._createAt(t,r+1));else{const e=t.offsetToIndex(r);l=new Yr(Jr._createAt(t,r),Jr._createAt(t.getChild(e),0))}e.push(...this._getAttributesDiff(l,o,i)),r++,a++}else r++,a++}e.sort((t,e)=>t.position.root!=e.position.root?t.position.root.rootName<e.position.root.rootName?-1:1:t.position.isEqual(e.position)?t.changeCount-e.changeCount:t.position.isBefore(e.position)?-1:1);for(let t=1;t<e.length;t++){const i=e[t-1],n=e[t],s="remove"==i.type&&"remove"==n.type&&"$text"==i.name&&"$text"==n.name&&i.position.isEqual(n.position),o="insert"==i.type&&"insert"==n.type&&"$text"==i.name&&"$text"==n.name&&i.position.parent==n.position.parent&&i.position.offset+i.length==n.position.offset,r="attribute"==i.type&&"attribute"==n.type&&i.position.parent==n.position.parent&&i.range.isFlat&&n.range.isFlat&&i.position.offset+i.length==n.position.offset&&i.attributeKey==n.attributeKey&&i.attributeOldValue==n.attributeOldValue&&i.attributeNewValue==n.attributeNewValue;(s||o||r)&&(e[t-1].length++,r&&(e[t-1].range.end=e[t-1].range.end.getShiftedBy(1)),e.splice(t,1),t--)}for(const t of e)delete t.changeCount,"attribute"==t.type&&(delete t.position,delete t.length);return this._changeCount=0,this._cachedChangesWithGraveyard=e.slice(),this._cachedChanges=e.slice().filter(Rl),t.includeChangesInGraveyard?this._cachedChangesWithGraveyard:this._cachedChanges}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._cachedChanges=null}_markInsert(t,e,i){const n={type:"insert",offset:e,howMany:i,count:this._changeCount++};this._markChange(t,n)}_markRemove(t,e,i){const n={type:"remove",offset:e,howMany:i,count:this._changeCount++};this._markChange(t,n),this._removeAllNestedChanges(t,e,i)}_markAttribute(t){const e={type:"attribute",offset:t.startOffset,howMany:t.offsetSize,count:this._changeCount++};this._markChange(t.parent,e)}_markChange(t,e){this._makeSnapshot(t);const i=this._getChangesForElement(t);this._handleChange(e,i),i.push(e);for(let t=0;t<i.length;t++)i[t].howMany<1&&(i.splice(t,1),t--)}_getChangesForElement(t){let e;return this._changesInElement.has(t)?e=this._changesInElement.get(t):(e=[],this._changesInElement.set(t,e)),e}_makeSnapshot(t){this._elementSnapshots.has(t)||this._elementSnapshots.set(t,El(t.getChildren()))}_handleChange(t,e){t.nodesToHandle=t.howMany;for(const i of e){const n=t.offset+t.howMany,s=i.offset+i.howMany;if("insert"==t.type&&("insert"==i.type&&(t.offset<=i.offset?i.offset+=t.howMany:t.offset<s&&(i.howMany+=t.nodesToHandle,t.nodesToHandle=0)),"remove"==i.type&&t.offset<i.offset&&(i.offset+=t.howMany),"attribute"==i.type))if(t.offset<=i.offset)i.offset+=t.howMany;else if(t.offset<s){const s=i.howMany;i.howMany=t.offset-i.offset,e.unshift({type:"attribute",offset:n,howMany:s-i.howMany,count:this._changeCount++})}if("remove"==t.type){if("insert"==i.type)if(n<=i.offset)i.offset-=t.howMany;else if(n<=s)if(t.offset<i.offset){const e=n-i.offset;i.offset=t.offset,i.howMany-=e,t.nodesToHandle-=e}else i.howMany-=t.nodesToHandle,t.nodesToHandle=0;else if(t.offset<=i.offset)t.nodesToHandle-=i.howMany,i.howMany=0;else if(t.offset<s){const e=s-t.offset;i.howMany-=e,t.nodesToHandle-=e}if("remove"==i.type&&(n<=i.offset?i.offset-=t.howMany:t.offset<i.offset&&(t.nodesToHandle+=i.howMany,i.howMany=0)),"attribute"==i.type)if(n<=i.offset)i.offset-=t.howMany;else if(t.offset<i.offset){const e=n-i.offset;i.offset=t.offset,i.howMany-=e}else if(t.offset<s)if(n<=s){const n=i.howMany;i.howMany=t.offset-i.offset;const s=n-i.howMany-t.nodesToHandle;e.unshift({type:"attribute",offset:t.offset,howMany:s,count:this._changeCount++})}else i.howMany-=s-t.offset}if("attribute"==t.type){if("insert"==i.type)if(t.offset<i.offset&&n>i.offset){if(n>s){const t={type:"attribute",offset:s,howMany:n-s,count:this._changeCount++};this._handleChange(t,e),e.push(t)}t.nodesToHandle=i.offset-t.offset,t.howMany=t.nodesToHandle}else t.offset>=i.offset&&t.offset<s&&(n>s?(t.nodesToHandle=n-s,t.offset=s):t.nodesToHandle=0);if("remove"==i.type&&t.offset<i.offset&&n>i.offset){const s={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(s,e),e.push(s),t.nodesToHandle=i.offset-t.offset,t.howMany=t.nodesToHandle}"attribute"==i.type&&(t.offset>=i.offset&&n<=s?(t.nodesToHandle=0,t.howMany=0,t.offset=0):t.offset<=i.offset&&n>=s&&(i.howMany=0))}}t.howMany=t.nodesToHandle,delete t.nodesToHandle}_getInsertDiff(t,e,i){return{type:"insert",position:Jr._createAt(t,e),name:i,length:1,changeCount:this._changeCount++}}_getRemoveDiff(t,e,i){return{type:"remove",position:Jr._createAt(t,e),name:i,length:1,changeCount:this._changeCount++}}_getAttributesDiff(t,e,i){const n=[];i=new Map(i);for(const[s,o]of e){const e=i.has(s)?i.get(s):null;e!==o&&n.push({type:"attribute",position:t.start,range:t.clone(),length:1,attributeKey:s,attributeOldValue:o,attributeNewValue:e,changeCount:this._changeCount++}),i.delete(s)}for(const[e,s]of i)n.push({type:"attribute",position:t.start,range:t.clone(),length:1,attributeKey:e,attributeOldValue:null,attributeNewValue:s,changeCount:this._changeCount++});return n}_isInInsertedElement(t){const e=t.parent;if(!e)return!1;const i=this._changesInElement.get(e),n=t.startOffset;if(i)for(const t of i)if("insert"==t.type&&n>=t.offset&&n<t.offset+t.howMany)return!0;return this._isInInsertedElement(e)}_removeAllNestedChanges(t,e,i){const n=new Yr(Jr._createAt(t,e),Jr._createAt(t,e+i));for(const t of n.getItems({shallow:!0}))t.is("element")&&(this._elementSnapshots.delete(t),this._changesInElement.delete(t),this._removeAllNestedChanges(t,0,t.maxOffset))}}function El(t){const e=[];for(const i of t)if(i.is("text"))for(let t=0;t<i.data.length;t++)e.push({name:"$text",attributes:new Map(i.getAttributes())});else e.push({name:i.name,attributes:new Map(i.getAttributes())});return e}function Sl(t,e){const i=[];let n=0,s=0;for(const t of e){if(t.offset>n){for(let e=0;e<t.offset-n;e++)i.push("e");s+=t.offset-n}if("insert"==t.type){for(let e=0;e<t.howMany;e++)i.push("i");n=t.offset+t.howMany}else if("remove"==t.type){for(let e=0;e<t.howMany;e++)i.push("r");n=t.offset,s+=t.howMany}else i.push(..."a".repeat(t.howMany).split("")),n=t.offset+t.howMany,s+=t.howMany}if(s<t)for(let e=0;e<t-s-n;e++)i.push("e");return i}function Rl(t){const e=t.position&&"$graveyard"==t.position.root.rootName,i=t.range&&"$graveyard"==t.range.root.rootName;return!e&&!i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ol{constructor(){this._operations=[],this._undoPairs=new Map,this._undoneOperations=new Set}addOperation(t){this._operations.includes(t)||this._operations.push(t)}getOperations(t=0,e=Number.POSITIVE_INFINITY){return t<0?[]:this._operations.slice(t,e)}getOperation(t){return this._operations[t]}setOperationAsUndone(t,e){this._undoPairs.set(e,t),this._undoneOperations.add(t)}isUndoingOperation(t){return this._undoPairs.has(t)}isUndoneOperation(t){return this._undoneOperations.has(t)}getUndoneOperation(t){return this._undoPairs.get(t)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Il(t,e){return!!(i=t.charAt(e-1))&&1==i.length&&/[\ud800-\udbff]/.test(i)&&function(t){return!!t&&1==t.length&&/[\udc00-\udfff]/.test(t)}(t.charAt(e));var i}function Ml(t,e){return!!(i=t.charAt(e))&&1==i.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(i);var i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Vl="$graveyard";class Nl{constructor(t){this.model=t,this.version=0,this.history=new Ol(this),this.selection=new ha(this),this.roots=new os({idProperty:"rootName"}),this.differ=new Tl(t.markers),this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",Vl),this.listenTo(t,"applyOperation",(t,e)=>{const i=e[0];if(i.isDocumentOperation&&i.baseVersion!==this.version)throw new Ki.b("model-document-applyOperation-wrong-version: Only operations with matching versions can be applied.",this,{operation:i})},{priority:"highest"}),this.listenTo(t,"applyOperation",(t,e)=>{const i=e[0];i.isDocumentOperation&&this.differ.bufferOperation(i)},{priority:"high"}),this.listenTo(t,"applyOperation",(t,e)=>{const i=e[0];i.isDocumentOperation&&(this.version++,this.history.addOperation(i))},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(t.markers,"update",(t,e,i,n)=>{this.differ.bufferMarkerChange(e.name,i,n,e.affectsData),null===i&&e.on("change",(t,i)=>{this.differ.bufferMarkerChange(e.name,i,e.getRange(),e.affectsData)})})}get graveyard(){return this.getRoot(Vl)}createRoot(t="$root",e="main"){if(this.roots.get(e))throw new Ki.b("model-document-createRoot-name-exists: Root with specified name already exists.",this,{name:e});const i=new vl(this,t,e);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(t="main"){return this.roots.get(t)}getRootNames(){return Array.from(this.roots,t=>t.rootName).filter(t=>t!=Vl)}registerPostFixer(t){this._postFixers.add(t)}toJSON(){const t=un(this);return t.selection="[engine.model.DocumentSelection]",t.model="[engine.model.Model]",t}_handleChangeBlock(t){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(t),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",t.batch):this.fire("change",t.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){for(const t of this.roots)if(t!==this.graveyard)return t;return this.graveyard}_getDefaultRange(){const t=this._getDefaultRoot(),e=this.model,i=e.schema,n=e.createPositionFromPath(t,[0]);return i.getNearestSelectionRange(n)||e.createRange(n)}_validateSelectionRange(t){return Bl(t.start)&&Bl(t.end)}_callPostFixers(t){let e=!1;do{for(const i of this._postFixers)if(this.selection.refresh(),e=i(t))break}while(e)}}function Bl(t){const e=t.textNode;if(e){const i=e.data,n=t.offset-e.startOffset;return!Il(i,n)&&!Ml(i,n)}return!0}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */cn(Nl,en);class Fl{constructor(){this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(t){return this._markers.has(t)}get(t){return this._markers.get(t)||null}_set(t,e,i=!1,n=!1){const s=t instanceof Dl?t.name:t,o=this._markers.get(s);if(o){const t=o.getRange();let r=!1;return t.isEqual(e)||(o._attachLiveRange(ra.fromRange(e)),r=!0),i!=o.managedUsingOperations&&(o._managedUsingOperations=i,r=!0),"boolean"==typeof n&&n!=o.affectsData&&(o._affectsData=n,r=!0),r&&this.fire("update:"+s,o,t,e),o}const r=ra.fromRange(e),a=new Dl(s,r,i,n);return this._markers.set(s,a),this.fire("update:"+s,a,null,e),a}_remove(t){const e=t instanceof Dl?t.name:t,i=this._markers.get(e);return!!i&&(this._markers.delete(e),this.fire("update:"+e,i,i.getRange(),null),this._destroyMarker(i),!0)}_refresh(t){const e=t instanceof Dl?t.name:t,i=this._markers.get(e);if(!i)throw new Ki.b("markercollection-refresh-marker-not-exists: Marker with provided name does not exists.",this);const n=i.getRange();this.fire("update:"+e,i,n,n,i.managedUsingOperations,i.affectsData)}*getMarkersAtPosition(t){for(const e of this)e.getRange().containsPosition(t)&&(yield e)}*getMarkersIntersectingRange(t){for(const e of this)null!==e.getRange().getIntersection(t)&&(yield e)}destroy(){for(const t of this._markers.values())this._destroyMarker(t);this._markers=null,this.stopListening()}*getMarkersGroup(t){for(const e of this._markers.values())e.name.startsWith(t+":")&&(yield e)}_destroyMarker(t){t.stopListening(),t._detachLiveRange()}}cn(Fl,en);class Dl{constructor(t,e,i,n){this.name=t,this._liveRange=this._attachLiveRange(e),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new Ki.b("marker-destroyed: Cannot use a destroyed marker instance.",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new Ki.b("marker-destroyed: Cannot use a destroyed marker instance.",this);return this._affectsData}getStart(){if(!this._liveRange)throw new Ki.b("marker-destroyed: Cannot use a destroyed marker instance.",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new Ki.b("marker-destroyed: Cannot use a destroyed marker instance.",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new Ki.b("marker-destroyed: Cannot use a destroyed marker instance.",this);return this._liveRange.toRange()}is(t){return"marker"==t||"model:marker"==t}_attachLiveRange(t){return this._liveRange&&this._detachLiveRange(),t.delegate("change:range").to(this),t.delegate("change:content").to(this),this._liveRange=t,t}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}cn(Dl,en);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ll extends Jr{constructor(t,e,i="toNone"){if(super(t,e,i),!this.root.is("rootElement"))throw new Ki.b("model-liveposition-root-not-rootelement: LivePosition's root has to be an instance of RootElement.",t);zl.call(this)}detach(){this.stopListening()}is(t){return"livePosition"==t||"model:livePosition"==t||super.is(t)}toPosition(){return new Jr(this.root,this.path.slice(),this.stickiness)}static fromPosition(t,e){return new this(t.root,t.path.slice(),e||t.stickiness)}}function zl(){this.listenTo(this.root.document.model,"applyOperation",(t,e)=>{const i=e[0];i.isDocumentOperation&&Hl.call(this,i)},{priority:"low"})}function Hl(t){const e=this.getTransformedByOperation(t);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}cn(Ll,en);class jl{constructor(t,e,i){this.model=t,this.writer=e,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=t.schema,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null}handleNodes(t,e){t=Array.from(t);for(let i=0;i<t.length;i++){const n=t[i];this._handleNode(n,{isFirst:0===i&&e.isFirst,isLast:i===t.length-1&&e.isLast})}this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}getSelectionRange(){return this.nodeToSelect?Yr._createOn(this.nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new Yr(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(t,e){if(this.schema.isObject(t))return void this._handleObject(t,e);this._checkAndSplitToAllowedPosition(t,e)?(this._insert(t),this._mergeSiblingsOf(t,e)):this._handleDisallowedNode(t,e)}_handleObject(t,e){this._checkAndSplitToAllowedPosition(t)?this._insert(t):this._tryAutoparagraphing(t,e)}_handleDisallowedNode(t,e){t.is("element")?this.handleNodes(t.getChildren(),e):this._tryAutoparagraphing(t,e)}_insert(t){if(!this.schema.checkChild(this.position,t))throw new Ki.b("insertcontent-wrong-position: Given node cannot be inserted on the given position.",this,{node:t,position:this.position});const e=Ll.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this.writer.insert(t,this.position),this.position=e.toPosition(),e.detach(),this.schema.isObject(t)&&!this.schema.checkChild(this.position,"$text")?this.nodeToSelect=t:this.nodeToSelect=null,this._filterAttributesOf.push(t)}_setAffectedBoundaries(t){this._affectedStart||(this._affectedStart=Ll.fromPosition(t,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(t)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=Ll.fromPosition(t,"toNext"))}_mergeSiblingsOf(t,e){if(!(t instanceof Ur))return;const i=this._canMergeLeft(t,e),n=this._canMergeRight(t,e),s=Ll._createBefore(t);s.stickiness="toNext";const o=Ll._createAfter(t);if(o.stickiness="toNext",i){const t=Ll.fromPosition(this.position);t.stickiness="toNext",this._affectedStart.isEqual(s)&&(this._affectedStart.detach(),this._affectedStart=Ll._createAt(s.nodeBefore,"end","toPrevious")),this.writer.merge(s),s.isEqual(this._affectedEnd)&&e.isLast&&(this._affectedEnd.detach(),this._affectedEnd=Ll._createAt(s.nodeBefore,"end","toNext")),this.position=t.toPosition(),t.detach()}if(n){if(!this.position.isEqual(o))throw new Ki.b("insertcontent-invalid-insertion-position",this);this.position=Jr._createAt(o.nodeBefore,"end");const t=Ll.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(o)&&(this._affectedEnd.detach(),this._affectedEnd=Ll._createAt(o.nodeBefore,"end","toNext")),this.writer.merge(o),o.getShiftedBy(-1).isEqual(this._affectedStart)&&e.isFirst&&(this._affectedStart.detach(),this._affectedStart=Ll._createAt(o.nodeBefore,0,"toPrevious")),this.position=t.toPosition(),t.detach()}(i||n)&&this._filterAttributesOf.push(this.position.parent),s.detach(),o.detach()}_canMergeLeft(t,e){const i=t.previousSibling;return e.isFirst&&i instanceof Ur&&this.canMergeWith.has(i)&&this.model.schema.checkMerge(i,t)}_canMergeRight(t,e){const i=t.nextSibling;return e.isLast&&i instanceof Ur&&this.canMergeWith.has(i)&&this.model.schema.checkMerge(t,i)}_tryAutoparagraphing(t,e){const i=this.writer.createElement("paragraph");this._getAllowedIn(i,this.position.parent)&&this.schema.checkChild(i,t)&&(i._appendChild(t),this._handleNode(i,e))}_checkAndSplitToAllowedPosition(t){const e=this._getAllowedIn(t,this.position.parent);if(!e)return!1;for(;e!=this.position.parent;){if(this.schema.isLimit(this.position.parent))return!1;if(this.position.isAtStart){const t=this.position.parent;this.position=this.writer.createPositionBefore(t),t.isEmpty&&t.parent===e&&this.writer.remove(t)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const t=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=t,this.canMergeWith.add(this.position.nodeAfter)}}return!0}_getAllowedIn(t,e){return this.schema.checkChild(e,t)?e:e.parent?this._getAllowedIn(t,e.parent):null}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function ql(t,e,i={}){if(e.isCollapsed)return;const n=e.getFirstRange();if("$graveyard"==n.root.rootName)return;const s=t.schema;t.change(t=>{if(!i.doNotResetEntireContent&&function(t,e){const i=t.getLimitElement(e);if(!e.containsEntireContent(i))return!1;const n=e.getFirstRange();if(n.start.parent==n.end.parent)return!1;return t.checkChild(i,"paragraph")}(s,e))return void function(t,e){const i=t.model.schema.getLimitElement(e);t.remove(t.createRangeIn(i)),Wl(t,t.createPositionAt(i,0),e)}(t,e);const o=n.start,r=Ll.fromPosition(n.end,"toNext");if(n.start.isTouching(n.end)||t.remove(n),i.leaveUnmerged||(!function t(e,i,n){const s=i.parent;const o=n.parent;if(s==o)return;if(e.model.schema.isLimit(s)||e.model.schema.isLimit(o))return;if(!function(t,e,i){const n=new Yr(t,e);for(const t of n.getWalker())if(i.isLimit(t.item))return!1;return!0}(i,n,e.model.schema))return;i=e.createPositionAfter(s);n=e.createPositionBefore(o);n.isEqual(i)||e.insert(o,i);e.merge(i);for(;n.parent.isEmpty;){const t=n.parent;n=e.createPositionBefore(t),e.remove(t)}t(e,i,n)}(t,o,r),s.removeDisallowedAttributes(o.parent.getChildren(),t)),Ul(t,e,o),function(t,e){const i=t.checkChild(e,"$text"),n=t.checkChild(e,"paragraph");return!i&&n}(s,o)){const n=s.getNearestSelectionRange(o);i.doNotAutoparagraph&&n?Ul(t,e,n):Wl(t,o,e)}r.detach()})}function Wl(t,e,i){const n=t.createElement("paragraph");t.insert(n,e),Ul(t,i,t.createPositionAt(n,0))}function Ul(t,e,i){e instanceof ha?t.setSelection(i):e.setTo(i)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const $l=' ,.?!:;"-()';function Gl(t,e){if("text"==e.type)return"word"===t.unit?function(t,e){let i=t.position.textNode;if(i){let n=t.position.offset-i.startOffset;for(;!Jl(i.data,n,e)&&!Yl(i,n,e);){t.next();const s=e?t.position.nodeAfter:t.position.nodeBefore;if(s&&s.is("text")){const n=s.data.charAt(e?0:s.data.length-1);$l.includes(n)||(t.next(),i=t.position.textNode)}n=t.position.offset-i.startOffset}}return t.position}(t.walker,t.isForward):function(t,e){const i=t.position.textNode;if(i){const n=i.data;let s=t.position.offset-i.startOffset;for(;Il(n,s)||"character"==e&&Ml(n,s);)t.next(),s=t.position.offset-i.startOffset}return t.position}(t.walker,t.unit,t.isForward);if(e.type==(t.isForward?"elementStart":"elementEnd")){if(t.schema.isObject(e.item))return Jr._createAt(e.item,t.isForward?"after":"before");if(t.schema.checkChild(e.nextPosition,"$text"))return e.nextPosition}else{if(t.schema.isLimit(e.item))return void t.walker.skip(()=>!0);if(t.schema.checkChild(e.nextPosition,"$text"))return e.nextPosition}}function Kl(t,e){const i=t.root,n=Jr._createAt(i,e?"end":0);return e?new Yr(t,n):new Yr(n,t)}function Jl(t,e,i){const n=e+(i?0:-1);return $l.includes(t.charAt(n))}function Yl(t,e,i){return e===(i?t.endOffset:0)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ql(t,e){const i=[];Array.from(t.getItems({direction:"backward"})).map(t=>e.createRangeOn(t)).filter(e=>{return(e.start.isAfter(t.start)||e.start.isEqual(t.start))&&(e.end.isBefore(t.end)||e.end.isEqual(t.end))}).forEach(t=>{i.push(t.start.parent),e.remove(t)}),i.forEach(t=>{let i=t;for(;i.parent&&i.isEmpty;){const t=e.createRangeOn(i);i=i.parent,e.remove(t)}})}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Xl(t){t.document.registerPostFixer(e=>(function(t,e){const i=e.document.selection,n=e.schema,s=[];let o=!1;for(const t of i.getRanges()){const e=Zl(t,n);e?(s.push(e),o=!0):s.push(t)}if(o){let e=s;if(s.length>1){const t=s[0].start,i=s[s.length-1].end;e=[new Yr(t,i)]}t.setSelection(e,{backward:i.isBackward})}})(e,t))}function Zl(t,e){return t.isCollapsed?function(t,e){const i=t.start,n=e.getNearestSelectionRange(i);if(!n)return null;const s=n.start;if(i.isEqual(s))return null;if(s.nodeAfter&&e.isLimit(s.nodeAfter))return new Yr(s,Jr._createAfter(s.nodeAfter));return new Yr(s)}(t,e):function(t,e){const i=t.start,n=t.end,s=e.checkChild(i,"$text"),o=e.checkChild(n,"$text"),r=e.getLimitElement(i),a=e.getLimitElement(n);if(r===a){if(s&&o)return null;if(function(t,e,i){const n=t.nodeAfter&&!i.isLimit(t.nodeAfter)||i.checkChild(t,"$text"),s=e.nodeBefore&&!i.isLimit(e.nodeBefore)||i.checkChild(e,"$text");return n||s}(i,n,e)){const t=i.nodeAfter&&e.isObject(i.nodeAfter)?null:e.getNearestSelectionRange(i,"forward"),s=n.nodeBefore&&e.isObject(n.nodeBefore)?null:e.getNearestSelectionRange(n,"backward"),o=t?t.start:i,r=s?s.start:n;return new Yr(o,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const t=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,s=l&&(!t||!ec(i.nodeAfter,e)),o=c&&(!t||!ec(n.nodeBefore,e));let h=i,d=n;return s&&(h=Jr._createBefore(tc(r,e))),o&&(d=Jr._createAfter(tc(a,e))),new Yr(h,d)}return null}(t,e)}function tc(t,e){let i=t,n=i;for(;e.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function ec(t,e){return t&&e.isObject(t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ic{constructor(){this.markers=new Fl,this.document=new Nl(this),this.schema=new Fa,this._pendingChanges=[],this._currentWriter=null,["insertContent","deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(t=>this.decorate(t)),this.on("applyOperation",(t,e)=>{e[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$block",{allowIn:"$root",isBlock:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",isLimit:!0}),this.schema.extend("$text",{allowIn:"$clipboardHolder"}),this.schema.register("$marker"),this.schema.addChildCheck((t,e)=>{if("$marker"===e.name)return!0}),Xl(this)}change(t){return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new tl,callback:t}),this._runPendingChanges()[0]):t(this._currentWriter)}enqueueChange(t,e){"string"==typeof t?t=new tl(t):"function"==typeof t&&(e=t,t=new tl),this._pendingChanges.push({batch:t,callback:e}),1==this._pendingChanges.length&&this._runPendingChanges()}applyOperation(t){t._execute()}insertContent(t,e,i){
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
return function(t,e,i,n){return t.change(s=>{let o;const r=(o=i?i instanceof ia||i instanceof ha?i:s.createSelection(i,n):t.document.selection).getFirstPosition();o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0});const a=new jl(t,s,r);let l;l=e.is("documentFragment")?e.getChildren():[e],a.handleNodes(l,{isFirst:!0,isLast:!0});const c=a.getSelectionRange();c&&(o instanceof ha?s.setSelection(c):o.setTo(c));const h=a.getAffectedRange()||t.createRange(r);return a.destroy(),h})}(this,t,e,i)}deleteContent(t,e){ql(this,t,e)}modifySelection(t,e){!function(t,e,i={}){const n=t.schema,s="backward"!=i.direction,o=i.unit?i.unit:"character",r=e.focus,a=new $r({boundaries:Kl(r,s),singleCharacters:!0,direction:s?"forward":"backward"}),l={walker:a,schema:n,isForward:s,unit:o};let c;for(;c=a.next();){if(c.done)return;const i=Gl(l,c.value);if(i)return void(e instanceof ha?t.change(t=>{t.setSelectionFocus(i)}):e.setFocus(i))}}(this,t,e)}getSelectedContent(t){return function(t,e){return t.change(t=>{const i=t.createDocumentFragment(),n=e.getFirstRange();if(!n||n.isCollapsed)return i;const s=n.start.root,o=n.start.getCommonPath(n.end),r=s.getNodeByPath(o);let a;const l=(a=n.start.parent==n.end.parent?n:t.createRange(t.createPositionAt(r,n.start.path[o.length]),t.createPositionAt(r,n.end.path[o.length]+1))).end.offset-a.start.offset;for(const e of a.getItems({shallow:!0}))e.is("textProxy")?t.appendText(e.data,e.getAttributes(),i):t.append(e._clone(!0),i);if(a!=n){const e=n._getTransformedByMove(a.start,t.createPositionAt(i,0),l)[0],s=t.createRange(t.createPositionAt(i,0),e.start);Ql(t.createRange(e.end,t.createPositionAt(i,"end")),t),Ql(s,t)}return i})}(this,t)}hasContent(t,e){const i=t instanceof Ur?Yr._createIn(t):t;if(i.isCollapsed)return!1;for(const t of this.markers.getMarkersIntersectingRange(i))if(t.affectsData)return!0;const{ignoreWhitespaces:n=!1}=e||{};for(const t of i.getItems())if(t.is("textProxy")){if(!n)return!0;if(-1!==t.data.search(/\S/))return!0}else if(this.schema.isObject(t))return!0;return!1}createPositionFromPath(t,e,i){return new Jr(t,e,i)}createPositionAt(t,e){return Jr._createAt(t,e)}createPositionAfter(t){return Jr._createAfter(t)}createPositionBefore(t){return Jr._createBefore(t)}createRange(t,e){return new Yr(t,e)}createRangeIn(t){return Yr._createIn(t)}createRangeOn(t){return Yr._createOn(t)}createSelection(t,e,i){return new ia(t,e,i)}createBatch(t){return new tl(t)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const t=[];for(this.fire("_beforeChanges");this._pendingChanges.length;){const e=this._pendingChanges[0].batch;this._currentWriter=new yl(this,e);const i=this._pendingChanges[0].callback(this._currentWriter);t.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}return this.fire("_afterChanges"),t}}cn(ic,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class nc{constructor(){this._listener=Object.create(ho)}listenTo(t){this._listener.listenTo(t,"keydown",(t,e)=>{this._listener.fire("_keydown:"+bs(e),e)})}set(t,e,i={}){const n=_s(t),s=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,(t,i)=>{e(i,()=>{i.preventDefault(),i.stopPropagation(),t.stop()}),t.return=!0},{priority:s})}press(t){return!!this._listener.fire("_keydown:"+bs(t),t)}destroy(){this._listener.stopListening()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class sc extends nc{constructor(t){super(),this.editor=t}set(t,e,i={}){if("string"==typeof e){const t=e;e=(e,i)=>{this.editor.execute(t),i()}}super.set(t,e,i)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class oc{constructor(t){const e=this.constructor.builtinPlugins;this.config=new $i(t,this.constructor.defaultConfig),this.config.define("plugins",e),this.plugins=new Sa(this,e),this.commands=new Ra;const i=this.config.get("language")||{};this.locale=new Ma({uiLanguage:"string"==typeof i?i:i.ui,contentLanguage:this.config.get("language.content")}),this.t=this.locale.t,this.set("state","initializing"),this.once("ready",()=>this.state="ready",{priority:"high"}),this.once("destroy",()=>this.state="destroyed",{priority:"high"}),this.set("isReadOnly",!1),this.model=new ic,this.data=new Ya(this.model),this.editing=new Ea(this.model),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new Qa([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 sc(this),this.keystrokes.listenTo(this.editing.view.document)}initPlugins(){const t=this.config,e=t.get("plugins")||[],i=t.get("removePlugins")||[],n=t.get("extraPlugins")||[];return this.plugins.init(e.concat(n),i)}destroy(){let t=Promise.resolve();return"initializing"==this.state&&(t=new Promise(t=>this.once("ready",t))),t.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()})}execute(...t){this.commands.execute(...t)}}cn(oc,jn);var rc={setData(t){this.data.set(t)},getData(t){return this.data.get(t)}};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */var ac={updateSourceElement(){if(!this.sourceElement)throw new Ki.b("editor-missing-sourceelement: Cannot update the source element of a detached editor.",this);var t,e;
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */t=this.sourceElement,e=this.data.get(),t instanceof HTMLTextAreaElement&&(t.value=e),t.innerHTML=e}};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class lc{getHtml(t){const e=document.implementation.createHTMLDocument("").createElement("div");return e.appendChild(t),e.innerHTML}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cc{constructor(){this._domParser=new DOMParser,this._domConverter=new ro({blockFiller:Fs}),this._htmlWriter=new lc}toData(t){const e=this._domConverter.viewToDom(t,document);return this._htmlWriter.getHtml(e)}toView(t){const e=this._toDom(t);return this._domConverter.domToView(e)}_toDom(t){const e=this._domParser.parseFromString(t,"text/html"),i=e.createDocumentFragment(),n=e.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hc{constructor(t){this.editor=t,this._components=new Map}*names(){for(const t of this._components.values())yield t.originalName}add(t,e){if(this.has(t))throw new Ki.b("componentfactory-item-exists: The item already exists in the component factory.",this,{name:t});this._components.set(dc(t),{callback:e,originalName:t})}create(t){if(!this.has(t))throw new Ki.b("componentfactory-item-missing: The required component is not registered in the factory.",this,{name:t});return this._components.get(dc(t)).callback(this.editor.locale)}has(t){return this._components.has(dc(t))}}function dc(t){return String(t).toLowerCase()}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class uc{constructor(){this.set("isFocused",!1),this.set("focusedElement",null),this._elements=new Set,this._nextEventLoopTimeout=null}add(t){if(this._elements.has(t))throw new Ki.b("focusTracker-add-element-already-exist",this);this.listenTo(t,"focus",()=>this._focus(t),{useCapture:!0}),this.listenTo(t,"blur",()=>this._blur(),{useCapture:!0}),this._elements.add(t)}remove(t){t===this.focusedElement&&this._blur(t),this._elements.has(t)&&(this.stopListening(t),this._elements.delete(t))}destroy(){this.stopListening()}_focus(t){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=t,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout(()=>{this.focusedElement=null,this.isFocused=!1},0)}}cn(uc,ho),cn(uc,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class fc{constructor(t){this.editor=t,this.componentFactory=new hc(t),this.focusTracker=new uc,this._editableElementsMap=new Map,this.listenTo(t.editing.view.document,"layoutChanged",()=>this.update())}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy();for(const t of this._editableElementsMap.values())t.ckeditorInstance=null;this._editableElementsMap=new Map}setEditableElement(t,e){this._editableElementsMap.set(t,e),e.ckeditorInstance||(e.ckeditorInstance=this.editor)}getEditableElement(t="main"){return this._editableElementsMap.get(t)}getEditableElementsNames(){return this._editableElementsMap.keys()}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}}cn(fc,en);i(14);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const mc=new WeakMap;function gc(t){const{view:e,element:i,text:n,isDirectHost:s=!0}=t,o=e.document;mc.has(o)||(mc.set(o,new Map),o.registerPostFixer(t=>wc(o,t))),mc.get(o).set(i,{text:n,isDirectHost:s}),e.change(t=>wc(o,t))}function pc(t,e){return!!e.hasClass("ck-placeholder")&&(t.removeClass("ck-placeholder",e),!0)}function wc(t,e){const i=mc.get(t);let n=!1;for(const[t,s]of i)bc(e,t,s)&&(n=!0);return n}function bc(t,e,i){const{text:n,isDirectHost:s}=i,o=s?e:function(t){if(1===t.childCount){const e=t.getChild(0);if(e.is("element")&&!e.is("uiElement"))return e}return null}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e);let r=!1;return!!o&&(i.hostElement=o,o.getAttribute("data-placeholder")!==n&&(t.setAttribute("data-placeholder",n,o),r=!0),!function(t){const e=t.document;if(!e)return!1;const i=!Array.from(t.getChildren()).some(t=>!t.is("uiElement"));if(!e.isFocused&&i)return!0;const n=e.selection.anchor;return!(!i||!n||n.parent===t)}(o)?pc(t,o)&&(r=!0):function(t,e){return!e.hasClass("ck-placeholder")&&(t.addClass("ck-placeholder",e),!0)}(t,o)&&(r=!0),r)}class _c{constructor(){this._replacedElements=[]}replace(t,e){this._replacedElements.push({element:t,newElement:e}),t.style.display="none",e&&t.parentNode.insertBefore(e,t.nextSibling)}restore(){this._replacedElements.forEach(({element:t,newElement:e})=>{t.style.display="",e&&e.remove()}),this._replacedElements=[]}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vc extends fc{constructor(t,e){
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
var i;super(t),this.view=e,this._toolbarConfig=(i=t.config.get("toolbar"),Array.isArray(i)?{items:i}:i?Object.assign({items:[]},i):{items:[]}),this._elementReplacer=new _c}get element(){return this.view.element}init(t){const e=this.editor,i=this.view,n=e.editing.view,s=i.editable,o=n.document.getRoot();s.name=o.rootName,i.render();const r=s.element;this.setEditableElement(s.name,r),this.focusTracker.add(r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),t&&this._elementReplacer.replace(t,this.element),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){const t=this.view,e=this.editor.editing.view;this._elementReplacer.restore(),e.detachDomRoot(t.editable.name),t.destroy(),super.destroy()}_initToolbar(){const t=this.editor,e=this.view,i=t.editing.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,this._toolbarConfig.viewportTopOffset&&(e.stickyPanel.viewportTopOffset=this._toolbarConfig.viewportTopOffset),e.toolbar.fillFromConfig(this._toolbarConfig.items,this.componentFactory),
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function({origin:t,originKeystrokeHandler:e,originFocusTracker:i,toolbar:n,beforeFocus:s,afterBlur:o}){i.add(n.element),e.set("Alt+F10",(t,e)=>{i.isFocused&&!n.focusTracker.isFocused&&(s&&s(),n.focus(),e())}),n.keystrokes.set("Esc",(e,i)=>{n.focusTracker.isFocused&&(t.focus(),o&&o(),i())})}({origin:i,originFocusTracker:this.focusTracker,originKeystrokeHandler:t.keystrokes,toolbar:e.toolbar})}_initPlaceholder(){const t=this.editor,e=t.editing.view,i=e.document.getRoot(),n=t.sourceElement,s=t.config.get("placeholder")||n&&"textarea"===n.tagName.toLowerCase()&&n.getAttribute("placeholder");s&&gc({view:e,element:i,text:s,isDirectHost:!1})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class yc extends os{constructor(t){super({idProperty:"viewUid"}),this.on("add",(t,e,i)=>{e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[i])}),this.on("remove",(t,e)=>{e.element&&this._parentElement&&e.element.remove()}),this.locale=t,this._parentElement=null}destroy(){this.map(t=>t.destroy())}setParent(t){this._parentElement=t}delegate(...t){if(!t.length||!t.every(t=>"string"==typeof t))throw new Ki.b("ui-viewcollection-delegate-wrong-events: All event names must be strings.",this);return{to:e=>{for(const i of this)for(const n of t)i.delegate(n).to(e);this.on("add",(i,n)=>{for(const i of t)n.delegate(i).to(e)}),this.on("remove",(i,n)=>{for(const i of t)n.stopDelegating(i,e)})}}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const kc="http://www.w3.org/1999/xhtml";class Ac{constructor(t){Object.assign(this,Mc(Ic(t))),this._isRendered=!1,this._revertData=null}render(){const t=this._renderNode({intoFragment:!0});return this._isRendered=!0,t}apply(t){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:t,isApplying:!0,revertData:this._revertData}),t}revert(t){if(!this._revertData)throw new Ki.b("ui-template-revert-not-applied: Attempting to revert a template which has not been applied yet.",[this,t]);this._revertTemplateFromNode(t,this._revertData)}*getViews(){yield*function*t(e){if(e.children)for(const i of e.children)Dc(i)?yield i:Lc(i)&&(yield*t(i))}(this)}static bind(t,e){return{to:(i,n)=>new xc({eventNameOrFunction:i,attribute:i,observable:t,emitter:e,callback:n}),if:(i,n,s)=>new Pc({observable:t,emitter:e,attribute:i,valueIfTrue:n,callback:s})}}static extend(t,e){if(t._isRendered)throw new Ki.b("template-extend-render: Attempting to extend a template which has already been rendered.",[this,t]);!function t(e,i){i.attributes&&(e.attributes||(e.attributes={}),Bc(e.attributes,i.attributes));i.eventListeners&&(e.eventListeners||(e.eventListeners={}),Bc(e.eventListeners,i.eventListeners));i.text&&e.text.push(...i.text);if(i.children&&i.children.length){if(e.children.length!=i.children.length)throw new Ki.b("ui-template-extend-children-mismatch: The number of children in extended definition does not match.",e);let n=0;for(const s of i.children)t(e.children[n++],s)}}(t,Mc(Ic(e)))}_renderNode(t){let e;if(e=t.node?this.tag&&this.text:this.tag?this.text:!this.text)throw new Ki.b('ui-template-wrong-syntax: Node definition must have either "tag" or "text" when rendering a new Node.',this);return this.text?this._renderText(t):this._renderElement(t)}_renderElement(t){let e=t.node;return e||(e=t.node=document.createElementNS(this.ns||kc,this.tag)),this._renderAttributes(t),this._renderElementChildren(t),this._setUpListeners(t),e}_renderText(t){let e=t.node;return e?t.revertData.text=e.textContent:e=t.node=document.createTextNode(""),Tc(this.text)?this._bindToObservable({schema:this.text,updater:Sc(e),data:t}):e.textContent=this.text.join(""),e}_renderAttributes(t){let e,i,n,s;if(!this.attributes)return;const o=t.node,r=t.revertData;for(e in this.attributes)if(n=o.getAttribute(e),i=this.attributes[e],r&&(r.attributes[e]=n),s=z(i[0])&&i[0].ns?i[0].ns:null,Tc(i)){const a=s?i[0].value:i;r&&Hc(e)&&a.unshift(n),this._bindToObservable({schema:a,updater:Rc(o,e,s),data:t})}else"style"==e&&"string"!=typeof i[0]?this._renderStyleAttribute(i[0],t):(r&&n&&Hc(e)&&i.unshift(n),Fc(i=i.map(t=>t&&t.value||t).reduce((t,e)=>t.concat(e),[]).reduce(Nc,""))||o.setAttributeNS(s,e,i))}_renderStyleAttribute(t,e){const i=e.node;for(const n in t){const s=t[n];Tc(s)?this._bindToObservable({schema:[s],updater:Oc(i,n),data:e}):i.style[n]=s}}_renderElementChildren(t){const e=t.node,i=t.intoFragment?document.createDocumentFragment():e,n=t.isApplying;let s=0;for(const o of this.children)if(zc(o)){if(!n){o.setParent(e);for(const t of o)i.appendChild(t.element)}}else if(Dc(o))n||(o.isRendered||o.render(),i.appendChild(o.element));else if(Xs(o))i.appendChild(o);else if(n){const e={children:[],bindings:[],attributes:{}};t.revertData.children.push(e),o._renderNode({node:i.childNodes[s++],isApplying:!0,revertData:e})}else i.appendChild(o.render());t.intoFragment&&e.appendChild(i)}_setUpListeners(t){if(this.eventListeners)for(const e in this.eventListeners){const i=this.eventListeners[e].map(i=>{const[n,s]=e.split("@");return i.activateDomEventListener(n,s,t)});t.revertData&&t.revertData.bindings.push(i)}}_bindToObservable({schema:t,updater:e,data:i}){const n=i.revertData;Ec(t,e,i);const s=t.filter(t=>!Fc(t)).filter(t=>t.observable).map(n=>n.activateAttributeListener(t,e,i));n&&n.bindings.push(s)}_revertTemplateFromNode(t,e){for(const t of e.bindings)for(const e of t)e();if(e.text)t.textContent=e.text;else{for(const i in e.attributes){const n=e.attributes[i];null===n?t.removeAttribute(i):t.setAttribute(i,n)}for(let i=0;i<e.children.length;++i)this._revertTemplateFromNode(t.childNodes[i],e.children[i])}}}cn(Ac,en);class Cc{constructor(t){Object.assign(this,t)}getValue(t){const e=this.observable[this.attribute];return this.callback?this.callback(e,t):e}activateAttributeListener(t,e,i){const n=()=>Ec(t,e,i);return this.emitter.listenTo(this.observable,"change:"+this.attribute,n),()=>{this.emitter.stopListening(this.observable,"change:"+this.attribute,n)}}}class xc extends Cc{activateDomEventListener(t,e,i){const n=(t,i)=>{e&&!i.target.matches(e)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(i):this.observable.fire(this.eventNameOrFunction,i))};return this.emitter.listenTo(i.node,t,n),()=>{this.emitter.stopListening(i.node,t,n)}}}class Pc extends Cc{getValue(t){return!Fc(super.getValue(t))&&(this.valueIfTrue||!0)}}function Tc(t){return!!t&&(t.value&&(t=t.value),Array.isArray(t)?t.some(Tc):t instanceof Cc)}function Ec(t,e,{node:i}){let n=function(t,e){return t.map(t=>t instanceof Cc?t.getValue(e):t)}(t,i);Fc(n=1==t.length&&t[0]instanceof Pc?n[0]:n.reduce(Nc,""))?e.remove():e.set(n)}function Sc(t){return{set(e){t.textContent=e},remove(){t.textContent=""}}}function Rc(t,e,i){return{set(n){t.setAttributeNS(i,e,n)},remove(){t.removeAttributeNS(i,e)}}}function Oc(t,e){return{set(i){t.style[e]=i},remove(){t.style[e]=null}}}function Ic(t){return Wi(t,t=>{if(t&&(t instanceof Cc||Lc(t)||Dc(t)||zc(t)))return t})}function Mc(t){if("string"==typeof t?t=function(t){return{text:[t]}}(t):t.text&&function(t){Array.isArray(t.text)||(t.text=[t.text])}(t),t.on&&(t.eventListeners=function(t){for(const e in t)Vc(t,e);return t}(t.on),delete t.on),!t.text){t.attributes&&function(t){for(const e in t)t[e].value&&(t[e].value=[].concat(t[e].value)),Vc(t,e)}(t.attributes);const e=[];if(t.children)if(zc(t.children))e.push(t.children);else for(const i of t.children)Lc(i)||Dc(i)||Xs(i)?e.push(i):e.push(new Ac(i));t.children=e}return t}function Vc(t,e){Array.isArray(t[e])||(t[e]=[t[e]])}function Nc(t,e){return Fc(e)?t:Fc(t)?e:`${t} ${e}`}function Bc(t,e){for(const i in e)t[i]?t[i].push(...e[i]):t[i]=e[i]}function Fc(t){return!t&&0!==t}function Dc(t){return t instanceof jc}function Lc(t){return t instanceof Ac}function zc(t){return t instanceof yc}function Hc(t){return"class"==t||"style"==t}i(15);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jc{constructor(t){this.element=null,this.isRendered=!1,this.locale=t,this.t=t&&t.t,this._viewCollections=new os,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",(e,i)=>{i.locale=t}),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=Ac.bind(this,this)}createCollection(){const t=new yc;return this._viewCollections.add(t),t}registerChild(t){wn(t)||(t=[t]);for(const e of t)this._unboundChildren.add(e)}deregisterChild(t){wn(t)||(t=[t]);for(const e of t)this._unboundChildren.remove(e)}setTemplate(t){this.template=new Ac(t)}extendTemplate(t){Ac.extend(this.template,t)}render(){if(this.isRendered)throw new Ki.b("ui-view-render-already-rendered: This View has already been rendered.",this);this.template&&(this.element=this.template.render(),this.registerChild(this.template.getViews())),this.isRendered=!0}destroy(){this.stopListening(),this._viewCollections.map(t=>t.destroy()),this.template&&this.template._revertData&&this.template.revert(this.element)}}cn(jc,ho),cn(jc,jn);i(16);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class qc extends jc{constructor(t){super(t),this.body=this.createCollection()}render(){super.render(),this._renderBodyCollection()}destroy(){return this._bodyCollectionContainer.remove(),super.destroy()}_renderBodyCollection(){const t=this.locale,e=this._bodyCollectionContainer=new Ac({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:t.uiLanguageDirection},children:this.body}).render();document.body.appendChild(e)}}i(17);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wc extends jc{constructor(t){super(t),this.set("text"),this.set("for");const e=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],for:e.to("for")},children:[{text:e.to("text")}]})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Uc extends qc{constructor(t){super(t);const e=Qi();this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createVoiceLabel(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-editor","ck-rounded-corners"],role:"application",dir:t.uiLanguageDirection,lang:t.uiLanguage,"aria-labelledby":`ck-editor__aria-label_${e}`},children:[this._voiceLabelView,{tag:"div",attributes:{class:["ck","ck-editor__top","ck-reset_all"],role:"presentation"},children:this.top},{tag:"div",attributes:{class:["ck","ck-editor__main"],role:"presentation"},children:this.main}]})}_createVoiceLabel(t){const e=this.t,i=new Wc;return i.text=e("Rich Text Editor"),i.extendTemplate({attributes:{id:`ck-editor__aria-label_${t}`,class:"ck-voice-label"}}),i}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $c extends jc{constructor(t,e,i){super(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:t.contentLanguage,dir:t.contentLanguageDirection}}),this.name=null,this.set("isFocused",!1),this._editableElement=i,this._hasExternalElement=!!this._editableElement,this._editingView=e}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()}_updateIsFocusedClasses(){const t=this._editingView;function e(e){t.change(i=>{const n=t.document.getRoot(e.name);i.addClass(e.isFocused?"ck-focused":"ck-blurred",n),i.removeClass(e.isFocused?"ck-blurred":"ck-focused",n)})}t.isRenderingInProgress?function i(n){t.once("change:isRenderingInProgress",(t,s,o)=>{o?i(n):e(n)})}(this):e(this)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gc extends $c{constructor(t,e,i){super(t,e,i),this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const t=this._editingView,e=this.t;t.change(i=>{const n=t.document.getRoot(this.name);i.setAttribute("aria-label",e("Rich Text Editor, %0",[this.name]),n)})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Kc(t){return e=>e+t}i(18);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Jc=Kc("px");class Yc extends jc{constructor(t){super(t);const e=this.bindTemplate;this.set("isActive",!1),this.set("isSticky",!1),this.set("limiterElement",null),this.set("limiterBottomOffset",50),this.set("viewportTopOffset",0),this.set("_marginLeft",null),this.set("_isStickyToTheLimiter",!1),this.set("_hasViewportTopOffset",!1),this.content=this.createCollection(),this._contentPanelPlaceholder=new Ac({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:e.to("isSticky",t=>t?"block":"none"),height:e.to("isSticky",t=>t?Jc(this._panelRect.height):null)}}}).render(),this._contentPanel=new Ac({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",e.if("isSticky","ck-sticky-panel__content_sticky"),e.if("_isStickyToTheLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:e.to("isSticky",t=>t?Jc(this._contentPanelPlaceholder.getBoundingClientRect().width):null),top:e.to("_hasViewportTopOffset",t=>t?Jc(this.viewportTopOffset):null),bottom:e.to("_isStickyToTheLimiter",t=>t?Jc(this.limiterBottomOffset):null),marginLeft:e.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this._contentPanel]})}render(){super.render(),this._checkIfShouldBeSticky(),this.listenTo(no.window,"scroll",()=>{this._checkIfShouldBeSticky()}),this.listenTo(this,"change:isActive",()=>{this._checkIfShouldBeSticky()})}_checkIfShouldBeSticky(){const t=this._panelRect=this._contentPanel.getBoundingClientRect();let e;this.limiterElement?(e=this._limiterRect=this.limiterElement.getBoundingClientRect(),this.isSticky=this.isActive&&e.top<this.viewportTopOffset&&this._panelRect.height+this.limiterBottomOffset<e.height):this.isSticky=!1,this.isSticky?(this._isStickyToTheLimiter=e.bottom<t.height+this.limiterBottomOffset+this.viewportTopOffset,this._hasViewportTopOffset=!this._isStickyToTheLimiter&&!!this.viewportTopOffset,this._marginLeft=this._isStickyToTheLimiter?null:Jc(-no.window.scrollX)):(this._isStickyToTheLimiter=!1,this._hasViewportTopOffset=!1,this._marginLeft=null)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Qc{constructor(t){if(Object.assign(this,t),t.actions&&t.keystrokeHandler)for(const e in t.actions){let i=t.actions[e];"string"==typeof i&&(i=[i]);for(const n of i)t.keystrokeHandler.set(n,(t,i)=>{this[e](),i()})}}get first(){return this.focusables.find(Xc)||null}get last(){return this.focusables.filter(Xc).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-1)}get current(){let t=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find((e,i)=>{const n=e.element===this.focusTracker.focusedElement;return n&&(t=i),n}),t)}focusFirst(){this._focus(this.first)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(t){t&&t.focus()}_getFocusableItem(t){const e=this.current,i=this.focusables.length;if(!i)return null;if(null===e)return this[1===t?"first":"last"];let n=(e+i+t)%i;do{const e=this.focusables.get(n);if(Xc(e))return e;n=(n+i+t)%i}while(n!==e);return null}}function Xc(t){return!(!t.focus||"none"==no.window.getComputedStyle(t.element).display)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zc extends jc{constructor(t){super(t),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */i(19);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class th extends jc{constructor(t){super(t);const e=this.bindTemplate,i=this.t;var n;this.set("ariaLabel",i("Editor toolbar")),this.items=this.createCollection(),this.focusTracker=new uc,this.keystrokes=new nc,this.set("isVertical",!1),this.set("class"),this._focusCycler=new Qc({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:["arrowleft","arrowup"],focusNext:["arrowright","arrowdown"]}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar",e.if("isVertical","ck-toolbar_vertical"),e.to("class")],role:"toolbar","aria-label":e.to("ariaLabel")},children:this.items,on:{mousedown:(n=this,n.bindTemplate.to(t=>{t.target===n.element&&t.preventDefault()}))}})}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",(t,e)=>{this.focusTracker.add(e.element)}),this.items.on("remove",(t,e)=>{this.focusTracker.remove(e.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(t,e){t.map(t=>{"|"==t?this.items.add(new Zc):e.has(t)?this.items.add(e.create(t)):console.warn(Object(Ki.a)("toolbarview-item-unavailable: The requested toolbar item is unavailable."),{name:t})})}}i(20);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class eh extends Uc{constructor(t,e){super(t),this.stickyPanel=new Yc(t),this.toolbar=new th(t),this.editable=new Gc(t,e)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ih extends oc{constructor(t,e){super(e),Ui(t)&&(this.sourceElement=t),this.data.processor=new cc,this.model.document.createRoot(),this.ui=new vc(this,new eh(this.locale,this.editing.view)),function(t){if(!$(t.updateSourceElement))throw new Ki.b("attachtoform-missing-elementapi-interface: Editor passed to attachToForm() must implement ElementApi.",t);const e=t.sourceElement;if(e&&"textarea"===e.tagName.toLowerCase()&&e.form){let i;const n=e.form,s=()=>t.updateSourceElement();$(n.submit)&&(i=n.submit,n.submit=()=>{s(),i.apply(n)}),n.addEventListener("submit",s),t.on("destroy",()=>{n.removeEventListener("submit",s),i&&(n.submit=i)})}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(t,e={}){return new Promise(i=>{const n=new this(t,e);i(n.initPlugins().then(()=>n.ui.init(Ui(t)?t:null)).then(()=>{if(!Ui(t)&&e.initialData)throw new Ki.b("editor-create-initial-data: The config.initialData option cannot be used together with initial data passed in Editor.create().",null);const i=e.initialData||function(t){return Ui(t)?(e=t,e instanceof HTMLTextAreaElement?e.value:e.innerHTML):t;var e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t);return n.data.init(i)}).then(()=>n.fire("ready")).then(()=>n))})}}cn(ih,rc),cn(ih,ac);class nh{constructor(t){this.editor=t}destroy(){this.stopListening()}}cn(nh,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class sh{constructor(t){this.files=function(t){const e=t.files?Array.from(t.files):[],i=t.items?Array.from(t.items):[];if(e.length)return e;return i.filter(t=>"file"===t.kind).map(t=>t.getAsFile())}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t),this._native=t}get types(){return this._native.types}getData(t){return this._native.getData(t)}setData(t,e){this._native.setData(t,e)}}class oh extends ir{constructor(t){super(t);const e=this.document;function i(t,i){i.preventDefault();const n=i.dropRange?[i.dropRange]:Array.from(e.selection.getRanges()),s=new Yi(e,"clipboardInput");e.fire(s,{dataTransfer:i.dataTransfer,targetRanges:n}),s.stop.called&&i.stopPropagation()}this.domEventType=["paste","copy","cut","drop","dragover"],this.listenTo(e,"paste",i,{priority:"low"}),this.listenTo(e,"drop",i,{priority:"low"})}onDomEvent(t){const e={dataTransfer:new sh(t.clipboardData?t.clipboardData:t.dataTransfer)};"drop"==t.type&&(e.dropRange=function(t,e){const i=e.target.ownerDocument,n=e.clientX,s=e.clientY;let o;i.caretRangeFromPoint&&i.caretRangeFromPoint(n,s)?o=i.caretRangeFromPoint(n,s):e.rangeParent&&((o=i.createRange()).setStart(e.rangeParent,e.rangeOffset),o.collapse(!0));return o?t.domConverter.domRangeToView(o):t.document.selection.getFirstRange()}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this.view,t)),this.fire(t.type,t,e)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const rh=["figcaption","li"];
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ah extends nh{static get pluginName(){return"Clipboard"}init(){const t=this.editor,e=t.model.document,i=t.editing.view,n=i.document;function s(i,s){const o=s.dataTransfer;s.preventDefault();const r=t.data.toView(t.model.getSelectedContent(e.selection));n.fire("clipboardOutput",{dataTransfer:o,content:r,method:i.name})}this._htmlDataProcessor=new cc,i.addObserver(oh),this.listenTo(n,"clipboardInput",e=>{t.isReadOnly&&e.stop()},{priority:"highest"}),this.listenTo(n,"clipboardInput",(t,e)=>{const n=e.dataTransfer;let s="";n.getData("text/html")?s=
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function(t){return t.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(t,e)=>1==e.length?" ":e)}(n.getData("text/html")):n.getData("text/plain")&&(s=function(t){return(t=t.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"</p><p>").replace(/^\s/,"&nbsp;").replace(/\s$/,"&nbsp;").replace(/\s\s/g," &nbsp;")).indexOf("</p><p>")>-1&&(t=`<p>${t}</p>`),t}(n.getData("text/plain"))),s=this._htmlDataProcessor.toView(s),this.fire("inputTransformation",{content:s,dataTransfer:n}),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(t,e)=>{if(!e.content.isEmpty){const t=this.editor.data,i=this.editor.model,n=t.toModel(e.content,"$clipboardHolder");if(0==n.childCount)return;i.insertContent(n)}},{priority:"low"}),this.listenTo(n,"copy",s,{priority:"low"}),this.listenTo(n,"cut",(e,i)=>{t.isReadOnly?i.preventDefault():s(e,i)},{priority:"low"}),this.listenTo(n,"clipboardOutput",(i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this._htmlDataProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",function t(e){let i="";if(e.is("text")||e.is("textProxy"))i=e.data;else if(e.is("img")&&e.hasAttribute("alt"))i=e.getAttribute("alt");else{let n=null;for(const s of e.getChildren()){const e=t(s);n&&(n.is("containerElement")||s.is("containerElement"))&&(rh.includes(n.name)||rh.includes(s.name)?i+="\n":i+="\n\n"),i+=e,n=s}}return i}(n.content))),"cut"==n.method&&t.model.deleteContent(e.selection)},{priority:"low"})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lh{constructor(t){this.editor=t,this.set("value",void 0),this.set("isEnabled",!1),this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",()=>{this.refresh()}),this.on("execute",t=>{this.isEnabled||t.stop()},{priority:"high"}),this.listenTo(t,"change:isReadOnly",(t,e,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})}refresh(){this.isEnabled=!0}forceDisabled(t){this._disableStack.add(t),1==this._disableStack.size&&(this.on("set:isEnabled",ch,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(t){this._disableStack.delete(t),0==this._disableStack.size&&(this.off("set:isEnabled",ch),this.refresh())}execute(){}destroy(){this.stopListening()}}function ch(t){t.return=!1,t.stop()}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function*hh(t,e){for(const i of e)i&&t.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */cn(lh,jn);class dh extends lh{execute(){const t=this.editor.model,e=t.document;t.change(i=>{!function(t,e,i,n){const s=i.isCollapsed,o=i.getFirstRange(),r=o.start.parent,a=o.end.parent;if(n.isLimit(r)||n.isLimit(a))return void(s||r!=a||t.deleteContent(i));if(s){const t=hh(e.model.schema,i.getAttributes());uh(e,o.start),e.setSelectionAttribute(t)}else{const n=!(o.start.isAtStart&&o.end.isAtEnd),s=r==a;t.deleteContent(i,{leaveUnmerged:n}),n&&(s?uh(e,i.focus):e.setSelection(a,0))}}(this.editor.model,i,e.selection,t.schema),this.fire("afterExecute",{writer:i})})}}function uh(t,e){t.split(e),t.setSelection(e.parent.nextSibling,0)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fh extends mo{constructor(t){super(t);const e=this.document;e.on("keydown",(t,i)=>{if(this.isEnabled&&i.keyCode==ws.enter){let n;e.once("enter",t=>n=t,{priority:"highest"}),e.fire("enter",new er(e,i.domEvent,{isSoft:i.shiftKey})),n&&n.stop.called&&t.stop()}})}observe(){}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class mh extends nh{static get pluginName(){return"Enter"}init(){const t=this.editor,e=t.editing.view,i=e.document;e.addObserver(fh),t.commands.add("enter",new dh(t)),this.listenTo(i,"enter",(i,n)=>{n.preventDefault(),n.isSoft||(t.execute("enter"),e.scrollToTheSelection())},{priority:"low"})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class gh extends lh{execute(){const t=this.editor.model,e=t.document;t.change(i=>{!function(t,e,i){const n=i.isCollapsed,s=i.getFirstRange(),o=s.start.parent,r=s.end.parent,a=o==r;if(n){const n=hh(t.schema,i.getAttributes());ph(e,s.end),e.removeSelectionAttribute(i.getAttributeKeys()),e.setSelectionAttribute(n)}else{const n=!(s.start.isAtStart&&s.end.isAtEnd);t.deleteContent(i,{leaveUnmerged:n}),a?ph(e,i.focus):n&&e.setSelection(r,0)}}(t,i,e.selection),this.fire("afterExecute",{writer:i})})}refresh(){const t=this.editor.model,e=t.document;this.isEnabled=function(t,e){if(e.rangeCount>1)return!1;const i=e.anchor;if(!i||!t.checkChild(i,"softBreak"))return!1;const n=e.getFirstRange(),s=n.start.parent,o=n.end.parent;if((wh(s,t)||wh(o,t))&&s!==o)return!1;return!0}(t.schema,e.selection)}}function ph(t,e){const i=t.createElement("softBreak");t.insert(i,e),t.setSelection(i,"after")}function wh(t,e){return!t.is("rootElement")&&(e.isLimit(t)||wh(t.parent,e))}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bh extends nh{static get pluginName(){return"ShiftEnter"}init(){const t=this.editor,e=t.model.schema,i=t.conversion,n=t.editing.view,s=n.document;e.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(t,e)=>e.createEmptyElement("br")}),n.addObserver(fh),t.commands.add("shiftEnter",new gh(t)),this.listenTo(s,"enter",(e,i)=>{i.preventDefault(),i.isSoft&&(t.execute("shiftEnter"),n.scrollToTheSelection())},{priority:"low"})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _h{constructor(t,e=20){this.model=t,this.size=0,this.limit=e,this.isLocked=!1,this._changeCallback=(t,e)=>{"transparent"!=e.type&&e!==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()),this._batch}input(t){this.size+=t,this.size>=this.limit&&this._reset(!0)}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(t){this.isLocked&&!t||(this._batch=null,this.size=0)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vh extends lh{constructor(t,e){super(t),this._buffer=new _h(t.model,e),this._batches=new WeakSet}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(t={}){const e=this.editor.model,i=e.document,n=t.text||"",s=n.length,o=t.range||i.selection.getFirstRange(),r=t.resultRange;e.enqueueChange(this._buffer.batch,t=>{const a=o.isCollapsed;this._buffer.lock(),e.deleteContent(e.createSelection(o)),n&&e.insertContent(t.createText(n,i.selection.getAttributes()),o.start),r?t.setSelection(r):a&&t.setSelection(o.start.getShiftedBy(s)),this._buffer.unlock(),this._buffer.input(s),this._batches.add(this._buffer.batch)})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function yh(t){let e=null;const i=t.model,n=t.editing.view,s=t.commands.get("input");function o(t){const o=i.document,a=n.document.isComposing,l=e&&e.isEqual(o.selection);e=null,s.isEnabled&&(function(t){if(t.ctrlKey)return!0;return kh.includes(t.keyCode)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t)||o.selection.isCollapsed||a&&229===t.keyCode||!a&&229===t.keyCode&&l||r())}function r(){const t=s.buffer;t.lock(),i.enqueueChange(t.batch,()=>{i.deleteContent(i.document.selection)}),t.unlock()}ms.isAndroid?n.document.on("beforeinput",(t,e)=>o(e),{priority:"lowest"}):n.document.on("keydown",(t,e)=>o(e),{priority:"lowest"}),n.document.on("compositionstart",(function(){const t=i.document,e=1!==t.selection.rangeCount||t.selection.getFirstRange().isFlat;if(t.selection.isCollapsed||e)return;r()}),{priority:"lowest"}),n.document.on("compositionend",()=>{e=i.createSelection(i.document.selection)},{priority:"lowest"})}const kh=[bs("arrowUp"),bs("arrowRight"),bs("arrowDown"),bs("arrowLeft"),9,16,17,18,19,20,27,33,34,35,36,45,91,93,144,145,173,174,175,176,177,178,179,255];for(let t=112;t<=135;t++)kh.push(t);function Ah(t){if(t.newChildren.length-t.oldChildren.length!=1)return;const e=function(t,e){const i=[];let n,s=0;return t.forEach(t=>{"equal"==t?(o(),s++):"insert"==t?(r("insert")?n.values.push(e[s]):(o(),n={type:"insert",index:s,values:[e[s]]}),s++):r("delete")?n.howMany++:(o(),n={type:"delete",index:s,howMany:1})}),o(),i;function o(){n&&(i.push(n),n=null)}function r(t){return n&&n.type==t}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(Js(t.oldChildren,t.newChildren,Ch),t.newChildren);if(e.length>1)return;const i=e[0];return i.values[0]&&i.values[0].is("text")?i:void 0}function Ch(t,e){return t&&t.is("text")&&e&&e.is("text")?t.data===e.data:t===e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class xh{constructor(t){this.editor=t,this.editing=this.editor.editing}handle(t,e){if(function(t){if(0==t.length)return!1;for(const e of t)if("children"===e.type&&!Ah(e))return!0;return!1}(t))this._handleContainerChildrenMutations(t,e);else for(const i of t)this._handleTextMutation(i,e),this._handleTextNodeInsertion(i)}_handleContainerChildrenMutations(t,e){const i=function(t){const e=t.map(t=>t.node).reduce((t,e)=>t.getCommonAncestor(e,{includeSelf:!0}));if(!e)return;return e.getAncestors({includeSelf:!0,parentFirst:!0}).find(t=>t.is("containerElement")||t.is("rootElement"))}(t);if(!i)return;const n=this.editor.editing.view.domConverter.mapViewToDom(i),s=new ro,o=this.editor.data.toModel(s.domToView(n)).getChild(0),r=this.editor.editing.mapper.toModelElement(i);if(!r)return;const a=Array.from(o.getChildren()),l=Array.from(r.getChildren()),c=a[a.length-1],h=l[l.length-1];c&&c.is("softBreak")&&h&&!h.is("softBreak")&&a.pop();const d=this.editor.model.schema;if(!Ph(a,d)||!Ph(l,d))return;const u=a.map(t=>t.is("text")?t.data:"@").join("").replace(/\u00A0/g," "),f=l.map(t=>t.is("text")?t.data:"@").join("").replace(/\u00A0/g," ");if(f===u)return;const m=Js(f,u),{firstChangeAt:g,insertions:p,deletions:w}=Th(m);let b=null;e&&(b=this.editing.mapper.toModelRange(e.getFirstRange()));const _=u.substr(g,p),v=this.editor.model.createRange(this.editor.model.createPositionAt(r,g),this.editor.model.createPositionAt(r,g+w));this.editor.execute("input",{text:_,range:v,resultRange:b})}_handleTextMutation(t,e){if("text"!=t.type)return;const i=t.newText.replace(/\u00A0/g," "),n=t.oldText.replace(/\u00A0/g," ");if(n===i)return;const s=Js(n,i),{firstChangeAt:o,insertions:r,deletions:a}=Th(s);let l=null;e&&(l=this.editing.mapper.toModelRange(e.getFirstRange()));const c=this.editing.view.createPositionAt(t.node,o),h=this.editing.mapper.toModelPosition(c),d=this.editor.model.createRange(h,h.getShiftedBy(a)),u=i.substr(o,r);this.editor.execute("input",{text:u,range:d,resultRange:l})}_handleTextNodeInsertion(t){if("children"!=t.type)return;const e=Ah(t),i=this.editing.view.createPositionAt(t.node,e.index),n=this.editing.mapper.toModelPosition(i),s=e.values[0].data;this.editor.execute("input",{text:s.replace(/\u00A0/g," "),range:this.editor.model.createRange(n)})}}function Ph(t,e){return t.every(t=>e.isInline(t))}function Th(t){let e=null,i=null;for(let n=0;n<t.length;n++){"equal"!=t[n]&&(e=null===e?n:e,i=n)}let n=0,s=0;for(let o=e;o<=i;o++)"insert"!=t[o]&&n++,"delete"!=t[o]&&s++;return{insertions:s,deletions:n,firstChangeAt:e}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Eh extends nh{static get pluginName(){return"Input"}init(){const t=this.editor,e=new vh(t,t.config.get("typing.undoStep")||20);t.commands.add("input",e),yh(t),function(t){t.editing.view.document.on("mutations",(e,i,n)=>{new xh(t).handle(i,n)})}(t)}isInput(t){return this.editor.commands.get("input")._batches.has(t)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Sh extends lh{constructor(t,e){super(t),this.direction=e,this._buffer=new _h(t.model,t.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(t={}){const e=this.editor.model,i=e.document;e.enqueueChange(this._buffer.batch,n=>{this._buffer.lock();const s=n.createSelection(t.selection||i.selection),o=s.isCollapsed;if(s.isCollapsed&&e.modifySelection(s,{direction:this.direction,unit:t.unit}),this._shouldEntireContentBeReplacedWithParagraph(t.sequence||1))return void this._replaceEntireContentWithParagraph(n);if(s.isCollapsed)return;let r=0;s.getFirstRange().getMinimalFlatRanges().forEach(t=>{r+=is(t.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))}),e.deleteContent(s,{doNotResetEntireContent:o}),this._buffer.input(r),n.setSelection(s),this._buffer.unlock()})}_shouldEntireContentBeReplacedWithParagraph(t){if(t>1)return!1;const e=this.editor.model,i=e.document.selection,n=e.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(n)))return!1;if(!e.schema.checkChild(n,"paragraph"))return!1;const s=n.getChild(0);return!s||"paragraph"!==s.name}_replaceEntireContentWithParagraph(t){const e=this.editor.model,i=e.document.selection,n=e.schema.getLimitElement(i),s=t.createElement("paragraph");t.remove(t.createRangeIn(n)),t.insert(s,n),t.setSelection(s,0)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Rh extends mo{constructor(t){super(t);const e=t.document;let i=0;function n(t,i,n){let s;e.once("delete",t=>s=t,{priority:Number.POSITIVE_INFINITY}),e.fire("delete",new er(e,i,n)),s&&s.stop.called&&t.stop()}e.on("keyup",(t,e)=>{e.keyCode!=ws.delete&&e.keyCode!=ws.backspace||(i=0)}),e.on("keydown",(t,e)=>{const s={};if(e.keyCode==ws.delete)s.direction="forward",s.unit="character";else{if(e.keyCode!=ws.backspace)return;s.direction="backward",s.unit="codePoint"}const o=ms.isMac?e.altKey:e.ctrlKey;s.unit=o?"word":s.unit,s.sequence=++i,n(t,e.domEvent,s)}),ms.isAndroid&&e.on("beforeinput",(e,i)=>{if("deleteContentBackward"!=i.domEvent.inputType)return;const s={unit:"codepoint",direction:"backward",sequence:1},o=i.domTarget.ownerDocument.defaultView.getSelection();o.anchorNode==o.focusNode&&o.anchorOffset+1!=o.focusOffset&&(s.selectionToRemove=t.domConverter.domSelectionToView(o)),n(e,i.domEvent,s)})}observe(){}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Oh extends nh{static get pluginName(){return"Delete"}init(){const t=this.editor,e=t.editing.view,i=e.document;if(e.addObserver(Rh),t.commands.add("forwardDelete",new Sh(t,"forward")),t.commands.add("delete",new Sh(t,"backward")),this.listenTo(i,"delete",(i,n)=>{const s={unit:n.unit,sequence:n.sequence};if(n.selectionToRemove){const e=t.model.createSelection(),i=[];for(const e of n.selectionToRemove.getRanges())i.push(t.editing.mapper.toModelRange(e));e.setTo(i),s.selection=e}t.execute("forward"==n.direction?"forwardDelete":"delete",s),n.preventDefault(),e.scrollToTheSelection()}),ms.isAndroid){let t=null;this.listenTo(i,"delete",(e,i)=>{const n=i.domTarget.ownerDocument.defaultView.getSelection();t={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}},{priority:"lowest"}),this.listenTo(i,"keyup",(e,i)=>{if(t){const e=i.domTarget.ownerDocument.defaultView.getSelection();e.collapse(t.anchorNode,t.anchorOffset),e.extend(t.focusNode,t.focusOffset),t=null}})}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ih extends nh{static get requires(){return[Eh,Oh]}static get pluginName(){return"Typing"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Mh extends el{get type(){return"noop"}clone(){return new Mh(this.baseVersion)}getReversed(){return new Mh(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Vh=new Map;function Nh(t,e,i){let n=Vh.get(t);n||(n=new Map,Vh.set(t,n)),n.set(e,i)}function Bh(t){return[t]}function Fh(t,e,i={}){const n=function(t,e){const i=Vh.get(t);return i&&i.has(e)?i.get(e):Bh}(t.constructor,e.constructor);try{return n(t=t.clone(),e,i)}catch(t){throw t}}function Dh(t,e,i){t=t.slice(),e=e.slice();const n=new Lh(i.document,i.useRelations,i.forceWeakRemove);n.setOriginalOperations(t),n.setOriginalOperations(e);const s=n.originalOperations;if(0==t.length||0==e.length)return{operationsA:t,operationsB:e,originalOperations:s};const o=new WeakMap;for(const e of t)o.set(e,0);const r={nextBaseVersionA:t[t.length-1].baseVersion+1,nextBaseVersionB:e[e.length-1].baseVersion+1,originalOperationsACount:t.length,originalOperationsBCount:e.length};let a=0;for(;a<t.length;){const i=t[a],s=o.get(i);if(s==e.length){a++;continue}const r=e[s],l=Fh(i,r,n.getContext(i,r,!0)),c=Fh(r,i,n.getContext(r,i,!1));n.updateRelation(i,r),n.setOriginalOperations(l,i),n.setOriginalOperations(c,r);for(const t of l)o.set(t,s+c.length);t.splice(a,1,...l),e.splice(s,1,...c)}if(i.padWithNoOps){const i=t.length-r.originalOperationsACount,n=e.length-r.originalOperationsBCount;Hh(t,n-i),Hh(e,i-n)}return zh(t,r.nextBaseVersionB),zh(e,r.nextBaseVersionA),{operationsA:t,operationsB:e,originalOperations:s}}class Lh{constructor(t,e,i=!1){this.originalOperations=new Map,this._history=t.history,this._useRelations=e,this._forceWeakRemove=!!i,this._relations=new Map}setOriginalOperations(t,e=null){const i=e?this.originalOperations.get(e):null;for(const e of t)this.originalOperations.set(e,i||e)}updateRelation(t,e){switch(t.constructor){case fl:switch(e.constructor){case bl:t.targetPosition.isEqual(e.sourcePosition)||e.movedRange.containsPosition(t.targetPosition)?this._setRelation(t,e,"insertAtSource"):t.targetPosition.isEqual(e.deletionPosition)?this._setRelation(t,e,"insertBetween"):t.targetPosition.isAfter(e.sourcePosition)&&this._setRelation(t,e,"moveTargetAfter");break;case fl:t.targetPosition.isEqual(e.sourcePosition)||t.targetPosition.isBefore(e.sourcePosition)?this._setRelation(t,e,"insertBefore"):this._setRelation(t,e,"insertAfter")}break;case _l:switch(e.constructor){case bl:t.splitPosition.isBefore(e.sourcePosition)&&this._setRelation(t,e,"splitBefore");break;case fl:(t.splitPosition.isEqual(e.sourcePosition)||t.splitPosition.isBefore(e.sourcePosition))&&this._setRelation(t,e,"splitBefore")}break;case bl:switch(e.constructor){case bl:t.targetPosition.isEqual(e.sourcePosition)||this._setRelation(t,e,"mergeTargetNotMoved"),t.sourcePosition.isEqual(e.targetPosition)&&this._setRelation(t,e,"mergeSourceNotMoved"),t.sourcePosition.isEqual(e.sourcePosition)&&this._setRelation(t,e,"mergeSameElement");break;case _l:t.sourcePosition.isEqual(e.splitPosition)&&this._setRelation(t,e,"splitAtSource")}break;case gl:{const i=t.newRange;if(!i)return;switch(e.constructor){case fl:{const n=Yr._createFromPositionAndShift(e.sourcePosition,e.howMany),s=n.containsPosition(i.start)||n.start.isEqual(i.start),o=n.containsPosition(i.end)||n.end.isEqual(i.end);!s&&!o||n.containsRange(i)||this._setRelation(t,e,{side:s?"left":"right",path:s?i.start.path.slice():i.end.path.slice()});break}case bl:{const n=i.start.isEqual(e.targetPosition),s=i.start.isEqual(e.deletionPosition),o=i.end.isEqual(e.deletionPosition),r=i.end.isEqual(e.sourcePosition);(n||s||o||r)&&this._setRelation(t,e,{wasInLeftElement:n,wasStartBeforeMergedElement:s,wasEndBeforeMergedElement:o,wasInRightElement:r});break}}break}}}getContext(t,e,i){return{aIsStrong:i,aWasUndone:this._wasUndone(t),bWasUndone:this._wasUndone(e),abRelation:this._useRelations?this._getRelation(t,e):null,baRelation:this._useRelations?this._getRelation(e,t):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(t){const e=this.originalOperations.get(t);return e.wasUndone||this._history.isUndoneOperation(e)}_getRelation(t,e){const i=this.originalOperations.get(e),n=this._history.getUndoneOperation(i);if(!n)return null;const s=this.originalOperations.get(t),o=this._relations.get(s);return o&&o.get(n)||null}_setRelation(t,e,i){const n=this.originalOperations.get(t),s=this.originalOperations.get(e);let o=this._relations.get(n);o||(o=new Map,this._relations.set(n,o)),o.set(s,i)}}function zh(t,e){for(const i of t)i.baseVersion=e++}function Hh(t,e){for(let i=0;i<e;i++)t.push(new Mh(0))}function jh(t,e,i){const n=t.nodes.getNode(0).getAttribute(e);if(n==i)return null;const s=new Yr(t.position,t.position.getShiftedBy(t.howMany));return new dl(s,e,n,i,0)}function qh(t,e){return null===t.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany)}function Wh(t,e){const i=[];for(let n=0;n<t.length;n++){const s=t[n],o=new fl(s.start,s.end.offset-s.start.offset,e,0);i.push(o);for(let e=n+1;e<t.length;e++)t[e]=t[e]._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)[0];e=e._getTransformedByMove(o.sourcePosition,o.targetPosition,o.howMany)}return i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */Nh(dl,dl,(t,e,i)=>{if(t.key===e.key){const n=t.range.getDifference(e.range).map(e=>new dl(e,t.key,t.oldValue,t.newValue,0)),s=t.range.getIntersection(e.range);return s&&i.aIsStrong&&n.push(new dl(s,e.key,e.newValue,t.newValue,0)),0==n.length?[new Mh(0)]:n}return[t]}),Nh(dl,ml,(t,e)=>{if(t.range.start.hasSameParentAs(e.position)&&t.range.containsPosition(e.position)){const i=t.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map(e=>new dl(e,t.key,t.oldValue,t.newValue,t.baseVersion));if(e.shouldReceiveAttributes){const n=jh(e,t.key,t.oldValue);n&&i.unshift(n)}return i}return t.range=t.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[t]}),Nh(dl,bl,(t,e)=>{const i=[];t.range.start.hasSameParentAs(e.deletionPosition)&&(t.range.containsPosition(e.deletionPosition)||t.range.start.isEqual(e.deletionPosition))&&i.push(Yr._createFromPositionAndShift(e.graveyardPosition,1));const n=t.range._getTransformedByMergeOperation(e);return n.isCollapsed||i.push(n),i.map(e=>new dl(e,t.key,t.oldValue,t.newValue,t.baseVersion))}),Nh(dl,fl,(t,e)=>{return function(t,e){const i=Yr._createFromPositionAndShift(e.sourcePosition,e.howMany);let n=null,s=[];i.containsRange(t,!0)?n=t:t.start.hasSameParentAs(i.start)?(s=t.getDifference(i),n=t.getIntersection(i)):s=[t];const o=[];for(let t of s){t=t._getTransformedByDeletion(e.sourcePosition,e.howMany);const i=e.getMovedRangeStart(),n=t.start.hasSameParentAs(i);t=t._getTransformedByInsertion(i,e.howMany,n),o.push(...t)}n&&o.push(n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]);return o}(t.range,e).map(e=>new dl(e,t.key,t.oldValue,t.newValue,t.baseVersion))}),Nh(dl,_l,(t,e)=>{if(t.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||t.range.end.offset++,[t];if(t.range.start.hasSameParentAs(e.splitPosition)&&t.range.containsPosition(e.splitPosition)){const i=t.clone();return i.range=new Yr(e.moveTargetPosition.clone(),t.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),t.range.end=e.splitPosition.clone(),t.range.end.stickiness="toPrevious",[t,i]}return t.range=t.range._getTransformedBySplitOperation(e),[t]}),Nh(ml,dl,(t,e)=>{const i=[t];if(t.shouldReceiveAttributes&&t.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(t.position)){const n=jh(t,e.key,e.newValue);n&&i.push(n)}return i}),Nh(ml,ml,(t,e,i)=>t.position.isEqual(e.position)&&i.aIsStrong?[t]:(t.position=t.position._getTransformedByInsertOperation(e),[t])),Nh(ml,fl,(t,e)=>(t.position=t.position._getTransformedByMoveOperation(e),[t])),Nh(ml,_l,(t,e)=>(t.position=t.position._getTransformedBySplitOperation(e),[t])),Nh(ml,bl,(t,e)=>(t.position=t.position._getTransformedByMergeOperation(e),[t])),Nh(gl,ml,(t,e)=>(t.oldRange&&(t.oldRange=t.oldRange._getTransformedByInsertOperation(e)[0]),t.newRange&&(t.newRange=t.newRange._getTransformedByInsertOperation(e)[0]),[t])),Nh(gl,gl,(t,e,i)=>{if(t.name==e.name){if(!i.aIsStrong)return[new Mh(0)];t.oldRange=e.newRange?e.newRange.clone():null}return[t]}),Nh(gl,bl,(t,e)=>(t.oldRange&&(t.oldRange=t.oldRange._getTransformedByMergeOperation(e)),t.newRange&&(t.newRange=t.newRange._getTransformedByMergeOperation(e)),[t])),Nh(gl,fl,(t,e,i)=>{if(t.oldRange&&(t.oldRange=Yr._createFromRanges(t.oldRange._getTransformedByMoveOperation(e))),t.newRange){if(i.abRelation){const n=Yr._createFromRanges(t.newRange._getTransformedByMoveOperation(e));if("left"==i.abRelation.side&&e.targetPosition.isEqual(t.newRange.start))return t.newRange.start.path=i.abRelation.path,t.newRange.end=n.end,[t];if("right"==i.abRelation.side&&e.targetPosition.isEqual(t.newRange.end))return t.newRange.start=n.start,t.newRange.end.path=i.abRelation.path,[t]}t.newRange=Yr._createFromRanges(t.newRange._getTransformedByMoveOperation(e))}return[t]}),Nh(gl,_l,(t,e,i)=>{if(t.oldRange&&(t.oldRange=t.oldRange._getTransformedBySplitOperation(e)),t.newRange){if(i.abRelation){const n=t.newRange._getTransformedBySplitOperation(e);return t.newRange.start.isEqual(e.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?t.newRange.start=Jr._createAt(e.insertionPosition):t.newRange.start.isEqual(e.splitPosition)&&!i.abRelation.wasInLeftElement&&(t.newRange.start=Jr._createAt(e.moveTargetPosition)),t.newRange.end.isEqual(e.splitPosition)&&i.abRelation.wasInRightElement?t.newRange.end=Jr._createAt(e.moveTargetPosition):t.newRange.end.isEqual(e.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?t.newRange.end=Jr._createAt(e.insertionPosition):t.newRange.end=n.end,[t]}t.newRange=t.newRange._getTransformedBySplitOperation(e)}return[t]}),Nh(bl,ml,(t,e)=>(t.sourcePosition.hasSameParentAs(e.position)&&(t.howMany+=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByInsertOperation(e),t.targetPosition=t.targetPosition._getTransformedByInsertOperation(e),[t])),Nh(bl,bl,(t,e,i)=>{if(t.sourcePosition.isEqual(e.sourcePosition)&&t.targetPosition.isEqual(e.targetPosition)){if(i.bWasUndone){const i=e.graveyardPosition.path.slice();return i.push(0),t.sourcePosition=new Jr(e.graveyardPosition.root,i),t.howMany=0,[t]}return[new Mh(0)]}if(t.sourcePosition.isEqual(e.sourcePosition)&&!t.targetPosition.isEqual(e.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==t.targetPosition.root.rootName,s="$graveyard"==e.targetPosition.root.rootName,o=n&&!s;if(s&&!n||!o&&i.aIsStrong){const i=e.targetPosition._getTransformedByMergeOperation(e),n=t.targetPosition._getTransformedByMergeOperation(e);return[new fl(i,t.howMany,n,0)]}return[new Mh(0)]}return t.sourcePosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByMergeOperation(e),t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),t.graveyardPosition.isEqual(e.graveyardPosition)&&i.aIsStrong||(t.graveyardPosition=t.graveyardPosition._getTransformedByMergeOperation(e)),[t]}),Nh(bl,fl,(t,e,i)=>{const n=Yr._createFromPositionAndShift(e.sourcePosition,e.howMany);return"remove"==e.type&&!i.bWasUndone&&!i.forceWeakRemove&&t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition)?[new Mh(0)]:(t.sourcePosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.sourcePosition.hasSameParentAs(e.sourcePosition)&&(t.howMany-=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByMoveOperation(e),t.targetPosition=t.targetPosition._getTransformedByMoveOperation(e),t.graveyardPosition.isEqual(e.targetPosition)||(t.graveyardPosition=t.graveyardPosition._getTransformedByMoveOperation(e)),[t])}),Nh(bl,_l,(t,e,i)=>{if(e.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),t.deletionPosition.isEqual(e.graveyardPosition)&&(t.howMany=e.howMany)),t.targetPosition.isEqual(e.splitPosition)){const n=0!=e.howMany,s=e.graveyardPosition&&t.deletionPosition.isEqual(e.graveyardPosition);if(n||s||"mergeTargetNotMoved"==i.abRelation)return t.sourcePosition=t.sourcePosition._getTransformedBySplitOperation(e),[t]}if(t.sourcePosition.isEqual(e.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return t.howMany=0,t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t];if("mergeSameElement"==i.abRelation||t.sourcePosition.offset>0)return t.sourcePosition=e.moveTargetPosition.clone(),t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t]}return t.sourcePosition.hasSameParentAs(e.splitPosition)&&(t.howMany=e.splitPosition.offset),t.sourcePosition=t.sourcePosition._getTransformedBySplitOperation(e),t.targetPosition=t.targetPosition._getTransformedBySplitOperation(e),[t]}),Nh(fl,ml,(t,e)=>{const i=Yr._createFromPositionAndShift(t.sourcePosition,t.howMany)._getTransformedByInsertOperation(e,!1)[0];return t.sourcePosition=i.start,t.howMany=i.end.offset-i.start.offset,t.targetPosition.isEqual(e.position)||(t.targetPosition=t.targetPosition._getTransformedByInsertOperation(e)),[t]}),Nh(fl,fl,(t,e,i)=>{const n=Yr._createFromPositionAndShift(t.sourcePosition,t.howMany),s=Yr._createFromPositionAndShift(e.sourcePosition,e.howMany);let o,r=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),o=t.targetPosition.isEqual(e.targetPosition)&&a?t.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):t.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),qh(t,e)&&qh(e,t))return[e.getReversed()];if(n.containsPosition(e.targetPosition)&&n.containsRange(s,!0))return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Wh([n],o);if(s.containsPosition(t.targetPosition)&&s.containsRange(n,!0))return n.start=n.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),n.end=n.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),Wh([n],o);const l=hn(t.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Wh([n],o);"remove"!=t.type||"remove"==e.type||i.aWasUndone||i.forceWeakRemove?"remove"==t.type||"remove"!=e.type||i.bWasUndone||i.forceWeakRemove||(r=!1):r=!0;const c=[],h=n.getDifference(s);for(const t of h){t.start=t.start._getTransformedByDeletion(e.sourcePosition,e.howMany),t.end=t.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const i="same"==hn(t.start.getParentPath(),e.getMovedRangeStart().getParentPath()),n=t._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,i);c.push(...n)}const d=n.getIntersection(s);return null!==d&&r&&(d.start=d.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),d.end=d.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),0===c.length?c.push(d):1==c.length?s.start.isBefore(n.start)||s.start.isEqual(n.start)?c.unshift(d):c.push(d):c.splice(1,0,d)),0===c.length?[new Mh(t.baseVersion)]:Wh(c,o)}),Nh(fl,_l,(t,e,i)=>{let n=t.targetPosition.clone();t.targetPosition.isEqual(e.insertionPosition)&&e.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=t.targetPosition._getTransformedBySplitOperation(e));const s=Yr._createFromPositionAndShift(t.sourcePosition,t.howMany);if(s.end.isEqual(e.insertionPosition))return e.graveyardPosition||t.howMany++,t.targetPosition=n,[t];if(s.start.hasSameParentAs(e.splitPosition)&&s.containsPosition(e.splitPosition)){let t=new Yr(e.splitPosition,s.end);return t=t._getTransformedBySplitOperation(e),Wh([new Yr(s.start,e.splitPosition),t],n)}t.targetPosition.isEqual(e.splitPosition)&&"insertAtSource"==i.abRelation&&(n=e.moveTargetPosition),t.targetPosition.isEqual(e.insertionPosition)&&"insertBetween"==i.abRelation&&(n=t.targetPosition);const o=[s._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const n=s.start.isEqual(e.graveyardPosition)||s.containsPosition(e.graveyardPosition);t.howMany>1&&n&&!i.aWasUndone&&o.push(Yr._createFromPositionAndShift(e.insertionPosition,1))}return Wh(o,n)}),Nh(fl,bl,(t,e,i)=>{const n=Yr._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition))if("remove"!=t.type||i.forceWeakRemove){if(1==t.howMany)return i.bWasUndone?(t.sourcePosition=e.graveyardPosition.clone(),t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),[t]):[new Mh(0)]}else if(!i.aWasUndone){const i=[];let n=e.graveyardPosition.clone(),s=e.targetPosition._getTransformedByMergeOperation(e);t.howMany>1&&(i.push(new fl(t.sourcePosition,t.howMany-1,t.targetPosition,0)),n=n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany-1),s=s._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany-1));const o=e.deletionPosition._getCombined(t.sourcePosition,t.targetPosition),r=new fl(n,1,o,0),a=r.getMovedRangeStart().path.slice();a.push(0);const l=new Jr(r.targetPosition.root,a);s=s._getTransformedByMove(n,o,1);const c=new fl(s,e.howMany,l,0);return i.push(r),i.push(c),i}const s=Yr._createFromPositionAndShift(t.sourcePosition,t.howMany)._getTransformedByMergeOperation(e);return t.sourcePosition=s.start,t.howMany=s.end.offset-s.start.offset,t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),[t]}),Nh(pl,ml,(t,e)=>(t.position=t.position._getTransformedByInsertOperation(e),[t])),Nh(pl,bl,(t,e)=>t.position.isEqual(e.deletionPosition)?(t.position=e.graveyardPosition.clone(),t.position.stickiness="toNext",[t]):(t.position=t.position._getTransformedByMergeOperation(e),[t])),Nh(pl,fl,(t,e)=>(t.position=t.position._getTransformedByMoveOperation(e),[t])),Nh(pl,pl,(t,e,i)=>{if(t.position.isEqual(e.position)){if(!i.aIsStrong)return[new Mh(0)];t.oldName=e.newName}return[t]}),Nh(pl,_l,(t,e)=>{if("same"==hn(t.position.path,e.splitPosition.getParentPath())&&!e.graveyardPosition){const e=new pl(t.position.getShiftedBy(1),t.oldName,t.newName,0);return[t,e]}return t.position=t.position._getTransformedBySplitOperation(e),[t]}),Nh(wl,wl,(t,e,i)=>{if(t.root===e.root&&t.key===e.key){if(!i.aIsStrong||t.newValue===e.newValue)return[new Mh(0)];t.oldValue=e.newValue}return[t]}),Nh(_l,ml,(t,e)=>(t.splitPosition.hasSameParentAs(e.position)&&t.splitPosition.offset<e.position.offset&&(t.howMany+=e.howMany),t.splitPosition=t.splitPosition._getTransformedByInsertOperation(e),t.insertionPosition=_l.getInsertionPosition(t.splitPosition),[t])),Nh(_l,bl,(t,e,i)=>{if(!t.graveyardPosition&&!i.bWasUndone&&t.splitPosition.hasSameParentAs(e.sourcePosition)){const i=e.graveyardPosition.path.slice();i.push(0);const n=new Jr(e.graveyardPosition.root,i),s=_l.getInsertionPosition(new Jr(e.graveyardPosition.root,i)),o=new _l(n,0,null,0);return o.insertionPosition=s,t.splitPosition=t.splitPosition._getTransformedByMergeOperation(e),t.insertionPosition=_l.getInsertionPosition(t.splitPosition),t.graveyardPosition=o.insertionPosition.clone(),t.graveyardPosition.stickiness="toNext",[o,t]}return t.splitPosition.hasSameParentAs(e.deletionPosition)&&!t.splitPosition.isAfter(e.deletionPosition)&&t.howMany--,t.splitPosition.hasSameParentAs(e.targetPosition)&&(t.howMany+=e.howMany),t.splitPosition=t.splitPosition._getTransformedByMergeOperation(e),t.insertionPosition=_l.getInsertionPosition(t.splitPosition),t.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedByMergeOperation(e)),[t]}),Nh(_l,fl,(t,e,i)=>{const n=Yr._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.graveyardPosition){const s=n.start.isEqual(t.graveyardPosition)||n.containsPosition(t.graveyardPosition);if(!i.bWasUndone&&s){const i=t.splitPosition._getTransformedByMoveOperation(e),n=t.graveyardPosition._getTransformedByMoveOperation(e),s=n.path.slice();s.push(0);const o=new Jr(n.root,s);return[new fl(i,t.howMany,o,0)]}t.graveyardPosition=t.graveyardPosition._getTransformedByMoveOperation(e)}if(t.splitPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.splitPosition)){const i=e.howMany-(t.splitPosition.offset-e.sourcePosition.offset);return t.howMany-=i,t.splitPosition.hasSameParentAs(e.targetPosition)&&t.splitPosition.offset<e.targetPosition.offset&&(t.howMany+=e.howMany),t.splitPosition=e.sourcePosition.clone(),t.insertionPosition=_l.getInsertionPosition(t.splitPosition),[t]}return!t.splitPosition.isEqual(e.targetPosition)||"insertAtSource"!=i.baRelation&&"splitBefore"!=i.abRelation?(e.sourcePosition.isEqual(e.targetPosition)||(t.splitPosition.hasSameParentAs(e.sourcePosition)&&t.splitPosition.offset<=e.sourcePosition.offset&&(t.howMany-=e.howMany),t.splitPosition.hasSameParentAs(e.targetPosition)&&t.splitPosition.offset<e.targetPosition.offset&&(t.howMany+=e.howMany)),t.splitPosition.stickiness="toNone",t.splitPosition=t.splitPosition._getTransformedByMoveOperation(e),t.splitPosition.stickiness="toNext",t.graveyardPosition?t.insertionPosition=t.insertionPosition._getTransformedByMoveOperation(e):t.insertionPosition=_l.getInsertionPosition(t.splitPosition),[t]):(t.howMany+=e.howMany,t.splitPosition=t.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),t.insertionPosition=_l.getInsertionPosition(t.splitPosition),[t])}),Nh(_l,_l,(t,e,i)=>{if(t.splitPosition.isEqual(e.splitPosition)){if(!t.graveyardPosition&&!e.graveyardPosition)return[new Mh(0)];if(t.graveyardPosition&&e.graveyardPosition&&t.graveyardPosition.isEqual(e.graveyardPosition))return[new Mh(0)];if("splitBefore"==i.abRelation)return t.howMany=0,t.graveyardPosition=t.graveyardPosition._getTransformedBySplitOperation(e),[t]}if(t.graveyardPosition&&e.graveyardPosition&&t.graveyardPosition.isEqual(e.graveyardPosition)){const n="$graveyard"==t.splitPosition.root.rootName,s="$graveyard"==e.splitPosition.root.rootName,o=n&&!s;if(s&&!n||!o&&i.aIsStrong){const i=[];return e.howMany&&i.push(new fl(e.moveTargetPosition,e.howMany,e.splitPosition,0)),t.howMany&&i.push(new fl(t.splitPosition,t.howMany,t.moveTargetPosition,0)),i}return[new Mh(0)]}if(t.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedBySplitOperation(e)),t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.abRelation)return t.howMany++,[t];if(e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.baRelation){const i=e.insertionPosition.path.slice();i.push(0);const n=new Jr(e.insertionPosition.root,i);return[t,new fl(t.insertionPosition,1,n,0)]}return t.splitPosition.hasSameParentAs(e.splitPosition)&&t.splitPosition.offset<e.splitPosition.offset&&(t.howMany-=e.howMany),t.splitPosition=t.splitPosition._getTransformedBySplitOperation(e),t.insertionPosition=_l.getInsertionPosition(t.splitPosition),[t]});class Uh extends lh{constructor(t){super(t),this._stack=[],this._createdBatches=new WeakSet,this.refresh()}refresh(){this.isEnabled=this._stack.length>0}addBatch(t){const e=this.editor.model.document.selection,i={ranges:e.hasOwnRange?Array.from(e.getRanges()):[],isBackward:e.isBackward};this._stack.push({batch:t,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(t,e,i){const n=this.editor.model,s=n.document,o=[];for(const e of t){const t=$h(e,i).find(t=>t.start.root!=s.graveyard);t&&o.push(t)}o.length&&n.change(t=>{t.setSelection(o,{backward:e})})}_undo(t,e){const i=this.editor.model,n=i.document;this._createdBatches.add(e);const s=t.operations.slice().filter(t=>t.isDocumentOperation);s.reverse();for(const t of s){const s=t.baseVersion+1,o=Array.from(n.history.getOperations(s)),r=Dh([t.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const s of r)e.addOperation(s),i.applyOperation(s),n.history.setOperationAsUndone(t,s)}}}function $h(t,e){const i=t.getTransformedByOperations(e);i.sort((t,e)=>t.start.isBefore(e.start)?-1:1);for(let t=1;t<i.length;t++){const e=i[t-1],n=i[t];e.end.isTouching(n.start)&&(e.end=n.end,i.splice(t,1),t--)}return i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gh extends Uh{execute(t=null){const e=t?this._stack.findIndex(e=>e.batch==t):this._stack.length-1,i=this._stack.splice(e,1)[0],n=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(n,()=>{this._undo(i.batch,n);const t=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,t),this.fire("revert",i.batch,n)}),this.refresh()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Kh extends Uh{execute(){const t=this._stack.pop(),e=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(e,()=>{const i=t.batch.operations[t.batch.operations.length-1].baseVersion+1,n=this.editor.model.document.history.getOperations(i);this._restoreSelection(t.selection.ranges,t.selection.isBackward,n),this._undo(t.batch,e)}),this.refresh()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jh extends nh{constructor(t){super(t),this._batchRegistry=new WeakSet}init(){const t=this.editor;this._undoCommand=new Gh(t),this._redoCommand=new Kh(t),t.commands.add("undo",this._undoCommand),t.commands.add("redo",this._redoCommand),this.listenTo(t.model,"applyOperation",(t,e)=>{const i=e[0];if(!i.isDocumentOperation)return;const n=i.batch,s=this._redoCommand._createdBatches.has(n),o=this._undoCommand._createdBatches.has(n);this._batchRegistry.has(n)||"transparent"==n.type&&!s&&!o||(s?this._undoCommand.addBatch(n):o||(this._undoCommand.addBatch(n),this._redoCommand.clearStack()),this._batchRegistry.add(n))},{priority:"highest"}),this.listenTo(this._undoCommand,"revert",(t,e,i)=>{this._redoCommand.addBatch(i)}),t.keystrokes.set("CTRL+Z","undo"),t.keystrokes.set("CTRL+Y","redo"),t.keystrokes.set("CTRL+SHIFT+Z","redo")}}i(21);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Yh extends jc{constructor(){super();const t=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon"],viewBox:t.to("viewBox")}})}render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",()=>{this._updateXMLContent(),this._colorFillPaths()}),this.on("change:fillColor",()=>{this._colorFillPaths()})}_updateXMLContent(){if(this.content){const t=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),e=t.getAttribute("viewBox");for(e&&(this.viewBox=e),this.element.innerHTML="";t.childNodes.length>0;)this.element.appendChild(t.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach(t=>{t.style.fill=this.fillColor})}}i(22);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Qh extends jc{constructor(t){super(t),this.set("text",""),this.set("position","s");const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip",e.to("position",t=>"ck-tooltip_"+t),e.if("text","ck-hidden",t=>!t.trim())]},children:[{tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:e.to("text")}]}]})}}i(23);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xh extends jc{constructor(t){super(t);const e=this.bindTemplate,i=Qi();this.set("class"),this.set("labelStyle"),this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.tooltipView=this._createTooltipView(),this.labelView=this._createLabelView(i),this.iconView=new Yh,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this)),this.setTemplate({tag:"button",attributes:{class:["ck","ck-button",e.to("class"),e.if("isEnabled","ck-disabled",t=>!t),e.if("isVisible","ck-hidden",t=>!t),e.to("isOn",t=>t?"ck-on":"ck-off"),e.if("withText","ck-button_with-text")],type:e.to("type",t=>t||"button"),tabindex:e.to("tabindex"),"aria-labelledby":`ck-editor__aria-label_${i}`,"aria-disabled":e.if("isEnabled",!0,t=>!t),"aria-pressed":e.to("isOn",t=>!!this.isToggleable&&String(t))},children:this.children,on:{mousedown:e.to(t=>{t.preventDefault()}),click:e.to(t=>{this.isEnabled?this.fire("execute"):t.preventDefault()})}})}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.tooltipView),this.children.add(this.labelView)}focus(){this.element.focus()}_createTooltipView(){const t=new Qh;return t.bind("text").to(this,"_tooltipString"),t.bind("position").to(this,"tooltipPosition"),t}_createLabelView(t){const e=new jc,i=this.bindTemplate;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:i.to("labelStyle"),id:`ck-editor__aria-label_${t}`},children:[{text:this.bindTemplate.to("label")}]}),e}_getTooltipString(t,e,i){return t?"string"==typeof t?t:(i&&(i=function(t){return ms.isMac?vs(t).map(t=>ps[t.toLowerCase()]||t).reduce((t,e)=>t.slice(-1)in gs?t+e:t+"+"+e):t}(i)),t instanceof Function?t(e,i):`${e}${i?` (${i})`:""}`):""}}var Zh='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5.042 9.367l2.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>',td='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M14.958 9.367l-2.189 1.837a.75.75 0 0 0 .965 1.149l3.788-3.18a.747.747 0 0 0 .21-.284.75.75 0 0 0-.17-.945L13.77 4.762a.75.75 0 1 0-.964 1.15l2.331 1.955H6.22A.75.75 0 0 0 6 7.9a4 4 0 1 0 1.477 7.718l-.344-1.489A2.5 2.5 0 1 1 6.039 9.4l-.008-.032h8.927z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ed extends nh{init(){const t=this.editor,e=t.locale,i=t.t,n="ltr"==e.uiLanguageDirection?Zh:td,s="ltr"==e.uiLanguageDirection?td:Zh;this._addButton("undo",i("Undo"),"CTRL+Z",n),this._addButton("redo",i("Redo"),"CTRL+Y",s)}_addButton(t,e,i,n){const s=this.editor;s.ui.componentFactory.add(t,o=>{const r=s.commands.get(t),a=new Xh(o);return a.set({label:e,icon:n,keystroke:i,tooltip:!0}),a.bind("isEnabled").to(r,"isEnabled"),this.listenTo(a,"execute",()=>s.execute(t)),a})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class id extends nh{static get requires(){return[Jh,ed]}static get pluginName(){return"Undo"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class nd extends nh{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new os({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(t){if("string"!=typeof t)throw new Ki.b("pendingactions-add-invalid-message: The message must be a string.",this);const e=Object.create(jn);return e.set("message",t),this._actions.add(e),this.hasAny=!0,e}remove(t){this._actions.remove(t),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class sd{constructor(){const t=new window.FileReader;this._reader=t,this._data=void 0,this.set("loaded",0),t.onprogress=t=>{this.loaded=t.loaded}}get error(){return this._reader.error}get data(){return this._data}read(t){const e=this._reader;return this.total=t.size,new Promise((i,n)=>{e.onload=()=>{const t=e.result;this._data=t,i(t)},e.onerror=()=>{n("error")},e.onabort=()=>{n("aborted")},this._reader.readAsDataURL(t)})}abort(){this._reader.abort()}}cn(sd,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class od extends nh{static get pluginName(){return"FileRepository"}static get requires(){return[nd]}init(){this.loaders=new os,this.loaders.on("add",()=>this._updatePendingAction()),this.loaders.on("remove",()=>this._updatePendingAction()),this._loadersMap=new Map,this._pendingAction=null,this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(t,e)=>e?t/e*100:0)}getLoader(t){return this._loadersMap.get(t)||null}createLoader(t){if(!this.createUploadAdapter)return console.warn(Object(Ki.a)("filerepository-no-upload-adapter: Upload adapter is not defined.")),null;const e=new rd(Promise.resolve(t),this.createUploadAdapter);return this.loaders.add(e),this._loadersMap.set(t,e),t instanceof Promise&&e.file.then(t=>{this._loadersMap.set(t,e)}),e.file.catch(()=>{}),e.on("change:uploaded",()=>{let t=0;for(const e of this.loaders)t+=e.uploaded;this.uploaded=t}),e.on("change:uploadTotal",()=>{let t=0;for(const e of this.loaders)e.uploadTotal&&(t+=e.uploadTotal);this.uploadTotal=t}),e}destroyLoader(t){const e=t instanceof rd?t:this.getLoader(t);e._destroy(),this.loaders.remove(e),this._loadersMap.forEach((t,i)=>{t===e&&this._loadersMap.delete(i)})}_updatePendingAction(){const t=this.editor.plugins.get(nd);if(this.loaders.length){if(!this._pendingAction){const e=this.editor.t,i=t=>`${e("Upload in progress")} ${parseInt(t)}%.`;this._pendingAction=t.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else t.remove(this._pendingAction),this._pendingAction=null}}cn(od,jn);class rd{constructor(t,e){this.id=Qi(),this._filePromiseWrapper=this._createFilePromiseWrapper(t),this._adapter=e(this),this._reader=new sd,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",(t,e)=>e?t/e*100:0),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then(t=>this._filePromiseWrapper?t:null):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new Ki.b("filerepository-read-wrong-status: You cannot call read if the status is different than idle.",this);return this.status="reading",this._filePromiseWrapper.promise.then(t=>this._reader.read(t)).then(t=>(this.status="idle",t)).catch(t=>{if("aborted"===t)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:t})}upload(){if("idle"!=this.status)throw new Ki.b("filerepository-upload-wrong-status: You cannot call upload if the status is different than idle.",this);return this.status="uploading",this._filePromiseWrapper.promise.then(()=>this._adapter.upload()).then(t=>(this.uploadResponse=t,this.status="idle",t)).catch(t=>{if("aborted"===this.status)throw"aborted";throw this.status="error",t})}abort(){const t=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==t?this._reader.abort():"uploading"==t&&this._adapter.abort&&this._adapter.abort():this._filePromiseWrapper.rejecter("aborted"),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(t){const e={};return e.promise=new Promise((i,n)=>{e.resolver=i,e.rejecter=n,e.isFulfilled=!1,t.then(t=>{e.isFulfilled=!0,i(t)}).catch(t=>{e.isFulfilled=!0,n(t)})}),e}}cn(rd,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const ad="ckCsrfToken",ld=40,cd="abcdefghijklmnopqrstuvwxyz0123456789";function hd(){let t=function(t){t=t.toLowerCase();const e=document.cookie.split(";");for(const i of e){const e=i.split("=");if(decodeURIComponent(e[0].trim().toLowerCase())===t)return decodeURIComponent(e[1])}return null}(ad);var e,i;return t&&t.length==ld||(t=function(t){let e="";const i=new Uint8Array(t);window.crypto.getRandomValues(i);for(let t=0;t<i.length;t++){const n=cd.charAt(i[t]%cd.length);e+=Math.random()>.5?n.toUpperCase():n}return e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(ld),e=ad,i=t,document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(i)+";path=/"),t}class dd{constructor(t,e,i){this.loader=t,this.url=e,this.t=i}upload(){return this.loader.file.then(t=>new Promise((e,i)=>{this._initRequest(),this._initListeners(e,i,t),this._sendRequest(t)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const t=this.xhr=new XMLHttpRequest;t.open("POST",this.url,!0),t.responseType="json"}_initListeners(t,e,i){const n=this.xhr,s=this.loader,o=(0,this.t)("Cannot upload file:")+` ${i.name}.`;n.addEventListener("error",()=>e(o)),n.addEventListener("abort",()=>e()),n.addEventListener("load",()=>{const i=n.response;if(!i||!i.uploaded)return e(i&&i.error&&i.error.message?i.error.message:o);t({default:i.url})}),n.upload&&n.upload.addEventListener("progress",t=>{t.lengthComputable&&(s.uploadTotal=t.total,s.uploaded=t.loaded)})}_sendRequest(t){const e=new FormData;e.append("upload",t),e.append("ckCsrfToken",hd()),this.xhr.send(e)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ud{constructor(t,e,i){let n,s=null;"function"==typeof i?n=i:(s=t.commands.get(i),n=()=>{t.execute(i)}),t.model.document.on("change",(i,o)=>{if(s&&!s.isEnabled)return;if("transparent"==o.type)return;const r=Array.from(t.model.document.differ.getChanges()),a=r[0];if(1!=r.length||"insert"!==a.type||"$text"!=a.name||1!=a.length)return;const l=a.position.textNode||a.position.nodeAfter;if(!l.parent.is("paragraph"))return;const c=e.exec(l.data);c&&t.model.enqueueChange(t=>{const e=t.createPositionAt(l.parent,0),i=t.createPositionAt(l.parent,c[0].length),s=new ra(e,i);!1!==n({match:c})&&t.remove(s),s.detach()})})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fd{constructor(t,e,i){let n,s,o,r;e instanceof RegExp?n=e:o=e,"string"==typeof i?s=i:r=i,o=o||(t=>{let e;const i=[],s=[];for(;null!==(e=n.exec(t))&&!(e&&e.length<4);){let{index:t,1:n,2:o,3:r}=e;const a=n+o+r,l=[t+=e[0].length-a.length,t+n.length],c=[t+n.length+o.length,t+n.length+o.length+r.length];i.push(l),i.push(c),s.push([t+n.length,t+n.length+o.length])}return{remove:i,format:s}}),r=r||((e,i)=>{const n=t.model.schema.getValidRanges(i,s);for(const t of n)e.setAttribute(s,!0,t);e.removeSelectionAttribute(s)}),t.model.document.on("change",(e,i)=>{if("transparent"==i.type)return;const n=t.model.document.selection;if(!n.isCollapsed)return;const s=Array.from(t.model.document.differ.getChanges()),a=s[0];if(1!=s.length||"insert"!==a.type||"$text"!=a.name||1!=a.length)return;const l=n.focus.parent,c=function(t){return Array.from(t.getChildren()).reduce((t,e)=>t+e.data,"")}(l).slice(0,n.focus.offset),h=o(c),d=md(l,h.format,t.model),u=md(l,h.remove,t.model);d.length&&u.length&&t.model.enqueueChange(t=>{if(!1!==r(t,d))for(const e of u.reverse())t.remove(e)})})}}function md(t,e,i){return e.filter(t=>void 0!==t[0]&&void 0!==t[1]).map(e=>i.createRange(i.createPositionAt(t,e[0]),i.createPositionAt(t,e[1])))}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function gd(t,e){return(i,n)=>{if(!t.commands.get(e).isEnabled)return!1;const s=t.model.schema.getValidRanges(n,e);for(const t of s)i.setAttribute(e,!0,t);i.removeSelectionAttribute(e)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class pd extends lh{constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model,i=e.document.selection,n=void 0===t.forceValue?!this.value:t.forceValue;e.change(t=>{if(i.isCollapsed)n?t.setSelectionAttribute(this.attributeKey,!0):t.removeSelectionAttribute(this.attributeKey);else{const s=e.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const e of s)n?t.setAttribute(this.attributeKey,n,e):t.removeAttribute(this.attributeKey,e)}})}_getValueFromFirstAllowedNode(){const t=this.editor.model,e=t.schema,i=t.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const t of i.getRanges())for(const i of t.getItems())if(e.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const wd="bold";class bd extends nh{init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:wd}),t.model.schema.setAttributeProperties(wd,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:wd,view:"strong",upcastAlso:["b",{styles:{"font-weight":"bold"}}]}),t.commands.add(wd,new pd(t,wd)),t.keystrokes.set("CTRL+B",wd)}}var _d='<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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const vd="bold";class yd extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(vd,i=>{const n=t.commands.get(vd),s=new Xh(i);return s.set({label:e("Bold"),icon:_d,keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute(vd)),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const kd="italic";class Ad extends nh{init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:kd}),t.model.schema.setAttributeProperties(kd,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:kd,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),t.commands.add(kd,new pd(t,kd)),t.keystrokes.set("CTRL+I",kd)}}var Cd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.586 14.633l.021.004c-.036.335.095.655.393.962.082.083.173.15.274.201h1.474a.6.6 0 1 1 0 1.2H5.304a.6.6 0 0 1 0-1.2h1.15c.474-.07.809-.182 1.005-.334.157-.122.291-.32.404-.597l2.416-9.55a1.053 1.053 0 0 0-.281-.823 1.12 1.12 0 0 0-.442-.296H8.15a.6.6 0 0 1 0-1.2h6.443a.6.6 0 1 1 0 1.2h-1.195c-.376.056-.65.155-.823.296-.215.175-.423.439-.623.79l-2.366 9.347z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const xd="italic";class Pd extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(xd,i=>{const n=t.commands.get(xd),s=new Xh(i);return s.set({label:e("Italic"),icon:Cd,keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute(xd)),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Td="underline";class Ed extends nh{init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Td}),t.model.schema.setAttributeProperties(Td,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:Td,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),t.commands.add(Td,new pd(t,Td)),t.keystrokes.set("CTRL+U","underline")}}var Sd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 18v-1.5h14V18zM5.2 10V3.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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Rd="underline";class Od extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(Rd,i=>{const n=t.commands.get(Rd),s=new Xh(i);return s.set({label:e("Underline"),icon:Sd,keystroke:"CTRL+U",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute(Rd)),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Id="strikethrough";class Md extends nh{init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Id}),t.model.schema.setAttributeProperties(Id,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:Id,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),t.commands.add(Id,new pd(t,Id)),t.keystrokes.set("CTRL+SHIFT+X","strikethrough")}}var Vd='<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 9L6 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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Nd="strikethrough";class Bd extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(Nd,i=>{const n=t.commands.get(Nd),s=new Xh(i);return s.set({label:e("Strikethrough"),icon:Vd,keystroke:"CTRL+SHIFT+X",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute(Nd)),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Fd="code";class Dd extends nh{init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Fd}),t.model.schema.setAttributeProperties(Fd,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:Fd,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),t.commands.add(Fd,new pd(t,Fd))}}var Ld='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.5 5.7l5.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>';i(9);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const zd="code";class Hd extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(zd,i=>{const n=t.commands.get(zd),s=new Xh(i);return s.set({label:e("Code"),icon:Ld,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute(zd)),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const jd="subscript";class qd extends nh{init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:jd}),t.model.schema.setAttributeProperties(jd,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:jd,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),t.commands.add(jd,new pd(t,jd))}}var Wd='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7.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.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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Ud="subscript";class $d extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(Ud,i=>{const n=t.commands.get(Ud),s=new Xh(i);return s.set({label:e("Subscript"),icon:Wd,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute(Ud)),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Gd="superscript";class Kd extends nh{init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Gd}),t.model.schema.setAttributeProperties(Gd,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:Gd,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),t.commands.add(Gd,new pd(t,Gd))}}var Jd='<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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Yd="superscript";class Qd extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(Yd,i=>{const n=t.commands.get(Yd),s=new Xh(i);return s.set({label:e("Superscript"),icon:Jd,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute(Yd)),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Xd(t){const e=t.next();return e.done?null:e.value}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zd extends lh{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,i=e.schema,n=e.document.selection,s=Array.from(n.getTopMostBlocks()),o=void 0===t.forceValue?!this.value:t.forceValue;e.change(t=>{if(o){const e=s.filter(t=>tu(t)||iu(i,t));this._applyQuote(t,e)}else this._removeQuote(t,s.filter(tu))})}_getValue(){const t=Xd(this.editor.model.document.selection.getTopMostBlocks());return!(!t||!tu(t))}_checkEnabled(){if(this.value)return!0;const t=this.editor.model.document.selection,e=this.editor.model.schema,i=Xd(t.getSelectedBlocks());return!!i&&iu(e,i)}_removeQuote(t,e){eu(t,e).reverse().forEach(e=>{if(e.start.isAtStart&&e.end.isAtEnd)return void t.unwrap(e.start.parent);if(e.start.isAtStart){const i=t.createPositionBefore(e.start.parent);return void t.move(e,i)}e.end.isAtEnd||t.split(e.end);const i=t.createPositionAfter(e.end.parent);t.move(e,i)})}_applyQuote(t,e){const i=[];eu(t,e).reverse().forEach(e=>{let n=tu(e.start);n||(n=t.createElement("blockQuote"),t.wrap(e,n)),i.push(n)}),i.reverse().reduce((e,i)=>e.nextSibling==i?(t.merge(t.createPositionAfter(e)),e):i)}}function tu(t){return"blockQuote"==t.parent.name?t.parent:null}function eu(t,e){let i,n=0;const s=[];for(;n<e.length;){const o=e[n],r=e[n+1];i||(i=t.createPositionBefore(o)),r&&o.nextSibling==r||(s.push(t.createRange(i,t.createPositionAfter(o))),i=null),n++}return s}function iu(t,e){const i=t.checkChild(e.parent,"blockQuote"),n=t.checkChild(["$root","blockQuote"],e);return i&&n}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class nu extends nh{init(){const t=this.editor,e=t.model.schema;t.commands.add("blockQuote",new Zd(t)),e.register("blockQuote",{allowWhere:"$block",allowContentOf:"$root"}),e.addChildCheck((t,e)=>{if(t.endsWith("blockQuote")&&"blockQuote"==e.name)return!1}),t.conversion.elementToElement({model:"blockQuote",view:"blockquote"}),t.model.document.registerPostFixer(i=>{const n=t.model.document.differ.getChanges();for(const t of n)if("insert"==t.type){const n=t.position.nodeAfter;if(!n)continue;if(n.is("blockQuote")&&n.isEmpty)return i.remove(n),!0;if(n.is("blockQuote")&&!e.checkChild(t.position,n))return i.unwrap(n),!0;if(n.is("element")){const t=i.createRangeIn(n);for(const n of t.getItems())if(n.is("blockQuote")&&!e.checkChild(i.createPositionBefore(n),n))return i.unwrap(n),!0}}else if("remove"==t.type){const e=t.position.parent;if(e.is("blockQuote")&&e.isEmpty)return i.remove(e),!0}return!1})}afterInit(){const t=this.editor.commands.get("blockQuote");this.listenTo(this.editor.editing.view.document,"enter",(e,i)=>{const n=this.editor.model.document,s=n.selection.getLastPosition().parent;n.selection.isCollapsed&&s.isEmpty&&t.value&&(this.editor.execute("blockQuote"),this.editor.editing.view.scrollToTheSelection(),i.preventDefault(),e.stop())})}}var su='<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>';i(24);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ou extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add("blockQuote",i=>{const n=t.commands.get("blockQuote"),s=new Xh(i);return s.set({label:e("Block quote"),icon:su,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute("blockQuote")),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ru extends lh{refresh(){const t=this.editor.model,e=Xd(t.document.selection.getSelectedBlocks());this.value=!!e&&e.is("paragraph"),this.isEnabled=!!e&&au(e,t.schema)}execute(t={}){const e=this.editor.model,i=e.document;e.change(n=>{const s=(t.selection||i.selection).getSelectedBlocks();for(const t of s)!t.is("paragraph")&&au(t,e.schema)&&n.rename(t,"paragraph")})}}function au(t,e){return e.checkChild(t.parent,"paragraph")&&!e.isObject(t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lu extends nh{static get pluginName(){return"Paragraph"}init(){const t=this.editor,e=t.model,i=t.data;t.commands.add("paragraph",new ru(t)),e.schema.register("paragraph",{inheritAllFrom:"$block"}),t.conversion.elementToElement({model:"paragraph",view:"p"}),t.conversion.for("upcast").elementToElement({model:(t,e)=>lu.paragraphLikeElements.has(t.name)?t.isEmpty?null:e.createElement("paragraph"):null,converterPriority:"low"}),i.upcastDispatcher.on("element",(t,e,i)=>{i.consumable.test(e.viewItem,{name:e.viewItem.name})&&hu(e.viewItem,e.modelCursor,i.schema)&&Object.assign(e,cu(e.viewItem,e.modelCursor,i))},{priority:"low"}),i.upcastDispatcher.on("text",(t,e,i)=>{e.modelRange||hu(e.viewItem,e.modelCursor,i.schema)&&Object.assign(e,cu(e.viewItem,e.modelCursor,i))},{priority:"lowest"}),e.document.registerPostFixer(t=>this._autoparagraphEmptyRoots(t)),t.data.on("ready",()=>{e.enqueueChange("transparent",t=>this._autoparagraphEmptyRoots(t))},{priority:"lowest"})}_autoparagraphEmptyRoots(t){const e=this.editor.model;for(const i of e.document.getRootNames()){const n=e.document.getRoot(i);if(n.isEmpty&&"$graveyard"!=n.rootName&&e.schema.checkChild(n,"paragraph"))return t.insertElement("paragraph",n),!0}}}function cu(t,e,i){const n=i.writer.createElement("paragraph");return i.writer.insert(n,e),i.convertItem(t,i.writer.createPositionAt(n,0))}function hu(t,e,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */lu.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td"]);class du extends lh{constructor(t,e){super(t),this.modelElements=e}refresh(){const t=Xd(this.editor.model.document.selection.getSelectedBlocks());this.value=!!t&&this.modelElements.includes(t.name)&&t.name,this.isEnabled=!!t&&this.modelElements.some(e=>uu(t,e,this.editor.model.schema))}execute(t){const e=this.editor.model,i=e.document,n=t.value;e.change(t=>{const s=Array.from(i.selection.getSelectedBlocks()).filter(t=>uu(t,n,e.schema));for(const e of s)e.is(n)||t.rename(e,n)})}}function uu(t,e,i){return i.checkChild(t.parent,e)&&!i.isObject(t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const fu="paragraph";class mu extends nh{constructor(t){super(t),t.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[lu]}init(){const t=this.editor,e=t.config.get("heading.options"),i=[];for(const n of e)n.model!==fu&&(t.model.schema.register(n.model,{inheritAllFrom:"$block"}),t.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(t),t.commands.add("heading",new du(t,i))}afterInit(){const t=this.editor,e=t.commands.get("enter"),i=t.config.get("heading.options");e&&this.listenTo(e,"afterExecute",(e,n)=>{const s=t.model.document.selection.getFirstPosition().parent;i.some(t=>s.is(t.model))&&!s.is(fu)&&0===s.childCount&&n.writer.rename(s,fu)})}_addDefaultH1Conversion(t){t.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:Xi.get("low")+1})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class gu{constructor(t,e){e&&Fn(this,e),t&&this.set(t)}}cn(gu,jn);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class pu extends jc{constructor(t){super(t);const e=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",e.to("position",t=>`ck-dropdown__panel_${t}`),e.if("isVisible","ck-dropdown__panel-visible")]},children:this.children,on:{selectstart:e.to(t=>t.preventDefault())}})}focus(){this.children.length&&this.children.first.focus()}focusLast(){if(this.children.length){const t=this.children.last;"function"==typeof t.focusLast?t.focusLast():t.focus()}}}i(25);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function wu({element:t,target:e,positions:i,limiter:n,fitInViewport:s}){$(e)&&(e=e()),$(n)&&(n=n());const o=function(t){for(;t&&"html"!=t.tagName.toLowerCase();){if("static"!=no.window.getComputedStyle(t).position)return t;t=t.parentElement}return null}(t.parentElement),r=new Pr(t),a=new Pr(e);let l,c;if(n||s){const t=n&&new Pr(n).getVisible(),e=s&&new Pr(no.window);[c,l]=function(t,e,i,n,s){let o,r,a=0,l=0;const c=i.getArea();return t.some(t=>{const[h,d]=bu(t,e,i);let u,f;if(n)if(s){const t=n.getIntersection(s);u=t?t.getIntersectionArea(d):0}else u=n.getIntersectionArea(d);function m(){l=f,a=u,o=d,r=h}return s&&(f=s.getIntersectionArea(d)),s&&!n?f>l&&m():!s&&n?u>a&&m():f>l&&u>=a?m():f>=l&&u>a&&m(),u===c}),o?[r,o]:null}(i,a,r,t,e)||bu(i[0],a,r)}else[c,l]=bu(i[0],a,r);let{left:h,top:d}=_u(l);if(o){const t=_u(new Pr(o)),e=Cr(o);h-=t.left,d-=t.top,h+=o.scrollLeft,d+=o.scrollTop,h-=e.left,d-=e.top}return{left:h,top:d,name:c}}function bu(t,e,i){const{left:n,top:s,name:o}=t(e,i);return[o,i.clone().moveTo(n,s)]}function _u({left:t,top:e}){const{scrollX:i,scrollY:n}=no.window;return{left:t+i,top:e+n}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class vu extends jc{constructor(t,e,i){super(t);const n=this.bindTemplate;this.buttonView=e,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class"),this.set("panelPosition","auto"),this.focusTracker=new uc,this.keystrokes=new nc,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",n.to("class"),n.if("isEnabled","ck-disabled",t=>!t)]},children:[e,i]}),e.extendTemplate({attributes:{class:["ck-dropdown__button"]}})}render(){super.render(),this.listenTo(this.buttonView,"open",()=>{this.isOpen=!this.isOpen}),this.panelView.bind("isVisible").to(this,"isOpen"),this.on("change:isOpen",()=>{this.isOpen&&("auto"===this.panelPosition?this.panelView.position=vu._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions}).name:this.panelView.position=this.panelPosition)}),this.keystrokes.listenTo(this.element),this.focusTracker.add(this.element);const t=(t,e)=>{this.isOpen&&(this.buttonView.focus(),this.isOpen=!1,e())};this.keystrokes.set("arrowdown",(t,e)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,e())}),this.keystrokes.set("arrowright",(t,e)=>{this.isOpen&&e()}),this.keystrokes.set("arrowleft",t),this.keystrokes.set("esc",t)}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:t,southWest:e,northEast:i,northWest:n}=vu.defaultPanelPositions;return"ltr"===this.locale.uiLanguageDirection?[t,e,i,n]:[e,t,n,i]}}vu.defaultPanelPositions={southEast:t=>({top:t.bottom,left:t.left,name:"se"}),southWest:(t,e)=>({top:t.bottom,left:t.left-e.width+t.width,name:"sw"}),northEast:(t,e)=>({top:t.top-e.height,left:t.left,name:"ne"}),northWest:(t,e)=>({top:t.bottom-e.height,left:t.left-e.width+t.width,name:"nw"})},vu._getOptimalPosition=wu;var yu='<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path d="M.941 4.523a.75.75 0 1 1 1.06-1.06l3.006 3.005 3.005-3.005a.75.75 0 1 1 1.06 1.06l-3.549 3.55a.75.75 0 0 1-1.168-.136L.941 4.523z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ku extends Xh{constructor(t){super(t),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const t=new Yh;return t.content=yu,t.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),t}}i(26);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Au extends jc{constructor(){super(),this.items=this.createCollection(),this.focusTracker=new uc,this.keystrokes=new nc,this._focusCycler=new Qc({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"]},children:this.items})}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",(t,e)=>{this.focusTracker.add(e.element)}),this.items.on("remove",(t,e)=>{this.focusTracker.remove(e.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Cu extends jc{constructor(t){super(t),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item"]},children:this.children})}focus(){this.children.first.focus()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class xu extends jc{constructor(t){super(t),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}i(27);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Pu extends Xh{constructor(t){super(t),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const t=new jc;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),t}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Tu({emitter:t,activator:e,callback:i,contextElements:n}){t.listenTo(document,"mousedown",(t,{target:s})=>{if(e()){for(const t of n)if(t.contains(s))return;i()}})}i(28),i(29);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Eu(t,e=ku){const i=new e(t),n=new pu(t),s=new vu(t,i,n);return i.bind("isEnabled").to(s),i instanceof ku?i.bind("isOn").to(s,"isOpen"):i.arrowView.bind("isOn").to(s,"isOpen"),function(t){(function(t){t.on("render",()=>{Tu({emitter:t,activator:()=>t.isOpen,callback:()=>{t.isOpen=!1},contextElements:[t.element]})})})(t),function(t){t.on("execute",e=>{e.source instanceof Pu||(t.isOpen=!1)})}(t),function(t){t.keystrokes.set("arrowdown",(e,i)=>{t.isOpen&&(t.panelView.focus(),i())}),t.keystrokes.set("arrowup",(e,i)=>{t.isOpen&&(t.panelView.focusLast(),i())})}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t)}(s),s}function Su(t,e){const i=t.locale,n=i.t,s=t.toolbarView=new th(i);s.set("ariaLabel",n("Dropdown toolbar")),t.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.map(t=>s.items.add(t)),t.panelView.children.add(s),s.items.delegate("execute").to(t)}function Ru(t,e){const i=t.locale,n=t.listView=new Au(i);n.items.bindTo(e).using(({type:t,model:e})=>{if("separator"===t)return new xu(i);if("button"===t||"switchbutton"===t){const n=new Cu(i);let s;return(s="button"===t?new Xh(i):new Pu(i)).bind(...Object.keys(e)).to(e),s.delegate("execute").to(n),n.children.add(s),n}}),t.panelView.children.add(n),n.items.delegate("execute").to(t)}i(10);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ou extends nh{init(){const t=this.editor,e=t.t,i=function(t){const e=t.t,i={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 t.config.get("heading.options").map(t=>{const e=i[t.title];return e&&e!=t.title&&(t.title=e),t})}(t),n=e("Choose heading"),s=e("Heading");t.ui.componentFactory.add("heading",e=>{const o={},r=new os,a=t.commands.get("heading"),l=t.commands.get("paragraph"),c=[a];for(const t of i){const e={type:"button",model:new gu({label:t.title,class:t.class,withText:!0})};"paragraph"===t.model?(e.model.bind("isOn").to(l,"value"),e.model.set("commandName","paragraph"),c.push(l)):(e.model.bind("isOn").to(a,"value",e=>e===t.model),e.model.set({commandName:"heading",commandValue:t.model})),r.add(e),o[t.model]=t.title}const h=Eu(e);return Ru(h,r),h.buttonView.set({isOn:!1,withText:!0,tooltip:s}),h.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),h.bind("isEnabled").toMany(c,"isEnabled",(...t)=>t.some(t=>t)),h.buttonView.bind("label").to(a,"value",l,"value",(t,e)=>{const i=t||e&&"paragraph";return o[i]?o[i]:n}),this.listenTo(h,"execute",e=>{t.execute(e.source.commandName,e.source.commandValue?{value:e.source.commandValue}:void 0),t.editing.view.focus()}),h})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Iu extends mo{constructor(t){super(t),this._observedElements=new Set}observe(t,e){this.document.getRoot(e).on("change:children",(e,i)=>{this.view.once("render",()=>this._updateObservedElements(t,i))})}_updateObservedElements(t,e){if(!e.is("element")||e.is("attributeElement"))return;const i=this.view.domConverter.mapViewToDom(e);if(i){for(const t of i.querySelectorAll("img"))this._observedElements.has(t)||(this.listenTo(t,"load",(t,e)=>this._fireEvents(e)),this._observedElements.add(t));for(const e of this._observedElements)t.contains(e)||(this.stopListening(e),this._observedElements.delete(e))}}_fireEvents(t){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",t))}destroy(){this._observedElements.clear(),super.destroy()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Mu(t){return i=>{i.on(`attribute:${t}:image`,e)};function e(t,e,i){if(!i.consumable.consume(e.item,t.name))return;const n=i.writer,s=i.mapper.toViewElement(e.item).getChild(0);null!==e.attributeNewValue?n.setAttribute(e.attributeKey,e.attributeNewValue,s):n.removeAttribute(e.attributeKey,s)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Vu{constructor(){this._stack=[]}add(t,e){const i=this._stack,n=i[0];this._insertDescriptor(t);const s=i[0];n===s||Nu(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:e})}remove(t,e){const i=this._stack,n=i[0];this._removeDescriptor(t);const s=i[0];n===s||Nu(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:e})}_insertDescriptor(t){const e=this._stack,i=e.findIndex(e=>e.id===t.id);if(Nu(t,e[i]))return;i>-1&&e.splice(i,1);let n=0;for(;e[n]&&Bu(e[n],t);)n++;e.splice(n,0,t)}_removeDescriptor(t){const e=this._stack,i=e.findIndex(e=>e.id===t);i>-1&&e.splice(i,1)}}function Nu(t,e){return t&&e&&t.priority==e.priority&&Fu(t.classes)==Fu(e.classes)}function Bu(t,e){return t.priority>e.priority||!(t.priority<e.priority)&&Fu(t.classes)>Fu(e.classes)}function Fu(t){return Array.isArray(t)?t.sort().join(","):t}cn(Vu,en);var Du='<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M4 0v1H1v3H0V.5A.5.5 0 0 1 .5 0H4zm8 0h3.5a.5.5 0 0 1 .5.5V4h-1V1h-3V0zM4 16H.5a.5.5 0 0 1-.5-.5V12h1v3h3v1zm8 0v-1h3v-3h1v3.5a.5.5 0 0 1-.5.5H12z"/><path fill-opacity=".256" d="M1 1h14v14H1z"/><g class="ck-icon__selected-indicator"><path d="M7 0h2v1H7V0zM0 7h1v2H0V7zm15 0h1v2h-1V7zm-8 8h2v1H7v-1z"/><path fill-opacity=".254" d="M1 1h14v14H1z"/></g></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Lu="ck-widget",zu="ck-widget_selected";function Hu(t){return!!t.is("element")&&!!t.getCustomProperty("widget")}function ju(t,e,i={}){return ms.isEdge||e.setAttribute("contenteditable","false",t),e.addClass(Lu,t),e.setCustomProperty("widget",!0,t),t.getFillerOffset=$u,i.label&&function(t,e,i){i.setCustomProperty("widgetLabel",e,t)}(t,i.label,e),i.hasSelectionHandler&&function(t,e){const i=e.createUIElement("div",{class:"ck ck-widget__selection-handler"},(function(t){const e=this.toDomElement(t),i=new Yh;return i.set("content",Du),i.render(),e.appendChild(i.element),e}));e.insert(e.createPositionAt(t,0),i),e.addClass(["ck-widget_with-selection-handler"],t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t,e),function(t,e,i,n){const s=new Vu;s.on("change:top",(e,s)=>{s.oldDescriptor&&n(t,s.oldDescriptor,s.writer),s.newDescriptor&&i(t,s.newDescriptor,s.writer)}),e.setCustomProperty("addHighlight",(t,e,i)=>s.add(e,i),t),e.setCustomProperty("removeHighlight",(t,e,i)=>s.remove(e,i),t)}(t,e,(t,e,i)=>i.addClass(n(e.classes),t),(t,e,i)=>i.removeClass(n(e.classes),t)),t;function n(t){return Array.isArray(t)?t:[t]}}function qu(t){const e=t.getCustomProperty("widgetLabel");return e?"function"==typeof e?e():e:""}function Wu(t,e){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],t),ms.isEdge||(e.setAttribute("contenteditable",t.isReadOnly?"false":"true",t),t.on("change:isReadOnly",(i,n,s)=>{e.setAttribute("contenteditable",s?"false":"true",t)})),t.on("change:isFocused",(i,n,s)=>{s?e.addClass("ck-editor__nested-editable_focused",t):e.removeClass("ck-editor__nested-editable_focused",t)}),t}function Uu(t,e){const i=t.getSelectedElement();if(i&&e.schema.isBlock(i))return e.createPositionAfter(i);const n=t.getSelectedBlocks().next().value;if(n){if(n.isEmpty)return e.createPositionAt(n,0);const i=e.createPositionAfter(n);return t.focus.isTouching(i)?i:e.createPositionBefore(n)}return t.focus}function $u(){return null}function Gu(t){const e=t.getSelectedElement();return e&&function(t){return!!t.getCustomProperty("image")&&Hu(t)}(e)?e:null}function Ku(t){return!!t&&t.is("image")}function Ju(t,e,i={}){const n=t.createElement("image",i),s=Uu(e.document.selection,e);e.insertContent(n,s),n.parent&&t.setSelection(n,"on")}function Yu(t){const e=t.schema,i=t.document.selection;return function(t,e,i){const n=function(t,e){const i=Uu(t,e).parent;if(i.isEmpty&&!i.is("$root"))return i.parent;return i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t,i);return e.checkChild(n,"image")}(i,e,t)&&!function(t,e){const i=t.getSelectedElement();return i&&e.isObject(i)}(i,e)&&function(t){return[...t.focus.getAncestors()].every(t=>!t.is("image"))}(i)}class Qu extends lh{refresh(){this.isEnabled=Yu(this.editor.model)}execute(t){const e=this.editor.model;e.change(i=>{const n=Array.isArray(t.source)?t.source:[t.source];for(const t of n)Ju(i,e,{src:t})})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xu extends nh{init(){const t=this.editor,e=t.model.schema,i=t.t,n=t.conversion;t.editing.view.addObserver(Iu),e.register("image",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["alt","src","srcset"]}),n.for("dataDowncast").elementToElement({model:"image",view:(t,e)=>Zu(e)}),n.for("editingDowncast").elementToElement({model:"image",view:(t,e)=>(function(t,e,i){return e.setCustomProperty("image",!0,t),ju(t,e,{label:function(){const e=t.getChild(0).getAttribute("alt");return e?`${e} ${i}`:i}})})(Zu(e),e,i("image widget"))}),n.for("downcast").add(Mu("src")).add(Mu("alt")).add(function(){return e=>{e.on("attribute:srcset:image",t)};function t(t,e,i){if(!i.consumable.consume(e.item,t.name))return;const n=i.writer,s=i.mapper.toViewElement(e.item).getChild(0);if(null===e.attributeNewValue){const t=e.attributeOldValue;t.data&&(n.removeAttribute("srcset",s),n.removeAttribute("sizes",s),t.width&&n.removeAttribute("width",s))}else{const t=e.attributeNewValue;t.data&&(n.setAttribute("srcset",t.data,s),n.setAttribute("sizes","100vw",s),t.width&&n.setAttribute("width",t.width,s))}}}()),n.for("upcast").elementToElement({view:{name:"img",attributes:{src:!0}},model:(t,e)=>e.createElement("image",{src:t.getAttribute("src")})}).attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:t=>{const e={data:t.getAttribute("srcset")};return t.hasAttribute("width")&&(e.width=t.getAttribute("width")),e}}}).add(function(){return e=>{e.on("element:figure",t)};function t(t,e,i){if(!i.consumable.test(e.viewItem,{name:!0,classes:"image"}))return;const n=Array.from(e.viewItem.getChildren()).find(t=>t.is("img"));if(!n||!n.hasAttribute("src")||!i.consumable.test(n,{name:!0}))return;const s=i.convertItem(n,e.modelCursor),o=Xd(s.modelRange.getItems());o&&(i.convertChildren(e.viewItem,i.writer.createPositionAt(o,0)),e.modelRange=s.modelRange,e.modelCursor=s.modelCursor)}}()),t.commands.add("imageInsert",new Qu(t))}}function Zu(t){const e=t.createEmptyElement("img"),i=t.createContainerElement("figure",{class:"image"});return t.insert(t.createPositionAt(i,0),e),i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tf extends ir{constructor(t){super(t),this.domEventType="mousedown"}onDomEvent(t){this.fire(t.type,t)}}i(30);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const ef=_s("Ctrl+A");class nf extends nh{static get pluginName(){return"Widget"}init(){const t=this.editor.editing.view,e=t.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",(t,e,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,s=n.document.selection,o=s.getSelectedElement();let r=null;for(const t of s.getRanges())for(const e of t){const t=e.item;Hu(t)&&!sf(t,r)&&(n.addClass(zu,t),this._previouslySelected.add(t),r=t,t==o&&n.setSelection(s.getRanges(),{fake:!0,label:qu(o)}))}},{priority:"low"}),t.addObserver(tf),this.listenTo(e,"mousedown",(...t)=>this._onMousedown(...t)),this.listenTo(e,"keydown",(...t)=>this._onKeydown(...t),{priority:"high"}),this.listenTo(e,"delete",(t,e)=>{this._handleDelete("forward"==e.direction)&&(e.preventDefault(),t.stop())},{priority:"high"})}_onMousedown(t,e){const i=this.editor,n=i.editing.view,s=n.document;let o=e.target;if(function(t){for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(Hu(t))return!1;t=t.parent}return!1}(o)){if(ms.isSafari&&e.domEvent.detail>=3){const t=i.editing.mapper.toModelElement(o);this.editor.model.change(i=>{e.preventDefault(),i.setSelection(t,"in")})}return}if(!Hu(o)&&!(o=o.findAncestor(Hu)))return;e.preventDefault(),s.isFocused||n.focus();const r=i.editing.mapper.toModelElement(o);this._setSelectionOverElement(r)}_onKeydown(t,e){const i=e.keyCode,n=i==ws.arrowdown||i==ws.arrowright;let s=!1;!function(t){return t==ws.arrowright||t==ws.arrowleft||t==ws.arrowup||t==ws.arrowdown}(i)?!function(t){return bs(t)==ef}(e)?i===ws.enter&&(s=this._handleEnterKey(e.shiftKey)):s=this._selectAllNestedEditableContent()||this._selectAllContent():s=this._handleArrowKeys(n),s&&(e.preventDefault(),t.stop())}_handleDelete(t){if(this.editor.isReadOnly)return;const e=this.editor.model.document.selection;if(!e.isCollapsed)return;const i=this._getObjectElementNextToSelection(t);return i?(this.editor.model.change(t=>{let n=e.anchor.parent;for(;n.isEmpty;){const e=n;n=e.parent,t.remove(e)}this._setSelectionOverElement(i)}),!0):void 0}_handleArrowKeys(t){const e=this.editor.model,i=e.schema,n=e.document.selection,s=n.getSelectedElement();if(s&&i.isObject(s)){const s=t?n.getLastPosition():n.getFirstPosition(),o=i.getNearestSelectionRange(s,t?"forward":"backward");return o&&e.change(t=>{t.setSelection(o)}),!0}if(!n.isCollapsed)return;const o=this._getObjectElementNextToSelection(t);return o&&i.isObject(o)?(this._setSelectionOverElement(o),!0):void 0}_handleEnterKey(t){const e=this.editor.model,i=e.document.selection.getSelectedElement();if(n=i,s=e.schema,n&&s.isObject(n)&&!s.isInline(n))return e.change(n=>{let s=n.createPositionAt(i,t?"before":"after");const o=n.createElement("paragraph");if(e.schema.isBlock(i.parent)){const t=e.schema.findAllowedParent(s,o);s=n.split(s,t).position}n.insert(o,s),n.setSelection(o,"in")}),!0;var n,s;
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */}_selectAllNestedEditableContent(){const t=this.editor.model,e=t.document.selection,i=t.schema.getLimitElement(e);return e.getFirstRange().root!=i&&(t.change(t=>{t.setSelection(t.createRangeIn(i))}),!0)}_selectAllContent(){const t=this.editor.model,e=this.editor.editing,i=e.view.document.selection.getSelectedElement();if(i&&Hu(i)){const n=e.mapper.toModelElement(i.parent);return t.change(t=>{t.setSelection(t.createRangeIn(n))}),!0}return!1}_setSelectionOverElement(t){this.editor.model.change(e=>{e.setSelection(e.createRangeOn(t))})}_getObjectElementNextToSelection(t){const e=this.editor.model,i=e.schema,n=e.document.selection,s=e.createSelection(n);e.modifySelection(s,{direction:t?"forward":"backward"});const o=t?s.focus.nodeBefore:s.focus.nodeAfter;return o&&i.isObject(o)?o:null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected)t.removeClass(zu,e);this._previouslySelected.clear()}}function sf(t,e){return!!e&&Array.from(t.getAncestors()).includes(e)}class of extends lh{refresh(){const t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=Ku(t),Ku(t)&&t.hasAttribute("alt")?this.value=t.getAttribute("alt"):this.value=!1}execute(t){const e=this.editor.model,i=e.document.selection.getSelectedElement();e.change(e=>{e.setAttribute("alt",t.newValue,i)})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rf extends nh{init(){this.editor.commands.add("imageTextAlternative",new of(this.editor))}}i(31);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class af extends jc{constructor(t,e){super(t);const i=`ck-input-${Qi()}`,n=`ck-status-${Qi()}`;this.set("label"),this.set("value"),this.set("isReadOnly",!1),this.set("errorText",null),this.set("infoText",null),this.labelView=this._createLabelView(i),this.inputView=this._createInputView(e,i,n),this.statusView=this._createStatusView(n),this.bind("_statusText").to(this,"errorText",this,"infoText",(t,e)=>t||e);const s=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-input",s.if("isReadOnly","ck-disabled")]},children:[this.labelView,this.inputView,this.statusView]})}_createLabelView(t){const e=new Wc(this.locale);return e.for=t,e.bind("text").to(this,"label"),e}_createInputView(t,e,i){const n=new t(this.locale,i);return n.id=e,n.ariaDescribedById=i,n.bind("value").to(this),n.bind("isReadOnly").to(this),n.bind("hasError").to(this,"errorText",t=>!!t),n.on("input",()=>{this.errorText=null}),n}_createStatusView(t){const e=new jc(this.locale),i=this.bindTemplate;return e.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-input__status",i.if("errorText","ck-labeled-input__status_error"),i.if("_statusText","ck-hidden",t=>!t)],id:t,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),e}select(){this.inputView.select()}focus(){this.inputView.focus()}}i(32);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lf extends jc{constructor(t){super(t),this.set("value"),this.set("id"),this.set("placeholder"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById");const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{type:"text",class:["ck","ck-input","ck-input-text",e.if("hasError","ck-error")],id:e.to("id"),placeholder:e.to("placeholder"),readonly:e.to("isReadOnly"),"aria-invalid":e.if("hasError",!0),"aria-describedby":e.to("ariaDescribedById")},on:{input:e.to("input")}})}render(){super.render();const t=t=>{this.element.value=t||0===t?t:""};t(this.value),this.on("change:value",(e,i,n)=>{t(n)})}select(){this.element.select()}focus(){this.element.focus()}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function cf({view:t}){t.listenTo(t.element,"submit",(e,i)=>{i.preventDefault(),t.fire("submit")},{useCapture:!0})}var hf='<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>',df='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.591 10.177l4.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>';i(33);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class uf extends jc{constructor(t){super(t);const e=this.locale.t;this.focusTracker=new uc,this.keystrokes=new nc,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(e("Save"),hf,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(e("Cancel"),df,"ck-button-cancel","cancel"),this._focusables=new yc,this._focusCycler=new Qc({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),cf({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)})}_createButton(t,e,i,n){const s=new Xh(this.locale);return s.set({label:t,icon:e,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createLabeledInputView(){const t=this.locale.t,e=new af(this.locale,lf);return e.label=t("Text alternative"),e.inputView.placeholder=t("Text alternative"),e}}i(34);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */const ff=Kc("px"),mf=no.document.body;class gf extends jc{constructor(t){super(t);const e=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"),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",e.to("position",t=>`ck-balloon-panel_${t}`),e.if("isVisible","ck-balloon-panel_visible"),e.if("withArrow","ck-balloon-panel_with-arrow"),e.to("class")],style:{top:e.to("top",ff),left:e.to("left",ff)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(t){this.show();const e=gf.defaultPositions,i=Object.assign({},{element:this.element,positions:[e.southArrowNorth,e.southArrowNorthWest,e.southArrowNorthEast,e.northArrowSouth,e.northArrowSouthWest,e.northArrowSouthEast],limiter:mf,fitInViewport:!0},t),n=gf._getOptimalPosition(i),s=parseInt(n.left),o=parseInt(n.top),r=n.name;Object.assign(this,{top:o,left:s,position:r})}pin(t){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(t):this._stopPinning()},this._startPinning(t),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(t){this.attachTo(t);const e=pf(t.target),i=t.limiter?pf(t.limiter):mf;this.listenTo(no.document,"scroll",(n,s)=>{const o=s.target,r=e&&o.contains(e),a=i&&o.contains(i);!r&&!a&&e&&i||this.attachTo(t)},{useCapture:!0}),this.listenTo(no.window,"resize",()=>{this.attachTo(t)})}_stopPinning(){this.stopListening(no.document,"scroll"),this.stopListening(no.window,"resize")}}function pf(t){return Ui(t)?t:Ar(t)?t.commonAncestorContainer:"function"==typeof t?pf(t()):null}function wf(t,e){return t.top-e.height-gf.arrowVerticalOffset}function bf(t){return t.bottom+gf.arrowVerticalOffset}gf.arrowHorizontalOffset=25,gf.arrowVerticalOffset=10,gf._getOptimalPosition=wu,gf.defaultPositions={northArrowSouth:(t,e)=>({top:wf(t,e),left:t.left+t.width/2-e.width/2,name:"arrow_s"}),northArrowSouthEast:(t,e)=>({top:wf(t,e),left:t.left+t.width/2-e.width+gf.arrowHorizontalOffset,name:"arrow_se"}),northArrowSouthWest:(t,e)=>({top:wf(t,e),left:t.left+t.width/2-gf.arrowHorizontalOffset,name:"arrow_sw"}),northWestArrowSouth:(t,e)=>({top:wf(t,e),left:t.left-e.width/2,name:"arrow_s"}),northWestArrowSouthWest:(t,e)=>({top:wf(t,e),left:t.left-gf.arrowHorizontalOffset,name:"arrow_sw"}),northWestArrowSouthEast:(t,e)=>({top:wf(t,e),left:t.left-e.width+gf.arrowHorizontalOffset,name:"arrow_se"}),northEastArrowSouth:(t,e)=>({top:wf(t,e),left:t.right-e.width/2,name:"arrow_s"}),northEastArrowSouthEast:(t,e)=>({top:wf(t,e),left:t.right-e.width+gf.arrowHorizontalOffset,name:"arrow_se"}),northEastArrowSouthWest:(t,e)=>({top:wf(t,e),left:t.right-gf.arrowHorizontalOffset,name:"arrow_sw"}),southArrowNorth:(t,e)=>({top:bf(t),left:t.left+t.width/2-e.width/2,name:"arrow_n"}),southArrowNorthEast:(t,e)=>({top:bf(t),left:t.left+t.width/2-e.width+gf.arrowHorizontalOffset,name:"arrow_ne"}),southArrowNorthWest:(t,e)=>({top:bf(t),left:t.left+t.width/2-gf.arrowHorizontalOffset,name:"arrow_nw"}),southWestArrowNorth:(t,e)=>({top:bf(t),left:t.left-e.width/2,name:"arrow_n"}),southWestArrowNorthWest:(t,e)=>({top:bf(t),left:t.left-gf.arrowHorizontalOffset,name:"arrow_nw"}),southWestArrowNorthEast:(t,e)=>({top:bf(t),left:t.left-e.width+gf.arrowHorizontalOffset,name:"arrow_ne"}),southEastArrowNorth:(t,e)=>({top:bf(t),left:t.right-e.width/2,name:"arrow_n"}),southEastArrowNorthEast:(t,e)=>({top:bf(t),left:t.right-e.width+gf.arrowHorizontalOffset,name:"arrow_ne"}),southEastArrowNorthWest:(t,e)=>({top:bf(t),left:t.right-gf.arrowHorizontalOffset,name:"arrow_nw"})};var _f='<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>\n',vf='<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>\n';i(35),i(36);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const yf=Kc("px");class kf extends nh{static get pluginName(){return"ContextualBalloon"}constructor(t){super(t),this.positionLimiter=()=>{const t=this.editor.editing.view,e=t.document.selection.editableElement;return e?t.domConverter.mapViewToDom(e.root):null},this.set("visibleView",null),this.view=new gf(t.locale),t.ui.view.body.add(this.view),t.ui.focusTracker.add(this.view.element),this._viewToStack=new Map,this._idToStack=new Map,this.set("_numberOfStacks",0),this.set("_singleViewMode",!1),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}hasView(t){return Array.from(this._viewToStack.keys()).includes(t)}add(t){if(this.hasView(t.view))throw new Ki.b("contextualballoon-add-view-exist: Cannot add configuration of the same view twice.",[this,t]);const e=t.stackId||"main";if(!this._idToStack.has(e))return this._idToStack.set(e,new Map([[t.view,t]])),this._viewToStack.set(t.view,this._idToStack.get(e)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!t.singleViewMode||this.showStack(e));const i=this._idToStack.get(e);t.singleViewMode&&this.showStack(e),i.set(t.view,t),this._viewToStack.set(t.view,i),i===this._visibleStack&&this._showView(t)}remove(t){if(!this.hasView(t))throw new Ki.b("contextualballoon-remove-view-not-exist: Cannot remove the configuration of a non-existent view.",[this,t]);const e=this._viewToStack.get(t);this._singleViewMode&&this.visibleView===t&&(this._singleViewMode=!1),this.visibleView===t&&(1===e.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(e.values())[e.size-2])),1===e.size?(this._idToStack.delete(this._getStackId(e)),this._numberOfStacks=this._idToStack.size):e.delete(t),this._viewToStack.delete(t)}updatePosition(t){t&&(this._visibleStack.get(this.visibleView).position=t),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(t){this.visibleStack=t;const e=this._idToStack.get(t);if(!e)throw new Ki.b("contextualballoon-showstack-stack-not-exist: Cannot show a stack that does not exist.",this);this._visibleStack!==e&&this._showView(Array.from(e.values()).pop())}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(t){return Array.from(this._idToStack.entries()).find(e=>e[1]===t)[0]}_showNextStack(){const t=Array.from(this._idToStack.values());let e=t.indexOf(this._visibleStack)+1;t[e]||(e=0),this.showStack(this._getStackId(t[e]))}_showPrevStack(){const t=Array.from(this._idToStack.values());let e=t.indexOf(this._visibleStack)-1;t[e]||(e=t.length-1),this.showStack(this._getStackId(t[e]))}_createRotatorView(){const t=new Af(this.editor.locale),e=this.editor.locale.t;return this.view.content.add(t),t.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",(t,e)=>!e&&t>1),t.on("change:isNavigationVisible",()=>this.updatePosition(),{priority:"low"}),t.bind("counter").to(this,"visibleView",this,"_numberOfStacks",(t,i)=>{if(i<2)return"";const n=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return e("%0 of %1",[n,i])}),t.buttonNextView.on("execute",()=>{t.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()}),t.buttonPrevView.on("execute",()=>{t.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()}),t}_createFakePanelsView(){const t=new Cf(this.editor.locale,this.view);return t.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",(t,e)=>{return!e&&t>=2?Math.min(t-1,2):0}),t.listenTo(this.view,"change:top",()=>t.updatePosition()),t.listenTo(this.view,"change:left",()=>t.updatePosition()),this.editor.ui.view.body.add(t),t}_showView({view:t,balloonClassName:e="",withArrow:i=!0,singleViewMode:n=!1}){this.view.class=e,this.view.withArrow=i,this._rotatorView.showView(t),this.visibleView=t,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),n&&(this._singleViewMode=!0)}_getBalloonPosition(){let t=Array.from(this._visibleStack.values()).pop().position;return t&&!t.limiter&&(t=Object.assign({},t,{limiter:this.positionLimiter})),t}}class Af extends jc{constructor(t){super(t);const e=t.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new uc,this.buttonPrevView=this._createButtonView(e("Previous"),_f),this.buttonNextView=this._createButtonView(e("Next"),vf),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",t=>t?"":"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)}showView(t){this.hideView(),this.content.add(t)}hideView(){this.content.clear()}_createButtonView(t,e){const i=new Xh(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i}}class Cf extends jc{constructor(t,e){super(t);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=e,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",i.to("numberOfPanels",t=>t?"":"ck-hidden")],style:{top:i.to("top",yf),left:i.to("left",yf),width:i.to("width",yf),height:i.to("height",yf)}},children:this.content}),this.on("change:numberOfPanels",(t,e,i,n)=>{i>n?this._addPanels(i-n):this._removePanels(n-i),this.updatePosition()})}_addPanels(t){for(;t--;){const t=new jc;t.setTemplate({tag:"div"}),this.content.add(t),this.registerChild(t)}}_removePanels(t){for(;t--;){const t=this.content.last;this.content.remove(t),this.deregisterChild(t),t.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:t,left:e}=this._balloonPanelView,{width:i,height:n}=new Pr(this._balloonPanelView.element);Object.assign(this,{top:t,left:e,width:i,height:n})}}}var xf='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5.085 6.22L2.943 4.078a.75.75 0 1 1 1.06-1.06l2.592 2.59A11.094 11.094 0 0 1 10 5.068c4.738 0 8.578 3.101 8.578 5.083 0 1.197-1.401 2.803-3.555 3.887l1.714 1.713a.75.75 0 0 1-.09 1.138.488.488 0 0 1-.15.084.75.75 0 0 1-.821-.16L6.17 7.304c-.258.11-.51.233-.757.365l6.239 6.24-.006.005.78.78c-.388.094-.78.166-1.174.215l-1.11-1.11h.011L4.55 8.197a7.2 7.2 0 0 0-.665.514l-.112.098 4.897 4.897-.005.006 1.276 1.276a10.164 10.164 0 0 1-1.477-.117l-.479-.479-.009.009-4.863-4.863-.022.031a2.563 2.563 0 0 0-.124.2c-.043.077-.08.158-.108.241a.534.534 0 0 0-.028.133.29.29 0 0 0 .008.072.927.927 0 0 0 .082.226c.067.133.145.26.234.379l3.242 3.365.025.01.59.623c-3.265-.918-5.59-3.155-5.59-4.668 0-1.194 1.448-2.838 3.663-3.93zm7.07.531a4.632 4.632 0 0 1 1.108 5.992l.345.344.046-.018a9.313 9.313 0 0 0 2-1.112c.256-.187.5-.392.727-.613.137-.134.27-.277.392-.431.072-.091.141-.185.203-.286.057-.093.107-.19.148-.292a.72.72 0 0 0 .036-.12.29.29 0 0 0 .008-.072.492.492 0 0 0-.028-.133.999.999 0 0 0-.036-.096 2.165 2.165 0 0 0-.071-.145 2.917 2.917 0 0 0-.125-.2 3.592 3.592 0 0 0-.263-.335 5.444 5.444 0 0 0-.53-.523 7.955 7.955 0 0 0-1.054-.768 9.766 9.766 0 0 0-1.879-.891c-.337-.118-.68-.219-1.027-.301zm-2.85.21l-.069.002a.508.508 0 0 0-.254.097.496.496 0 0 0-.104.679.498.498 0 0 0 .326.199l.045.005c.091.003.181.003.272.012a2.45 2.45 0 0 1 2.017 1.513c.024.061.043.125.069.185a.494.494 0 0 0 .45.287h.008a.496.496 0 0 0 .35-.158.482.482 0 0 0 .13-.335.638.638 0 0 0-.048-.219 3.379 3.379 0 0 0-.36-.723 3.438 3.438 0 0 0-2.791-1.543l-.028-.001h-.013z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Pf(t){const e=t.editing.view,i=gf.defaultPositions;return{target:e.domConverter.viewToDom(e.document.selection.getSelectedElement()),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast]}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Tf extends nh{static get requires(){return[kf]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton(),this._createForm()}destroy(){super.destroy(),this._form.destroy()}_createButton(){const t=this.editor,e=t.t;t.ui.componentFactory.add("imageTextAlternative",i=>{const n=t.commands.get("imageTextAlternative"),s=new Xh(i);return s.set({label:e("Change image text alternative"),icon:xf,tooltip:!0}),s.bind("isEnabled").to(n,"isEnabled"),this.listenTo(s,"execute",()=>this._showForm()),s})}_createForm(){const t=this.editor,e=t.editing.view.document;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new uf(t.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{t.execute("imageTextAlternative",{newValue:this._form.labeledInput.inputView.element.value}),this._hideForm(!0)}),this.listenTo(this._form,"cancel",()=>{this._hideForm(!0)}),this._form.keystrokes.set("Esc",(t,e)=>{this._hideForm(!0),e()}),this.listenTo(t.ui,"update",()=>{Gu(e.selection)?this._isVisible&&function(t){const e=t.plugins.get("ContextualBalloon");if(Gu(t.editing.view.document.selection)){const i=Pf(t);e.updatePosition(i)}}(t):this._hideForm(!0)}),Tu({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;const t=this.editor,e=t.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._isInBalloon||this._balloon.add({view:this._form,position:Pf(t)}),i.value=i.inputView.element.value=e.value||"",this._form.labeledInput.select()}_hideForm(t){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),t&&this.editor.editing.view.focus())}get _isVisible(){return this._balloon.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ef extends nh{static get requires(){return[rf,Tf]}static get pluginName(){return"ImageTextAlternative"}}i(37);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Sf(t){for(const e of t.getChildren())if(e&&e.is("caption"))return e;return null}function Rf(t){const e=t.parent;return"figcaption"==t.name&&e&&"figure"==e.name&&e.hasClass("image")?{name:!0}:null}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Of extends nh{init(){const t=this.editor,e=t.editing.view,i=t.model.schema,n=t.data,s=t.editing,o=t.t;i.register("caption",{allowIn:"image",allowContentOf:"$block",isLimit:!0}),t.model.document.registerPostFixer(t=>this._insertMissingModelCaptionElement(t)),t.conversion.for("upcast").elementToElement({view:Rf,model:"caption"});n.downcastDispatcher.on("insert:caption",If(t=>t.createContainerElement("figcaption"),!1));const r=
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function(t,e){return i=>{const n=i.createEditableElement("figcaption");return i.setCustomProperty("imageCaption",!0,n),gc({view:t,element:n,text:e}),Wu(n,i)}}(e,o("Enter image caption"));s.downcastDispatcher.on("insert:caption",If(r)),s.downcastDispatcher.on("insert",this._fixCaptionVisibility(t=>t.item),{priority:"high"}),s.downcastDispatcher.on("remove",this._fixCaptionVisibility(t=>t.position.parent),{priority:"high"}),e.document.registerPostFixer(t=>this._updateCaptionVisibility(t))}_updateCaptionVisibility(t){const e=this.editor.editing.mapper,i=this._lastSelectedCaption;let n;const s=this.editor.model.document.selection,o=s.getSelectedElement();if(o&&o.is("image")){const t=Sf(o);n=e.toViewElement(t)}const r=Mf(s.getFirstPosition().parent);if(r&&(n=e.toViewElement(r)),n)return i?i===n?Nf(n,t):(Vf(i,t),this._lastSelectedCaption=n,Nf(n,t)):(this._lastSelectedCaption=n,Nf(n,t));if(i){const e=Vf(i,t);return this._lastSelectedCaption=null,e}return!1}_fixCaptionVisibility(t){return(e,i,n)=>{const s=Mf(t(i)),o=this.editor.editing.mapper,r=n.writer;if(s){const t=o.toViewElement(s);t&&(s.childCount?r.removeClass("ck-hidden",t):r.addClass("ck-hidden",t))}}}_insertMissingModelCaptionElement(t){const e=this.editor.model,i=e.document.differ.getChanges(),n=[];for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter;if(i.is("image")&&!Sf(i)&&n.push(i),!i.is("image")&&i.childCount)for(const t of e.createRangeIn(i).getItems())t.is("image")&&!Sf(t)&&n.push(t)}for(const e of n)t.appendElement("caption",e);return!!n.length}}function If(t,e=!0){return(i,n,s)=>{const o=n.item;if((o.childCount||e)&&Ku(o.parent)){if(!s.consumable.consume(n.item,"insert"))return;const e=s.mapper.toViewElement(n.range.start.parent),i=t(s.writer),r=s.writer;o.childCount||r.addClass("ck-hidden",i),function(t,e,i,n){const s=n.writer.createPositionAt(i,"end");n.writer.insert(s,t),n.mapper.bindElements(e,t)}(i,n.item,e,s)}}}function Mf(t){const e=t.getAncestors({includeSelf:!0}).find(t=>"caption"==t.name);return e&&e.parent&&"image"==e.parent.name?e:null}function Vf(t,e){return!t.childCount&&!t.hasClass("ck-hidden")&&(e.addClass("ck-hidden",t),!0)}function Nf(t,e){return!!t.hasClass("ck-hidden")&&(e.removeClass("ck-hidden",t),!0)}i(38);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Bf extends lh{constructor(t,e){super(t),this.defaultStyle=!1,this.styles=e.reduce((t,e)=>(t[e.name]=e,e.isDefault&&(this.defaultStyle=e.name),t),{})}refresh(){const t=this.editor.model.document.selection.getSelectedElement();if(this.isEnabled=Ku(t),t)if(t.hasAttribute("imageStyle")){const e=t.getAttribute("imageStyle");this.value=!!this.styles[e]&&e}else this.value=this.defaultStyle;else this.value=!1}execute(t){const e=t.value,i=this.editor.model,n=i.document.selection.getSelectedElement();i.change(t=>{this.styles[e].isDefault?t.removeAttribute("imageStyle",n):t.setAttribute("imageStyle",e,n)})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Ff(t,e){for(const i of e)if(i.name===t)return i}var Df='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 4.5V3h16v1.5zm2.5 3V12h11V7.5h-11zM4.061 6H15.94c.586 0 1.061.407 1.061.91v5.68c0 .503-.475.91-1.061.91H4.06c-.585 0-1.06-.407-1.06-.91V6.91C3 6.406 3.475 6 4.061 6zM2 16.5V15h16v1.5z"/></svg>',Lf='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M18 4.5V3H2v1.5h16zm0 3V6h-5.674v1.5H18zm0 3V9h-5.674v1.5H18zm0 3V12h-5.674v1.5H18zm-8.5-6V12h-6V7.5h6zm.818-1.5H2.682C2.305 6 2 6.407 2 6.91v5.68c0 .503.305.91.682.91h7.636c.377 0 .682-.407.682-.91V6.91c0-.503-.305-.91-.682-.91zM18 16.5V15H2v1.5h16z"/></svg>',zf='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 4.5V3h16v1.5zm4.5 3V12h7V7.5h-7zM5.758 6h8.484c.419 0 .758.407.758.91v5.681c0 .502-.34.909-.758.909H5.758c-.419 0-.758-.407-.758-.91V6.91c0-.503.34-.91.758-.91zM2 16.5V15h16v1.5z"/></svg>',Hf='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2 4.5V3h16v1.5zm0 3V6h5.674v1.5zm0 3V9h5.674v1.5zm0 3V12h5.674v1.5zm8.5-6V12h6V7.5h-6zM9.682 6h7.636c.377 0 .682.407.682.91v5.68c0 .503-.305.91-.682.91H9.682c-.377 0-.682-.407-.682-.91V6.91c0-.503.305-.91.682-.91zM2 16.5V15h16v1.5z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const jf={full:{name:"full",title:"Full size image",icon:Df,isDefault:!0},side:{name:"side",title:"Side image",icon:Hf,className:"image-style-side"},alignLeft:{name:"alignLeft",title:"Left aligned image",icon:Lf,className:"image-style-align-left"},alignCenter:{name:"alignCenter",title:"Centered image",icon:zf,className:"image-style-align-center"},alignRight:{name:"alignRight",title:"Right aligned image",icon:Hf,className:"image-style-align-right"}},qf={full:Df,left:Lf,right:Hf,center:zf};function Wf(t=[]){return t.map(Uf)}function Uf(t){if("string"==typeof t){const e=t;jf[e]?t=Object.assign({},jf[e]):(console.warn(Object(Ki.a)("image-style-not-found: There is no such image style of given name."),{name:e}),t={name:e})}else if(jf[t.name]){const e=jf[t.name],i=Object.assign({},t);for(const n in e)t.hasOwnProperty(n)||(i[n]=e[n]);t=i}return"string"==typeof t.icon&&qf[t.icon]&&(t.icon=qf[t.icon]),t}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $f extends nh{static get pluginName(){return"ImageStyleEditing"}init(){const t=this.editor,e=t.model.schema,i=t.data,n=t.editing;t.config.define("image.styles",["full","side"]);const s=Wf(t.config.get("image.styles"));e.extend("image",{allowAttributes:"imageStyle"});const o=function(t){return(e,i,n)=>{if(!n.consumable.consume(i.item,e.name))return;const s=Ff(i.attributeNewValue,t),o=Ff(i.attributeOldValue,t),r=n.mapper.toViewElement(i.item),a=n.writer;o&&a.removeClass(o.className,r),s&&a.addClass(s.className,r)}}(s);n.downcastDispatcher.on("attribute:imageStyle:image",o),i.downcastDispatcher.on("attribute:imageStyle:image",o),i.upcastDispatcher.on("element:figure",function(t){const e=t.filter(t=>!t.isDefault);return(t,i,n)=>{if(!i.modelRange)return;const s=i.viewItem,o=Xd(i.modelRange.getItems());if(n.schema.checkAttribute(o,"imageStyle"))for(const t of e)n.consumable.consume(s,{classes:t.className})&&n.writer.setAttribute("imageStyle",t.name,o)}}(s),{priority:"low"}),t.commands.add("imageStyle",new Bf(t,s))}}i(39);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Gf extends nh{static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const t=this.editor.t;return{"Full size image":t("Full size image"),"Side image":t("Side image"),"Left aligned image":t("Left aligned image"),"Centered image":t("Centered image"),"Right aligned image":t("Right aligned image")}}init(){const t=function(t,e){for(const i of t)e[i.title]&&(i.title=e[i.title]);return t}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(Wf(this.editor.config.get("image.styles")),this.localizedDefaultStylesTitles);for(const e of t)this._createButton(e)}_createButton(t){const e=this.editor,i=`imageStyle:${t.name}`;e.ui.componentFactory.add(i,i=>{const n=e.commands.get("imageStyle"),s=new Xh(i);return s.set({label:t.title,icon:t.icon,tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n,"isEnabled"),s.bind("isOn").to(n,"value",e=>e===t.name),this.listenTo(s,"execute",()=>e.execute("imageStyle",{value:t.name})),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Kf extends nh{static get requires(){return[kf]}static get pluginName(){return"WidgetToolbarRepository"}init(){const t=this.editor;if(t.plugins.has("BalloonToolbar")){const e=t.plugins.get("BalloonToolbar");this.listenTo(e,"show",e=>{(function(t){const e=t.getSelectedElement();return!(!e||!Hu(e))}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */)(t.editing.view.document.selection)&&e.stop()},{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.listenTo(t.ui,"update",()=>{this._updateToolbarsVisibility()}),this.listenTo(t.ui.focusTracker,"change:isFocused",()=>{this._updateToolbarsVisibility()},{priority:"low"})}destroy(){super.destroy();for(const t of this._toolbarDefinitions.values())t.view.destroy()}register(t,{ariaLabel:e,items:i,getRelatedElement:n,balloonClassName:s="ck-toolbar-container"}){const o=this.editor,r=o.t,a=new th(o.locale);if(a.ariaLabel=e||r("Widget toolbar"),this._toolbarDefinitions.has(t))throw new Ki.b("widget-toolbar-duplicated: Toolbar with the given id was already added.",this,{toolbarId:t});a.fillFromConfig(i,o.ui.componentFactory),this._toolbarDefinitions.set(t,{view:a,getRelatedElement:n,balloonClassName:s})}_updateToolbarsVisibility(){let t=0,e=null,i=null;for(const n of this._toolbarDefinitions.values()){const s=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.editor.ui.focusTracker.isFocused)if(s){const o=s.getAncestors().length;o>t&&(t=o,e=s,i=n)}else this._isToolbarInBalloon(n)&&this._hideToolbar(n);else this._isToolbarVisible(n)&&this._hideToolbar(n)}i&&this._showToolbar(i,e)}_hideToolbar(t){this._balloon.remove(t.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){this._isToolbarVisible(t)?Jf(this.editor,e):this._isToolbarInBalloon(t)||(this._balloon.add({view:t.view,position:Yf(this.editor,e),balloonClassName:t.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",()=>{for(const t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){const e=t.getRelatedElement(this.editor.editing.view.document.selection);Jf(this.editor,e)}}))}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function Jf(t,e){const i=t.plugins.get("ContextualBalloon"),n=Yf(t,e);i.updatePosition(n)}function Yf(t,e){const i=t.editing.view,n=gf.defaultPositions;return{target:i.domConverter.mapViewToDom(e),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast]}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Qf extends jc{constructor(t){super(t),this.buttonView=new Xh(t),this._fileInputView=new Xf(t),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.setTemplate({tag:"span",attributes:{class:"ck-file-dialog-button"},children:[this.buttonView,this._fileInputView]}),this.buttonView.on("execute",()=>{this._fileInputView.open()})}focus(){this.buttonView.focus()}}class Xf extends jc{constructor(t){super(t),this.set("acceptedType"),this.set("allowMultipleFiles",!1);const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:e.to("acceptedType"),multiple:e.to("allowMultipleFiles")},on:{change:e.to(()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""})}})}open(){this.element.click()}}var Zf='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M6.91 10.54c.26-.23.64-.21.88.03l3.36 3.14 2.23-2.06a.64.64 0 0 1 .87 0l2.52 2.97V4.5H3.2v10.12l3.71-4.08zm10.27-7.51c.6 0 1.09.47 1.09 1.05v11.84c0 .59-.49 1.06-1.09 1.06H2.79c-.6 0-1.09-.47-1.09-1.06V4.08c0-.58.49-1.05 1.1-1.05h14.38zm-5.22 5.56a1.96 1.96 0 1 1 3.4-1.96 1.96 1.96 0 0 1-3.4 1.96z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function tm(t){return/^image\/(jpeg|png|gif|bmp)$/.test(t.type)}function em(t){return new Promise((e,i)=>{const n=t.getAttribute("src");fetch(n).then(t=>t.blob()).then(t=>{const s=function(t,e){return t.type?t.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}(t,n),o=function(t,e,i){try{return new File([t],e,{type:i})}catch(t){return null}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t,`image.${s.replace("image/","")}`,s);o?e(o):i()}).catch(i)})}class im extends nh{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add("imageUpload",i=>{const n=new Qf(i),s=t.commands.get("imageUpload");return n.set({acceptedType:"image/*",allowMultipleFiles:!0}),n.buttonView.set({label:e("Insert image"),icon:Zf,tooltip:!0}),n.buttonView.bind("isEnabled").to(s),n.on("done",(e,i)=>{const n=Array.from(i).filter(tm);n.length&&t.execute("imageUpload",{file:n})}),n})}}var nm='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 700 250"><rect rx="4"/></svg>';i(40),i(41),i(42);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class sm extends nh{constructor(t){super(t),this.placeholder="data:image/svg+xml;utf8,"+encodeURIComponent(nm)}init(){this.editor.editing.downcastDispatcher.on("attribute:uploadStatus:image",(...t)=>this.uploadStatusChange(...t))}uploadStatusChange(t,e,i){const n=this.editor,s=e.item,o=s.getAttribute("uploadId");if(!i.consumable.consume(e.item,t.name))return;const r=n.plugins.get(od),a=o?e.attributeNewValue:null,l=this.placeholder,c=n.editing.mapper.toViewElement(s),h=i.writer;if("reading"==a)return om(c,h),void rm(l,c,h);if("uploading"==a){const t=r.loaders.get(o);return om(c,h),void(t?(am(c,h),function(t,e,i,n){const s=function(t){const e=t.createUIElement("div",{class:"ck-progress-bar"});return t.setCustomProperty("progressBar",!0,e),e}(e);e.insert(e.createPositionAt(t,"end"),s),i.on("change:uploadedPercent",(t,e,i)=>{n.change(t=>{t.setStyle("width",i+"%",s)})})}(c,h,t,n.editing.view),function(t,e,i){if(i.data){const n=t.getChild(0);e.setAttribute("src",i.data,n)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(c,h,t)):rm(l,c,h))}"complete"==a&&r.loaders.get(o)&&!ms.isEdge&&function(t,e,i){const n=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(t,"end"),n),setTimeout(()=>{i.change(t=>t.remove(t.createRangeOn(n)))},3e3)}(c,h,n.editing.view),function(t,e){cm(t,e,"progressBar")}(c,h),am(c,h),function(t,e){e.removeClass("ck-appear",t)}(c,h)}}function om(t,e){t.hasClass("ck-appear")||e.addClass("ck-appear",t)}function rm(t,e,i){e.hasClass("ck-image-upload-placeholder")||i.addClass("ck-image-upload-placeholder",e);const n=e.getChild(0);n.getAttribute("src")!==t&&i.setAttribute("src",t,n),lm(e,"placeholder")||i.insert(i.createPositionAfter(n),function(t){const e=t.createUIElement("div",{class:"ck-upload-placeholder-loader"});return t.setCustomProperty("placeholder",!0,e),e}(i))}function am(t,e){t.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",t),cm(t,e,"placeholder")}function lm(t,e){for(const i of t.getChildren())if(i.getCustomProperty(e))return i}function cm(t,e,i){const n=lm(t,i);n&&e.remove(e.createRangeOn(n))}class hm extends nh{static get pluginName(){return"Notification"}init(){this.on("show:warning",(t,e)=>{window.alert(e.message)},{priority:"lowest"})}showSuccess(t,e={}){this._showNotification({message:t,type:"success",namespace:e.namespace,title:e.title})}showInfo(t,e={}){this._showNotification({message:t,type:"info",namespace:e.namespace,title:e.title})}showWarning(t,e={}){this._showNotification({message:t,type:"warning",namespace:e.namespace,title:e.title})}_showNotification(t){const e=`show:${t.type}`+(t.namespace?`:${t.namespace}`:"");this.fire(e,{message:t.message,type:t.type,title:t.title||""})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class dm{createDocumentFragment(t){return new Cs(t)}createElement(t,e,i){return new vn(t,e,i)}createText(t){return new mn(t)}clone(t,e=!1){return t._clone(e)}appendChild(t,e){return e._appendChild(t)}insertChild(t,e,i){return i._insertChild(t,e)}removeChildren(t,e,i){return i._removeChildren(t,e)}remove(t){const e=t.parent;return e?this.removeChildren(e.getChildIndex(t),1,e):[]}replace(t,e){const i=t.parent;if(i){const n=i.getChildIndex(t);return this.removeChildren(n,1,i),this.insertChild(n,e,i),!0}return!1}unwrapElement(t){const e=t.parent;if(e){const i=e.getChildIndex(t);this.remove(t),this.insertChild(i,t.getChildren(),e)}}rename(t,e){const i=new vn(t,e.getAttributes(),e.getChildren());return this.replace(e,i)?i:null}setAttribute(t,e,i){i._setAttribute(t,e)}removeAttribute(t,e){e._removeAttribute(t)}addClass(t,e){e._addClass(t)}removeClass(t,e){e._removeClass(t)}setStyle(t,e,i){x(t)&&void 0===i&&(i=e),i._setStyle(t,e)}removeStyle(t,e){e._removeStyle(t)}setCustomProperty(t,e,i){i._setCustomProperty(t,e)}removeCustomProperty(t,e){return e._removeCustomProperty(t)}createPositionAt(t,e){return Zn._createAt(t,e)}createPositionAfter(t){return Zn._createAfter(t)}createPositionBefore(t){return Zn._createBefore(t)}createRange(t,e){return new ts(t,e)}createRangeOn(t){return ts._createOn(t)}createRangeIn(t){return ts._createIn(t)}createSelection(t,e,i){return new ns(t,e,i)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class um extends lh{refresh(){this.isEnabled=Yu(this.editor.model)}execute(t){const e=this.editor,i=e.model,n=e.plugins.get(od);i.change(e=>{const s=Array.isArray(t.file)?t.file:[t.file];for(const t of s)fm(e,i,n,t)})}}function fm(t,e,i,n){const s=i.createLoader(n);s&&Ju(t,e,{uploadId:s.id})}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class mm extends nh{static get requires(){return[od,hm]}init(){const t=this.editor,e=t.model.document,i=t.model.schema,n=t.conversion,s=t.plugins.get(od);i.extend("image",{allowAttributes:["uploadId","uploadStatus"]}),t.commands.add("imageUpload",new um(t)),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(t.editing.view.document,"clipboardInput",(e,i)=>{if(function(t){return Array.from(t.types).includes("text/html")&&""!==t.getData("text/html")}(i.dataTransfer))return;const n=Array.from(i.dataTransfer.files).filter(t=>!!t&&tm(t)),s=i.targetRanges.map(e=>t.editing.mapper.toModelRange(e));t.model.change(i=>{i.setSelection(s),n.length&&(e.stop(),t.model.enqueueChange("default",()=>{t.execute("imageUpload",{file:n})}))})}),t.plugins.has("Clipboard")&&this.listenTo(t.plugins.get("Clipboard"),"inputTransformation",(e,i)=>{const n=Array.from(t.editing.view.createRangeIn(i.content)).filter(t=>(function(t){return!(!t.is("element","img")||!t.getAttribute("src"))&&(t.getAttribute("src").match(/^data:image\/\w+;base64,/g)||t.getAttribute("src").match(/^blob:/g))})(t.item)&&!t.item.getAttribute("uploadProcessed")).map(t=>({promise:em(t.item),imageElement:t.item}));if(!n.length)return;const o=new dm;for(const t of n){o.setAttribute("uploadProcessed",!0,t.imageElement);const e=s.createLoader(t.promise);e&&(o.setAttribute("src","",t.imageElement),o.setAttribute("uploadId",e.id,t.imageElement))}}),t.editing.view.document.on("dragover",(t,e)=>{e.preventDefault()}),e.on("change",()=>{const i=e.differ.getChanges({includeChangesInGraveyard:!0});for(const e of i)if("insert"==e.type&&"$text"!=e.name){const i=e.position.nodeAfter,n="$graveyard"==e.position.root.rootName;for(const e of gm(t,i)){const t=e.getAttribute("uploadId");if(!t)continue;const i=s.loaders.get(t);i&&(n?i.abort():"idle"==i.status&&this._readAndUpload(i,e))}}})}_readAndUpload(t,e){const i=this.editor,n=i.model,s=i.locale.t,o=i.plugins.get(od),r=i.plugins.get(hm);return n.enqueueChange("transparent",t=>{t.setAttribute("uploadStatus","reading",e)}),t.read().then(()=>{const s=t.upload();if(ms.isSafari){const t=i.editing.mapper.toViewElement(e).getChild(0);i.editing.view.once("render",()=>{if(!t.parent)return;const e=i.editing.view.domConverter.mapViewToDom(t.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n})}return n.enqueueChange("transparent",t=>{t.setAttribute("uploadStatus","uploading",e)}),s}).then(t=>{n.enqueueChange("transparent",i=>{i.setAttributes({uploadStatus:"complete",src:t.default},e),this._parseAndSetSrcsetAttributeOnImage(t,e,i)}),a()}).catch(i=>{if("error"!==t.status&&"aborted"!==t.status)throw i;"error"==t.status&&i&&r.showWarning(i,{title:s("Upload failed"),namespace:"upload"}),a(),n.enqueueChange("transparent",t=>{t.remove(e)})});function a(){n.enqueueChange("transparent",t=>{t.removeAttribute("uploadId",e),t.removeAttribute("uploadStatus",e)}),o.destroyLoader(t)}}_parseAndSetSrcsetAttributeOnImage(t,e,i){let n=0;const s=Object.keys(t).filter(t=>{const e=parseInt(t,10);if(!isNaN(e))return n=Math.max(n,e),!0}).map(e=>`${t[e]} ${e}w`).join(", ");""!=s&&i.setAttribute("srcset",{data:s,width:n},e)}}function gm(t,e){return Array.from(t.model.createRangeOn(e)).filter(t=>t.item.is("image")).map(t=>t.item)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function pm(t,e,i){return i.createRange(wm(t,e,!0,i),wm(t,e,!1,i))}function wm(t,e,i,n){let s=t.textNode||(i?t.nodeBefore:t.nodeAfter),o=null;for(;s&&s.getAttribute("linkHref")==e;)o=s,s=i?s.previousSibling:s.nextSibling;return o?n.createPositionAt(o,i?"before":"after"):t}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class bm extends lh{constructor(t){super(t),this.manualDecorators=new os}restoreManualDecoratorStates(){for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}refresh(){const t=this.editor.model,e=t.document;this.value=e.selection.getAttribute("linkHref");for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id);this.isEnabled=t.schema.checkAttributeInSelection(e.selection,"linkHref")}execute(t,e={}){const i=this.editor.model,n=i.document.selection,s=[],o=[];for(const t in e)e[t]?s.push(t):o.push(t);i.change(e=>{if(n.isCollapsed){const r=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=pm(r,n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,a),s.forEach(t=>{e.setAttribute(t,!0,a)}),o.forEach(t=>{e.removeAttribute(t,a)}),e.setSelection(a)}else if(""!==t){const o=zr(n.getAttributes());o.set("linkHref",t),s.forEach(t=>{o.set(t,!0)});const a=e.createText(t,o);i.insertContent(a,r),e.setSelection(e.createRangeOn(a))}}else{const r=i.schema.getValidRanges(n.getRanges(),"linkHref");for(const i of r)e.setAttribute("linkHref",t,i),s.forEach(t=>{e.setAttribute(t,!0,i)}),o.forEach(t=>{e.removeAttribute(t,i)})}})}_getDecoratorStateFromModel(t){return this.editor.model.document.selection.getAttribute(t)||!1}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _m extends lh{refresh(){this.isEnabled=this.editor.model.document.selection.hasAttribute("linkHref")}execute(){const t=this.editor,e=this.editor.model,i=e.document.selection,n=t.commands.get("link");e.change(t=>{const s=i.isCollapsed?[pm(i.getFirstPosition(),i.getAttribute("linkHref"),e)]:i.getRanges();for(const e of s)if(t.removeAttribute("linkHref",e),n)for(const i of n.manualDecorators)t.removeAttribute(i.id,e)})}}var vm=function(t,e,i){var n=-1,s=t.length;e<0&&(e=-e>s?0:s+e),(i=i>s?s:i)<0&&(i+=s),s=e>i?0:i-e>>>0,e>>>=0;for(var o=Array(s);++n<s;)o[n]=t[n+e];return o};var ym=function(t,e,i){var n=t.length;return i=void 0===i?n:i,!e&&i>=n?t:vm(t,e,i)},km=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Am=function(t){return km.test(t)};var Cm=function(t){return t.split("")},xm="[\\ud800-\\udfff]",Pm="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Tm="\\ud83c[\\udffb-\\udfff]",Em="[^\\ud800-\\udfff]",Sm="(?:\\ud83c[\\udde6-\\uddff]){2}",Rm="[\\ud800-\\udbff][\\udc00-\\udfff]",Om="(?:"+Pm+"|"+Tm+")"+"?",Im="[\\ufe0e\\ufe0f]?"+Om+("(?:\\u200d(?:"+[Em,Sm,Rm].join("|")+")[\\ufe0e\\ufe0f]?"+Om+")*"),Mm="(?:"+[Em+Pm+"?",Pm,Sm,Rm,xm].join("|")+")",Vm=RegExp(Tm+"(?="+Tm+")|"+Mm+Im,"g");var Nm=function(t){return t.match(Vm)||[]};var Bm=function(t){return Am(t)?Nm(t):Cm(t)};var Fm=function(t,e){for(var i=-1,n=null==t?0:t.length,s=Array(n);++i<n;)s[i]=e(t[i],i,t);return s},Dm=1/0,Lm=s?s.prototype:void 0,zm=Lm?Lm.toString:void 0;var Hm=function t(e){if("string"==typeof e)return e;if($t(e))return Fm(e,t)+"";if(rr(e))return zm?zm.call(e):"";var i=e+"";return"0"==i&&1/e==-Dm?"-0":i};var jm=function(t){return null==t?"":Hm(t)};var qm=function(t){return function(e){e=jm(e);var i=Am(e)?Bm(e):void 0,n=i?i[0]:e.charAt(0),s=i?ym(i,1).join(""):e.slice(1);return n[t]()+s}}("toUpperCase");
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Wm=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Um=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i;function $m(t,e){const i=e.createAttributeElement("a",{href:t},{priority:5});return e.setCustomProperty("link",!0,i),i}function Gm(t){return function(t){return t.replace(Wm,"").match(Um)}(t=String(t))?t:"#"}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */
class Km{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(t){Array.isArray(t)?t.forEach(t=>this._definitions.add(t)):this._definitions.add(t)}getDispatcher(){return t=>{t.on("attribute:linkHref",(t,e,i)=>{if(!i.consumable.test(e.item,"attribute:linkHref"))return;const n=i.writer,s=n.document.selection;for(const t of this._definitions){const o=n.createAttributeElement("a",t.attributes,{priority:5});n.setCustomProperty("link",!0,o),t.callback(e.attributeNewValue)?e.item.is("selection")?n.wrap(s.getFirstRange(),o):n.wrap(i.mapper.toViewRange(e.range),o):n.unwrap(i.mapper.toViewRange(e.range),o)}},{priority:"high"})}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Jm{constructor({id:t,label:e,attributes:i}){this.id=t,this.set("value"),this.label=e,this.attributes=i}}cn(Jm,jn);class Ym{constructor(t,e,i){this.model=t,this.attribute=i,this._modelSelection=t.document.selection,this._overrideUid=null,this._isNextGravityRestorationSkipped=!1,e.listenTo(this._modelSelection,"change:range",(t,e)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!e.directChange&&Qm(this._modelSelection.getFirstPosition(),i)||this._restoreGravity())})}handleForwardMovement(t,e){const i=this.attribute;if(!(this._isGravityOverridden||t.isAtStart&&this._hasSelectionAttribute))return tg(t,i)&&this._hasSelectionAttribute?(this._preventCaretMovement(e),this._removeSelectionAttribute(),!0):Xm(t,i)?(this._preventCaretMovement(e),this._overrideGravity(),!0):Zm(t,i)&&this._hasSelectionAttribute?(this._preventCaretMovement(e),this._overrideGravity(),!0):void 0}handleBackwardMovement(t,e){const i=this.attribute;return this._isGravityOverridden?tg(t,i)&&this._hasSelectionAttribute?(this._preventCaretMovement(e),this._restoreGravity(),this._removeSelectionAttribute(),!0):(this._preventCaretMovement(e),this._restoreGravity(),t.isAtStart&&this._removeSelectionAttribute(),!0):tg(t,i)&&!this._hasSelectionAttribute?(this._preventCaretMovement(e),this._setSelectionAttributeFromTheNodeBefore(t),!0):t.isAtEnd&&Zm(t,i)?this._hasSelectionAttribute?void(eg(t,i)&&(this._skipNextAutomaticGravityRestoration(),this._overrideGravity())):(this._preventCaretMovement(e),this._setSelectionAttributeFromTheNodeBefore(t),!0):t.isAtStart?this._hasSelectionAttribute?(this._removeSelectionAttribute(),this._preventCaretMovement(e),!0):void 0:void(eg(t,i)&&(this._skipNextAutomaticGravityRestoration(),this._overrideGravity()))}get _isGravityOverridden(){return!!this._overrideUid}get _hasSelectionAttribute(){return this._modelSelection.hasAttribute(this.attribute)}_overrideGravity(){this._overrideUid=this.model.change(t=>t.overrideSelectionGravity())}_restoreGravity(){this.model.change(t=>{t.restoreSelectionGravity(this._overrideUid),this._overrideUid=null})}_preventCaretMovement(t){t.preventDefault()}_removeSelectionAttribute(){this.model.change(t=>{t.removeSelectionAttribute(this.attribute)})}_setSelectionAttributeFromTheNodeBefore(t){const e=this.attribute;this.model.change(i=>{i.setSelectionAttribute(this.attribute,t.nodeBefore.getAttribute(e))})}_skipNextAutomaticGravityRestoration(){this._isNextGravityRestorationSkipped=!0}}function Qm(t,e){return Xm(t,e)||Zm(t,e)}function Xm(t,e){const{nodeBefore:i,nodeAfter:n}=t,s=!!i&&i.hasAttribute(e);return!!n&&n.hasAttribute(e)&&(!s||i.getAttribute(e)!==n.getAttribute(e))}function Zm(t,e){const{nodeBefore:i,nodeAfter:n}=t,s=!!i&&i.hasAttribute(e),o=!!n&&n.hasAttribute(e);return s&&(!o||i.getAttribute(e)!==n.getAttribute(e))}function tg(t,e){const{nodeBefore:i,nodeAfter:n}=t,s=!!i&&i.hasAttribute(e);if(!!n&&n.hasAttribute(e)&&s)return n.getAttribute(e)!==i.getAttribute(e)}function eg(t,e){return Qm(t.getShiftedBy(-1),e)}i(43);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const ig="ck-link_selected",ng="automatic",sg="manual",og=/^(https?:)?\/\//;class rg extends nh{constructor(t){super(t),t.config.define("link",{addTargetToExternalLinks:!1})}init(){const t=this.editor,e=t.locale;t.model.schema.extend("$text",{allowAttributes:"linkHref"}),t.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:$m}),t.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(t,e)=>$m(Gm(t),e)}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:t=>t.getAttribute("href")}}),t.commands.add("link",new bm(t)),t.commands.add("unlink",new _m(t));const i=function(t,e){const i={"Open in a new tab":t("Open in a new tab"),Downloadable:t("Downloadable")};return e.forEach(t=>(t.label&&i[t.label]&&(t.label=i[t.label]),t)),e}(t.t,function(t){const e=[];if(t)for(const[i,n]of Object.entries(t)){const t=Object.assign({},n,{id:`link${qm(i)}`});e.push(t)}return e}(t.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter(t=>t.mode===ng)),this._enableManualDecorators(i.filter(t=>t.mode===sg)),
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function({view:t,model:e,emitter:i,attribute:n,locale:s}){const o=new Ym(e,i,n),r=e.document.selection;i.listenTo(t.document,"keydown",(t,e)=>{if(!r.isCollapsed)return;if(e.shiftKey||e.altKey||e.ctrlKey)return;const i=e.keyCode==ws.arrowright,n=e.keyCode==ws.arrowleft;if(!i&&!n)return;const a=r.getFirstPosition(),l=s.contentLanguageDirection;let c;(c="ltr"===l&&i||"rtl"===l&&n?o.handleForwardMovement(a,e):o.handleBackwardMovement(a,e))&&t.stop()},{priority:Xi.get("high")+1})}({view:t.editing.view,model:t.model,emitter:this,attribute:"linkHref",locale:e}),this._setupLinkHighlight()}_enableAutomaticDecorators(t){const e=this.editor,i=new Km;e.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:ng,callback:t=>og.test(t),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(t),i.length&&e.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(t){if(!t.length)return;const e=this.editor,i=e.commands.get("link").manualDecorators;t.forEach(t=>{e.model.schema.extend("$text",{allowAttributes:t.id}),i.add(new Jm(t)),e.conversion.for("downcast").attributeToElement({model:t.id,view:(e,n)=>{if(e){const e=i.get(t.id).attributes,s=n.createAttributeElement("a",e,{priority:5});return n.setCustomProperty("link",!0,s),s}}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:i.get(t.id).attributes},model:{key:t.id}})})}_setupLinkHighlight(){const t=this.editor,e=t.editing.view,i=new Set;e.document.registerPostFixer(e=>{const n=t.model.document.selection;let s=!1;if(n.hasAttribute("linkHref")){const o=pm(n.getFirstPosition(),n.getAttribute("linkHref"),t.model),r=t.editing.mapper.toViewRange(o);for(const t of r.getItems())t.is("a")&&!t.hasClass(ig)&&(e.addClass(ig,t),i.add(t),s=!0)}return s}),t.conversion.for("editingDowncast").add(t=>{function n(){e.change(t=>{for(const e of i.values())t.removeClass(ig,e),i.delete(e)})}t.on("insert",n,{priority:"highest"}),t.on("remove",n,{priority:"highest"}),t.on("attribute",n,{priority:"highest"}),t.on("selection",n,{priority:"highest"})})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ag extends ir{constructor(t){super(t),this.domEventType="click"}onDomEvent(t){this.fire(t.type,t)}}i(44);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lg extends jc{constructor(t,e=[]){super(t);const i=t.t;this.focusTracker=new uc,this.keystrokes=new nc,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),hf,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),df,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e),this.children=this._createFormChildren(e),this._focusables=new yc,this._focusCycler=new Qc({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const n=["ck","ck-link-form"];e.length&&n.push("ck-link-form_layout-vertical"),this.setTemplate({tag:"form",attributes:{class:n,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce((t,e)=>(t[e.name]=e.isOn,t),{})}render(){super.render(),cf({view:this}),[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const t=this.locale.t,e=new af(this.locale,lf);return e.label=t("Link URL"),e.inputView.placeholder="https://example.com",e}_createButton(t,e,i,n){const s=new Xh(this.locale);return s.set({label:t,icon:e,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const i of t){const t=new Pu(this.locale);t.set({name:i.id,label:i.label,withText:!0}),t.bind("isOn").to(i,"value"),t.on("execute",()=>{i.set("value",!t.isOn)}),e.add(t)}return e}_createFormChildren(t){const e=this.createCollection();if(e.add(this.urlInputView),t.length){const t=new jc;t.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map(t=>({tag:"li",children:[t],attributes:{class:["ck","ck-list__item"]}})),attributes:{class:["ck","ck-reset","ck-list"]}}),e.add(t)}return e.add(this.saveButtonView),e.add(this.cancelButtonView),e}}var cg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.077 15l.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.562l-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>',hg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7.3 17.37l-.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.506L13.271 5.8c.316-.452-.16-1.333-1.065-1.966-.905-.634-1.895-.78-2.212-.328zM8 18.5L9.375 17H19v1.5H8z"/></svg>';i(45);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class dg extends jc{constructor(t){super(t);const e=t.t;this.focusTracker=new uc,this.keystrokes=new nc,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(e("Unlink"),cg,"unlink"),this.editButtonView=this._createButton(e("Edit link"),hg,"edit"),this.set("href"),this._focusables=new yc,this._focusCycler=new Qc({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render(),[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}_createButton(t,e,i){const n=new Xh(this.locale);return n.set({label:t,icon:e,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const t=new Xh(this.locale),e=this.bindTemplate,i=this.t;return t.set({withText:!0,tooltip:i("Open link in new tab")}),t.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:e.to("href",t=>t&&Gm(t)),target:"_blank"}}),t.bind("label").to(this,"href",t=>t||i("This link has no URL")),t.bind("isEnabled").to(this,"href",t=>!!t),t.template.tag="a",t.template.eventListeners={},t}}var ug='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M11.077 15l.991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const fg="Ctrl+K";class mg extends nh{static get requires(){return[kf]}static get pluginName(){return"LinkUI"}init(){const t=this.editor;t.editing.view.addObserver(ag),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=t.plugins.get(kf),this._createToolbarLinkButton(),this._enableUserBalloonInteractions()}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const t=this.editor,e=new dg(t.locale),i=t.commands.get("link"),n=t.commands.get("unlink");return e.bind("href").to(i,"value"),e.editButtonView.bind("isEnabled").to(i),e.unlinkButtonView.bind("isEnabled").to(n),this.listenTo(e,"edit",()=>{this._addFormView()}),this.listenTo(e,"unlink",()=>{t.execute("unlink"),this._hideUI()}),e.keystrokes.set("Esc",(t,e)=>{this._hideUI(),e()}),e.keystrokes.set(fg,(t,e)=>{this._addFormView(),e()}),e}_createFormView(){const t=this.editor,e=t.commands.get("link"),i=new lg(t.locale,e.manualDecorators);return i.urlInputView.bind("value").to(e,"value"),i.urlInputView.bind("isReadOnly").to(e,"isEnabled",t=>!t),i.saveButtonView.bind("isEnabled").to(e),this.listenTo(i,"submit",()=>{t.execute("link",i.urlInputView.inputView.element.value,i.getDecoratorSwitchesState()),this._closeFormView()}),this.listenTo(i,"cancel",()=>{this._closeFormView()}),i.keystrokes.set("Esc",(t,e)=>{this._closeFormView(),e()}),i}_createToolbarLinkButton(){const t=this.editor,e=t.commands.get("link"),i=t.t;t.keystrokes.set(fg,(t,i)=>{i(),e.isEnabled&&this._showUI(!0)}),t.ui.componentFactory.add("link",t=>{const n=new Xh(t);return n.isEnabled=!0,n.label=i("Link"),n.icon=ug,n.keystroke=fg,n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(e,"isEnabled"),n.bind("isOn").to(e,"value",t=>!!t),this.listenTo(n,"execute",()=>this._showUI(!0)),n})}_enableUserBalloonInteractions(){const t=this.editor.editing.view.document;this.listenTo(t,"click",()=>{this._getSelectedLinkElement()&&this._showUI()}),this.editor.keystrokes.set("Tab",(t,e)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),e())},{priority:"high"}),this.editor.keystrokes.set("Esc",(t,e)=>{this._isUIVisible&&(this._hideUI(),e())}),Tu({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel)return;const t=this.editor.commands.get("link");this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.select(),this.formView.urlInputView.inputView.element.value=t.value||""}_closeFormView(){const t=this.editor.commands.get("link");t.restoreManualDecoratorStates(),void 0!==t.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus())}_showUI(t=!1){this.editor.commands.get("link").isEnabled&&(this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),t&&this._balloon.showStack("main")):(this._addActionsView(),t&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI())}_hideUI(){if(!this._isUIInPanel)return;const t=this.editor;this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),t.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView)}_startUpdatingUI(){const t=this.editor,e=t.editing.view.document;let i=this._getSelectedLinkElement(),n=o();const s=()=>{const t=this._getSelectedLinkElement(),e=o();i&&!t||!i&&e!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=t,n=e};function o(){return e.selection.focus.getAncestors().reverse().find(t=>t.is("element"))}this.listenTo(t.ui,"update",s),this.listenTo(this._balloon,"change:visibleView",s)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const t=this.editor.editing.view,e=t.document,i=this._getSelectedLinkElement();return{target:i?t.domConverter.mapViewToDom(i):t.domConverter.viewRangeToDom(e.selection.getFirstRange())}}_getSelectedLinkElement(){const t=this.editor.editing.view,e=t.document.selection;if(e.isCollapsed)return gg(e.getFirstPosition());{const i=e.getFirstRange().getTrimmed(),n=gg(i.start),s=gg(i.end);return n&&n==s&&t.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}}function gg(t){return t.getAncestors().find(t=>(function(t){return t.is("attributeElement")&&!!t.getCustomProperty("link")})(t))}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class pg extends lh{constructor(t,e){super(t),this.type=e}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model,e=t.document,i=Array.from(e.selection.getSelectedBlocks()).filter(e=>bg(e,t.schema)),n=!0===this.value;t.change(t=>{if(n){let e=i[i.length-1].nextSibling,n=Number.POSITIVE_INFINITY,s=[];for(;e&&"listItem"==e.name&&0!==e.getAttribute("listIndent");){const t=e.getAttribute("listIndent");t<n&&(n=t);const i=t-n;s.push({element:e,listIndent:i}),e=e.nextSibling}s=s.reverse();for(const e of s)t.setAttribute("listIndent",e.listIndent,e.element)}if(!n){let t=Number.POSITIVE_INFINITY;for(const e of i)e.is("listItem")&&e.getAttribute("listIndent")<t&&(t=e.getAttribute("listIndent"));wg(i,!0,t=0===t?1:t),wg(i,!1,t)}for(const e of i.reverse())n&&"listItem"==e.name?t.rename(e,"paragraph"):n||"listItem"==e.name?n||"listItem"!=e.name||e.getAttribute("listType")==this.type||t.setAttribute("listType",this.type,e):(t.setAttributes({listType:this.type,listIndent:0},e),t.rename(e,"listItem"))})}_getValue(){const t=Xd(this.editor.model.document.selection.getSelectedBlocks());return!!t&&t.is("listItem")&&t.getAttribute("listType")==this.type}_checkEnabled(){if(this.value)return!0;const t=this.editor.model.document.selection,e=this.editor.model.schema,i=Xd(t.getSelectedBlocks());return!!i&&bg(i,e)}}function wg(t,e,i){const n=e?t[0]:t[t.length-1];if(n.is("listItem")){let s=n[e?"previousSibling":"nextSibling"],o=n.getAttribute("listIndent");for(;s&&s.is("listItem")&&s.getAttribute("listIndent")>=i;)o>s.getAttribute("listIndent")&&(o=s.getAttribute("listIndent")),s.getAttribute("listIndent")==o&&t[e?"unshift":"push"](s),s=s[e?"previousSibling":"nextSibling"]}}function bg(t,e){return e.checkChild(t.parent,"listItem")&&!e.isObject(t)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _g extends lh{constructor(t,e){super(t),this._indentBy="forward"==e?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model,e=t.document;let i=Array.from(e.selection.getSelectedBlocks());t.change(t=>{const e=i[i.length-1];let n=e.nextSibling;for(;n&&"listItem"==n.name&&n.getAttribute("listIndent")>e.getAttribute("listIndent");)i.push(n),n=n.nextSibling;this._indentBy<0&&(i=i.reverse());for(const e of i){const i=e.getAttribute("listIndent")+this._indentBy;i<0?t.rename(e,"paragraph"):t.setAttribute("listIndent",i,e)}})}_checkEnabled(){const t=Xd(this.editor.model.document.selection.getSelectedBlocks());if(!t||!t.is("listItem"))return!1;if(this._indentBy>0){const e=t.getAttribute("listIndent"),i=t.getAttribute("listType");let n=t.previousSibling;for(;n&&n.is("listItem")&&n.getAttribute("listIndent")>=e;){if(n.getAttribute("listIndent")==e)return n.getAttribute("listType")==i;n=n.previousSibling}return!1}return!0}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function vg(t,e){const i=e.mapper,n=e.writer,s="numbered"==t.getAttribute("listType")?"ol":"ul",o=function(t){const e=t.createContainerElement("li");return e.getFillerOffset=Tg,e}(n),r=n.createContainerElement(s,null);return n.insert(n.createPositionAt(r,0),o),i.bindElements(t,o),o}function yg(t,e,i,n){const s=e.parent,o=i.mapper,r=i.writer;let a=o.toViewPosition(n.createPositionBefore(t));const l=Cg(t.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:t.getAttribute("listIndent")}),c=t.previousSibling;if(l&&l.getAttribute("listIndent")==t.getAttribute("listIndent")){const t=o.toViewElement(l);a=r.breakContainer(r.createPositionAfter(t))}else a=c&&"listItem"==c.name?o.toViewPosition(n.createPositionAt(c,"end")):o.toViewPosition(n.createPositionBefore(t));if(a=Ag(a),r.insert(a,s),c&&"listItem"==c.name){const t=o.toViewElement(c),i=r.createRange(r.createPositionAt(t,0),a).getWalker({ignoreElementEnd:!0});for(const t of i)if(t.item.is("li")){const n=r.breakContainer(r.createPositionBefore(t.item)),s=t.item.parent,o=r.createPositionAt(e,"end");kg(r,o.nodeBefore,o.nodeAfter),r.move(r.createRangeOn(s),o),i.position=n}}else{const i=s.nextSibling;if(i&&(i.is("ul")||i.is("ol"))){let n=null;for(const e of i.getChildren()){const i=o.toModelElement(e);if(!(i&&i.getAttribute("listIndent")>t.getAttribute("listIndent")))break;n=e}n&&(r.breakContainer(r.createPositionAfter(n)),r.move(r.createRangeOn(n.parent),r.createPositionAt(e,"end")))}}kg(r,s,s.nextSibling),kg(r,s.previousSibling,s)}function kg(t,e,i){return!e||!i||"ul"!=e.name&&"ol"!=e.name?null:e.name!=i.name||e.getAttribute("class")!==i.getAttribute("class")?null:t.mergeContainers(t.createPositionAfter(e))}function Ag(t){return t.getLastMatchingPosition(t=>t.item.is("uiElement"))}function Cg(t,e){const i=!!e.sameIndent,n=!!e.smallerIndent,s=e.listIndent;let o=t;for(;o&&"listItem"==o.name;){const t=o.getAttribute("listIndent");if(i&&s==t||n&&s>t)return o;o=o.previousSibling}return null}function xg(t,e){for(const i of t.getItems()){const t=e(i);if(t)return t}}function Pg(t,e,i,n){t.ui.componentFactory.add(e,s=>{const o=t.commands.get(e),r=new Xh(s);return r.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),r.on("execute",()=>t.execute(e)),r})}function Tg(){const t=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||t?0:Cn.call(this)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Eg(t){return(e,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;s.consume(i.item,"insert"),s.consume(i.item,"attribute:listType"),s.consume(i.item,"attribute:listIndent");const o=i.item;yg(o,vg(o,n),n,t)}}function Sg(t,e,i){if(!i.consumable.consume(e.item,"attribute:listType"))return;const n=i.mapper.toViewElement(e.item),s=i.writer;s.breakContainer(s.createPositionBefore(n)),s.breakContainer(s.createPositionAfter(n));const o=n.parent,r="numbered"==e.attributeNewValue?"ol":"ul";s.rename(r,o)}function Rg(t,e,i){const n=i.mapper.toViewElement(e.item).parent,s=i.writer;kg(s,n,n.nextSibling),kg(s,n.previousSibling,n);for(const t of e.item.getChildren())i.consumable.consume(t,"insert")}function Og(t,e,i){if("listItem"!=e.item.name){let t=i.mapper.toViewPosition(e.range.start);const n=i.writer,s=[];for(;("ul"==t.parent.name||"ol"==t.parent.name)&&"li"==(t=n.breakContainer(t)).parent.name;){const e=t,i=n.createPositionAt(t.parent,"end");if(!e.isEqual(i)){const t=n.remove(n.createRange(e,i));s.push(t)}t=n.createPositionAfter(t.parent)}if(s.length>0){for(let e=0;e<s.length;e++){const i=t.nodeBefore;if(t=n.insert(t,s[e]).end,e>0){const e=kg(n,i,i.nextSibling);e&&e.parent==i&&t.offset--}}kg(n,t.nodeBefore,t.nodeAfter)}}}function Ig(t,e,i){const n=i.mapper.toViewPosition(e.position),s=n.nodeBefore,o=n.nodeAfter;kg(i.writer,s,o)}function Mg(t,e,i){if(i.consumable.consume(e.viewItem,{name:!0})){const t=i.writer,n=this.conversionApi.store,s=t.createElement("listItem");n.indent=n.indent||0,t.setAttribute("listIndent",n.indent,s);const o=e.viewItem.parent&&"ol"==e.viewItem.parent.name?"numbered":"bulleted";t.setAttribute("listType",o,s),n.indent++;const r=i.splitToAllowedParent(s,e.modelCursor);if(!r)return;t.insert(s,r.position);const a=function(t,e,i){const{writer:n,schema:s}=i;let o=n.createPositionAfter(t);for(const r of e)if("ul"==r.name||"ol"==r.name)o=i.convertItem(r,o).modelCursor;else{const e=i.convertItem(r,n.createPositionAt(t,"end")),a=e.modelRange.start.nodeAfter;a&&a.is("element")&&!s.checkChild(t,a.name)&&(t=e.modelCursor.parent.is("listItem")?e.modelCursor.parent:Dg(e.modelCursor),o=n.createPositionAfter(t))}return o}(s,e.viewItem.getChildren(),i);n.indent--,e.modelRange=t.createRange(e.modelCursor,a),r.cursorParent?e.modelCursor=t.createPositionAt(r.cursorParent,0):e.modelCursor=e.modelRange.end}}function Vg(t,e,i){if(i.consumable.test(e.viewItem,{name:!0})){const t=Array.from(e.viewItem.getChildren());for(const e of t)e.is("li")||e._remove()}}function Ng(t,e,i){if(i.consumable.test(e.viewItem,{name:!0})){if(0===e.viewItem.childCount)return;const t=[...e.viewItem.getChildren()];let i=!1,n=!0;for(const e of t)!i||e.is("ul")||e.is("ol")||e._remove(),e.is("text")?(n&&(e._data=e.data.replace(/^\s+/,"")),(!e.nextSibling||e.nextSibling.is("ul")||e.nextSibling.is("ol"))&&(e._data=e.data.replace(/\s+$/,""))):(e.is("ul")||e.is("ol"))&&(i=!0),n=!1}}function Bg(t){return(e,i)=>{if(i.isPhantom)return;const n=i.modelPosition.nodeBefore;if(n&&n.is("listItem")){const e=i.mapper.toViewElement(n),s=e.getAncestors().find(t=>t.is("ul")||t.is("ol")),o=t.createPositionAt(e,0).getWalker();for(const t of o){if("elementStart"==t.type&&t.item.is("li")){i.viewPosition=t.previousPosition;break}if("elementEnd"==t.type&&t.item==s){i.viewPosition=t.nextPosition;break}}}}}function Fg(t,[e,i]){let n,s=e.is("documentFragment")?e.getChild(0):e;if(n=i?this.createSelection(i):this.document.selection,s&&s.is("listItem")){const t=n.getFirstPosition();let e=null;if(t.parent.is("listItem")?e=t.parent:t.nodeBefore&&t.nodeBefore.is("listItem")&&(e=t.nodeBefore),e){const t=e.getAttribute("listIndent");if(t>0)for(;s&&s.is("listItem");)s._setAttribute("listIndent",s.getAttribute("listIndent")+t),s=s.nextSibling}}}function Dg(t){const e=new $r({startPosition:t});let i;do{i=e.next()}while(!i.value.item.is("listItem"));return i.value.item}function Lg(t,e,i,n,s,o){const r=Cg(e.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:t,foo:"b"}),a=s.mapper,l=s.writer,c=r?r.getAttribute("listIndent"):null;let h;if(r)if(c==t){const t=a.toViewElement(r).parent;h=l.createPositionAfter(t)}else{const t=o.createPositionAt(r,"end");h=a.toViewPosition(t)}else h=i;h=Ag(h);for(const t of[...n.getChildren()])(t.is("ul")||t.is("ol"))&&(h=l.move(l.createRangeOn(t),h).end,kg(l,t,t.nextSibling),kg(l,t.previousSibling,t))}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zg extends nh{static get requires(){return[lu]}init(){const t=this.editor;t.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const e=t.data,i=t.editing;var n;t.model.document.registerPostFixer(e=>(function(t,e){const i=t.document.differ.getChanges(),n=new Map;let s=!1;for(const t of i)if("insert"==t.type&&"listItem"==t.name)o(t.position);else if("insert"==t.type&&"listItem"!=t.name){if("$text"!=t.name){const i=t.position.nodeAfter;i.hasAttribute("listIndent")&&(e.removeAttribute("listIndent",i),s=!0),i.hasAttribute("listType")&&(e.removeAttribute("listType",i),s=!0)}o(t.position.getShiftedBy(t.length))}else"remove"==t.type&&"listItem"==t.name?o(t.position):"attribute"==t.type&&"listIndent"==t.attributeKey?o(t.range.start):"attribute"==t.type&&"listType"==t.attributeKey&&o(t.range.start);for(const t of n.values())r(t),a(t);return s;function o(t){const e=t.nodeBefore;if(e&&e.is("listItem")){let i=e;if(n.has(i))return;for(;i.previousSibling&&i.previousSibling.is("listItem");)if(i=i.previousSibling,n.has(i))return;n.set(t.nodeBefore,i)}else{const e=t.nodeAfter;e&&e.is("listItem")&&n.set(e,e)}}function r(t){let i=0,n=null;for(;t&&t.is("listItem");){const o=t.getAttribute("listIndent");if(o>i){let r;null===n?(n=o-i,r=i):(n>o&&(n=o),r=o-n),e.setAttribute("listIndent",r,t),s=!0}else n=null,i=t.getAttribute("listIndent")+1;t=t.nextSibling}}function a(t){let i=[],n=null;for(;t&&t.is("listItem");){const o=t.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>o&&(i=i.slice(0,o+1)),0!=o)if(i[o]){const n=i[o];t.getAttribute("listType")!=n&&(e.setAttribute("listType",n,t),s=!0)}else i[o]=t.getAttribute("listType");n=t,t=t.nextSibling}}})(t.model,e)),i.mapper.registerViewToModelLength("li",Hg),e.mapper.registerViewToModelLength("li",Hg),i.mapper.on("modelToViewPosition",Bg(i.view)),i.mapper.on("viewToModelPosition",(n=t.model,(t,e)=>{const i=e.viewPosition,s=i.parent,o=e.mapper;if("ul"==s.name||"ol"==s.name){if(i.isAtEnd){const t=o.toModelElement(i.nodeBefore),s=o.getModelLength(i.nodeBefore);e.modelPosition=n.createPositionBefore(t).getShiftedBy(s)}else{const t=o.toModelElement(i.nodeAfter);e.modelPosition=n.createPositionBefore(t)}t.stop()}else if("li"==s.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const r=o.toModelElement(s);let a=1,l=i.nodeBefore;for(;l&&(l.is("ul")||l.is("ol"));)a+=o.getModelLength(l),l=l.previousSibling;e.modelPosition=n.createPositionBefore(r).getShiftedBy(a),t.stop()}})),e.mapper.on("modelToViewPosition",Bg(i.view)),i.downcastDispatcher.on("insert",Og,{priority:"high"}),i.downcastDispatcher.on("insert:listItem",Eg(t.model)),e.downcastDispatcher.on("insert",Og,{priority:"high"}),e.downcastDispatcher.on("insert:listItem",Eg(t.model)),i.downcastDispatcher.on("attribute:listType:listItem",Sg,{priority:"high"}),i.downcastDispatcher.on("attribute:listType:listItem",Rg,{priority:"low"}),i.downcastDispatcher.on("attribute:listIndent:listItem",function(t){return(e,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const s=n.mapper.toViewElement(i.item),o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r);o.remove(l),a&&a.nextSibling&&kg(o,a,a.nextSibling),Lg(i.attributeOldValue+1,i.range.start,l.start,s,n,t),yg(i.item,s,n,t);for(const t of i.item.getChildren())n.consumable.consume(t,"insert")}}(t.model)),i.downcastDispatcher.on("remove:listItem",function(t){return(e,i,n)=>{const s=n.mapper.toViewPosition(i.position).getLastMatchingPosition(t=>!t.item.is("li")).nodeAfter,o=n.writer;o.breakContainer(o.createPositionBefore(s)),o.breakContainer(o.createPositionAfter(s));const r=s.parent,a=r.previousSibling,l=o.createRangeOn(r),c=o.remove(l);a&&a.nextSibling&&kg(o,a,a.nextSibling),Lg(n.mapper.toModelElement(s).getAttribute("listIndent")+1,i.position,l.start,s,n,t);for(const t of o.createRangeIn(c).getItems())n.mapper.unbindViewElement(t);e.stop()}}(t.model)),i.downcastDispatcher.on("remove",Ig,{priority:"low"}),e.upcastDispatcher.on("element:ul",Vg,{priority:"high"}),e.upcastDispatcher.on("element:ol",Vg,{priority:"high"}),e.upcastDispatcher.on("element:li",Ng,{priority:"high"}),e.upcastDispatcher.on("element:li",Mg),t.model.on("insertContent",Fg,{priority:"high"}),t.commands.add("numberedList",new pg(t,"numbered")),t.commands.add("bulletedList",new pg(t,"bulleted")),t.commands.add("indentList",new _g(t,"forward")),t.commands.add("outdentList",new _g(t,"backward"));const s=i.view.document;this.listenTo(s,"enter",(t,e)=>{const i=this.editor.model.document,n=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==n.name&&n.isEmpty&&(this.editor.execute("outdentList"),e.preventDefault(),t.stop())}),this.listenTo(s,"delete",(t,e)=>{if("backward"!==e.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const n=i.getFirstPosition();if(!n.isAtStart)return;const s=n.parent;"listItem"===s.name&&(s.previousSibling&&"listItem"===s.previousSibling.name||(this.editor.execute("outdentList"),e.preventDefault(),t.stop()))},{priority:"high"});const o=t=>(e,i)=>{this.editor.commands.get(t).isEnabled&&(this.editor.execute(t),i())};t.keystrokes.set("Tab",o("indentList")),t.keystrokes.set("Shift+Tab",o("outdentList"))}afterInit(){const t=this.editor.commands,e=t.get("indent"),i=t.get("outdent");e&&e.registerChildCommand(t.get("indentList")),i&&i.registerChildCommand(t.get("outdentList"))}}function Hg(t){let e=1;for(const i of t.getChildren())if("ul"==i.name||"ol"==i.name)for(const t of i.getChildren())e+=Hg(t);return e}var jg='<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>',qg='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.75c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0C1 4.784 1.777 4 2.75 4c.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75C1.784 7.5 1 6.723 1 5.75zm6 9c0 .414.336.75.75.75h9.5a.75.75 0 1 0 0-1.5h-9.5a.75.75 0 0 0-.75.75zm-6 0c0-.966.777-1.75 1.75-1.75.966 0 1.75.777 1.75 1.75 0 .966-.777 1.75-1.75 1.75-.966 0-1.75-.777-1.75-1.75z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Wg extends nh{init(){const t=this.editor.t;Pg(this.editor,"numberedList",t("Numbered List"),jg),Pg(this.editor,"bulletedList",t("Bulleted List"),qg)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ug{constructor(t){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=t,this._referenceCoordinates=null}begin(t,e,i){const n=new Pr(e);this.activeHandlePosition=function(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const i of e)if(t.classList.contains(`ck-widget__resizer__handle-${i}`))return i}(t),this._referenceCoordinates=function(t,e){const i=new Pr(t),n=e.split("-"),s={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return s.x+=t.ownerDocument.defaultView.scrollX,s.y+=t.ownerDocument.defaultView.scrollY,s}(e,function(t){const e=t.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[e[0]]}-${i[e[1]]}`}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(this.activeHandlePosition)),this.originalWidth=n.width,this.originalHeight=n.height,this.aspectRatio=n.width/n.height;const s=i.style.width;s?s.match(/^\d+\.?\d*%$/)?this.originalWidthPercents=parseFloat(s):this.originalWidthPercents=50:this.originalWidthPercents=100}update(t){this.proposedWidth=t.width,this.proposedHeight=t.height,this.proposedWidthPercents=t.widthPercents,this.proposedHandleHostWidth=t.handleHostWidth,this.proposedHandleHostHeight=t.handleHostHeight}}cn(Ug,jn);class $g{constructor(t){this._options=t,this._domResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize")}attach(){const t=this,e=this._options.viewElement,i=this._options.downcastWriter,n=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(e){const i=this.toDomElement(e);return t._appendHandles(i),t._appendSizeUI(i),t._domResizerWrapper=i,t.on("change:isEnabled",(t,e,n)=>{i.style.display=n?"":"none"}),i.style.display=t.isEnabled?"":"none",i}));i.insert(i.createPositionAt(e,"end"),n),i.addClass("ck-widget_with-resizer",e)}begin(t){this.state=new Ug(this._options),this._sizeUI.bindToState(this._options,this.state),this.state.begin(t,this._getHandleHost(),this._getResizeHost()),this.redraw()}updateSize(t){const e=this._getHandleHost(),i=this._getResizeHost(),n=this._options.unit,s=this._proposeNewSize(t);i.style.width=("%"===n?s.widthPercents:s.width)+this._options.unit;const o=new Pr(e);s.handleHostWidth=Math.round(o.width),s.handleHostHeight=Math.round(o.height);const r=new Pr(e);s.width=Math.round(r.width),s.height=Math.round(r.height),this.state.update(s),this._domResizerWrapper.style.width=s.handleHostWidth+"px",this._domResizerWrapper.style.height=s.handleHostHeight+"px"}commit(){const t=("%"===this._options.unit?this.state.proposedWidthPercents:this.state.proposedWidth)+this._options.unit;this._options.onCommit(t),this._cleanup()}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(){const t=this._domResizerWrapper;if((e=t)&&e.ownerDocument&&e.ownerDocument.contains(e)){const e=t.parentElement,i=this._getHandleHost(),n=new Pr(i);t.style.width=n.width+"px",t.style.height=n.height+"px",e.isSameNode(i)||(t.style.left=i.offsetLeft+"px",t.style.top=i.offsetTop+"px",t.style.height=i.offsetHeight+"px",t.style.width=i.offsetWidth+"px")}var e}containsHandle(t){return this._domResizerWrapper.contains(t)}static isResizeHandle(t){return t.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeUI.dismiss(),this._sizeUI.isVisible=!1}_proposeNewSize(t){const e=this.state,i={x:(n=t).pageX,y:n.pageY};var n;const s=!this._options.isCentered||this._options.isCentered(this),o={x:e._referenceCoordinates.x-(i.x+e.originalWidth),y:i.y-e.originalHeight-e._referenceCoordinates.y};s&&e.activeHandlePosition.endsWith("-right")&&(o.x=i.x-(e._referenceCoordinates.x+e.originalWidth)),s&&(o.x*=2);const r={width:Math.abs(e.originalWidth+o.x),height:Math.abs(e.originalHeight+o.y)};r.dominant=r.width/e.aspectRatio>r.height?"width":"height",r.max=r[r.dominant];const a={width:r.width,height:r.height};return"width"==r.dominant?a.height=a.width/e.aspectRatio:a.width=a.height*e.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(e.originalWidthPercents/e.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const t=this._domResizerWrapper.parentElement;return this._options.getResizeHost(t)}_getHandleHost(){const t=this._domResizerWrapper.parentElement;return this._options.getHandleHost(t)}_appendHandles(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const i of e)t.appendChild(new Ac({tag:"div",attributes:{class:`ck-widget__resizer__handle ${Kg(i)}`}}).render())}_appendSizeUI(t){const e=new Gg;e.render(),this._sizeUI=e,t.appendChild(e.element)}_getHandlePosition(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const i of e)if(t.classList.contains(Kg(i)))return i}}cn($g,jn);class Gg extends jc{constructor(){super();const t=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",t.to("activeHandlePosition",t=>t?`ck-orientation-${t}`:"")],style:{display:t.if("isVisible","none",t=>!t)}},children:[{text:t.to("label")}]})}bindToState(t,e){this.bind("isVisible").to(e,"proposedWidth",e,"proposedHeight",(t,e)=>null!==t&&null!==e),this.bind("label").to(e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",e,"proposedWidthPercents",(e,i,n)=>"px"===t.unit?`${e}×${i}`:`${n}%`),this.bind("activeHandlePosition").to(e)}dismiss(){this.unbind(),this.isVisible=!1}}function Kg(t){return`ck-widget__resizer__handle-${t}`}var Jg="Expected a function";var Yg=function(t,e,i){var n=!0,s=!0;if("function"!=typeof t)throw new TypeError(Jg);return z(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),wr(t,e,{leading:n,maxWait:e,trailing:s})};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Qg extends nh{static get pluginName(){return"WidgetResize"}init(){this.resizers=[],this.activeResizer=null;const t=no.window.document;this.editor.model.schema.setAttributeProperties("width",{isFormatting:!0}),this._observer=Object.create(ho),this._observer.listenTo(t,"mousedown",(t,e)=>{if(!$g.isResizeHandle(e.target))return;const i=e.target;this.activeResizer=this._getResizerByHandle(i),this.activeResizer&&this.activeResizer.begin(i)}),this._observer.listenTo(t,"mousemove",Yg((t,e)=>{this.activeResizer&&this.activeResizer.updateSize(e)},16)),this._observer.listenTo(t,"mouseup",()=>{this.activeResizer&&(this.activeResizer.commit(),this.activeResizer=null)});const e=Yg(()=>{for(const t of this.resizers)t.redraw()},16);this.editor.ui.on("update",e),this._observer.listenTo(no.window,"resize",e)}destroy(){this._observer.stopListening()}attachTo(t){const e=new $g(t);return e.attach(),this.editor.editing.view.once("render",()=>e.redraw()),this.resizers.push(e),e}_getResizerByHandle(t){for(const e of this.resizers)if(e.containsHandle(t))return e}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xg extends lh{refresh(){const t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=Ku(t),t&&t.hasAttribute("width")?this.value={width:t.getAttribute("width"),height:null}:this.value=null}execute(t){const e=this.editor.model,i=e.document.selection.getSelectedElement();e.change(e=>{e.setAttribute("width",t.width,i)})}}i(46);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zg{constructor(t,e){this.loader=t,this.options=e}upload(){return this.loader.file.then(t=>new Promise((e,i)=>{this._initRequest(),this._initListeners(e,i,t),this._sendRequest(t)}))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const t=this.xhr=new XMLHttpRequest;t.open("POST",this.options.uploadUrl,!0),t.responseType="json"}_initListeners(t,e,i){const n=this.xhr,s=this.loader,o=`Couldn't upload file: ${i.name}.`;n.addEventListener("error",()=>e(o)),n.addEventListener("abort",()=>e()),n.addEventListener("load",()=>{const i=n.response;if(!i||i.error)return e(i&&i.error&&i.error.message?i.error.message:o);t(i.url?{default:i.url}:i.urls)}),n.upload&&n.upload.addEventListener("progress",t=>{t.lengthComputable&&(s.uploadTotal=t.total,s.uploaded=t.loaded)})}_sendRequest(t){const e=this.options.headers||{};for(const t of Object.keys(e))this.xhr.setRequestHeader(t,e[t]);const i=new FormData;i.append("upload",t),this.xhr.send(i)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const tp=["left","right","center","justify"];function ep(t){return tp.includes(t)}function ip(t,e){return"rtl"==e.contentLanguageDirection?"right"===t:"left"===t}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const np="alignment";class sp extends lh{refresh(){const t=this.editor.locale,e=Xd(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=!!e&&this._canBeAligned(e),this.isEnabled&&e.hasAttribute("alignment")?this.value=e.getAttribute("alignment"):this.value="rtl"===t.contentLanguageDirection?"right":"left"}execute(t={}){const e=this.editor,i=e.locale,n=e.model,s=n.document,o=t.value;n.change(t=>{const e=Array.from(s.selection.getSelectedBlocks()).filter(t=>this._canBeAligned(t)),n=e[0].getAttribute("alignment");ip(o,i)||n===o||!o?function(t,e){for(const i of t)e.removeAttribute(np,i)}(e,t):function(t,e,i){for(const n of t)e.setAttribute(np,i,n)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e,t,o)})}_canBeAligned(t){return this.editor.model.schema.checkAttribute(t,np)}}class op extends nh{constructor(t){super(t),t.config.define("alignment",{options:[...tp]})}init(){const t=this.editor,e=t.locale,i=t.model.schema,n=t.config.get("alignment.options").filter(ep);i.extend("$block",{allowAttributes:"alignment"}),t.model.schema.setAttributeProperties("alignment",{isFormatting:!0});const s=function(t){const e={model:{key:"alignment",values:t.slice()},view:{}};for(const i of t)e.view[i]={key:"style",value:{"text-align":i}};return e}(n.filter(t=>!ip(t,e)));t.conversion.attributeToAttribute(s),t.commands.add("alignment",new sp(t))}}var rp='<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>',ap='<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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const lp=new Map([["left",rp],["right",ap],["center",'<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>'],["justify",'<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>']]);class cp extends nh{get localizedOptionTitles(){const t=this.editor.t;return{left:t("Align left"),right:t("Align right"),center:t("Align center"),justify:t("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const t=this.editor,e=t.ui.componentFactory,i=t.t,n=t.config.get("alignment.options");n.filter(ep).forEach(t=>this._addButton(t)),e.add("alignment",t=>{const s=Eu(t),o=n.map(t=>e.create(`alignment:${t}`));Su(s,o),s.buttonView.set({label:i("Text alignment"),tooltip:!0}),s.toolbarView.isVertical=!0,s.toolbarView.ariaLabel=i("Text alignment toolbar"),s.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===t.contentLanguageDirection?ap:rp;return s.buttonView.bind("icon").toMany(o,"isOn",(...t)=>{const e=t.findIndex(t=>t);return e<0?r:o[e].icon}),s.bind("isEnabled").toMany(o,"isEnabled",(...t)=>t.some(t=>t)),s})}_addButton(t){const e=this.editor;e.ui.componentFactory.add(`alignment:${t}`,i=>{const n=e.commands.get("alignment"),s=new Xh(i);return s.set({label:this.localizedOptionTitles[t],icon:lp.get(t),tooltip:!0,isToggleable:!0}),s.bind("isEnabled").to(n),s.bind("isOn").to(n,"value",e=>e===t),this.listenTo(s,"execute",()=>{e.execute("alignment",{value:t}),e.editing.view.focus()}),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function hp(t,e){if(!t.childCount)return;const i=new dm,n=function(t,e){const i=e.createRangeIn(t),n=new bn({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),s=[];for(const t of i)if("elementStart"===t.type&&n.match(t.item)){const e=dp(t.item);s.push({element:t.item,id:e.id,order:e.order,indent:e.indent})}return s}(t,i);if(!n.length)return;let s=null;n.forEach((t,o)=>{if(!s||function(t,e){if(t.id!==e.id)return!0;const i=e.element.previousSibling;if(!i)return!0;return!up(i)}(n[o-1],t)){const n=function(t,e){const i=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]*);/gi,s=i.exec(e);let o="decimal";if(s&&s[1]){const t=n.exec(s[1]);t&&t[1]&&(o=t[1].trim())}return{type:"bullet"!==o&&"image"!==o?"ol":"ul",style:o}}(t,e);s=function(t,e,i){const n=new vn(t.type),s=e.parent.getChildIndex(e);return i.insertChild(s,n,e.parent),n}(n,t.element,i)}const r=function(t,e){return function(t,e){const i=new bn({name:"span",styles:{"mso-list":"Ignore"}}),n=e.createRangeIn(t);for(const t of n)"elementStart"===t.type&&i.match(t.item)&&e.remove(t.item)}(t,e),e.rename("li",t)}(t.element,i);i.appendChild(r,s)})}function dp(t){const e={},i=t.getStyle("mso-list");return i&&(e.id=parseInt(i.match(/(^|\s+)l(\d+)/i)[2]),e.order=parseInt(i.match(/\s*lfo(\d+)/i)[1]),e.indent=parseInt(i.match(/\s*level(\d+)/i)[1])),e}function up(t){return t.is("ol")||t.is("ul")}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const fp=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class mp{isActive(t){return fp.test(t)}execute(t){const e=new dm;!
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function(t,e){for(const i of t.getChildren())if(i.is("b")&&"normal"===i.getStyle("font-weight")){const n=t.getChildIndex(i);e.remove(i),e.insertChild(n,i.getChildren(),t)}}(t.content,e),function(t,e){for(const i of e.createRangeIn(t)){const t=i.item;if(t.is("li")){const i=t.nextSibling;i&&up(i)&&(e.remove(i),e.insertChild(t.childCount,i,t))}if(up(t)){let i=t.getChild(0);for(;up(i);)e.unwrapElement(i),i=t.getChild(0)}}}(t.content,e),function(t,e){for(const i of e.createRangeIn(t)){const t=i.item;if(t.is("li")){const i=t.getChild(0);i.is("p")&&e.unwrapElement(i)}}}(t.content,e)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function gp(t){return t.replace(/<span(?: class="Apple-converted-space"|)>(\s+)<\/span>/g,(t,e)=>1===e.length?" ":Array(e.length+1).join("  ").substr(0,e.length))}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function pp(t){const e=new DOMParser,i=function(t){return gp(gp(t)).replace(/(<span style=['"]mso-spacerun:yes['"]>[\s]*?)[\r\n]+(\s*<\/span>)/g,"$1$2").replace(/<span style=['"]mso-spacerun:yes['"]><\/span>/g,"").replace(/ <\//g," </").replace(/ <o:p><\/o:p>/g," <o:p></o:p>").replace(/>(\s*[\r\n]\s*)</g,"><")}(function(t){const e=t.match(/<\/body>(.*?)(<\/html>|$)/);e&&e[1]&&(t=t.slice(0,e.index)+t.slice(e.index).replace(e[1],""));return t}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t=t.replace(/<!--\[if gte vml 1]>/g,""))),n=e.parseFromString(i,"text/html");!function(t){t.querySelectorAll("span[style*=spacerun]").forEach(t=>{const e=t.childNodes[0].data.length;t.innerHTML=Array(e+1).join("  ").substr(0,e)})}(n);const s=n.body.innerHTML,o=function(t){const e=new ro({blockFiller:Fs}),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return e.domToView(i)}(n),r=function(t){const e=[],i=[],n=Array.from(t.getElementsByTagName("style"));for(const t of n)t.sheet&&t.sheet.cssRules&&t.sheet.cssRules.length&&(e.push(t.sheet),i.push(t.innerHTML));return{styles:e,stylesString:i.join(" ")}}(n);return{body:o,bodyString:s,styles:r.styles,stylesString:r.stylesString}}function wp(t,e){if(!t.childCount)return;const i=new dm;!function(t,e,i){const n=i.createRangeIn(e),s=new bn({name:"img"}),o=[];for(const e of n)if(s.match(e.item)){const i=e.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every(e=>t.indexOf(e)>-1)?o.push(i):i.getAttribute("src")||o.push(i)}for(const t of o)i.remove(t)}(function(t,e){const i=e.createRangeIn(t),n=new bn({name:/v:(.+)/}),s=[];for(const t of i){const e=t.item,i=e.previousSibling&&e.previousSibling.name||null;n.match(e)&&e.getAttribute("o:gfxdata")&&"v:shapetype"!==i&&s.push(t.item.getAttribute("id"))}return s}(t,i),t,i),function(t,e){const i=e.createRangeIn(t),n=new bn({name:/v:(.+)/}),s=[];for(const t of i)n.match(t.item)&&s.push(t.item);for(const t of s)e.remove(t)}(t,i);const n=function(t,e){const i=e.createRangeIn(t),n=new bn({name:"img"}),s=[];for(const t of i)n.match(t.item)&&t.item.getAttribute("src").startsWith("file://")&&s.push(t.item);return s}(t,i);n.length&&function(t,e,i){if(t.length===e.length)for(let s=0;s<t.length;s++){const o=`data:${e[s].type};base64,${n=e[s].hex,btoa(n.match(/\w{2}/g).map(t=>String.fromCharCode(parseInt(t,16))).join(""))}`;i.setAttribute("src",o,t[s])}var n}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(n,function(t){if(!t)return[];const e=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+e.source+"))([\\da-fA-F\\s]+)\\}","g"),n=t.match(i),s=[];if(n)for(const t of n){let i=!1;t.includes("\\pngblip")?i="image/png":t.includes("\\jpegblip")&&(i="image/jpeg"),i&&s.push({hex:t.replace(e,"").replace(/[^\da-fA-F]/g,""),type:i})}return s}(e),i)}const bp=/<meta\s*name="?generator"?\s*content="?microsoft\s*word\s*\d+"?\/?>/i,_p=/xmlns:o="urn:schemas-microsoft-com/i;class vp{isActive(t){return bp.test(t)||_p.test(t)}execute(t){const{body:e,stylesString:i}=pp(t.dataTransfer.getData("text/html"));hp(e,i),wp(e,t.dataTransfer.getData("text/rtf")),t.content=e}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class yp extends lh{constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=e.selection.getAttribute(this.attributeKey),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model,i=e.document.selection,n=t.value;e.change(t=>{if(i.isCollapsed)n?t.setSelectionAttribute(this.attributeKey,n):t.removeSelectionAttribute(this.attributeKey);else{const s=e.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const e of s)n?t.setAttribute(this.attributeKey,n,e):t.removeAttribute(this.attributeKey,e)}})}}var kp='<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M6.193 17.02l-.102-.121-2.553-3.536a2 2 0 0 1 .956-3.3c.699-.182 1.442.026 2.005.614L7.642 12.1l6.515-8.164.074-.083c.757-.756 1.652-.65 2.38-.081.77.6.869 1.79.159 2.573L9.203 16.896l-.105.124c-.385.386-.91.597-1.453.586-.543.01-1.067-.2-1.452-.586z" fill-opacity=".8"/><path d="M7.645 16.606a.997.997 0 0 0 .745-.292l7.606-10.606c.391-.39.28-.93 0-1.148-.28-.219-.667-.39-1.058 0L7.645 13.7 5.72 11.304a1 1 0 1 0-1.414 1.414l2.596 3.596a.997.997 0 0 0 .744.292z"/></svg>\n';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ap extends Xh{constructor(t){super(t);const e=this.bindTemplate;this.set("color"),this.set("hasBorder"),this.icon=kp,this.extendTemplate({attributes:{style:{backgroundColor:e.to("color")},class:["ck","ck-color-grid__tile",e.if("hasBorder","ck-color-table__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}i(47);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Cp extends jc{constructor(t,e){super(t);const i=e&&e.colorDefinitions||[],n={};e&&e.columns&&(n.gridTemplateColumns=`repeat( ${e.columns}, 1fr)`),this.set("selectedColor"),this.items=this.createCollection(),this.focusTracker=new uc,this.keystrokes=new nc,this._focusCycler=new Qc({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.items.on("add",(t,e)=>{e.isOn=e.color===this.selectedColor}),i.forEach(t=>{const e=new Ap;e.set({color:t.color,label:t.label,tooltip:!0,hasBorder:t.options.hasBorder}),e.on("execute",()=>{this.fire("execute",{value:t.color,hasBorder:t.options.hasBorder,label:t.label})}),this.items.add(e)}),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:n}}),this.on("change:selectedColor",(t,e,i)=>{for(const t of this.items)t.isOn=t.color===i})}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.items.on("add",(t,e)=>{this.focusTracker.add(e.element)}),this.items.on("remove",(t,e)=>{this.focusTracker.remove(e.element)}),this.keystrokes.listenTo(this.element)}}class xp extends os{constructor(t){super(t),this.set("isEmpty",!0)}add(t,e){this.find(e=>e.color===t.color)||(super.add(t,e),this.set("isEmpty",!1))}remove(t){const e=super.remove(t);return 0===this.length&&this.set("isEmpty",!0),e}hasColor(t){return!!this.find(e=>e.color===t)}}cn(xp,jn);var Pp='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8.636 9.531l-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>';i(48);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Tp extends jc{constructor(t,{colors:e,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o}){if(super(t),this.items=this.createCollection(),this.colorDefinitions=e,this.focusTracker=new uc,this.keystrokes=new nc,this.set("selectedColor"),this.removeButtonLabel=n,this.columns=i,this.documentColors=new xp,this.documentColorsCount=o,this.staticColorsGrid=this._createStaticColorsGrid(),this.documentColorsGrid,this._focusCycler=new Qc({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table"]},children:this.items}),this.items.add(this._removeColorButton()),this.items.add(this.staticColorsGrid),o){const t=Ac.bind(this.documentColors,this.documentColors),e=new Wc(this.locale);e.text=s,e.extendTemplate({attributes:{class:["ck","ck-color-grid__label",t.if("isEmpty","ck-hidden")]}}),this.items.add(e),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}}updateDocumentColors(t,e){const i=t.document,n=this.documentColorsCount;this.documentColors.clear();for(const s of i.getRootNames()){const o=i.getRoot(s),r=t.createRangeIn(o);for(const t of r.getItems())if(t.is("textProxy")&&t.hasAttribute(e)&&(this._addColorToDocumentColors(t.getAttribute(e)),this.documentColors.length>=n))return}}updateSelectedColors(){const t=this.documentColorsGrid,e=this.staticColorsGrid,i=this.selectedColor;e.selectedColor=i,t&&(t.selectedColor=i)}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_removeColorButton(){const t=new Xh;return t.set({withText:!0,icon:Pp,tooltip:!0,label:this.removeButtonLabel}),t.class="ck-color-table__remove-color",t.on("execute",()=>{this.fire("execute",{value:null})}),t}_createStaticColorsGrid(){const t=new Cp(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return t.delegate("execute").to(this),t}_createDocumentColorsGrid(){const t=Ac.bind(this.documentColors,this.documentColors),e=new Cp(this.locale,{columns:this.columns});return e.delegate("execute").to(this),e.extendTemplate({attributes:{class:t.if("isEmpty","ck-hidden")}}),e.items.bindTo(this.documentColors).using(t=>{const e=new Ap;return e.set({color:t.color,hasBorder:t.options&&t.options.hasBorder}),t.label&&e.set({label:t.label,tooltip:!0}),e.on("execute",()=>{this.fire("execute",{value:t.color})}),e}),this.documentColors.on("change:isEmpty",(t,i,n)=>{n&&(e.selectedColor=null)}),e}_addColorToDocumentColors(t){const e=this.colorDefinitions.find(e=>e.color===t);e?this.documentColors.add(Object.assign({},e)):this.documentColors.add({color:t,label:t,options:{hasBorder:!1}})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Ep="fontSize",Sp="fontFamily",Rp="fontColor",Op="fontBackgroundColor";function Ip(t,e){const i={model:{key:t,values:[]},view:{},upcastAlso:{}};for(const t of e)i.model.values.push(t.model),i.view[t.model]=t.view,t.upcastAlso&&(i.upcastAlso[t.model]=t.upcastAlso);return i}function Mp(t){return e=>(function(t){return t.replace(/\s/g,"")})(e.getStyle(t))}function Vp(t){return(e,i)=>i.createAttributeElement("span",{style:`${t}:${e}`},{priority:7})}function Np(t){return"string"==typeof t?{model:t.replace(/ /g,""),label:t,hasBorder:!1,view:{name:"span",styles:{color:t}}}:{model:t.color.replace(/ /g,""),label:t.label||t.color,hasBorder:void 0!==t.hasBorder&&t.hasBorder,view:{name:"span",styles:{color:`${t.color}`}}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Bp extends yp{constructor(t){super(t,Sp)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Fp(t){return t.map(Dp).filter(t=>!!t)}function Dp(t){return"object"==typeof t?t:"default"===t?{title:"Default",model:void 0}:"string"==typeof t?function(t){const e=t.replace(/"|'/g,"").split(","),i=e[0],n=e.map(Lp).join(", ");return{title:i,model:i,view:{name:"span",styles:{"font-family":n},priority:7}}}(t):void 0}function Lp(t){return(t=t.trim()).indexOf(" ")>0&&(t=`'${t}'`),t}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class zp extends nh{constructor(t){super(t),t.config.define(Sp,{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"]})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Sp}),t.model.schema.setAttributeProperties(Sp,{isFormatting:!0,copyOnEnter:!0});const e=Fp(t.config.get("fontFamily.options")).filter(t=>t.model),i=Ip(Sp,e);t.conversion.attributeToElement(i),t.commands.add(Sp,new Bp(t))}}var Hp='<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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class jp extends nh{init(){const t=this.editor,e=t.t,i=this._getLocalizedOptions(),n=t.commands.get(Sp);t.ui.componentFactory.add(Sp,s=>{const o=Eu(s);return Ru(o,function(t,e){const i=new os;for(const n of t){const t={type:"button",model:new gu({commandName:Sp,commandParam:n.model,label:n.title,withText:!0})};t.model.bind("isOn").to(e,"value",t=>t===n.model),n.view&&n.view.styles&&t.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(t)}return i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(i,n)),o.buttonView.set({label:e("Font Family"),icon:Hp,tooltip:!0}),o.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),o.bind("isEnabled").to(n),this.listenTo(o,"execute",e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()}),o})}_getLocalizedOptions(){const t=this.editor,e=t.t;return Fp(t.config.get(Sp).options).map(t=>("Default"===t.title&&(t.title=e("Default")),t))}}class qp extends nh{static get requires(){return[zp,jp]}static get pluginName(){return"FontFamily"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wp extends yp{constructor(t){super(t,Ep)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Up(t){return t.map(Gp).filter(t=>!!t)}const $p={tiny:{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}},small:{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}},big:{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}},huge:{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}};function Gp(t){if("object"==typeof t)return t;if($p[t])return $p[t];if("default"===t)return{model:void 0,title:"Default"};const e=parseFloat(t);var i;
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */return isNaN(e)?void 0:(i=e,{title:String(i),model:i,view:{name:"span",styles:{"font-size":`${i}px`},priority:7}})}class Kp extends nh{constructor(t){super(t),t.config.define(Ep,{options:["tiny","small","default","big","huge"]});const e=Up(this.editor.config.get("fontSize.options")).filter(t=>t.model),i=Ip(Ep,e);t.conversion.attributeToElement(i),t.commands.add(Ep,new Wp(t))}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Ep}),t.model.schema.setAttributeProperties(Ep,{isFormatting:!0,copyOnEnter:!0})}}var Jp='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M9.816 11.5L7.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.279l.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>';i(49);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Yp extends nh{init(){const t=this.editor,e=t.t,i=this._getLocalizedOptions(),n=t.commands.get(Ep);t.ui.componentFactory.add(Ep,s=>{const o=Eu(s);return Ru(o,function(t,e){const i=new os;for(const n of t){const t={type:"button",model:new gu({commandName:Ep,commandParam:n.model,label:n.title,class:"ck-fontsize-option",withText:!0})};n.view&&n.view.styles&&t.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view&&n.view.classes&&t.model.set("class",`${t.model.class} ${n.view.classes}`),t.model.bind("isOn").to(e,"value",t=>t===n.model),i.add(t)}return i}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(i,n)),o.buttonView.set({label:e("Font Size"),icon:Jp,tooltip:!0}),o.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),o.bind("isEnabled").to(n),this.listenTo(o,"execute",e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()}),o})}_getLocalizedOptions(){const t=this.editor,e=t.t,i={Default:e("Default"),Tiny:e("Tiny"),Small:e("Small"),Big:e("Big"),Huge:e("Huge")};return Up(t.config.get(Ep).options).map(t=>{const e=i[t.title];return e&&e!=t.title&&(t=Object.assign({},t,{title:e})),t})}}class Qp extends nh{static get requires(){return[Kp,Yp]}static get pluginName(){return"FontSize"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Xp extends yp{constructor(t){super(t,Rp)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Zp extends nh{constructor(t){super(t),t.config.define(Rp,{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}),t.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:Rp,value:Mp("color")}}),t.conversion.for("downcast").attributeToElement({model:Rp,view:Vp("color")}),t.commands.add(Rp,new Xp(t)),t.model.schema.extend("$text",{allowAttributes:Rp}),t.model.schema.setAttributeProperties(Rp,{isFormatting:!0,copyOnEnter:!0})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class tw extends nh{constructor(t,{commandName:e,icon:i,componentName:n,dropdownLabel:s}){super(t),this.commandName=e,this.componentName=n,this.icon=i,this.dropdownLabel=s,this.columns=t.config.get(`${this.componentName}.columns`),this.colorTableView}init(){const t=this.editor,e=t.t,i=t.commands.get(this.commandName),n=t.config.get(this.componentName).colors.map(Np).filter(t=>!!t);const s=function(t,e){const i=t.t,n={Black:i("Black"),"Dim grey":i("Dim grey"),Grey:i("Grey"),"Light grey":i("Light grey"),White:i("White"),Red:i("Red"),Orange:i("Orange"),Yellow:i("Yellow"),"Light green":i("Light green"),Green:i("Green"),Aquamarine:i("Aquamarine"),Turquoise:i("Turquoise"),"Light blue":i("Light blue"),Blue:i("Blue"),Purple:i("Purple")};return e.map(t=>{const e=n[t.label];return e&&e!=t.label&&(t.label=e),t})}(t,n),o=t.config.get(`${this.componentName}.documentColors`);t.ui.componentFactory.add(this.componentName,n=>{const r=Eu(n);return this.colorTableView=function({dropdownView:t,colors:e,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o}){const r=t.locale,a=new Tp(r,{colors:e,columns:i,removeButtonLabel:n,documentColorsLabel:s,documentColorsCount:o});return t.colorTableView=a,t.panelView.children.add(a),a.delegate("execute").to(t,"execute"),a}({dropdownView:r,colors:s.map(t=>({label:t.label,color:t.model,options:{hasBorder:t.hasBorder}})),columns:this.columns,removeButtonLabel:e("Remove color"),documentColorsLabel:0!==o?e("Document colors"):void 0,documentColorsCount:void 0===o?this.columns:o}),this.colorTableView.bind("selectedColor").to(i,"value"),r.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),r.bind("isEnabled").to(i),r.on("execute",(e,i)=>{t.execute(this.commandName,i),t.editing.view.focus()}),r.on("change:isOpen",(e,i,n)=>{n&&(0!==o&&this.colorTableView.updateDocumentColors(t.model,this.componentName),this.colorTableView.updateSelectedColors())}),r})}}var ew='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M12.4 10.3L10 4.5l-2.4 5.8h4.8zm.5 1.2H7.1L5.7 15H4.2l5-12h1.6l5 12h-1.5L13 11.5zM16 18.5H4a1 1 0 0 1 0-2h12a1 1 0 0 1 0 2z"/></svg>\n';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class iw extends tw{constructor(t){const e=t.locale.t;super(t,{commandName:Rp,componentName:Rp,icon:ew,dropdownLabel:e("Font Color")})}static get pluginName(){return"FontColorUI"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class nw extends nh{static get requires(){return[Zp,iw]}static get pluginName(){return"FontColor"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class sw extends yp{constructor(t){super(t,Op)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ow extends nh{constructor(t){super(t),t.config.define(Op,{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}),t.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:Op,value:Mp("background-color")}}),t.conversion.for("downcast").attributeToElement({model:Op,view:Vp("background-color")}),t.commands.add(Op,new sw(t)),t.model.schema.extend("$text",{allowAttributes:Op}),t.model.schema.setAttributeProperties(Op,{isFormatting:!0,copyOnEnter:!0})}}var rw='<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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class aw extends tw{constructor(t){const e=t.locale.t;super(t,{commandName:Op,componentName:Op,icon:rw,dropdownLabel:e("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lw extends nh{static get requires(){return[ow,aw]}static get pluginName(){return"FontBackgroundColor"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function cw(t,e){return t=>{t.on("attribute:url:media",i)};function i(i,n,s){if(!s.consumable.consume(n.item,i.name))return;const o=n.attributeNewValue,r=s.writer,a=s.mapper.toViewElement(n.item);r.remove(r.createRangeIn(a));const l=t.getMediaViewElement(r,o,e);r.insert(r.createPositionAt(a,0),l)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function hw(t,e,i,n){const s=t.createContainerElement("figure",{class:"media"});return s.getFillerOffset=fw,t.insert(t.createPositionAt(s,0),e.getMediaViewElement(t,i,n)),s}function dw(t){const e=t.getSelectedElement();return e&&e.is("media")?e:null}function uw(t,e,i){t.change(n=>{const s=n.createElement("media",{url:e});t.insertContent(s,i),n.setSelection(s,"on")})}function fw(){return null}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class mw extends lh{refresh(){const t=this.editor.model,e=t.document.selection,i=t.schema,n=e.getFirstPosition(),s=dw(e);let o=n.parent;o!=o.root&&(o=o.parent),this.value=s?s.getAttribute("url"):null,this.isEnabled=i.checkChild(o,"media")}execute(t){const e=this.editor.model,i=e.document.selection,n=dw(i);if(n)e.change(e=>{e.setAttribute("url",t,n)});else{const n=Uu(i,e);uw(e,t,n)}}}var gw='<svg viewBox="0 0 64 42" xmlns="http://www.w3.org/2000/svg"><path d="M47.426 17V3.713L63.102 0v19.389h-.001l.001.272c0 1.595-2.032 3.43-4.538 4.098-2.506.668-4.538-.083-4.538-1.678 0-1.594 2.032-3.43 4.538-4.098.914-.244 2.032-.565 2.888-.603V4.516L49.076 7.447v9.556A1.014 1.014 0 0 0 49 17h-1.574zM29.5 17h-8.343a7.073 7.073 0 1 0-4.657 4.06v3.781H3.3a2.803 2.803 0 0 1-2.8-2.804V8.63a2.803 2.803 0 0 1 2.8-2.805h4.082L8.58 2.768A1.994 1.994 0 0 1 10.435 1.5h8.985c.773 0 1.477.448 1.805 1.149l1.488 3.177H26.7c1.546 0 2.8 1.256 2.8 2.805V17zm-11.637 0H17.5a1 1 0 0 0-1 1v.05A4.244 4.244 0 1 1 17.863 17zm29.684 2c.97 0 .953-.048.953.889v20.743c0 .953.016.905-.953.905H19.453c-.97 0-.953.048-.953-.905V19.89c0-.937-.016-.889.97-.889h28.077zm-4.701 19.338V22.183H24.154v16.155h18.692zM20.6 21.375v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616v-1.616H20.6zm0 3.231v1.616h1.616V37.53H20.6zm24.233-16.155v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615v-1.616h-1.615zm0 3.231v1.616h1.615V37.53h-1.615zM29.485 25.283a.4.4 0 0 1 .593-.35l9.05 4.977a.4.4 0 0 1 0 .701l-9.05 4.978a.4.4 0 0 1-.593-.35v-9.956z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const pw="0 0 64 42";class ww{constructor(t,e){const i=e.providers,n=e.extraProviders||[],s=new Set(e.removeProviders),o=i.concat(n).filter(t=>{const e=t.name;return e?!s.has(e):(console.warn(Object(Ki.a)("media-embed-no-provider-name: The configured media provider has no name and cannot be used."),{provider:t}),!1)});this.locale=t,this.providerDefinitions=o}hasMedia(t){return!!this._getMedia(t)}getMediaViewElement(t,e,i){return this._getMedia(e).getViewElement(t,i)}_getMedia(t){if(!t)return new bw(this.locale);t=t.trim();for(const e of this.providerDefinitions){const i=e.html;let n=e.url;Array.isArray(n)||(n=[n]);for(const e of n){const n=this._getUrlMatches(t,e);if(n)return new bw(this.locale,t,n,i)}}return null}_getUrlMatches(t,e){let i=t.match(e);if(i)return i;let n=t.replace(/^https?:\/\//,"");return(i=n.match(e))?i:(i=(n=n.replace(/^www\./,"")).match(e))||null}}class bw{constructor(t,e,i,n){this.url=this._getValidUrl(e),this._t=t.t,this._match=i,this._previewRenderer=n}getViewElement(t,e){const i={};if(e.renderForEditingView||e.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(i["data-oembed-url"]=this.url),e.renderForEditingView&&(i.class="ck-media__wrapper");const n=this._getPreviewHtml(e);return t.createUIElement("div",i,(function(t){const e=this.toDomElement(t);return e.innerHTML=n,e}))}return this.url&&(i.url=this.url),t.createEmptyElement("oembed",i)}_getPreviewHtml(t){return this._previewRenderer?this._previewRenderer(this._match):this.url&&t.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const t=new Qh,e=new Yh;return t.text=this._t("Open media in new tab"),e.content=gw,e.viewBox=pw,new Ac({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[e]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]},t]}]}).render().outerHTML}_getValidUrl(t){return t?t.match(/^https?/)?t:"https://"+t:null}}i(50);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class _w extends nh{static get pluginName(){return"MediaEmbedEditing"}constructor(t){super(t),t.config.define("mediaEmbed",{providers:[{name:"dailymotion",url:/^dailymotion\.com\/video\/(\w+)/,html:t=>{return'<div style="position: relative; padding-bottom: 100%; height: 0; ">'+`<iframe src="https://www.dailymotion.com/embed/video/${t[1]}" `+'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" width="480" height="270" allowfullscreen allow="autoplay"></iframe></div>'}},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:t=>{return'<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 126%;">'+`<iframe src="https://open.spotify.com/embed/${t[1]}" `+'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe></div>'}},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)/,/^youtube\.com\/embed\/([\w-]+)/,/^youtu\.be\/([\w-]+)/],html:t=>{return'<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">'+`<iframe src="https://www.youtube.com/embed/${t[1]}" `+'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div>'}},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:t=>{return'<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 56.2493%;">'+`<iframe src="https://player.vimeo.com/video/${t[1]}" `+'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>'}},{name:"instagram",url:/^instagram\.com\/p\/(\w+)/},{name:"twitter",url:/^twitter\.com/},{name:"googleMaps",url:/^google\.com\/maps/},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new ww(t.locale,t.config.get("mediaEmbed"))}init(){const t=this.editor,e=t.model.schema,i=t.t,n=t.conversion,s=t.config.get("mediaEmbed.previewsInData"),o=this.registry;t.commands.add("mediaEmbed",new mw(t)),e.register("media",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["url"]}),n.for("dataDowncast").elementToElement({model:"media",view:(t,e)=>{const i=t.getAttribute("url");return hw(e,o,i,{renderMediaPreview:i&&s})}}),n.for("dataDowncast").add(cw(o,{renderMediaPreview:s})),n.for("editingDowncast").elementToElement({model:"media",view:(t,e)=>{const n=t.getAttribute("url");return function(t,e,i){return e.setCustomProperty("media",!0,t),ju(t,e,{label:i})}(hw(e,o,n,{renderForEditingView:!0}),e,i("media widget"))}}),n.for("editingDowncast").add(cw(o,{renderForEditingView:!0})),n.for("upcast").elementToElement({view:{name:"oembed",attributes:{url:!0}},model:(t,e)=>{const i=t.getAttribute("url");if(o.hasMedia(i))return e.createElement("media",{url:i})}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(t,e)=>{const i=t.getAttribute("data-oembed-url");if(o.hasMedia(i))return e.createElement("media",{url:i})}})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const vw=/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]+$/;class yw extends nh{static get requires(){return[ah,id]}static get pluginName(){return"AutoMediaEmbed"}constructor(t){super(t),this._timeoutId=null,this._positionToInsert=null}init(){const t=this.editor,e=t.model.document;this.listenTo(t.plugins.get(ah),"inputTransformation",()=>{const t=e.selection.getFirstRange(),i=Ll.fromPosition(t.start);i.stickiness="toPrevious";const n=Ll.fromPosition(t.end);n.stickiness="toNext",e.once("change:data",()=>{this._embedMediaBetweenPositions(i,n),i.detach(),n.detach()},{priority:"high"})}),t.commands.get("undo").on("execute",()=>{this._timeoutId&&(no.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedMediaBetweenPositions(t,e){const i=this.editor,n=i.plugins.get(_w).registry,s=new ra(t,e),o=s.getWalker({ignoreElementEnd:!0});let r="";for(const t of o)t.item.is("textProxy")&&(r+=t.item.data);if(!(r=r.trim()).match(vw))return;if(!n.hasMedia(r))return;i.commands.get("mediaEmbed").isEnabled&&(this._positionToInsert=Ll.fromPosition(t),this._timeoutId=no.window.setTimeout(()=>{i.model.change(t=>{let e;this._timeoutId=null,t.remove(s),"$graveyard"!==this._positionToInsert.root.rootName&&(e=this._positionToInsert),uw(i.model,r,e),this._positionToInsert.detach(),this._positionToInsert=null})},100))}}i(51);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class kw extends jc{constructor(t,e){super(e);const i=e.t;this.focusTracker=new uc,this.keystrokes=new nc,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),hf,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),df,"ck-button-cancel","cancel"),this._focusables=new yc,this._focusCycler=new Qc({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._validators=t,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form"],tabindex:"-1"},children:[this.urlInputView,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),cf({view:this}),[this.urlInputView,this.saveButtonView,this.cancelButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)}),this.keystrokes.listenTo(this.element);const t=t=>t.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t),this.listenTo(this.urlInputView.element,"selectstart",(t,e)=>{e.stopPropagation()},{priority:"high"})}focus(){this._focusCycler.focusFirst()}get url(){return this.urlInputView.inputView.element.value.trim()}set url(t){this.urlInputView.inputView.element.value=t.trim()}isValid(){this.resetFormStatus();for(const t of this._validators){const e=t(this);if(e)return this.urlInputView.errorText=e,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const t=this.locale.t,e=new af(this.locale,lf),i=e.inputView;return this._urlInputViewInfoDefault=t("Paste the media URL in the input."),this._urlInputViewInfoTip=t("Tip: Paste the URL into the content to embed faster."),e.label=t("Media URL"),e.infoText=this._urlInputViewInfoDefault,i.placeholder="https://example.com",i.on("input",()=>{e.infoText=i.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault}),e}_createButton(t,e,i,n){const s=new Xh(this.locale);return s.set({label:t,icon:e,tooltip:!0}),s.extendTemplate({attributes:{class:i}}),n&&s.delegate("execute").to(this,n),s}}var Aw='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M18.68 2.53c.6 0 .59-.03.59.55v12.84c0 .59.01.56-.59.56H1.29c-.6 0-.59.03-.59-.56V3.08c0-.58-.01-.55.6-.55h17.38zM15.77 14.5v-10H4.2v10h11.57zM2 4v1h1V4H2zm0 2v1h1V6H2zm0 2v1h1V8H2zm0 2v1h1v-1H2zm0 2v1h1v-1H2zm0 2v1h1v-1H2zM17 4v1h1V4h-1zm0 2v1h1V6h-1zm0 2v1h1V8h-1zm0 2v1h1v-1h-1zm0 2v1h1v-1h-1zm0 2v1h1v-1h-1zM7.5 6.677a.4.4 0 0 1 .593-.351l5.133 2.824a.4.4 0 0 1 0 .7l-5.133 2.824a.4.4 0 0 1-.593-.35V6.676z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Cw extends nh{static get requires(){return[_w]}static get pluginName(){return"MediaEmbedUI"}init(){const t=this.editor,e=t.commands.get("mediaEmbed"),i=t.plugins.get(_w).registry;this.form=new kw(function(t,e){return[e=>{if(!e.url.length)return t("The URL must not be empty.")},i=>{if(!e.hasMedia(i.url))return t("This media URL is not supported.")}]}(t.t,i),t.locale),t.ui.componentFactory.add("mediaEmbed",i=>{const n=Eu(i);return this._setUpDropdown(n,this.form,e,t),this._setUpForm(this.form,n,e),n})}_setUpDropdown(t,e,i){const n=this.editor,s=n.t,o=t.buttonView;function r(){n.editing.view.focus(),t.isOpen=!1}t.bind("isEnabled").to(i),t.panelView.children.add(e),o.set({label:s("Insert media"),icon:Aw,tooltip:!0}),o.on("open",()=>{e.url=i.value||"",e.urlInputView.select(),e.focus()},{priority:"low"}),t.on("submit",()=>{e.isValid()&&(n.execute("mediaEmbed",e.url),r())}),t.on("change:isOpen",()=>e.resetFormStatus()),t.on("cancel",()=>r())}_setUpForm(t,e,i){t.delegate("submit","cancel").to(e),t.urlInputView.bind("value").to(i,"value"),t.urlInputView.bind("isReadOnly").to(i,"isEnabled",t=>!t),t.saveButtonView.bind("isEnabled").to(i)}}i(52);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */var xw='<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>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */const Pw="removeFormat";class Tw extends nh{static get pluginName(){return"RemoveFormatUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(Pw,i=>{const n=t.commands.get(Pw),s=new Xh(i);return s.set({label:e("Remove Format"),icon:xw,tooltip:!0}),s.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(s,"execute",()=>t.execute(Pw)),s})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Ew extends lh{refresh(){const t=this.editor.model;this.isEnabled=!!Xd(this._getFormattingItems(t.document.selection,t.schema))}execute(){const t=this.editor.model,e=t.schema;t.change(i=>{for(const n of this._getFormattingItems(t.document.selection,e))if(n.is("selection"))for(const t of this._getFormattingAttributes(n,e))i.removeSelectionAttribute(t);else{const t=i.createRangeOn(n);for(const s of this._getFormattingAttributes(n,e))i.removeAttribute(s,t)}})}*_getFormattingItems(t,e){const i=t=>!!Xd(this._getFormattingAttributes(t,e));for(const e of t.getRanges())for(const t of e.getItems())i(t)&&(yield t);i(t)&&(yield t)}*_getFormattingAttributes(t,e){for(const[i]of t.getAttributes()){const t=e.getAttributeProperties(i);t&&t.isFormatting&&(yield i)}}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Sw extends nh{static get pluginName(){return"RemoveFormatEditing"}init(){const t=this.editor;t.commands.add("removeFormat",new Ew(t))}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
function Rw(t,e){let i=e.parent;for(;i;){if(i.name===t)return i;i=i.parent}}function Ow(t,e,i,n,s=1){e>s?n.setAttribute(t,e,i):n.removeAttribute(t,i)}function Iw(t,e,i={}){const n=t.createElement("tableCell",i);t.insertElement("paragraph",n),t.insert(n,e)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Mw(){return t=>{t.on("element:table",(t,e,i)=>{const n=e.viewItem;if(!i.consumable.test(n,{name:!0}))return;const{rows:s,headingRows:o,headingColumns:r}=function(t){const e={headingRows:0,headingColumns:0},i=[],n=[];let s;for(const o of Array.from(t.getChildren()))if("tbody"===o.name||"thead"===o.name||"tfoot"===o.name){"thead"!==o.name||s||(s=o);const t=Array.from(o.getChildren()).filter(t=>t.is("element","tr"));for(const o of t)if("thead"===o.parent.name&&o.parent===s)e.headingRows++,i.push(o);else{n.push(o);const t=Nw(o);t>e.headingColumns&&(e.headingColumns=t)}}return e.rows=[...i,...n],e}(n),a={};r&&(a.headingColumns=r),o&&(a.headingRows=o);const l=i.writer.createElement("table",a),c=i.splitToAllowedParent(l,e.modelCursor);if(c){if(i.writer.insert(l,c.position),i.consumable.consume(n,{name:!0}),s.length)s.forEach(t=>i.convertItem(t,i.writer.createPositionAt(l,"end")));else{const t=i.writer.createElement("tableRow");i.writer.insert(t,i.writer.createPositionAt(l,"end")),Iw(i.writer,i.writer.createPositionAt(t,"end"))}e.modelRange=i.writer.createRange(i.writer.createPositionBefore(l),i.writer.createPositionAfter(l)),c.cursorParent?e.modelCursor=i.writer.createPositionAt(c.cursorParent,0):e.modelCursor=e.modelRange.end}})}}function Vw(t){return e=>{e.on(`element:${t}`,(t,e,i)=>{const n=e.viewItem;if(!i.consumable.test(n,{name:!0}))return;const s=i.writer.createElement("tableCell"),o=i.splitToAllowedParent(s,e.modelCursor);if(!o)return;i.writer.insert(s,o.position),i.consumable.consume(n,{name:!0});const r=i.writer.createPositionAt(s,0);i.convertChildren(n,r),s.childCount||i.writer.insertElement("paragraph",r),e.modelRange=i.writer.createRange(i.writer.createPositionBefore(s),i.writer.createPositionAfter(s)),e.modelCursor=e.modelRange.end})}}function Nw(t){let e=0,i=0;const n=Array.from(t.getChildren()).filter(t=>"th"===t.name||"td"===t.name);for(;i<n.length&&"th"===n[i].name;){const t=n[i];e+=parseInt(t.getAttribute("colspan")||1),i++}return e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Bw{constructor(t,e={}){this.table=t,this.startRow=e.startRow||0,this.endRow="number"==typeof e.endRow?e.endRow:void 0,this.includeSpanned=!!e.includeSpanned,this.column="number"==typeof e.column?e.column:void 0,this._skipRows=new Set,this._row=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){const t=this.table.getChild(this._row);if(!t||this._isOverEndRow())return{done:!0};let e,i,n;if(this._isSpanned(this._row,this._column))e=this._getSpanned(this._row,this._column),i=!this.includeSpanned||this._shouldSkipRow()||this._shouldSkipColumn(),n=this._formatOutValue(e,this._column,!0);else{if(!(e=t.getChild(this._cellIndex)))return this._row++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next();const s=parseInt(e.getAttribute("colspan")||1),o=parseInt(e.getAttribute("rowspan")||1);(s>1||o>1)&&this._recordSpans(this._row,this._column,o,s,e),this._nextCellAtColumn=this._column+s,i=this._shouldSkipRow()||this._shouldSkipColumn(),n=this._formatOutValue(e,this._column,!1,o,s)}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,i?this.next():n}skipRow(t){this._skipRows.add(t)}_isOverEndRow(){return void 0!==this.endRow&&this._row>this.endRow}_formatOutValue(t,e,i,n=1,s=1){return{done:!1,value:{cell:t,row:this._row,column:e,isSpanned:i,rowspan:n,colspan:s,cellIndex:this._cellIndex}}}_shouldSkipRow(){const t=this._row<this.startRow,e=this._skipRows.has(this._row);return t||e}_shouldSkipColumn(){return void 0!==this.column&&this.column!=this._column}_isSpanned(t,e){if(!this._spannedCells.has(t))return!1;return this._spannedCells.get(t).has(e)}_getSpanned(t,e){return this._spannedCells.get(t).get(e)}_recordSpans(t,e,i,n,s){for(let i=e+1;i<=e+n-1;i++)this._markSpannedCell(t,i,s);for(let o=t+1;o<t+i;o++)for(let t=e;t<=e+n-1;t++)this._markSpannedCell(o,t,s)}_markSpannedCell(t,e,i){this._spannedCells.has(t)||this._spannedCells.set(t,new Map),this._spannedCells.get(t).set(e,i)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Fw(t){return!!t.getCustomProperty("table")&&Hu(t)}function Dw(t){const e=t.getSelectedElement();return e&&Fw(e)?e:null}function Lw(t){const e=Rw("table",t.getFirstPosition());return e&&Fw(e.parent)?e.parent:null}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function zw(t={}){return e=>e.on("insert:table",(e,i,n)=>{const s=i.item;if(!n.consumable.consume(s,"insert"))return;n.consumable.consume(s,"attribute:headingRows:table"),n.consumable.consume(s,"attribute:headingColumns:table");const o=t&&t.asWidget,r=n.writer.createContainerElement("figure",{class:"table"}),a=n.writer.createContainerElement("table");let l;n.writer.insert(n.writer.createPositionAt(r,0),a),o&&(l=function(t,e){return e.setCustomProperty("table",!0,t),ju(t,e,{hasSelectionHandler:!0})}(r,n.writer));const c=new Bw(s),h={headingRows:s.getAttribute("headingRows")||0,headingColumns:s.getAttribute("headingColumns")||0},d=new Map;for(const e of c){const{row:i,cell:o}=e,r=Qw(Yw(i,h),a,n),l=s.getChild(i),c=d.get(i)||Kw(l,i,r,n);d.set(i,c),n.consumable.consume(o,"insert"),Gw(e,h,n.writer.createPositionAt(c,"end"),n,t)}const u=n.mapper.toViewPosition(i.range.start);n.mapper.bindElements(s,o?l:r),n.writer.insert(u,o?l:r)})}function Hw(t={}){return e=>e.on("insert:tableRow",(e,i,n)=>{const s=i.item;if(!n.consumable.consume(s,"insert"))return;const o=s.parent,r=eb(n.mapper.toViewElement(o)),a=o.getChildIndex(s),l=new Bw(o,{startRow:a,endRow:a}),c={headingRows:o.getAttribute("headingRows")||0,headingColumns:o.getAttribute("headingColumns")||0},h=new Map;for(const e of l){const i=Qw(Yw(a,c),r,n),o=h.get(a)||Kw(s,a,i,n);h.set(a,o),n.consumable.consume(e.cell,"insert"),Gw(e,c,n.writer.createPositionAt(o,"end"),n,t)}})}function jw(t={}){return e=>e.on("insert:tableCell",(e,i,n)=>{const s=i.item;if(!n.consumable.consume(s,"insert"))return;const o=s.parent,r=o.parent,a=r.getChildIndex(o),l=new Bw(r,{startRow:a,endRow:a}),c={headingRows:r.getAttribute("headingRows")||0,headingColumns:r.getAttribute("headingColumns")||0};for(const e of l)if(e.cell===s){const i=n.mapper.toViewElement(o);return void Gw(e,c,n.writer.createPositionAt(i,o.getChildIndex(s)),n,t)}})}function qw(t={}){const e=!!t.asWidget;return t=>t.on("attribute:headingRows:table",(t,i,n)=>{const s=i.item;if(!n.consumable.consume(i.item,t.name))return;const o=eb(n.mapper.toViewElement(s)),r=i.attributeOldValue,a=i.attributeNewValue;if(a>r){const t=Array.from(s.getChildren()).filter(({index:t})=>l(t,r-1,a));tb(t,Qw("thead",o,n),n,"end");for(const i of t)for(const t of i.getChildren())Uw(t,"th",n,e);Zw("tbody",o,n)}else{tb(Array.from(s.getChildren()).filter(({index:t})=>l(t,a-1,r)).reverse(),Qw("tbody",o,n),n,0);const t=new Bw(s,{startRow:a?a-1:a,endRow:r-1}),i={headingRows:s.getAttribute("headingRows")||0,headingColumns:s.getAttribute("headingColumns")||0};for(const s of t)$w(s,i,n,e);Zw("thead",o,n)}function l(t,e,i){return t>e&&t<i}})}function Ww(t={}){const e=!!t.asWidget;return t=>t.on("attribute:headingColumns:table",(t,i,n)=>{const s=i.item;if(!n.consumable.consume(i.item,t.name))return;const o={headingRows:s.getAttribute("headingRows")||0,headingColumns:s.getAttribute("headingColumns")||0},r=i.attributeOldValue,a=i.attributeNewValue,l=(r>a?r:a)-1;for(const t of new Bw(s))t.column>l||$w(t,o,n,e)})}function Uw(t,e,i,n){const s=i.writer,o=i.mapper.toViewElement(t);if(!o)return;let r;if(n){r=Wu(s.createEditableElement(e,o.getAttributes()),s),s.insert(s.createPositionAfter(o),r),s.move(s.createRangeIn(o),s.createPositionAt(r,0)),s.remove(s.createRangeOn(o))}else r=s.rename(e,o);i.mapper.unbindViewElement(o),i.mapper.bindElements(t,r)}function $w(t,e,i,n){const{cell:s}=t,o=Jw(t,e),r=i.mapper.toViewElement(s);r&&r.name!==o&&Uw(s,o,i,n)}function Gw(t,e,i,n,s){const o=s&&s.asWidget,r=Jw(t,e),a=o?Wu(n.writer.createEditableElement(r),n.writer):n.writer.createContainerElement(r),l=t.cell,c=l.getChild(0),h=1===l.childCount&&"paragraph"===c.name;if(n.writer.insert(i,a),h&&![...c.getAttributeKeys()].length){const t=l.getChild(0),e=n.writer.createPositionAt(a,"end");if(n.consumable.consume(t,"insert"),s.asWidget){const i=n.writer.createContainerElement("span");n.mapper.bindElements(t,i),n.writer.insert(e,i),n.mapper.bindElements(l,a)}else n.mapper.bindElements(l,a),n.mapper.bindElements(t,a)}else n.mapper.bindElements(l,a)}function Kw(t,e,i,n){n.consumable.consume(t,"insert");const s=n.writer.createContainerElement("tr");n.mapper.bindElements(t,s);const o=t.parent.getAttribute("headingRows")||0,r=o>0&&e>=o?e-o:e,a=n.writer.createPositionAt(i,r);return n.writer.insert(a,s),s}function Jw(t,e){const{row:i,column:n}=t,{headingColumns:s,headingRows:o}=e;return o&&o>i?"th":s&&s>n?"th":"td"}function Yw(t,e){return t<e.headingRows?"thead":"tbody"}function Qw(t,e,i){const n=Xw(t,e);return n||function(t,e,i){const n=i.writer.createContainerElement(t),s=i.writer.createPositionAt(e,"tbody"==t?"end":0);return i.writer.insert(s,n),n}(t,e,i)}function Xw(t,e){for(const i of e.getChildren())if(i.name==t)return i}function Zw(t,e,i){const n=Xw(t,e);n&&0===n.childCount&&i.writer.remove(i.writer.createRangeOn(n))}function tb(t,e,i,n){for(const s of t){const t=i.mapper.toViewElement(s);t&&i.writer.move(i.writer.createRangeOn(t),i.writer.createPositionAt(e,n))}}function eb(t){for(const e of t.getChildren())if("table"===e.name)return e}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class ib extends lh{refresh(){const t=this.editor.model,e=t.document.selection,i=t.schema,n=function(t){const e=t.parent;return e===e.root?e:e.parent}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(e.getFirstPosition());this.isEnabled=i.checkChild(n,"table")}execute(t={}){const e=this.editor.model,i=e.document.selection,n=this.editor.plugins.get("TableUtils"),s=parseInt(t.rows)||2,o=parseInt(t.columns)||2,r=Uu(i,e);e.change(t=>{const i=n.createTable(t,s,o);e.insertContent(i,r),t.setSelection(t.createPositionAt(i.getNodeByPath([0,0,0]),0))})}}class nb extends lh{constructor(t,e={}){super(t),this.order=e.order||"below"}refresh(){const t=Rw("table",this.editor.model.document.selection.getFirstPosition());this.isEnabled=!!t}execute(){const t=this.editor,e=t.model.document.selection,i=t.plugins.get("TableUtils"),n=Rw("tableCell",e.getFirstPosition()).parent,s=n.parent,o=s.getChildIndex(n),r="below"===this.order?o+1:o;i.insertRows(s,{rows:1,at:r})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class sb extends lh{constructor(t,e={}){super(t),this.order=e.order||"right"}refresh(){const t=Rw("table",this.editor.model.document.selection.getFirstPosition());this.isEnabled=!!t}execute(){const t=this.editor,e=t.model.document.selection,i=t.plugins.get("TableUtils"),n=Rw("tableCell",e.getFirstPosition()),s=n.parent.parent,{column:o}=i.getCellLocation(n),r="right"===this.order?o+1:o;i.insertColumns(s,{columns:1,at:r})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ob extends lh{constructor(t,e={}){super(t),this.direction=e.direction||"horizontally"}refresh(){const t=Rw("tableCell",this.editor.model.document.selection.getFirstPosition());this.isEnabled=!!t}execute(){const t=Rw("tableCell",this.editor.model.document.selection.getFirstPosition()),e="horizontally"===this.direction,i=this.editor.plugins.get("TableUtils");e?i.splitCellHorizontally(t,2):i.splitCellVertically(t,2)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class rb extends lh{constructor(t,e){super(t),this.direction=e.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const t=this._getMergeableCell();this.isEnabled=!!t,this.value=t}execute(){const t=this.editor.model,e=Rw("tableCell",t.document.selection.getFirstPosition()),i=this.value,n=this.direction;t.change(t=>{const s="right"==n||"down"==n,o=s?e:i,r=s?i:e,a=r.parent;!function(t,e,i){ab(t)||(ab(e)&&i.remove(i.createRangeIn(e)),i.move(i.createRangeIn(t),i.createPositionAt(e,"end")));i.remove(t)}(r,o,t);const l=this.isHorizontal?"colspan":"rowspan",c=parseInt(e.getAttribute(l)||1),h=parseInt(i.getAttribute(l)||1);t.setAttribute(l,c+h,o),t.setSelection(t.createRangeIn(o)),a.childCount||function(t,e){const i=t.parent,n=i.getChildIndex(t);for(const{cell:t,row:s,rowspan:o}of new Bw(i,{endRow:n})){s+o-1>=n&&Ow("rowspan",o-1,t,e)}e.remove(t)}(a,t)})}_getMergeableCell(){const t=Rw("tableCell",this.editor.model.document.selection.getFirstPosition());if(!t)return;const e=this.editor.plugins.get("TableUtils"),i=this.isHorizontal?function(t,e,i){const n="right"==e?t.nextSibling:t.previousSibling;if(!n)return;const s="right"==e?t:n,o="right"==e?n:t,{column:r}=i.getCellLocation(s),{column:a}=i.getCellLocation(o),l=parseInt(s.getAttribute("colspan")||1);return r+l===a?n:void 0}(t,this.direction,e):function(t,e){const i=t.parent,n=i.parent,s=n.getChildIndex(i);if("down"==e&&s===n.childCount-1||"up"==e&&0===s)return;const o=parseInt(t.getAttribute("rowspan")||1),r=n.getAttribute("headingRows")||0,a="down"==e&&s+o===r,l="up"==e&&s===r;if(r&&(a||l))return;const c=parseInt(t.getAttribute("rowspan")||1),h="down"==e?s+c:s,d=[...new Bw(n,{endRow:h})],u=d.find(e=>e.cell===t).column,f=d.find(({row:t,rowspan:i,column:n})=>n===u&&("down"==e?t===h:h===t+i));return f&&f.cell}(t,this.direction);if(!i)return;const n=this.isHorizontal?"rowspan":"colspan",s=parseInt(t.getAttribute(n)||1);return parseInt(i.getAttribute(n)||1)===s?i:void 0}}function ab(t){return 1==t.childCount&&t.getChild(0).is("paragraph")&&t.getChild(0).isEmpty}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class lb extends lh{refresh(){const t=Rw("tableCell",this.editor.model.document.selection.getFirstPosition());this.isEnabled=!!t&&t.parent.parent.childCount>1}execute(){const t=this.editor.model,e=Rw("tableCell",t.document.selection.getFirstPosition()).parent,i=e.parent,n=i.getChildIndex(e),s=i.getAttribute("headingRows")||0;t.change(t=>{s&&n<=s&&Ow("headingRows",s-1,i,t,0);const o=[...new Bw(i,{endRow:n})],r=new Map;o.filter(({row:t,rowspan:e})=>t===n&&e>1).forEach(({column:t,cell:e,rowspan:i})=>r.set(t,{cell:e,rowspanToSet:i-1})),o.filter(({row:t,rowspan:e})=>t<=n-1&&t+e>n).forEach(({cell:e,rowspan:i})=>Ow("rowspan",i-1,e,t));const a=n+1,l=new Bw(i,{includeSpanned:!0,startRow:a,endRow:a});let c;for(const{row:e,column:n,cell:s}of[...l])if(r.has(n)){const{cell:s,rowspanToSet:o}=r.get(n),a=c?t.createPositionAfter(c):t.createPositionAt(i.getChild(e),0);t.move(t.createRangeOn(s),a),Ow("rowspan",o,s,t),c=s}else c=s;t.remove(e)})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class cb extends lh{refresh(){const t=this.editor,e=t.model.document.selection,i=t.plugins.get("TableUtils"),n=Rw("tableCell",e.getFirstPosition());this.isEnabled=!!n&&i.getColumns(n.parent.parent)>1}execute(){const t=this.editor.model,e=Rw("tableCell",t.document.selection.getFirstPosition()),i=e.parent,n=i.parent,s=n.getAttribute("headingColumns")||0,o=n.getChildIndex(i),r=[...new Bw(n)],a=r.find(t=>t.cell===e).column;t.change(t=>{s&&o<=s&&t.setAttribute("headingColumns",s-1,n);for(const{cell:e,column:i,colspan:n}of r)i<=a&&n>1&&i+n>a?Ow("colspan",n-1,e,t):i===a&&t.remove(e)})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class hb extends lh{refresh(){const t=Rw("tableCell",this.editor.model.document.selection.getFirstPosition()),e=!!t;this.isEnabled=e,this.value=e&&this._isInHeading(t,t.parent.parent)}execute(t={}){const e=this.editor.model,i=Rw("tableCell",e.document.selection.getFirstPosition()).parent,n=i.parent,s=n.getAttribute("headingRows")||0,o=i.index;if(t.forceValue===this.value)return;const r=this.value?o:o+1;e.change(t=>{if(r){const e=function(t,e,i){const n=[],s=new Bw(t,{startRow:e>i?i:0,endRow:e-1});for(const{row:t,rowspan:i,cell:o}of s)i>1&&t+i>e&&n.push(o);return n}(n,r,s);for(const i of e)db(i,r,t)}Ow("headingRows",r,n,t,0)})}_isInHeading(t,e){const i=parseInt(e.getAttribute("headingRows")||0);return!!i&&t.parent.index<i}}function db(t,e,i){const n=t.parent,s=n.parent,o=e-n.index,r={},a=parseInt(t.getAttribute("rowspan"))-o;a>1&&(r.rowspan=a);const l=parseInt(t.getAttribute("colspan")||1);l>1&&(r.colspan=l);const c=s.getChildIndex(n),h=c+o,d=[...new Bw(s,{startRow:c,endRow:h,includeSpanned:!0})];let u;for(const{row:e,column:n,cell:o,cellIndex:a}of d)if(o===t&&void 0===u&&(u=n),void 0!==u&&u===n&&e===h){const t=s.getChild(e),n=i.createPositionAt(t,a);Iw(i,n,r)}Ow("rowspan",o,t,i)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class ub extends lh{refresh(){const t=Rw("tableCell",this.editor.model.document.selection.getFirstPosition()),e=!!t;this.isEnabled=e,this.value=e&&this._isInHeading(t,t.parent.parent)}execute(t={}){const e=this.editor.model,i=e.document.selection,n=this.editor.plugins.get("TableUtils"),s=Rw("tableCell",i.getFirstPosition()),o=s.parent.parent,{column:r}=n.getCellLocation(s);if(t.forceValue===this.value)return;const a=this.value?r:r+1;e.change(t=>{Ow("headingColumns",a,o,t,0)})}_isInHeading(t,e){const i=parseInt(e.getAttribute("headingColumns")||0),n=this.editor.plugins.get("TableUtils"),{column:s}=n.getCellLocation(t);return!!i&&s<i}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class fb extends nh{static get pluginName(){return"TableUtils"}getCellLocation(t){const e=t.parent,i=e.parent,n=i.getChildIndex(e),s=new Bw(i,{startRow:n,endRow:n});for(const{cell:e,row:i,column:n}of s)if(e===t)return{row:i,column:n}}createTable(t,e,i){const n=t.createElement("table");return mb(t,n,0,e,i),n}insertRows(t,e={}){const i=this.editor.model,n=e.at||0,s=e.rows||1;i.change(e=>{const i=t.getAttribute("headingRows")||0;if(i>n&&e.setAttribute("headingRows",i+s,t),0===n||n===t.childCount)return void mb(e,t,n,s,this.getColumns(t));const o=new Bw(t,{endRow:n});let r=0;for(const{row:t,rowspan:i,colspan:a,cell:l}of o){const o=t+i>n;t<n&&o&&e.setAttribute("rowspan",i+s,l),t===n&&(r+=a)}mb(e,t,n,s,r)})}insertColumns(t,e={}){const i=this.editor.model,n=e.at||0,s=e.columns||1;i.change(e=>{const i=t.getAttribute("headingColumns");n<i&&e.setAttribute("headingColumns",i+s,t);const o=this.getColumns(t);if(0===n||o===n){for(const i of t.getChildren())gb(s,e,e.createPositionAt(i,n?"end":0));return}const r=new Bw(t,{column:n,includeSpanned:!0});for(const{row:i,cell:o,cellIndex:a}of r){const l=parseInt(o.getAttribute("rowspan")||1),c=parseInt(o.getAttribute("colspan")||1);if(o.index!==n&&c>1){if(e.setAttribute("colspan",c+s,o),r.skipRow(i),l>1)for(let t=i+1;t<i+l;t++)r.skipRow(t)}else{const n=e.createPositionAt(t.getChild(i),a);gb(s,e,n)}}})}splitCellVertically(t,e=2){const i=this.editor.model,n=t.parent.parent,s=parseInt(t.getAttribute("rowspan")||1),o=parseInt(t.getAttribute("colspan")||1);i.change(i=>{if(o>1){const{newCellsSpan:n,updatedSpan:r}=pb(o,e);Ow("colspan",r,t,i);const a={};n>1&&(a.colspan=n),s>1&&(a.rowspan=s),gb(o>e?e-1:o-1,i,i.createPositionAfter(t),a)}if(o<e){const r=e-o,a=[...new Bw(n)],{column:l}=a.find(({cell:e})=>e===t),c=a.filter(({cell:e,colspan:i,column:n})=>{return e!==t&&n===l||n<l&&n+i>l});for(const{cell:t,colspan:e}of c)i.setAttribute("colspan",e+r,t);const h={};s>1&&(h.rowspan=s),gb(r,i,i.createPositionAfter(t),h);const d=n.getAttribute("headingColumns")||0;d>l&&Ow("headingColumns",d+r,n,i)}})}splitCellHorizontally(t,e=2){const i=this.editor.model,n=t.parent,s=n.parent,o=s.getChildIndex(n),r=parseInt(t.getAttribute("rowspan")||1),a=parseInt(t.getAttribute("colspan")||1);i.change(i=>{if(r>1){const n=[...new Bw(s,{startRow:o,endRow:o+r-1,includeSpanned:!0})],{newCellsSpan:l,updatedSpan:c}=pb(r,e);Ow("rowspan",c,t,i);const{column:h}=n.find(({cell:e})=>e===t),d={};l>1&&(d.rowspan=l),a>1&&(d.colspan=a);for(const{column:t,row:e,cellIndex:r}of n){const n=t===h,a=(e+o+c)%l==0;if(e>=o+c&&n&&a){const t=i.createPositionAt(s.getChild(e),r);gb(1,i,t,d)}}}if(r<e){const n=e-r,l=[...new Bw(s,{startRow:0,endRow:o})];for(const{cell:e,rowspan:s,row:r}of l)if(e!==t&&r+s>o){const t=s+n;i.setAttribute("rowspan",t,e)}const c={};a>1&&(c.colspan=a),mb(i,s,o+1,n,1,c);const h=s.getAttribute("headingRows")||0;h>o&&Ow("headingRows",h+n,s,i)}})}getColumns(t){return[...t.getChild(0).getChildren()].reduce((t,e)=>{return t+parseInt(e.getAttribute("colspan")||1)},0)}}function mb(t,e,i,n,s,o={}){for(let r=0;r<n;r++){const n=t.createElement("tableRow");t.insert(n,e,i),gb(s,t,t.createPositionAt(n,"end"),o)}}function gb(t,e,i,n={}){for(let s=0;s<t;s++)Iw(e,i,n)}function pb(t,e){if(t<e)return{newCellsSpan:1,updatedSpan:1};const i=Math.floor(t/e);return{newCellsSpan:i,updatedSpan:t-i*e+i}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function wb(t){t.document.registerPostFixer(e=>(function(t,e){const i=e.document.differ.getChanges();let n=!1;const s=new Set;for(const e of i){let i;"table"==e.name&&"insert"==e.type&&(i=e.position.nodeAfter),"tableRow"!=e.name&&"tableCell"!=e.name||(i=Rw("table",e.position)),vb(e)&&(i=Rw("table",e.range.start)),i&&!s.has(i)&&(n=bb(i,t)||n,n=_b(i,t)||n,s.add(i))}return n})(e,t))}function bb(t,e){let i=!1;const n=function(t){const e=parseInt(t.getAttribute("headingRows")||0),i=t.childCount,n=[];for(const{row:s,rowspan:o,cell:r}of new Bw(t)){if(o<2)continue;const t=s<e?e:i;if(s+o>t){const e=t-s;n.push({cell:r,rowspan:e})}}return n}(t);if(n.length){i=!0;for(const t of n)Ow("rowspan",t.rowspan,t.cell,e,1)}return i}function _b(t,e){let i=!1;const n=function(t){const e={};for(const{row:i}of new Bw(t,{includeSpanned:!0}))e[i]||(e[i]=0),e[i]+=1;return e}(t),s=n[0];if(!Object.values(n).every(t=>t===s)){const s=Object.values(n).reduce((t,e)=>e>t?e:t,0);for(const[o,r]of Object.entries(n)){const n=s-r;if(n){for(let i=0;i<n;i++)Iw(e,e.createPositionAt(t.getChild(o),"end"));i=!0}}}return i}function vb(t){const e="attribute"===t.type,i=t.attributeKey;return e&&("headingRows"===i||"colspan"===i||"rowspan"===i)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function yb(t){t.document.registerPostFixer(e=>(function(t,e){const i=e.document.differ.getChanges();let n=!1;for(const e of i)"insert"==e.type&&"table"==e.name&&(n=kb(e.position.nodeAfter,t)||n),"insert"==e.type&&"tableRow"==e.name&&(n=Ab(e.position.nodeAfter,t)||n),"insert"==e.type&&"tableCell"==e.name&&(n=Cb(e.position.nodeAfter,t)||n),xb(e)&&(n=Cb(e.position.parent,t)||n);return n})(e,t))}function kb(t,e){let i=!1;for(const n of t.getChildren())i=Ab(n,e)||i;return i}function Ab(t,e){let i=!1;for(const n of t.getChildren())i=Cb(n,e)||i;return i}function Cb(t,e){if(0==t.childCount)return e.insertElement("paragraph",t),!0;const i=Array.from(t.getChildren()).filter(t=>t.is("text"));for(const t of i)e.wrap(e.createRangeOn(t),"paragraph");return!!i.length}function xb(t){return!(!t.position||!t.position.parent.is("tableCell"))&&("insert"==t.type&&"$text"==t.name||"remove"==t.type)}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function Pb(t){t.document.registerPostFixer(()=>(function(t){const e=t.document.differ,i=new Set;for(const t of e.getChanges()){const e="insert"==t.type||"remove"==t.type?t.position.parent:t.range.start.parent;e.is("tableCell")&&Tb(e,t.type)&&i.add(e)}if(i.size){for(const t of i.values())e.refreshItem(t);return!0}return!1})(t))}function Tb(t,e){if(!Array.from(t.getChildren()).some(t=>t.is("paragraph")))return!1;if("attribute"==e){const e=Array.from(t.getChild(0).getAttributeKeys()).length;return 1===t.childCount&&e<2}return t.childCount<=("insert"==e?2:1)}i(53);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Eb extends nh{init(){const t=this.editor,e=t.model,i=e.schema,n=t.conversion;i.register("table",{allowWhere:"$block",allowAttributes:["headingRows","headingColumns"],isLimit:!0,isObject:!0,isBlock:!0}),i.register("tableRow",{allowIn:"table",isLimit:!0}),i.register("tableCell",{allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0}),i.extend("$block",{allowIn:"tableCell"}),i.addChildCheck((t,e)=>{if("table"==e.name&&Array.from(t.getNames()).includes("table"))return!1}),n.for("upcast").add(Mw()),n.for("editingDowncast").add(zw({asWidget:!0})),n.for("dataDowncast").add(zw()),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("editingDowncast").add(Hw({asWidget:!0})),n.for("dataDowncast").add(Hw()),n.for("downcast").add(t=>t.on("remove:tableRow",(t,e,i)=>{t.stop();const n=i.writer,s=i.mapper,o=s.toViewPosition(e.position).getLastMatchingPosition(t=>!t.item.is("tr")).nodeAfter,r=o.parent,a=n.createRangeOn(o),l=n.remove(a);for(const t of n.createRangeIn(l).getItems())s.unbindViewElement(t);r.childCount||n.remove(n.createRangeOn(r))},{priority:"higher"})),n.for("upcast").add(Vw("td")),n.for("upcast").add(Vw("th")),n.for("editingDowncast").add(jw({asWidget:!0})),n.for("dataDowncast").add(jw()),n.attributeToAttribute({model:"colspan",view:"colspan"}),n.attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("editingDowncast").add(Ww({asWidget:!0})),n.for("dataDowncast").add(Ww()),n.for("editingDowncast").add(qw({asWidget:!0})),n.for("dataDowncast").add(qw()),t.commands.add("insertTable",new ib(t)),t.commands.add("insertTableRowAbove",new nb(t,{order:"above"})),t.commands.add("insertTableRowBelow",new nb(t,{order:"below"})),t.commands.add("insertTableColumnLeft",new sb(t,{order:"left"})),t.commands.add("insertTableColumnRight",new sb(t,{order:"right"})),t.commands.add("removeTableRow",new lb(t)),t.commands.add("removeTableColumn",new cb(t)),t.commands.add("splitTableCellVertically",new ob(t,{direction:"vertically"})),t.commands.add("splitTableCellHorizontally",new ob(t,{direction:"horizontally"})),t.commands.add("mergeTableCellRight",new rb(t,{direction:"right"})),t.commands.add("mergeTableCellLeft",new rb(t,{direction:"left"})),t.commands.add("mergeTableCellDown",new rb(t,{direction:"down"})),t.commands.add("mergeTableCellUp",new rb(t,{direction:"up"})),t.commands.add("setTableColumnHeader",new ub(t)),t.commands.add("setTableRowHeader",new hb(t)),wb(e),Pb(e),yb(e),this.editor.keystrokes.set("Tab",(...t)=>this._handleTabOnSelectedTable(...t),{priority:"low"}),this.editor.keystrokes.set("Tab",this._getTabHandler(!0),{priority:"low"}),this.editor.keystrokes.set("Shift+Tab",this._getTabHandler(!1),{priority:"low"})}static get requires(){return[fb]}_handleTabOnSelectedTable(t,e){const i=this.editor,n=i.model.document.selection;if(!n.isCollapsed&&1===n.rangeCount&&n.getFirstRange().isFlat){const t=n.getSelectedElement();if(!t||!t.is("table"))return;e(),i.model.change(e=>{e.setSelection(e.createRangeIn(t.getChild(0).getChild(0)))})}}_getTabHandler(t){const e=this.editor;return(i,n)=>{const s=Rw("tableCell",e.model.document.selection.getFirstPosition());if(!s)return;n();const o=s.parent,r=o.parent,a=r.getChildIndex(o),l=o.getChildIndex(s),c=0===l;if(!t&&c&&0===a)return;const h=l===o.childCount-1,d=a===r.childCount-1;if(t&&d&&h&&(e.execute("insertTableRowBelow"),a===r.childCount-1))return;let u;if(t&&h){const t=r.getChild(a+1);u=t.getChild(0)}else if(!t&&c){const t=r.getChild(a-1);u=t.getChild(t.childCount-1)}else u=o.getChild(l+(t?1:-1));e.model.change(t=>{t.setSelection(t.createRangeIn(u))})}}}i(54);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Sb extends jc{constructor(t){super(t);const e=this.bindTemplate;this.items=this.createCollection(),this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",(t,e)=>`${e} × ${t}`),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},children:this.items},{tag:"div",attributes:{class:["ck-insert-table-dropdown__label"]},children:[{text:e.to("label")}]}],on:{mousedown:e.to(t=>{t.preventDefault()}),click:e.to(()=>{this.fire("execute")})}});for(let t=0;t<100;t++){const e=new Rb;e.on("over",()=>{const e=Math.floor(t/10),i=t%10;this.set("rows",e+1),this.set("columns",i+1)}),this.items.add(e)}this.on("change:columns",()=>{this._highlightGridBoxes()}),this.on("change:rows",()=>{this._highlightGridBoxes()})}focus(){}focusLast(){}_highlightGridBoxes(){const t=this.rows,e=this.columns;this.items.map((i,n)=>{const s=Math.floor(n/10)<t&&n%10<e;i.set("isOn",s)})}}class Rb extends jc{constructor(t){super(t);const e=this.bindTemplate;this.set("isOn",!1),this.setTemplate({tag:"div",attributes:{class:["ck-insert-table-dropdown-grid-box",e.if("isOn","ck-on")]},on:{mouseover:e.to("over")}})}}var Ob='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M3 6v3h4V6H3zm0 4v3h4v-3H3zm0 4v3h4v-3H3zm5 3h4v-3H8v3zm5 0h4v-3h-4v3zm4-4v-3h-4v3h4zm0-4V6h-4v3h4zm1.5 8a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 17V4c.222-.863 1.068-1.5 2-1.5h13c.932 0 1.778.637 2 1.5v13zM12 13v-3H8v3h4zm0-4V6H8v3h4z"/></svg>',Ib='<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>',Mb='<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>',Vb='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.5 1h15A1.5 1.5 0 0 1 19 2.5v15a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1zM2 2v16h16V2H2z" opacity=".6"/><path d="M7 2h1v16H7V2zm5 0h1v7h-1V2zm6 5v1H2V7h16zM8 12v1H2v-1h6z" opacity=".6"/><path d="M7 7h12a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1zm1 2v9h10V9H8z"/></svg>';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Nb extends nh{init(){const t=this.editor,e=this.editor.t;t.ui.componentFactory.add("insertTable",i=>{const n=t.commands.get("insertTable"),s=Eu(i);s.bind("isEnabled").to(n),s.buttonView.set({icon:Ob,label:e("Insert table"),tooltip:!0});const o=new Sb(i);return s.panelView.children.add(o),o.delegate("execute").to(s),s.buttonView.on("open",()=>{o.rows=0,o.columns=0}),s.on("execute",()=>{t.execute("insertTable",{rows:o.rows,columns:o.columns}),t.editing.view.focus()}),s}),t.ui.componentFactory.add("tableColumn",t=>{const i=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:e("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableColumnLeft",label:e("Insert column left")}},{type:"button",model:{commandName:"insertTableColumnRight",label:e("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:e("Delete column")}}];return this._prepareDropdown(e("Column"),Ib,i,t)}),t.ui.componentFactory.add("tableRow",t=>{const i=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:e("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowBelow",label:e("Insert row below")}},{type:"button",model:{commandName:"insertTableRowAbove",label:e("Insert row above")}},{type:"button",model:{commandName:"removeTableRow",label:e("Delete row")}}];return this._prepareDropdown(e("Row"),Mb,i,t)}),t.ui.componentFactory.add("mergeTableCells",t=>{const i=[{type:"button",model:{commandName:"mergeTableCellUp",label:e("Merge cell up")}},{type:"button",model:{commandName:"mergeTableCellRight",label:e("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:e("Merge cell down")}},{type:"button",model:{commandName:"mergeTableCellLeft",label:e("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:e("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:e("Split cell horizontally")}}];return this._prepareDropdown(e("Merge cells"),Vb,i,t)})}_prepareDropdown(t,e,i,n){const s=this.editor,o=Eu(n),r=[],a=new os;for(const t of i)Bb(t,s,r,a);return Ru(o,a),o.buttonView.set({label:t,icon:e,tooltip:!0}),o.bind("isEnabled").toMany(r,"isEnabled",(...t)=>t.some(t=>t)),this.listenTo(o,"execute",t=>{s.execute(t.source.commandName),s.editing.view.focus()}),o}}function Bb(t,e,i,n){const s=t.model=new gu(t.model),{commandName:o,bindIsOn:r}=t.model;if("separator"!==t.type){const t=e.commands.get(o);i.push(t),s.set({commandName:o}),s.bind("isEnabled").to(t),r&&s.bind("isOn").to(t,"value")}s.set({withText:!0}),n.add(t)}i(55);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Fb extends lh{constructor(t){super(t),this._childCommands=[]}refresh(){}execute(...t){this._getFirstEnabledCommand().execute(t)}registerChildCommand(t){this._childCommands.push(t),t.on("change:isEnabled",()=>this._checkEnabled()),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){return this._childCommands.find(t=>t.isEnabled)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Db extends nh{static get pluginName(){return"IndentEditing"}init(){const t=this.editor;t.commands.add("indent",new Fb(t)),t.commands.add("outdent",new Fb(t))}}var Lb='<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.5z"/><path d="M1.632 6.95L5.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>\n',zb='<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.5z"/><path d="M4.368 6.95L.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>\n';
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Hb extends nh{static get pluginName(){return"IndentUI"}init(){const t=this.editor,e=t.locale,i=t.t,n="ltr"==e.uiLanguageDirection?Lb:zb,s="ltr"==e.uiLanguageDirection?zb:Lb;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),s)}_defineButton(t,e,i){const n=this.editor;n.ui.componentFactory.add(t,s=>{const o=n.commands.get(t),r=new Xh(s);return r.set({label:e,icon:i,tooltip:!0}),r.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(r,"execute",()=>n.execute(t)),r})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class jb extends lh{constructor(t,e){super(t),this._indentBehavior=e}refresh(){const t=this.editor.model,e=Xd(t.document.selection.getTopMostBlocks());e&&t.schema.checkAttribute(e,"blockIndent")?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const t=this.editor.model,e=function(t){const e=t.document.selection,i=t.schema;return Array.from(e.getTopMostBlocks()).filter(t=>i.checkAttribute(t,"blockIndent"))}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(t);t.change(t=>{for(const i of e){const e=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(e);n?t.setAttribute("blockIndent",n,i):t.removeAttribute("blockIndent",i)}})}}class qb{constructor(t){this.isForward="forward"===t.direction,this.offset=t.offset,this.unit=t.unit}checkEnabled(t){const e=parseFloat(t||0);return this.isForward||e>0}getNextIndent(t){const e=parseFloat(t||0);if(!(!t||t.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const i=e+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Wb{constructor(t){this.isForward="forward"===t.direction,this.classes=t.classes}checkEnabled(t){const e=this.classes.indexOf(t);return this.isForward?e<this.classes.length-1:e>=0}getNextIndent(t){const e=this.classes.indexOf(t),i=this.isForward?1:-1;return this.classes[e+i]}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Ub extends lh{refresh(){const t=this.editor.model,e=t.document;this.value=e.selection.getAttribute("highlight"),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,"highlight")}execute(t={}){const e=this.editor.model,i=e.document.selection,n=t.value;e.change(t=>{const s=e.schema.getValidRanges(i.getRanges(),"highlight");if(i.isCollapsed){const e=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=t=>t.item.hasAttribute("highlight")&&t.item.getAttribute("highlight")===this.value,s=e.getLastMatchingPosition(i,{direction:"backward"}),o=e.getLastMatchingPosition(i),r=t.createRange(s,o);n&&this.value!==n?(t.setAttribute("highlight",n,r),t.setSelectionAttribute("highlight",n)):(t.removeAttribute("highlight",r),t.removeSelectionAttribute("highlight"))}else n&&t.setSelectionAttribute("highlight",n)}else for(const e of s)n?t.setAttribute("highlight",n,e):t.removeAttribute("highlight",e)})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class $b extends nh{constructor(t){super(t),t.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-highlight-pen-green)",type:"pen"}]})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"highlight"});const e=t.config.get("highlight.options");t.conversion.attributeToElement(function(t){const e={model:{key:"highlight",values:[]},view:{}};for(const i of t)e.model.values.push(i.model),e.view[i.model]={name:"mark",classes:i.class};return e}(e)),t.commands.add("highlight",new Ub(t))}}var Gb='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M10.798 1.59L3.002 12.875l1.895 1.852 2.521 1.402 6.997-12.194z"/><path d="M2.556 16.727l.234-.348c-.297-.151-.462-.293-.498-.426-.036-.137.002-.416.115-.837.094-.25.15-.449.169-.595a4.495 4.495 0 0 0 0-.725c-.209-.621-.303-1.041-.284-1.26.02-.218.178-.506.475-.862l6.77-9.414c.539-.91 1.605-.85 3.199.18 1.594 1.032 2.188 1.928 1.784 2.686l-5.877 10.36c-.158.412-.333.673-.526.782-.193.108-.604.179-1.232.21-.362.131-.608.237-.738.318-.13.081-.305.238-.526.47-.293.265-.504.397-.632.397-.096 0-.27-.075-.524-.226l-.31.41-1.6-1.12zm-.279.415l1.575 1.103-.392.515H1.19l1.087-1.618zm8.1-13.656l-4.953 6.9L8.75 12.57l4.247-7.574c.175-.25-.188-.647-1.092-1.192-.903-.546-1.412-.652-1.528-.32zM8.244 18.5L9.59 17h9.406v1.5H8.245z"/></svg>',Kb='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path class="ck-icon__fill" d="M10.126 2.268L2.002 13.874l1.895 1.852 2.521 1.402L14.47 5.481l-1.543-2.568-2.801-.645z"/><path d="M4.5 18.088l-2.645-1.852-.04-2.95-.006-.005.006-.008v-.025l.011.008L8.73 2.97c.165-.233.356-.417.567-.557l-1.212.308L4.604 7.9l-.83-.558 3.694-5.495 2.708-.69 1.65 1.145.046.018.85-1.216 2.16 1.512-.856 1.222c.828.967 1.144 2.141.432 3.158L7.55 17.286l.006.005-3.055.797H4.5zm-.634.166l-1.976.516-.026-1.918 2.002 1.402zM9.968 3.817l-.006-.004-6.123 9.184 3.277 2.294 6.108-9.162.005.003c.317-.452-.16-1.332-1.064-1.966-.891-.624-1.865-.776-2.197-.349zM8.245 18.5L9.59 17h9.406v1.5H8.245z"/></svg>';i(56);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class Jb extends jc{constructor(t){super(t);const e=this.bindTemplate;this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(),this.arrowView=this._createArrowView(),this.keystrokes=new nc,this.focusTracker=new uc,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",e.if("isVisible","ck-hidden",t=>!t),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",(t,e)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),e())}),this.keystrokes.set("arrowleft",(t,e)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),e())})}focus(){this.actionView.focus()}_createActionView(){const t=new Xh;return 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 t=new Xh,e=t.bindTemplate;return t.icon=yu,t.extendTemplate({attributes:{class:"ck-splitbutton__arrow","aria-haspopup":!0,"aria-expanded":e.to("isOn",t=>String(t))}}),t.bind("isEnabled").to(this),t.delegate("execute").to(this,"open"),t}}i(57);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class Yb extends nh{get localizedOptionTitles(){const t=this.editor.t;return{"Yellow marker":t("Yellow marker"),"Green marker":t("Green marker"),"Pink marker":t("Pink marker"),"Blue marker":t("Blue marker"),"Red pen":t("Red pen"),"Green pen":t("Green pen")}}static get pluginName(){return"HighlightUI"}init(){const t=this.editor.config.get("highlight.options");for(const e of t)this._addHighlighterButton(e);this._addRemoveHighlightButton(),this._addDropdown(t)}_addRemoveHighlightButton(){const t=this.editor.t;this._addButton("removeHighlight",t("Remove highlight"),Pp)}_addHighlighterButton(t){const e=this.editor.commands.get("highlight");this._addButton("highlight:"+t.model,t.title,Qb(t.type),t.model,(function(i){i.bind("isEnabled").to(e,"isEnabled"),i.bind("isOn").to(e,"value",e=>e===t.model),i.iconView.fillColor=t.color,i.isToggleable=!0}))}_addButton(t,e,i,n,s=(()=>{})){const o=this.editor;o.ui.componentFactory.add(t,t=>{const r=new Xh(t),a=this.localizedOptionTitles[e]?this.localizedOptionTitles[e]:e;return r.set({label:a,icon:i,tooltip:!0}),r.on("execute",()=>{o.execute("highlight",{value:n}),o.editing.view.focus()}),s(r),r})}_addDropdown(t){const e=this.editor,i=e.t,n=e.ui.componentFactory,s=t[0],o=t.reduce((t,e)=>(t[e.model]=e,t),{});n.add("highlight",r=>{const a=e.commands.get("highlight"),l=Eu(r,Jb),c=l.buttonView;c.set({tooltip:i("Highlight"),lastExecuted:s.model,commandValue:s.model,isToggleable:!0}),c.bind("icon").to(a,"value",t=>Qb(d(t,"type"))),c.bind("color").to(a,"value",t=>d(t,"color")),c.bind("commandValue").to(a,"value",t=>d(t,"model")),c.bind("isOn").to(a,"value",t=>!!t),c.delegate("execute").to(l);const h=t.map(t=>{const e=n.create("highlight:"+t.model);return this.listenTo(e,"execute",()=>l.buttonView.set({lastExecuted:t.model})),e});function d(t,e){const i=t&&t!==c.lastExecuted?t:c.lastExecuted;return o[i][e]}return l.bind("isEnabled").toMany(h,"isEnabled",(...t)=>t.some(t=>t)),h.push(new Zc),h.push(n.create("removeHighlight")),Su(l,h),function(t){t.buttonView.actionView.iconView.bind("fillColor").to(t.buttonView,"color")}(l),l.toolbarView.ariaLabel=i("Text highlight toolbar"),c.on("execute",()=>{e.execute("highlight",{value:c.commandValue}),e.editing.view.focus()}),l})}}function Qb(t){return"marker"===t?Gb:Kb}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
const Xb="todoListChecked";class Zb extends lh{constructor(t){super(t),this._selectedElements=[],this.on("execute",()=>{this.refresh()},{priority:"highest"})}refresh(){this._selectedElements=this._getSelectedItems(),this.value=this._selectedElements.every(t=>!!t.getAttribute("todoListChecked")),this.isEnabled=!!this._selectedElements.length}_getSelectedItems(){const t=this.editor.model,e=t.schema,i=t.document.selection.getFirstRange(),n=i.start.parent,s=[];e.checkAttribute(n,Xb)&&s.push(n);for(const t of i.getItems())e.checkAttribute(t,Xb)&&!s.includes(t)&&s.push(t);return s}execute(t={}){this.editor.model.change(e=>{for(const i of this._selectedElements){(void 0===t.forceValue?!this.value:t.forceValue)?e.setAttribute(Xb,!0,i):e.removeAttribute(Xb,i)}})}}var t_="[object String]";var e_=function(t){return"string"==typeof t||!$t(t)&&b(t)&&g(t)==t_};
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */function i_(t,e,i){const n=e.range.start.parent;if("listItem"!=n.name||"todo"!=n.getAttribute("listType"))return;if(!i.consumable.consume(e.item,"insert"))return;const s=i.writer,o=i.mapper.toViewPosition(e.range.start),r=s.createText(e.item.data);s.insert(o.offset?o:o.getShiftedBy(1),r)}function n_(t,e,i){const n=e.range.start.parent;if("listItem"!=n.name||"todo"!=n.getAttribute("listType"))return;if(!i.consumable.consume(e.item,"insert"))return;const s=i.writer,o=i.mapper.toViewPosition(e.range.start),r=s.createText(e.item.data),a=s.createAttributeElement("span",{class:"todo-list__label__description"}),l=o.parent.getChild(0);s.insert(s.createPositionAt(o.parent,"end"),r),s.wrap(s.createRangeOn(r),a),s.wrap(s.createRangeOn(r.parent),l)}function s_(t,e,i){const n=e.modelCursor,s=n.parent,o=e.viewItem;if("checkbox"!=o.getAttribute("type")||"listItem"!=s.name||!n.isAtStart)return;if(!i.consumable.consume(o,{name:!0}))return;const r=i.writer;r.setAttribute("listType","todo",s),e.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,s),e.modelRange=r.createRange(n)}function o_(t,e,i,n){const s=e.createUIElement("label",{class:"todo-list__checkmark",contenteditable:!1},(function(e){const s=function(t,e,i={},n=[]){const s=t.createElement(e);for(const t in i)s.setAttribute(t,i[t]);!e_(n)&&wn(n)||(n=[n]);for(let e of n)e_(e)&&(e=t.createTextNode(e)),s.appendChild(e);return s}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */(document,"input",{type:"checkbox"});s.checked=i,s.addEventListener("change",()=>n(t));const o=this.toDomElement(e);return o.appendChild(s),o}));return i&&e.addClass("todo-list__checkmark_checked",s),s}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class r_ extends nh{static get requires(){return[zg]}init(){const t=this.editor,{editing:e,data:i,model:n}=t,s=e.view.document;var o;n.schema.extend("listItem",{allowAttributes:["todoListChecked"]}),n.schema.addAttributeCheck((t,e)=>{const i=t.last;if("todoListChecked"==e&&"listItem"==i.name&&"todo"!=i.getAttribute("listType"))return!1}),t.commands.add("todoList",new pg(t,"todo")),t.commands.add("todoListCheck",new Zb(t)),e.downcastDispatcher.on("insert:listItem",function(t,e){return(i,n,s)=>{const o=s.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;if("todo"!=n.item.getAttribute("listType"))return;const r=n.item;o.consume(r,"insert"),o.consume(r,"attribute:listType"),o.consume(r,"attribute:listIndent"),o.consume(r,"attribute:todoListChecked");const a=s.writer,l=vg(r,s),c=!!r.getAttribute("todoListChecked"),h=o_(r,a,c,e);a.addClass("todo-list",l.parent),a.insert(a.createPositionAt(l,0),h),yg(r,l,s,t)}}(n,t=>this._handleCheckmarkChange(t)),{priority:"high"}),e.downcastDispatcher.on("insert:$text",i_,{priority:"high"}),i.downcastDispatcher.on("insert:listItem",function(t){return(e,i,n)=>{const s=n.consumable;if(!s.test(i.item,"insert")||!s.test(i.item,"attribute:listType")||!s.test(i.item,"attribute:listIndent"))return;if("todo"!=i.item.getAttribute("listType"))return;s.consume(i.item,"insert"),s.consume(i.item,"attribute:listType"),s.consume(i.item,"attribute:listIndent");const o=n.writer,r=i.item,a=vg(r,n);o.addClass("todo-list",a.parent);const l=o.createAttributeElement("label",{class:"todo-list__label"}),c=o.createEmptyElement("input",{type:"checkbox",disabled:"disabled",class:"todo-list__label__checkmark"});i.item.getAttribute("todoListChecked")&&(o.setAttribute("checked","checked",c),o.addClass("todo-list__label_checked",l)),o.insert(o.createPositionAt(a,0),c),o.wrap(o.createRangeOn(c),l),yg(r,a,n,t)}}(n),{priority:"high"}),i.downcastDispatcher.on("insert:$text",n_,{priority:"high"}),e.downcastDispatcher.on("attribute:listType:listItem",(o=t=>this._handleCheckmarkChange(t),(t,e,i)=>{const n=i.mapper.toViewElement(e.item),s=i.writer;if("todo"==e.attributeNewValue){const t=!!e.item.getAttribute("todoListChecked"),i=o_(e.item,s,t,o);s.addClass("todo-list",n.parent),s.insert(s.createPositionAt(n,0),i)}else"todo"==e.attributeOldValue&&(s.removeClass("todo-list",n.parent),s.remove(n.getChild(0)))})),e.downcastDispatcher.on("attribute:todoListChecked:listItem",function(t){return(e,i,n)=>{if("todo"!=i.item.getAttribute("listType"))return;if(!n.consumable.consume(i.item,"attribute:todoListChecked"))return;const{mapper:s,writer:o}=n,r=!!i.item.getAttribute("todoListChecked"),a=s.toViewElement(i.item),l=xg(o.createRangeIn(a),t=>!!t.is("uiElement")&&t),c=o_(i.item,o,r,t);o.insert(o.createPositionAfter(l),c),o.remove(l)}}(t=>this._handleCheckmarkChange(t))),i.upcastDispatcher.on("element:input",s_,{priority:"high"});const r=new Set;function a(t){t.on("change:children",(t,e)=>r.add(e))}Array.from(s.roots).forEach(a),this.listenTo(s.roots,"add",(t,e)=>a(e)),s.registerPostFixer(t=>{const e=function(t,e){const i=[];for(const n of e)for(const e of t.createRangeIn(n).getItems())e.is("uiElement")&&e.hasClass("todo-list__checkmark")&&!i.includes(e)&&n.document&&i.push(e);return i}(t,r);return r.clear(),function(t,e){let i=!1;for(const n of e){const e=a_(n),s=t.createPositionAt(e,0),o=t.createPositionBefore(n);if(s.isEqual(o))continue;const r=t.createRange(s,o);for(const e of Array.from(r.getItems()))e.is("uiElement")&&(t.move(t.createRangeOn(e),t.createPositionAfter(n)),i=!0)}return i}(t,e)}),s.registerPostFixer(t=>(function(t,e){if(!e.isCollapsed)return!1;const i=e.getFirstPosition();if("li"!=i.parent.name||!i.parent.parent.hasClass("todo-list"))return!1;const n=t.createPositionAt(i.parent,"end"),s=xg(t.createRange(i,n),t=>!(!t.is("uiElement")||!t.hasClass("todo-list__checkmark"))&&t);if(s&&!i.isAfter(t.createPositionBefore(s))){const i=xg(t.createRange(t.createPositionAfter(s),n),t=>!!t.is("textProxy")&&t.textNode),o=i?t.createPositionAt(i,0):n;return t.setSelection(t.createRange(o),{isBackward:e.isBackward}),!0}return!1})(t,s.selection)),t.keystrokes.set("arrowleft",(t,e)=>(function(t,e){const i=e.schema,n=e.document.selection;if(!n.isCollapsed)return;const s=n.getFirstPosition(),o=s.parent;if("listItem"===o.name&&"todo"==o.getAttribute("listType")&&s.isAtStart){const n=i.getNearestSelectionRange(e.createPositionBefore(o),"backward");n&&(t(),e.change(t=>t.setSelection(n)))}})(e,n)),t.keystrokes.set("Ctrl+space",()=>t.execute("todoListCheck"));const l=new Set;this.listenTo(n,"applyOperation",(t,e)=>{const i=e[0];if("rename"==i.type&&"listItem"==i.oldName){const t=i.position.nodeAfter;t.hasAttribute("todoListChecked")&&l.add(t)}else if("changeAttribute"==i.type&&"listType"==i.key&&"todo"===i.oldValue)for(const t of i.range.getItems())t.hasAttribute("todoListChecked")&&"todo"!==t.getAttribute("listType")&&l.add(t)}),n.document.registerPostFixer(t=>{let e=!1;for(const i of l)t.removeAttribute("todoListChecked",i),e=!0;return l.clear(),e})}_handleCheckmarkChange(t){const e=this.editor,i=e.model,n=Array.from(i.document.selection.getRanges());i.change(i=>{i.setSelection(t,"end"),e.execute("todoListCheck"),i.setSelection(n)})}}function a_(t){for(const e of t.getAncestors({parentFirst:!0}))if("li"==e.name)return e}var l_='<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M2.3148 14.7048l2.2237-2.2406c.2661-.2622.6975-.2622.9636 0a.6644.6644 0 0 1 0 .9494l-2.6373 2.6573a.6823.6823 0 0 1-.1115.089c-.2526.1968-.6193.1797-.852-.0512L.6885 14.886a.6352.6352 0 0 1 0-.9032.6471.6471 0 0 1 .9102 0l.7161.722zM7.5 14.75a.75.75 0 0 1 .75-.75h9.5a.75.75 0 1 1 0 1.5h-9.5c-.414 0-.75-.336-.75-.75zM2.3288 5.7453l2.2097-2.2265c.2661-.2622.6975-.2622.9636 0a.6644.6644 0 0 1 0 .9494L2.8648 7.1256a.6848.6848 0 0 1-.4953.1965.6444.6444 0 0 1-.4682-.187L.6885 5.9125a.6352.6352 0 0 1 0-.9033.6471.6471 0 0 1 .9102 0l.7301.7361zM7.5 5.75A.75.75 0 0 1 8.25 5h9.5a.75.75 0 1 1 0 1.5h-9.5c-.414 0-.75-.336-.75-.75z"/></svg>';i(58);
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */
class c_ extends nh{init(){const t=this.editor.t;Pg(this.editor,"todoList",t("To-do List"),l_)}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */class h_ extends ih{}h_.builtinPlugins=[class extends nh{static get requires(){return[ah,mh,bh,Ih,id]}static get pluginName(){return"Essentials"}},class extends nh{static get requires(){return[od]}static get pluginName(){return"CKFinderUploadAdapter"}init(){const t=this.editor.config.get("ckfinder.uploadUrl");t&&(this.editor.plugins.get(od).createUploadAdapter=e=>new dd(e,t,this.editor.t))}},class extends nh{static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats()}_addListAutoformats(){const t=this.editor.commands;t.get("bulletedList")&&new ud(this.editor,/^[*-]\s$/,"bulletedList"),t.get("numberedList")&&new ud(this.editor,/^1[.|)]\s$/,"numberedList")}_addBasicStylesAutoformats(){const t=this.editor.commands;if(t.get("bold")){const t=gd(this.editor,"bold");new fd(this.editor,/(\*\*)([^*]+)(\*\*)$/g,t),new fd(this.editor,/(__)([^_]+)(__)$/g,t)}if(t.get("italic")){const t=gd(this.editor,"italic");new fd(this.editor,/(?:^|[^*])(\*)([^*_]+)(\*)$/g,t),new fd(this.editor,/(?:^|[^_])(_)([^_]+)(_)$/g,t)}if(t.get("code")){const t=gd(this.editor,"code");new fd(this.editor,/(`)([^`]+)(`)$/g,t)}}_addHeadingAutoformats(){const t=this.editor.commands.get("heading");t&&t.modelElements.filter(t=>t.match(/^heading[1-6]$/)).forEach(e=>{const i=e[7],n=new RegExp(`^(#{${i}})\\s$`);new ud(this.editor,n,()=>{if(!t.isEnabled)return!1;this.editor.execute("heading",{value:e})})})}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&new ud(this.editor,/^>\s$/,"blockQuote")}},class extends nh{static get requires(){return[bd,yd]}static get pluginName(){return"Bold"}},class extends nh{static get requires(){return[Ad,Pd]}static get pluginName(){return"Italic"}},class extends nh{static get requires(){return[Ed,Od]}static get pluginName(){return"Underline"}},class extends nh{static get requires(){return[Md,Bd]}static get pluginName(){return"Strikethrough"}},class extends nh{static get requires(){return[Dd,Hd]}static get pluginName(){return"Code"}},class extends nh{static get requires(){return[qd,$d]}static get pluginName(){return"Subscript"}},class extends nh{static get requires(){return[Kd,Qd]}static get pluginName(){return"Superscript"}},class extends nh{static get requires(){return[nu,ou]}static get pluginName(){return"BlockQuote"}},class extends nh{static get requires(){return[mu,Ou]}static get pluginName(){return"Heading"}},class extends nh{static get requires(){return[Xu,nf,Ef]}static get pluginName(){return"Image"}},class extends nh{static get requires(){return[Of]}static get pluginName(){return"ImageCaption"}},class extends nh{static get requires(){return[$f,Gf]}static get pluginName(){return"ImageStyle"}},class extends nh{static get requires(){return[Kf]}static get pluginName(){return"ImageToolbar"}afterInit(){const t=this.editor,e=t.t;t.plugins.get(Kf).register("image",{ariaLabel:e("Image toolbar"),items:t.config.get("image.toolbar")||[],getRelatedElement:Gu})}},class extends nh{static get pluginName(){return"ImageUpload"}static get requires(){return[mm,im,sm]}},class extends nh{static get requires(){return[Qg]}static get pluginName(){return"ImageResize"}init(){const t=this.editor,e=new Xg(t);this._registerSchema(),this._registerConverters(),t.commands.add("imageResize",e),t.editing.downcastDispatcher.on("insert:image",(i,n,s)=>{const o=s.mapper.toViewElement(n.item),r=t.plugins.get(Qg).attachTo({unit:t.config.get("image.resizeUnit")||"%",modelElement:n.item,viewElement:o,downcastWriter:s.writer,getHandleHost:t=>t.querySelector("img"),getResizeHost:t=>t,isCentered(){const t=n.item.getAttribute("imageStyle");return!t||"full"==t||"alignCenter"==t},onCommit(e){t.execute("imageResize",{width:e})}});r.on("updateSize",()=>{o.hasClass("image_resized")||t.editing.view.change(t=>{t.addClass("image_resized",o)})}),r.bind("isEnabled").to(e)},{priority:"low"})}_registerSchema(){this.editor.model.schema.extend("image",{allowAttributes:"width"})}_registerConverters(){const t=this.editor;t.conversion.for("downcast").add(t=>t.on("attribute:width:image",(t,e,i)=>{if(!i.consumable.consume(e.item,t.name))return;const n=i.writer,s=i.mapper.toViewElement(e.item);null!==e.attributeNewValue?(n.setStyle("width",e.attributeNewValue,s),n.addClass("image_resized",s)):(n.removeStyle("width",s),n.removeClass("image_resized",s))})),t.conversion.for("upcast").attributeToAttribute({view:{name:"figure",styles:{width:/.+/}},model:{key:"width",value:t=>t.getStyle("width")}})}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends nh{static get requires(){return[rg,mg]}static get pluginName(){return"Link"}},class extends nh{static get requires(){return[zg,Wg]}static get pluginName(){return"List"}},lu,class extends nh{static get requires(){return[op,cp]}static get pluginName(){return"Alignment"}},class extends nh{static get requires(){return[qp,Qp,nw,lw]}static get pluginName(){return"Font"}},class extends nh{static get pluginName(){return"PasteFromOffice"}static get requires(){return[ah]}init(){const t=this.editor,e=[];e.push(new vp),e.push(new mp),t.plugins.get("Clipboard").on("inputTransformation",(t,i)=>{if(i.isTransformedWithPasteFromOffice)return;const n=i.dataTransfer.getData("text/html"),s=e.find(t=>t.isActive(n));s&&(s.execute(i),i.isTransformedWithPasteFromOffice=!0)},{priority:"high"})}},class extends nh{static get requires(){return[od]}static get pluginName(){return"SimpleUploadAdapter"}init(){const t=this.editor.config.get("simpleUpload");t&&(t.uploadUrl?this.editor.plugins.get(od).createUploadAdapter=e=>new Zg(e,t):console.warn(Object(Ki.a)('simple-upload-adapter-missing-uploadUrl: Missing the "uploadUrl" property in the "simpleUpload" editor configuration.')))}},class extends nh{static get requires(){return[_w,Cw,yw,nf]}static get pluginName(){return"MediaEmbed"}},class extends nh{static get requires(){return[Sw,Tw]}static get pluginName(){return"RemoveFormat"}},class extends nh{static get requires(){return[Eb,Nb,nf]}static get pluginName(){return"Table"}}
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
 */,class extends nh{static get requires(){return[Kf]}static get pluginName(){return"TableToolbar"}afterInit(){const t=this.editor,e=t.t,i=t.plugins.get(Kf),n=t.config.get("table.contentToolbar"),s=t.config.get("table.tableToolbar");n&&i.register("tableContent",{ariaLabel:e("Table toolbar"),items:n,getRelatedElement:Lw}),s&&i.register("table",{ariaLabel:e("Table toolbar"),items:s,getRelatedElement:Dw})}},class extends nh{static get pluginName(){return"Indent"}static get requires(){return[Db,Hb]}},class extends nh{constructor(t){super(t),t.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}init(){const t=this.editor,e=t.model.schema,i=t.conversion,n=t.config.get("indentBlock");["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"].forEach(t=>{e.isRegistered(t)&&e.extend(t,{allowAttributes:"blockIndent"})});const s=!n.classes||!n.classes.length,o=Object.assign({direction:"forward"},n),r=Object.assign({direction:"backward"},n);s?(this._setupConversionUsingOffset(i),t.commands.add("indentBlock",new jb(t,new qb(o))),t.commands.add("outdentBlock",new jb(t,new qb(r)))):(this._setupConversionUsingClasses(n.classes),t.commands.add("indentBlock",new jb(t,new Wb(o))),t.commands.add("outdentBlock",new jb(t,new Wb(r))))}afterInit(){const t=this.editor,e=t.commands.get("indent"),i=t.commands.get("outdent");e.registerChildCommand(t.commands.get("indentBlock")),i.registerChildCommand(t.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const t=this.editor.conversion,e="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";t.for("upcast").attributeToAttribute({view:{styles:{[e]:/[\s\S]+/}},model:{key:"blockIndent",value:t=>t.getStyle(e)}}),t.for("upcast").attributeToAttribute({view:{styles:{margin:/[\s\S]+/}},model:{key:"blockIndent",value:t=>(function(t,e){const i=t.split(" ");let n;n=i[0],i[1]&&(n=i[1]);i[3]&&(n="margin-left"===e?i[3]:i[1]);return n})(t.getStyle("margin"),e)}}),t.for("downcast").attributeToAttribute({model:"blockIndent",view:t=>({key:"style",value:{[e]:t}})})}_setupConversionUsingClasses(t){const e={model:{key:"blockIndent",values:[]},view:{}};for(const i of t)e.model.values.push(i),e.view[i]={key:"class",value:[i]};this.editor.conversion.attributeToAttribute(e)}},class extends nh{static get requires(){return[$b,Yb]}static get pluginName(){return"Highlight"}},class extends nh{static get requires(){return[r_,c_]}static get pluginName(){return"TodoList"}}];i(59);function d_(t){let e=null;if(document.cookie&&""!==document.cookie){let i=document.cookie.split(";");for(let n=0;n<i.length;n++){let s=i[n].trim();if(s.substring(0,t.length+1)===t+"="){e=decodeURIComponent(s.substring(t.length+1));break}}}return e}document.addEventListener("DOMContentLoaded",()=>{let t=document.querySelectorAll(".django_ckeditor_5");for(let e=0;e<t.length;++e){let i=`${t[e].id}_script`;document.querySelector(`[for$="${t[e].id}"]`).style.float="none";let n=JSON.parse(document.getElementById(i).textContent);n.simpleUpload={uploadUrl:"/ckeditor5/image_upload/",headers:{"X-CSRFToken":d_("csrftoken")}},h_.create(t[e],n).then(t=>{}).catch(t=>{})}})}]);
//# sourceMappingURL=bundle.js.map