{"version":3,"file":"ckeditor.js","sources":["webpack://ClassicEditor/ckeditor.js"],"sourcesContent":["/*!\n * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md.\n */\n(function(t){t[\"fa\"]=Object.assign(t[\"fa\"]||{},{a:\"انتخاب عنوان\",b:\"عنوان\",c:\"افزایش تورفتگی\",d:\"کاهش تورفتگی\",e:\"لیست عددی\",f:\"لیست نشانهدار\",g:\"تراز چپ\",h:\"تراز راست\",i:\"تراز وسط\",j:\"هم تراز کردن\",k:\"تراز متن\",l:\"نوارابزار تراز متن\",m:\"Insert code block\",n:\"درشت\",o:\"کج\",p:\"کد\",q:\"پاراگراف\",r:\"عنوان 1\",s:\"عنوان 2\",t:\"عنوان 3\",u:\"عنوان 4\",v:\"عنوان 5\",w:\"عنوان 6\",x:\"Plain text\",y:\"نوارابزار ویرایشگر\",z:\"Show more items\",aa:\"نوارابزار کشویی\",ab:\"ویرایشگر متن غنی\",ac:\"ویرایشگر متن غنی، %0\",ad:\"بازگردانی\",ae:\"باز انجام\"})})(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));(function t(e,n){if(typeof exports===\"object\"&&typeof module===\"object\")module.exports=n();else if(typeof define===\"function\"&&define.amd)define([],n);else if(typeof exports===\"object\")exports[\"ClassicEditor\"]=n();else e[\"ClassicEditor\"]=n()})(window,(function(){return function(t){var e={};function n(i){if(e[i]){return e[i].exports}var s=e[i]={i:i,l:false,exports:{}};t[i].call(s.exports,s,s.exports,n);s.l=true;return s.exports}n.m=t;n.c=e;n.d=function(t,e,i){if(!n.o(t,e)){Object.defineProperty(t,e,{enumerable:true,get:i})}};n.r=function(t){if(typeof Symbol!==\"undefined\"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"})}Object.defineProperty(t,\"__esModule\",{value:true})};n.t=function(t,e){if(e&1)t=n(t);if(e&8)return t;if(e&4&&typeof t===\"object\"&&t&&t.__esModule)return t;var i=Object.create(null);n.r(i);Object.defineProperty(i,\"default\",{enumerable:true,value:t});if(e&2&&typeof t!=\"string\")for(var s in t)n.d(i,s,function(e){return t[e]}.bind(null,s));return i};n.n=function(t){var e=t&&t.__esModule?function e(){return t[\"default\"]}:function e(){return t};n.d(e,\"a\",e);return e};n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};n.p=\"\";return n(n.s=50)}([function(t,e,n){\"use strict\";n.d(e,\"b\",(function(){return s}));n.d(e,\"a\",(function(){return o}));const i=\"https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html\";class s extends Error{constructor(t,e,n){t=o(t);if(n){t+=\" \"+JSON.stringify(n)}super(t);this.name=\"CKEditorError\";this.context=e;this.data=n}is(t){return t===\"CKEditorError\"}static rethrowUnexpectedError(t,e){if(t.is&&t.is(\"CKEditorError\")){throw t}const n=new s(t.message,e);n.stack=t.stack;throw n}}function o(t){const e=t.match(/^([^:]+):/);if(!e){return t}return t+` Read more: ${i}#error-${e[1]}\\n`}},,function(t,e,n){\"use strict\";var i=n(7);var s=typeof self==\"object\"&&self&&self.Object===Object&&self;var o=i[\"a\"]||s||Function(\"return this\")();e[\"a\"]=o},function(t,e,n){\"use strict\";var i=function t(){var e;return function t(){if(typeof e===\"undefined\"){e=Boolean(window&&document&&document.all&&!window.atob)}return e}}();var s=function t(){var e={};return function t(n){if(typeof e[n]===\"undefined\"){var i=document.querySelector(n);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement){try{i=i.contentDocument.head}catch(t){i=null}}e[n]=i}return e[n]}}();var o=[];function r(t){var e=-1;for(var n=0;n0){if(++e>=fc){return arguments[0]}}else{e=0}return t.apply(undefined,arguments)}}var bc=mc;var _c=bc(dc);var wc=_c;function kc(t,e){return wc(cc(t,e,ic),t+\"\")}var vc=kc;function yc(t,e,n){if(!ct(n)){return false}var i=typeof e;if(i==\"number\"?Zn(n)&&tn(e,n.length):i==\"string\"&&e in n){return V(n[e],t)}return false}var Pc=yc;function xc(t){return vc((function(e,n){var i=-1,s=n.length,o=s>1?n[s-1]:undefined,r=s>2?n[2]:undefined;o=t.length>3&&typeof o==\"function\"?(s--,o):undefined;if(r&&Pc(n[0],n[1],r)){o=s<3?undefined:o;s=1}e=Object(e);while(++ie===t);return Array.isArray(n)}set(t,e){if(ct(t)){for(const[e,n]of Object.entries(t)){this._styleProcessor.toNormalizedForm(e,n,this._styles)}}else{this._styleProcessor.toNormalizedForm(t,e,this._styles)}}remove(t){const e=Bc(t);Fa(this._styles,e);delete this._styles[t];this._cleanEmptyObjectsOnPath(e)}getNormalized(t){return this._styleProcessor.getNormalized(t,this._styles)}toString(){if(this.isEmpty){return\"\"}return this._getStylesEntries().map(t=>t.join(\":\")).sort().join(\";\")+\";\"}getAsString(t){if(this.isEmpty){return}if(this._styles[t]&&!ct(this._styles[t])){return this._styles[t]}const e=this._styleProcessor.getReducedForm(t,this._styles);const n=e.find(([e])=>e===t);if(Array.isArray(n)){return n[1]}}getStyleNames(){if(this.isEmpty){return[]}const t=this._getStylesEntries();return t.map(([t])=>t)}clear(){this._styles={}}_getStylesEntries(){const t=[];const e=Object.keys(this._styles);for(const n of e){t.push(...this._styleProcessor.getReducedForm(n,this._styles))}return t}_cleanEmptyObjectsOnPath(t){const e=t.split(\".\");const n=e.length>1;if(!n){return}const i=e.splice(0,e.length-1).join(\".\");const s=La(this._styles,i);if(!s){return}const o=!Array.from(Object.keys(s)).length;if(o){this.remove(i)}}}class Ic{constructor(){this._normalizers=new Map;this._extractors=new Map;this._reducers=new Map;this._consumables=new Map}toNormalizedForm(t,e,n){if(ct(e)){Dc(n,Bc(t),e);return}if(this._normalizers.has(t)){const i=this._normalizers.get(t);const{path:s,value:o}=i(e);Dc(n,s,o)}else{Dc(n,t,e)}}getNormalized(t,e){if(!t){return Tc({},e)}if(e[t]!==undefined){return e[t]}if(this._extractors.has(t)){const n=this._extractors.get(t);if(typeof n===\"string\"){return La(e,n)}const i=n(t,e);if(i){return i}}return La(e,Bc(t))}getReducedForm(t,e){const n=this.getNormalized(t,e);if(n===undefined){return[]}if(this._reducers.has(t)){const e=this._reducers.get(t);return e(n)}return[[t,n]]}getRelatedStyles(t){return this._consumables.get(t)||[]}setNormalizer(t,e){this._normalizers.set(t,e)}setExtractor(t,e){this._extractors.set(t,e)}setReducer(t,e){this._reducers.set(t,e)}setStyleRelation(t,e){this._mapStyleNames(t,e);for(const n of e){this._mapStyleNames(n,[t])}}_mapStyleNames(t,e){if(!this._consumables.has(t)){this._consumables.set(t,[])}this._consumables.get(t).push(...e)}}function Nc(t){let e=null;let n=0;let i=0;let s=null;const o=new Map;if(t===\"\"){return o}if(t.charAt(t.length-1)!=\";\"){t=t+\";\"}for(let r=0;rs){t.nodesToHandle=i-s;t.offset=s}else{t.nodesToHandle=0}}}if(n.type==\"remove\"){if(t.offset]*>([\\S\\s]*)<\\/code>$/).exec(t)[1];return e.replace(/</g,\"<\").replace(/>/g,\">\")}const qk=\"paragraph\";class Wk extends S_{static get pluginName(){return\"CodeBlockEditing\"}static get requires(){return[Ak]}constructor(t){super(t);t.config.define(\"codeBlock\",{languages:[{language:\"plaintext\",label:\"Plain text\"},{language:\"c\",label:\"C\"},{language:\"cs\",label:\"C#\"},{language:\"cpp\",label:\"C++\"},{language:\"css\",label:\"CSS\"},{language:\"diff\",label:\"Diff\"},{language:\"xml\",label:\"HTML/XML\"},{language:\"java\",label:\"Java\"},{language:\"javascript\",label:\"JavaScript\"},{language:\"php\",label:\"PHP\"},{language:\"python\",label:\"Python\"},{language:\"ruby\",label:\"Ruby\"},{language:\"typescript\",label:\"TypeScript\"}],indentSequence:\"\\t\"})}init(){const t=this.editor;const e=t.model.schema;const n=t.model;const i=Ck(t);t.commands.add(\"codeBlock\",new Mk(t));t.commands.add(\"indentCodeBlock\",new Nk(t));t.commands.add(\"outdentCodeBlock\",new Bk(t));const s=t=>(e,n)=>{const i=this.editor.commands.get(t);if(i.isEnabled){this.editor.execute(t);n()}};t.keystrokes.set(\"Tab\",s(\"indentCodeBlock\"));t.keystrokes.set(\"Shift+Tab\",s(\"outdentCodeBlock\"));e.register(\"codeBlock\",{allowWhere:\"$block\",isBlock:true,allowAttributes:[\"language\"]});e.extend(\"$text\",{allowIn:\"codeBlock\"});e.addAttributeCheck(t=>{if(t.endsWith(\"codeBlock $text\")){return false}});t.editing.downcastDispatcher.on(\"insert:codeBlock\",Vk(n,i,true));t.data.downcastDispatcher.on(\"insert:codeBlock\",Vk(n,i));t.data.downcastDispatcher.on(\"insert:softBreak\",Lk(n),{priority:\"high\"});t.data.upcastDispatcher.on(\"element:pre\",jk(t.data,i));this.listenTo(t.editing.view.document,\"clipboardInput\",(t,e)=>{const i=n.document.selection;if(!i.anchor.parent.is(\"codeBlock\")){return}const s=e.dataTransfer.getData(\"text/plain\");n.change(e=>{n.insertContent(Ek(e,s),i);t.stop()})});this.listenTo(n,\"getSelectedContent\",(t,[i])=>{const s=i.anchor;if(i.isCollapsed||!s.parent.is(\"codeBlock\")||!s.hasSameParentAs(i.focus)){return}n.change(n=>{const o=t.return;if(o.childCount>1||i.containsEntireContent(s.parent)){const e=n.createElement(\"codeBlock\",s.parent.getAttributes());n.append(o,e);const i=n.createDocumentFragment();n.append(e,i);t.return=i}else{const t=o.getChild(0);if(e.checkAttribute(t,\"code\")){n.setAttribute(\"code\",true,t)}}})})}afterInit(){const t=this.editor;const e=t.commands;const n=e.get(\"indent\");const i=e.get(\"outdent\");if(n){n.registerChildCommand(e.get(\"indentCodeBlock\"))}if(i){i.registerChildCommand(e.get(\"outdentCodeBlock\"))}this.listenTo(t.editing.view.document,\"enter\",(e,n)=>{const i=t.model.document.selection.getLastPosition().parent;if(!i.is(\"codeBlock\")){return}$k(t,n.isSoft)||Uk(t,n.isSoft)||Hk(t);n.preventDefault();e.stop()})}}function Hk(t){const e=t.model;const n=e.document;const i=n.selection.getLastPosition();const s=i.nodeBefore||i.textNode;let o;if(s&&s.is(\"text\")){o=Sk(s)}t.model.change(e=>{t.execute(\"shiftEnter\");if(o){e.insertText(o,n.selection.anchor)}})}function $k(t,e){const n=t.model;const i=n.document;const s=t.editing.view;const o=i.selection.getLastPosition();const r=o.nodeAfter;if(e||!i.selection.isCollapsed||!o.isAtStart){return false}if(!r||!r.is(\"softBreak\")){return false}t.model.change(e=>{t.execute(\"enter\");const n=i.selection.anchor.parent.previousSibling;e.rename(n,qk);e.setSelection(n,\"in\");t.model.schema.removeDisallowedAttributes([n],e);e.remove(r)});s.scrollToTheSelection();return true}function Uk(t,e){const n=t.model;const i=n.document;const s=t.editing.view;const o=i.selection.getLastPosition();const r=o.nodeBefore;let a;if(e||!i.selection.isCollapsed||!o.isAtEnd||!r){return false}if(r.is(\"softBreak\")){a=n.createRangeOn(r)}else if(r.is(\"text\")&&!r.data.match(/\\S/)&&r.previousSibling&&r.previousSibling.is(\"softBreak\")){a=n.createRange(n.createPositionBefore(r.previousSibling),n.createPositionAfter(r))}else{return false}t.model.change(e=>{e.remove(a);t.execute(\"enter\");const n=i.selection.anchor.parent;e.rename(n,qk);t.model.schema.removeDisallowedAttributes([n],e)});s.scrollToTheSelection();return true}var Kk=n(46);class Jk extends pb{constructor(t){super(t);const e=this.bindTemplate;this.set(\"icon\");this.set(\"isEnabled\",true);this.set(\"isOn\",false);this.set(\"isToggleable\",false);this.set(\"isVisible\",true);this.set(\"keystroke\");this.set(\"label\");this.set(\"tabindex\",-1);this.set(\"tooltip\");this.set(\"tooltipPosition\",\"s\");this.set(\"type\",\"button\");this.set(\"withText\",false);this.children=this.createCollection();this.actionView=this._createActionView();this.arrowView=this._createArrowView();this.keystrokes=new um;this.focusTracker=new Pm;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)=>{if(this.focusTracker.focusedElement===this.actionView.element){this.arrowView.focus();e()}});this.keystrokes.set(\"arrowleft\",(t,e)=>{if(this.focusTracker.focusedElement===this.arrowView.element){this.actionView.focus();e()}})}focus(){this.actionView.focus()}_createActionView(){const t=new Zb;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);return t}_createArrowView(){const t=new Zb;const e=t.bindTemplate;t.icon=Qb;t.extendTemplate({attributes:{class:\"ck-splitbutton__arrow\",\"aria-haspopup\":true,\"aria-expanded\":e.to(\"isOn\",t=>String(t))}});t.bind(\"isEnabled\").to(this);t.delegate(\"execute\").to(this,\"open\");return t}}var Gk='';var Yk=n(48);class Xk extends S_{init(){const t=this.editor;const e=t.t;const n=t.ui.componentFactory;const i=Ck(t);const s=i[0];n.add(\"codeBlock\",n=>{const o=t.commands.get(\"codeBlock\");const r=u_(n,Jk);const a=r.buttonView;a.set({label:e(\"m\"),tooltip:true,icon:Gk,isToggleable:true});a.bind(\"isOn\").to(o,\"value\",t=>!!t);a.on(\"execute\",()=>{t.execute(\"codeBlock\",{language:s.language});t.editing.view.focus()});r.on(\"execute\",e=>{t.execute(\"codeBlock\",{language:e.source._codeBlockLanguage,forceValue:true});t.editing.view.focus()});r.class=\"ck-code-block-dropdown\";r.bind(\"isEnabled\").to(o);d_(r,this._getLanguageListItemDefinitions(i));return r})}_getLanguageListItemDefinitions(t){const e=this.editor;const n=e.commands.get(\"codeBlock\");const i=new yr;for(const e of t){const t={type:\"button\",model:new G_({_codeBlockLanguage:e.language,label:e.label,withText:true})};t.model.bind(\"isOn\").to(n,\"value\",e=>e===t.model._codeBlockLanguage);i.add(t)}return i}}class Zk extends S_{static get requires(){return[Wk,Xk]}static get pluginName(){return\"CodeBlock\"}}class Qk{constructor(t){this.files=tv(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)}}function tv(t){const e=t.files?Array.from(t.files):[];const n=t.items?Array.from(t.items):[];if(e.length){return e}return n.filter(t=>t.kind===\"file\").map(t=>t.getAsFile())}class ev extends Gh{constructor(t){super(t);const e=this.document;this.domEventType=[\"paste\",\"copy\",\"cut\",\"drop\",\"dragover\"];this.listenTo(e,\"paste\",n,{priority:\"low\"});this.listenTo(e,\"drop\",n,{priority:\"low\"});function n(t,n){n.preventDefault();const i=n.dropRange?[n.dropRange]:Array.from(e.selection.getRanges());const s=new tr(e,\"clipboardInput\");e.fire(s,{dataTransfer:n.dataTransfer,targetRanges:i});if(s.stop.called){n.stopPropagation()}}}onDomEvent(t){const e={dataTransfer:new Qk(t.clipboardData?t.clipboardData:t.dataTransfer)};if(t.type==\"drop\"){e.dropRange=nv(this.view,t)}this.fire(t.type,t,e)}}function nv(t,e){const n=e.target.ownerDocument;const i=e.clientX;const s=e.clientY;let o;if(n.caretRangeFromPoint&&n.caretRangeFromPoint(i,s)){o=n.caretRangeFromPoint(i,s)}else if(e.rangeParent){o=n.createRange();o.setStart(e.rangeParent,e.rangeOffset);o.collapse(true)}if(o){return t.domConverter.domRangeToView(o)}else{return t.document.selection.getFirstRange()}}function iv(t){t=t.replace(//g,\">\").replace(/\\n/g,\"
\").replace(/^\\s/,\" \").replace(/\\s$/,\" \").replace(/\\s\\s/g,\" \");if(t.indexOf(\"
\")>-1){t=`
${t}
`}return t}function sv(t){return t.replace(/(\\s+)<\\/span>/g,(t,e)=>{if(e.length==1){return\" \"}return e})}const ov=[\"figcaption\",\"li\"];function rv(t){let e=\"\";if(t.is(\"text\")||t.is(\"textProxy\")){e=t.data}else if(t.is(\"img\")&&t.hasAttribute(\"alt\")){e=t.getAttribute(\"alt\")}else{let n=null;for(const i of t.getChildren()){const t=rv(i);if(n&&(n.is(\"containerElement\")||i.is(\"containerElement\"))){if(ov.includes(n.name)||ov.includes(i.name)){e+=\"\\n\"}else{e+=\"\\n\\n\"}}e+=t;n=i}}return e}class av extends S_{static get pluginName(){return\"Clipboard\"}init(){const t=this.editor;const e=t.model.document;const n=t.editing.view;const i=n.document;this._htmlDataProcessor=new km(i);n.addObserver(ev);this.listenTo(i,\"clipboardInput\",e=>{if(t.isReadOnly){e.stop()}},{priority:\"highest\"});this.listenTo(i,\"clipboardInput\",(t,e)=>{const i=e.dataTransfer;let s=\"\";if(i.getData(\"text/html\")){s=sv(i.getData(\"text/html\"))}else if(i.getData(\"text/plain\")){s=iv(i.getData(\"text/plain\"))}s=this._htmlDataProcessor.toView(s);this.fire(\"inputTransformation\",{content:s,dataTransfer:i});n.scrollToTheSelection()},{priority:\"low\"});this.listenTo(this,\"inputTransformation\",(t,e)=>{if(!e.content.isEmpty){const t=this.editor.data;const n=this.editor.model;const i=t.toModel(e.content,\"$clipboardHolder\");if(i.childCount==0){return}n.insertContent(i)}},{priority:\"low\"});function s(n,s){const o=s.dataTransfer;s.preventDefault();const r=t.data.toView(t.model.getSelectedContent(e.selection));i.fire(\"clipboardOutput\",{dataTransfer:o,content:r,method:n.name})}this.listenTo(i,\"copy\",s,{priority:\"low\"});this.listenTo(i,\"cut\",(e,n)=>{if(t.isReadOnly){n.preventDefault()}else{s(e,n)}},{priority:\"low\"});this.listenTo(i,\"clipboardOutput\",(n,i)=>{if(!i.content.isEmpty){i.dataTransfer.setData(\"text/html\",this._htmlDataProcessor.toData(i.content));i.dataTransfer.setData(\"text/plain\",rv(i.content))}if(i.method==\"cut\"){t.model.deleteContent(e.selection)}},{priority:\"low\"})}}class cv extends O_{execute(){const t=this.editor.model;const e=t.document;t.change(n=>{lv(this.editor.model,n,e.selection,t.schema);this.fire(\"afterExecute\",{writer:n})})}}function lv(t,e,n,i){const s=n.isCollapsed;const o=n.getFirstRange();const r=o.start.parent;const a=o.end.parent;if(i.isLimit(r)||i.isLimit(a)){if(!s&&r==a){t.deleteContent(n)}return}if(s){const t=_k(e.model.schema,n.getAttributes());uv(e,o.start);e.setSelectionAttribute(t)}else{const i=!(o.start.isAtStart&&o.end.isAtEnd);const s=r==a;t.deleteContent(n,{leaveUnmerged:i});if(i){if(s){uv(e,n.focus)}else{e.setSelection(a,0)}}}}function uv(t,e){t.split(e);t.setSelection(e.parent.nextSibling,0)}class hv extends S_{static get pluginName(){return\"Enter\"}init(){const t=this.editor;const e=t.editing.view;const n=e.document;e.addObserver(xk);t.commands.add(\"enter\",new cv(t));this.listenTo(n,\"enter\",(n,i)=>{i.preventDefault();if(i.isSoft){return}t.execute(\"enter\");e.scrollToTheSelection()},{priority:\"low\"})}}class dv{constructor(t,e=20){this.model=t;this.size=0;this.limit=e;this.isLocked=false;this._changeCallback=(t,e)=>{if(e.type!=\"transparent\"&&e!==this._batch){this._reset(true)}};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(){if(!this._batch){this._batch=this.model.createBatch()}return this._batch}input(t){this.size+=t;if(this.size>=this.limit){this._reset(true)}}lock(){this.isLocked=true}unlock(){this.isLocked=false}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){if(!this.isLocked||t){this._batch=null;this.size=0}}}class fv extends O_{constructor(t,e){super(t);this._buffer=new dv(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;const n=e.document;const i=t.text||\"\";const s=i.length;const o=t.range?e.createSelection(t.range):n.selection;const r=t.resultRange;e.enqueueChange(this._buffer.batch,t=>{this._buffer.lock();e.deleteContent(o);if(i){e.insertContent(t.createText(i,n.selection.getAttributes()),o)}if(r){t.setSelection(r)}else if(!o.is(\"documentSelection\")){t.setSelection(o)}this._buffer.unlock();this._buffer.input(s);this._batches.add(this._buffer.batch)})}}function gv(t){let e=null;const n=t.model;const i=t.editing.view;const s=t.commands.get(\"input\");if(Al.isAndroid){i.document.on(\"beforeinput\",(t,e)=>o(e),{priority:\"lowest\"})}else{i.document.on(\"keydown\",(t,e)=>o(e),{priority:\"lowest\"})}i.document.on(\"compositionstart\",r,{priority:\"lowest\"});i.document.on(\"compositionend\",()=>{e=n.createSelection(n.document.selection)},{priority:\"lowest\"});function o(t){const o=n.document;const r=i.document.isComposing;const c=e&&e.isEqual(o.selection);e=null;if(!s.isEnabled){return}if(mv(t)||o.selection.isCollapsed){return}if(r&&t.keyCode===229){return}if(!r&&t.keyCode===229&&c){return}a()}function r(){const t=n.document;const e=t.selection.rangeCount===1?t.selection.getFirstRange().isFlat:true;if(t.selection.isCollapsed||e){return}a()}function a(){const t=s.buffer;t.lock();n.enqueueChange(t.batch,()=>{n.deleteContent(n.document.selection)});t.unlock()}}const pv=[Bl(\"arrowUp\"),Bl(\"arrowRight\"),Bl(\"arrowDown\"),Bl(\"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++){pv.push(t)}function mv(t){if(t.ctrlKey){return true}return pv.includes(t.keyCode)}function bv(t,e){const n=[];let i=0;let s;t.forEach(t=>{if(t==\"equal\"){o();i++}else if(t==\"insert\"){if(r(\"insert\")){s.values.push(e[i])}else{o();s={type:\"insert\",index:i,values:[e[i]]}}i++}else{if(r(\"delete\")){s.howMany++}else{o();s={type:\"delete\",index:i,howMany:1}}}});o();return n;function o(){if(s){n.push(s);s=null}}function r(t){return s&&s.type==t}}function _v(t){if(t.length==0){return false}for(const e of t){if(e.type===\"children\"&&!wv(e)){return true}}return false}function wv(t){if(t.newChildren.length-t.oldChildren.length!=1){return}const e=ku(t.oldChildren,t.newChildren,kv);const n=bv(e,t.newChildren);if(n.length>1){return}const i=n[0];if(!(!!i.values[0]&&i.values[0].is(\"text\"))){return}return i}function kv(t,e){if(!!t&&t.is(\"text\")&&!!e&&e.is(\"text\")){return t.data===e.data}else{return t===e}}function vv(t){t.editing.view.document.on(\"mutations\",(e,n,i)=>{new yv(t).handle(n,i)})}class yv{constructor(t){this.editor=t;this.editing=this.editor.editing}handle(t,e){if(_v(t)){this._handleContainerChildrenMutations(t,e)}else{for(const n of t){this._handleTextMutation(n,e);this._handleTextNodeInsertion(n)}}}_handleContainerChildrenMutations(t,e){const n=Pv(t);if(!n){return}const i=this.editor.editing.view.domConverter;const s=i.mapViewToDom(n);const o=new Fu(this.editor.editing.view.document);const r=this.editor.data.toModel(o.domToView(s)).getChild(0);const a=this.editor.editing.mapper.toModelElement(n);if(!a){return}const c=Array.from(r.getChildren());const l=Array.from(a.getChildren());const u=c[c.length-1];const h=l[l.length-1];if(u&&u.is(\"softBreak\")&&h&&!h.is(\"softBreak\")){c.pop()}const d=this.editor.model.schema;if(!xv(c,d)||!xv(l,d)){return}const f=c.map(t=>t.is(\"text\")?t.data:\"@\").join(\"\").replace(/\\u00A0/g,\" \");const g=l.map(t=>t.is(\"text\")?t.data:\"@\").join(\"\").replace(/\\u00A0/g,\" \");if(g===f){return}const p=ku(g,f);const{firstChangeAt:m,insertions:b,deletions:_}=Av(p);let w=null;if(e){w=this.editing.mapper.toModelRange(e.getFirstRange())}const k=f.substr(m,b);const v=this.editor.model.createRange(this.editor.model.createPositionAt(a,m),this.editor.model.createPositionAt(a,m+_));this.editor.execute(\"input\",{text:k,range:v,resultRange:w})}_handleTextMutation(t,e){if(t.type!=\"text\"){return}const n=t.newText.replace(/\\u00A0/g,\" \");const i=t.oldText.replace(/\\u00A0/g,\" \");if(i===n){return}const s=ku(i,n);const{firstChangeAt:o,insertions:r,deletions:a}=Av(s);let c=null;if(e){c=this.editing.mapper.toModelRange(e.getFirstRange())}const l=this.editing.view.createPositionAt(t.node,o);const u=this.editing.mapper.toModelPosition(l);const h=this.editor.model.createRange(u,u.getShiftedBy(a));const d=n.substr(o,r);this.editor.execute(\"input\",{text:d,range:h,resultRange:c})}_handleTextNodeInsertion(t){if(t.type!=\"children\"){return}const e=wv(t);const n=this.editing.view.createPositionAt(t.node,e.index);const i=this.editing.mapper.toModelPosition(n);const s=e.values[0].data;this.editor.execute(\"input\",{text:s.replace(/\\u00A0/g,\" \"),range:this.editor.model.createRange(i)})}}function Pv(t){const e=t.map(t=>t.node).reduce((t,e)=>t.getCommonAncestor(e,{includeSelf:true}));if(!e){return}return e.getAncestors({includeSelf:true,parentFirst:true}).find(t=>t.is(\"containerElement\")||t.is(\"rootElement\"))}function xv(t,e){return t.every(t=>e.isInline(t))}function Av(t){let e=null;let n=null;for(let i=0;i