`),n=r),n=this._htmlDataProcessor.toView(n);const s=new ai(this,"inputTransformation");this.fire(s,{content:n,dataTransfer:o}),s.stop.called&&t.stop(),i.scrollToTheSelection()},{priority:"low"}),this.listenTo(this,"inputTransformation",(t,e)=>{if(!e.content.isEmpty){const i=this.editor.data,o=this.editor.model,n=i.toModel(e.content,"$clipboardHolder");if(0==n.childCount)return;o.insertContent(n),t.stop()}},{priority:"low"}),this.listenTo(o,"copy",n,{priority:"low"}),this.listenTo(o,"cut",(e,i)=>{t.isReadOnly?i.preventDefault():n(e,i)},{priority:"low"}),this.listenTo(o,"clipboardOutput",(i,o)=>{o.content.isEmpty||(o.dataTransfer.setData("text/html",this._htmlDataProcessor.toData(o.content)),o.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 o=null;for(const n of e.getChildren()){const e=t(n);o&&(o.is("containerElement")||n.is("containerElement"))&&(gh.includes(o.name)||gh.includes(n.name)?i+="\n":i+="\n\n"),i+=e,o=n}}return i}(o.content))),"cut"==o.method&&t.model.deleteContent(e.selection)},{priority:"low"})}}class fh extends qc{execute(){const t=this.editor.model,e=t.document;t.change(i=>{!function(t,e,i,o){const n=i.isCollapsed,r=i.getFirstRange(),s=r.start.parent,a=r.end.parent;if(o.isLimit(s)||o.isLimit(a))return void(n||s!=a||t.deleteContent(i));if(n){const t=Wu(e.model.schema,i.getAttributes());ph(e,r.start),e.setSelectionAttribute(t)}else{const o=!(r.start.isAtStart&&r.end.isAtEnd),n=s==a;t.deleteContent(i,{leaveUnmerged:o}),o&&(n?ph(e,i.focus):e.setSelection(a,0))}}(this.editor.model,i,e.selection,t.schema),this.fire("afterExecute",{writer:i})})}}function ph(t,e){t.split(e),t.setSelection(e.parent.nextSibling,0)}class bh extends Wc{static get pluginName(){return"Enter"}init(){const t=this.editor,e=t.editing.view,i=e.document;e.addObserver($u),t.commands.add("enter",new fh(t)),this.listenTo(i,"enter",(i,o)=>{o.preventDefault(),o.isSoft||(t.execute("enter"),e.scrollToTheSelection())},{priority:"low"})}}class wh extends qc{execute(){const t=this.editor.model,e=t.schema.getLimitElement(t.document.selection);t.change(t=>{t.setSelection(e,"in")})}}const kh=bn("Ctrl+A");class _h extends Wc{static get pluginName(){return"SelectAllEditing"}init(){const t=this.editor,e=t.editing.view.document;t.commands.add("selectAll",new wh(t)),this.listenTo(e,"keydown",(e,i)=>{pn(i)===kh&&(t.execute("selectAll"),i.preventDefault())})}}class vh extends Wc{static get pluginName(){return"SelectAllUI"}init(){const t=this.editor;t.ui.componentFactory.add("selectAll",e=>{const i=t.commands.get("selectAll"),o=new Tc(e),n=e.t;return o.set({label:n("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",()=>{t.execute("selectAll"),t.editing.view.focus()}),o})}}class yh extends Wc{static get requires(){return[_h,vh]}static get pluginName(){return"SelectAll"}}class xh{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)}}class Ah extends qc{constructor(t,e){super(t),this._buffer=new xh(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,o=t.text||"",n=o.length,r=t.range?e.createSelection(t.range):i.selection,s=t.resultRange;e.enqueueChange(this._buffer.batch,t=>{this._buffer.lock(),e.deleteContent(r),o&&e.insertContent(t.createText(o,i.selection.getAttributes()),r),s?t.setSelection(s):r.is("documentSelection")||t.setSelection(r),this._buffer.unlock(),this._buffer.input(n),this._batches.add(this._buffer.batch)})}}function Ch(t){let e=null;const i=t.model,o=t.editing.view,n=t.commands.get("input");function r(t){const r=i.document,a=o.document.isComposing,l=e&&e.isEqual(r.selection);e=null,n.isEnabled&&(function(t){if(t.ctrlKey)return!0;return Th.includes(t.keyCode)}(t)||r.selection.isCollapsed||a&&229===t.keyCode||!a&&229===t.keyCode&&l||s())}function s(){const t=n.buffer;t.lock(),i.enqueueChange(t.batch,()=>{i.deleteContent(i.document.selection)}),t.unlock()}hn.isAndroid?o.document.on("beforeinput",(t,e)=>r(e),{priority:"lowest"}):o.document.on("keydown",(t,e)=>r(e),{priority:"lowest"}),o.document.on("compositionstart",(function(){const t=i.document,e=1!==t.selection.rangeCount||t.selection.getFirstRange().isFlat;if(t.selection.isCollapsed||e)return;s()}),{priority:"lowest"}),o.document.on("compositionend",()=>{e=i.createSelection(i.document.selection)},{priority:"lowest"})}const Th=[pn("arrowUp"),pn("arrowRight"),pn("arrowDown"),pn("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++)Th.push(t);function Sh(t){if(t.newChildren.length-t.oldChildren.length!=1)return;const e=function(t,e){const i=[];let o,n=0;return t.forEach(t=>{"equal"==t?(r(),n++):"insert"==t?(s("insert")?o.values.push(e[n]):(r(),o={type:"insert",index:n,values:[e[n]]}),n++):s("delete")?o.howMany++:(r(),o={type:"delete",index:n,howMany:1})}),r(),i;function r(){o&&(i.push(o),o=null)}function s(t){return o&&o.type==t}}(qn(t.oldChildren,t.newChildren,Ph),t.newChildren);if(e.length>1)return;const i=e[0];return i.values[0]&&i.values[0].is("text")?i:void 0}function Ph(t,e){return t&&t.is("text")&&e&&e.is("text")?t.data===e.data:t===e}class Eh{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&&!Sh(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 o=this.editor.editing.view.domConverter.mapViewToDom(i),n=new or(this.editor.editing.view.document),r=this.editor.data.toModel(n.domToView(o)).getChild(0),s=this.editor.editing.mapper.toModelElement(i);if(!s)return;const a=Array.from(r.getChildren()),l=Array.from(s.getChildren()),c=a[a.length-1],d=l[l.length-1];c&&c.is("softBreak")&&d&&!d.is("softBreak")&&a.pop();const u=this.editor.model.schema;if(!Mh(a,u)||!Mh(l,u))return;const h=a.map(t=>t.is("text")?t.data:"@").join("").replace(/\u00A0/g," "),g=l.map(t=>t.is("text")?t.data:"@").join("").replace(/\u00A0/g," ");if(g===h)return;const m=qn(g,h),{firstChangeAt:f,insertions:p,deletions:b}=Ih(m);let w=null;e&&(w=this.editing.mapper.toModelRange(e.getFirstRange()));const k=h.substr(f,p),_=this.editor.model.createRange(this.editor.model.createPositionAt(s,f),this.editor.model.createPositionAt(s,f+b));this.editor.execute("input",{text:k,range:_,resultRange:w})}_handleTextMutation(t,e){if("text"!=t.type)return;const i=t.newText.replace(/\u00A0/g," "),o=t.oldText.replace(/\u00A0/g," ");if(o===i)return;const n=qn(o,i),{firstChangeAt:r,insertions:s,deletions:a}=Ih(n);let l=null;e&&(l=this.editing.mapper.toModelRange(e.getFirstRange()));const c=this.editing.view.createPositionAt(t.node,r),d=this.editing.mapper.toModelPosition(c),u=this.editor.model.createRange(d,d.getShiftedBy(a)),h=i.substr(r,s);this.editor.execute("input",{text:h,range:u,resultRange:l})}_handleTextNodeInsertion(t){if("children"!=t.type)return;const e=Sh(t),i=this.editing.view.createPositionAt(t.node,e.index),o=this.editing.mapper.toModelPosition(i),n=e.values[0].data;this.editor.execute("input",{text:n.replace(/\u00A0/g," "),range:this.editor.model.createRange(o)})}}function Mh(t,e){return t.every(t=>e.isInline(t))}function Ih(t){let e=null,i=null;for(let o=0;o{new Eh(t).handle(i,o)})}(t)}isInput(t){return this.editor.commands.get("input")._batches.has(t)}}class Rh extends qc{constructor(t,e){super(t),this.direction=e,this._buffer=new xh(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,o=>{this._buffer.lock();const n=o.createSelection(t.selection||i.selection),r=n.isCollapsed;if(n.isCollapsed&&e.modifySelection(n,{direction:this.direction,unit:t.unit}),this._shouldEntireContentBeReplacedWithParagraph(t.sequence||1))return void this._replaceEntireContentWithParagraph(o);if(n.isCollapsed)return;let s=0;n.getFirstRange().getMinimalFlatRanges().forEach(t=>{s+=en(t.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))}),e.deleteContent(n,{doNotResetEntireContent:r,direction:this.direction}),this._buffer.input(s),o.setSelection(n),this._buffer.unlock()})}_shouldEntireContentBeReplacedWithParagraph(t){if(t>1)return!1;const e=this.editor.model,i=e.document.selection,o=e.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(o)))return!1;if(!e.schema.checkChild(o,"paragraph"))return!1;const n=o.getChild(0);return!n||"paragraph"!==n.name}_replaceEntireContentWithParagraph(t){const e=this.editor.model,i=e.document.selection,o=e.schema.getLimitElement(i),n=t.createElement("paragraph");t.remove(t.createRangeIn(o)),t.insert(n,o),t.setSelection(n,0)}}class Oh extends ur{constructor(t){super(t);const e=t.document;let i=0;function o(t,i,o){let n;e.once("delete",t=>n=t,{priority:Number.POSITIVE_INFINITY}),e.fire("delete",new Ir(e,i,o)),n&&n.stop.called&&t.stop()}e.on("keyup",(t,e)=>{e.keyCode!=fn.delete&&e.keyCode!=fn.backspace||(i=0)}),e.on("keydown",(t,e)=>{const n={};if(e.keyCode==fn.delete)n.direction="forward",n.unit="character";else{if(e.keyCode!=fn.backspace)return;n.direction="backward",n.unit="codePoint"}const r=hn.isMac?e.altKey:e.ctrlKey;n.unit=r?"word":n.unit,n.sequence=++i,o(t,e.domEvent,n)}),hn.isAndroid&&e.on("beforeinput",(e,i)=>{if("deleteContentBackward"!=i.domEvent.inputType)return;const n={unit:"codepoint",direction:"backward",sequence:1},r=i.domTarget.ownerDocument.defaultView.getSelection();r.anchorNode==r.focusNode&&r.anchorOffset+1!=r.focusOffset&&(n.selectionToRemove=t.domConverter.domSelectionToView(r)),o(e,i.domEvent,n)})}observe(){}}class Vh extends Wc{static get pluginName(){return"Delete"}init(){const t=this.editor,e=t.editing.view,i=e.document;if(e.addObserver(Oh),t.commands.add("forwardDelete",new Rh(t,"forward")),t.commands.add("delete",new Rh(t,"backward")),this.listenTo(i,"delete",(i,o)=>{const n={unit:o.unit,sequence:o.sequence};if(o.selectionToRemove){const e=t.model.createSelection(),i=[];for(const e of o.selectionToRemove.getRanges())i.push(t.editing.mapper.toModelRange(e));e.setTo(i),n.selection=e}t.execute("forward"==o.direction?"forwardDelete":"delete",n),o.preventDefault(),e.scrollToTheSelection()}),hn.isAndroid){let t=null;this.listenTo(i,"delete",(e,i)=>{const o=i.domTarget.ownerDocument.defaultView.getSelection();t={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.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}})}}}class Lh extends Wc{static get requires(){return[Nh,Vh]}static get pluginName(){return"Typing"}}const zh=new Map;function Dh(t,e,i){let o=zh.get(t);o||(o=new Map,zh.set(t,o)),o.set(e,i)}function Bh(t){return[t]}function jh(t,e,i={}){const o=function(t,e){const i=zh.get(t);return i&&i.has(e)?i.get(e):Bh}(t.constructor,e.constructor);try{return o(t=t.clone(),e,i)}catch(t){throw t}}function Fh(t,e,i){t=t.slice(),e=e.slice();const o=new Hh(i.document,i.useRelations,i.forceWeakRemove);o.setOriginalOperations(t),o.setOriginalOperations(e);const n=o.originalOperations;if(0==t.length||0==e.length)return{operationsA:t,operationsB:e,originalOperations:n};const r=new WeakMap;for(const e of t)r.set(e,0);const s={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{if(t.key===e.key&&t.range.start.hasSameParentAs(e.range.start)){const o=t.range.getDifference(e.range).map(e=>new Na(e,t.key,t.oldValue,t.newValue,0)),n=t.range.getIntersection(e.range);return n&&i.aIsStrong&&o.push(new Na(n,e.key,e.newValue,t.newValue,0)),0==o.length?[new rl(0)]:o}return[t]}),Dh(Na,Va,(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 Na(e,t.key,t.oldValue,t.newValue,t.baseVersion));if(e.shouldReceiveAttributes){const o=qh(e,t.key,t.oldValue);o&&i.unshift(o)}return i}return t.range=t.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[t]}),Dh(Na,Ba,(t,e)=>{const i=[];t.range.start.hasSameParentAs(e.deletionPosition)&&(t.range.containsPosition(e.deletionPosition)||t.range.start.isEqual(e.deletionPosition))&&i.push(xs._createFromPositionAndShift(e.graveyardPosition,1));const o=t.range._getTransformedByMergeOperation(e);return o.isCollapsed||i.push(o),i.map(e=>new Na(e,t.key,t.oldValue,t.newValue,t.baseVersion))}),Dh(Na,Oa,(t,e)=>function(t,e){const i=xs._createFromPositionAndShift(e.sourcePosition,e.howMany);let o=null,n=[];i.containsRange(t,!0)?o=t:t.start.hasSameParentAs(i.start)?(n=t.getDifference(i),o=t.getIntersection(i)):n=[t];const r=[];for(let t of n){t=t._getTransformedByDeletion(e.sourcePosition,e.howMany);const i=e.getMovedRangeStart(),o=t.start.hasSameParentAs(i);t=t._getTransformedByInsertion(i,e.howMany,o),r.push(...t)}o&&r.push(o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]);return r}(t.range,e).map(e=>new Na(e,t.key,t.oldValue,t.newValue,t.baseVersion))),Dh(Na,ja,(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 xs(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]}),Dh(Va,Na,(t,e)=>{const i=[t];if(t.shouldReceiveAttributes&&t.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(t.position)){const o=qh(t,e.key,e.newValue);o&&i.push(o)}return i}),Dh(Va,Va,(t,e,i)=>(t.position.isEqual(e.position)&&i.aIsStrong||(t.position=t.position._getTransformedByInsertOperation(e)),[t])),Dh(Va,Oa,(t,e)=>(t.position=t.position._getTransformedByMoveOperation(e),[t])),Dh(Va,ja,(t,e)=>(t.position=t.position._getTransformedBySplitOperation(e),[t])),Dh(Va,Ba,(t,e)=>(t.position=t.position._getTransformedByMergeOperation(e),[t])),Dh(La,Va,(t,e)=>(t.oldRange&&(t.oldRange=t.oldRange._getTransformedByInsertOperation(e)[0]),t.newRange&&(t.newRange=t.newRange._getTransformedByInsertOperation(e)[0]),[t])),Dh(La,La,(t,e,i)=>{if(t.name==e.name){if(!i.aIsStrong)return[new rl(0)];t.oldRange=e.newRange?e.newRange.clone():null}return[t]}),Dh(La,Ba,(t,e)=>(t.oldRange&&(t.oldRange=t.oldRange._getTransformedByMergeOperation(e)),t.newRange&&(t.newRange=t.newRange._getTransformedByMergeOperation(e)),[t])),Dh(La,Oa,(t,e,i)=>{if(t.oldRange&&(t.oldRange=xs._createFromRanges(t.oldRange._getTransformedByMoveOperation(e))),t.newRange){if(i.abRelation){const o=xs._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=o.end,[t];if("right"==i.abRelation.side&&e.targetPosition.isEqual(t.newRange.end))return t.newRange.start=o.start,t.newRange.end.path=i.abRelation.path,[t]}t.newRange=xs._createFromRanges(t.newRange._getTransformedByMoveOperation(e))}return[t]}),Dh(La,ja,(t,e,i)=>{if(t.oldRange&&(t.oldRange=t.oldRange._getTransformedBySplitOperation(e)),t.newRange){if(i.abRelation){const o=t.newRange._getTransformedBySplitOperation(e);return t.newRange.start.isEqual(e.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?t.newRange.start=ks._createAt(e.insertionPosition):t.newRange.start.isEqual(e.splitPosition)&&!i.abRelation.wasInLeftElement&&(t.newRange.start=ks._createAt(e.moveTargetPosition)),t.newRange.end.isEqual(e.splitPosition)&&i.abRelation.wasInRightElement?t.newRange.end=ks._createAt(e.moveTargetPosition):t.newRange.end.isEqual(e.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?t.newRange.end=ks._createAt(e.insertionPosition):t.newRange.end=o.end,[t]}t.newRange=t.newRange._getTransformedBySplitOperation(e)}return[t]}),Dh(Ba,Va,(t,e)=>(t.sourcePosition.hasSameParentAs(e.position)&&(t.howMany+=e.howMany),t.sourcePosition=t.sourcePosition._getTransformedByInsertOperation(e),t.targetPosition=t.targetPosition._getTransformedByInsertOperation(e),[t])),Dh(Ba,Ba,(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 ks(e.graveyardPosition.root,i),t.howMany=0,[t]}return[new rl(0)]}if(t.sourcePosition.isEqual(e.sourcePosition)&&!t.targetPosition.isEqual(e.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const o="$graveyard"==t.targetPosition.root.rootName,n="$graveyard"==e.targetPosition.root.rootName,r=o&&!n;if(n&&!o||!r&&i.aIsStrong){const i=e.targetPosition._getTransformedByMergeOperation(e),o=t.targetPosition._getTransformedByMergeOperation(e);return[new Oa(i,t.howMany,o,0)]}return[new rl(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]}),Dh(Ba,Oa,(t,e,i)=>{const o=xs._createFromPositionAndShift(e.sourcePosition,e.howMany);return"remove"==e.type&&!i.bWasUndone&&!i.forceWeakRemove&&t.deletionPosition.hasSameParentAs(e.sourcePosition)&&o.containsPosition(t.sourcePosition)?[new rl(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])}),Dh(Ba,ja,(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 o=0!=e.howMany,n=e.graveyardPosition&&t.deletionPosition.isEqual(e.graveyardPosition);if(o||n||"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]}),Dh(Oa,Va,(t,e)=>{const i=xs._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]}),Dh(Oa,Oa,(t,e,i)=>{const o=xs._createFromPositionAndShift(t.sourcePosition,t.howMany),n=xs._createFromPositionAndShift(e.sourcePosition,e.howMany);let r,s=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),r=t.targetPosition.isEqual(e.targetPosition)&&a?t.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):t.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Yh(t,e)&&Yh(e,t))return[e.getReversed()];if(o.containsPosition(e.targetPosition)&&o.containsRange(n,!0))return o.start=o.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),o.end=o.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),$h([o],r);if(n.containsPosition(t.targetPosition)&&n.containsRange(o,!0))return o.start=o.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),o.end=o.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),$h([o],r);const l=Mi(t.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return o.start=o.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),o.end=o.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),$h([o],r);"remove"!=t.type||"remove"==e.type||i.aWasUndone||i.forceWeakRemove?"remove"==t.type||"remove"!=e.type||i.bWasUndone||i.forceWeakRemove||(s=!1):s=!0;const c=[],d=o.getDifference(n);for(const t of d){t.start=t.start._getTransformedByDeletion(e.sourcePosition,e.howMany),t.end=t.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const i="same"==Mi(t.start.getParentPath(),e.getMovedRangeStart().getParentPath()),o=t._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,i);c.push(...o)}const u=o.getIntersection(n);return null!==u&&s&&(u.start=u.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),u.end=u.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),0===c.length?c.push(u):1==c.length?n.start.isBefore(o.start)||n.start.isEqual(o.start)?c.unshift(u):c.push(u):c.splice(1,0,u)),0===c.length?[new rl(t.baseVersion)]:$h(c,r)}),Dh(Oa,ja,(t,e,i)=>{let o=t.targetPosition.clone();t.targetPosition.isEqual(e.insertionPosition)&&e.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(o=t.targetPosition._getTransformedBySplitOperation(e));const n=xs._createFromPositionAndShift(t.sourcePosition,t.howMany);if(n.end.isEqual(e.insertionPosition))return e.graveyardPosition||t.howMany++,t.targetPosition=o,[t];if(n.start.hasSameParentAs(e.splitPosition)&&n.containsPosition(e.splitPosition)){let t=new xs(e.splitPosition,n.end);t=t._getTransformedBySplitOperation(e);return $h([new xs(n.start,e.splitPosition),t],o)}t.targetPosition.isEqual(e.splitPosition)&&"insertAtSource"==i.abRelation&&(o=e.moveTargetPosition),t.targetPosition.isEqual(e.insertionPosition)&&"insertBetween"==i.abRelation&&(o=t.targetPosition);const r=[n._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const o=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);t.howMany>1&&o&&!i.aWasUndone&&r.push(xs._createFromPositionAndShift(e.insertionPosition,1))}return $h(r,o)}),Dh(Oa,Ba,(t,e,i)=>{const o=xs._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.deletionPosition.hasSameParentAs(t.sourcePosition)&&o.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 rl(0)]}else if(!i.aWasUndone){const i=[];let o=e.graveyardPosition.clone(),n=e.targetPosition._getTransformedByMergeOperation(e);t.howMany>1&&(i.push(new Oa(t.sourcePosition,t.howMany-1,t.targetPosition,0)),o=o._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany-1),n=n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany-1));const r=e.deletionPosition._getCombined(t.sourcePosition,t.targetPosition),s=new Oa(o,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const l=new ks(s.targetPosition.root,a);n=n._getTransformedByMove(o,r,1);const c=new Oa(n,e.howMany,l,0);return i.push(s),i.push(c),i}const n=xs._createFromPositionAndShift(t.sourcePosition,t.howMany)._getTransformedByMergeOperation(e);return t.sourcePosition=n.start,t.howMany=n.end.offset-n.start.offset,t.targetPosition=t.targetPosition._getTransformedByMergeOperation(e),[t]}),Dh(za,Va,(t,e)=>(t.position=t.position._getTransformedByInsertOperation(e),[t])),Dh(za,Ba,(t,e)=>t.position.isEqual(e.deletionPosition)?(t.position=e.graveyardPosition.clone(),t.position.stickiness="toNext",[t]):(t.position=t.position._getTransformedByMergeOperation(e),[t])),Dh(za,Oa,(t,e)=>(t.position=t.position._getTransformedByMoveOperation(e),[t])),Dh(za,za,(t,e,i)=>{if(t.position.isEqual(e.position)){if(!i.aIsStrong)return[new rl(0)];t.oldName=e.newName}return[t]}),Dh(za,ja,(t,e)=>{if("same"==Mi(t.position.path,e.splitPosition.getParentPath())&&!e.graveyardPosition){const e=new za(t.position.getShiftedBy(1),t.oldName,t.newName,0);return[t,e]}return t.position=t.position._getTransformedBySplitOperation(e),[t]}),Dh(Da,Da,(t,e,i)=>{if(t.root===e.root&&t.key===e.key){if(!i.aIsStrong||t.newValue===e.newValue)return[new rl(0)];t.oldValue=e.newValue}return[t]}),Dh(ja,Va,(t,e)=>(t.splitPosition.hasSameParentAs(e.position)&&t.splitPosition.offset{if(!t.graveyardPosition&&!i.bWasUndone&&t.splitPosition.hasSameParentAs(e.sourcePosition)){const i=e.graveyardPosition.path.slice();i.push(0);const o=new ks(e.graveyardPosition.root,i),n=ja.getInsertionPosition(new ks(e.graveyardPosition.root,i)),r=new ja(o,0,null,0);return r.insertionPosition=n,t.splitPosition=t.splitPosition._getTransformedByMergeOperation(e),t.insertionPosition=ja.getInsertionPosition(t.splitPosition),t.graveyardPosition=r.insertionPosition.clone(),t.graveyardPosition.stickiness="toNext",[r,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=ja.getInsertionPosition(t.splitPosition),t.graveyardPosition&&(t.graveyardPosition=t.graveyardPosition._getTransformedByMergeOperation(e)),[t]}),Dh(ja,Oa,(t,e,i)=>{const o=xs._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.graveyardPosition){const n=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);if(!i.bWasUndone&&n){const i=t.splitPosition._getTransformedByMoveOperation(e),o=t.graveyardPosition._getTransformedByMoveOperation(e),n=o.path.slice();n.push(0);const r=new ks(o.root,n);return[new Oa(i,t.howMany,r,0)]}t.graveyardPosition=t.graveyardPosition._getTransformedByMoveOperation(e)}if(t.splitPosition.hasSameParentAs(e.sourcePosition)&&o.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{if(t.splitPosition.isEqual(e.splitPosition)){if(!t.graveyardPosition&&!e.graveyardPosition)return[new rl(0)];if(t.graveyardPosition&&e.graveyardPosition&&t.graveyardPosition.isEqual(e.graveyardPosition))return[new rl(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 o="$graveyard"==t.splitPosition.root.rootName,n="$graveyard"==e.splitPosition.root.rootName,r=o&&!n;if(n&&!o||!r&&i.aIsStrong){const i=[];return e.howMany&&i.push(new Oa(e.moveTargetPosition,e.howMany,e.splitPosition,0)),t.howMany&&i.push(new Oa(t.splitPosition,t.howMany,t.moveTargetPosition,0)),i}return[new rl(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 o=new ks(e.insertionPosition.root,i);return[t,new Oa(t.insertionPosition,1,o,0)]}return t.splitPosition.hasSameParentAs(e.splitPosition)&&t.splitPosition.offset0}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 o=this.editor.model,n=o.document,r=[];for(const e of t){const t=Kh(e,i).find(t=>t.start.root!=n.graveyard);t&&r.push(t)}r.length&&o.change(t=>{t.setSelection(r,{backward:e})})}_undo(t,e){const i=this.editor.model,o=i.document;this._createdBatches.add(e);const n=t.operations.slice().filter(t=>t.isDocumentOperation);n.reverse();for(const t of n){const n=t.baseVersion+1,r=Array.from(o.history.getOperations(n)),s=Fh([t.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const n of s)e.addOperation(n),i.applyOperation(n),o.history.setOperationAsUndone(t,n)}}}function Kh(t,e){const i=t.getTransformedByOperations(e);i.sort((t,e)=>t.start.isBefore(e.start)?-1:1);for(let t=1;te.batch==t):this._stack.length-1,i=this._stack.splice(e,1)[0],o=this.editor.model.createBatch("transparent");this.editor.model.enqueueChange(o,()=>{this._undo(i.batch,o);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,o)}),this.refresh()}}class Jh extends Gh{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,o=this.editor.model.document.history.getOperations(i);this._restoreSelection(t.selection.ranges,t.selection.isBackward,o),this._undo(t.batch,e)}),this.refresh()}}class Zh extends Wc{static get pluginName(){return"UndoEditing"}constructor(t){super(t),this._batchRegistry=new WeakSet}init(){const t=this.editor;this._undoCommand=new Qh(t),this._redoCommand=new Jh(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 o=i.batch,n=this._redoCommand._createdBatches.has(o),r=this._undoCommand._createdBatches.has(o);this._batchRegistry.has(o)||"transparent"==o.type&&!n&&!r||(n?this._undoCommand.addBatch(o):r||(this._undoCommand.addBatch(o),this._redoCommand.clearStack()),this._batchRegistry.add(o))},{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")}}var Xh='',tg='';class eg extends Wc{init(){const t=this.editor,e=t.locale,i=t.t,o="ltr"==e.uiLanguageDirection?Xh:tg,n="ltr"==e.uiLanguageDirection?tg:Xh;this._addButton("undo",i("Undo"),"CTRL+Z",o),this._addButton("redo",i("Redo"),"CTRL+Y",n)}_addButton(t,e,i,o){const n=this.editor;n.ui.componentFactory.add(t,r=>{const s=n.commands.get(t),a=new Tc(r);return a.set({label:e,icon:o,keystroke:i,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",()=>{n.execute(t),n.editing.view.focus()}),a})}}class ig extends Wc{static get requires(){return[Zh,eg]}static get pluginName(){return"Undo"}}class og extends qc{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,o=t.value;e.change(t=>{if(i.isCollapsed)o?t.setSelectionAttribute(this.attributeKey,o):t.removeSelectionAttribute(this.attributeKey);else{const n=e.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const e of n)o?t.setAttribute(this.attributeKey,o,e):t.removeAttribute(this.attributeKey,e)}})}}class ng extends Tc{constructor(t){super(t);const e=this.bindTemplate;this.set("color"),this.set("hasBorder"),this.icon='',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(51);class rg extends sc{constructor(t,e){super(t);const i=e&&e.colorDefinitions||[],o={};e&&e.columns&&(o.gridTemplateColumns=`repeat( ${e.columns}, 1fr)`),this.set("selectedColor"),this.items=this.createCollection(),this.focusTracker=new Nl,this.keystrokes=new Al,this._focusCycler=new gc({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 ng;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:o}}),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)}}i(53);class sg extends sc{constructor(t){super(t),this.set("text"),this.set("for"),this.id="ck-editor__label_"+ci();const e=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:e.to("for")},children:[{text:e.to("text")}]})}}class ag extends xi{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)}}yi(ag,Ho);var lg='';i(55);function cg(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}class dg extends og{constructor(t){super(t,"fontFamily")}}function ug(t){return t.map(hg).filter(t=>!!t)}function hg(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],o=e.map(gg).join(", ");return{title:i,model:i,view:{name:"span",styles:{"font-family":o},priority:7}}}(t):void 0}function gg(t){return(t=t.trim()).indexOf(" ")>0&&(t=`'${t}'`),t}class mg extends Wc{static get pluginName(){return"FontFamilyEditing"}constructor(t){super(t),t.config.define("fontFamily",{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"fontFamily"}),t.model.schema.setAttributeProperties("fontFamily",{isFormatting:!0,copyOnEnter:!0});const e=cg("fontFamily",ug(t.config.get("fontFamily.options")).filter(t=>t.model));t.config.get("fontFamily.supportAllValues")?this._prepareAnyValueConverters():t.conversion.attributeToElement(e),t.commands.add("fontFamily",new dg(t))}_prepareAnyValueConverters(){const t=this.editor;t.conversion.for("downcast").attributeToElement({model:"fontFamily",view:(t,e)=>e.createAttributeElement("span",{style:"font-family:"+t},{priority:7})}),t.conversion.for("upcast").attributeToAttribute({model:{key:"fontFamily",value:t=>t.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}}class fg extends Wc{init(){const t=this.editor,e=t.t,i=this._getLocalizedOptions(),o=t.commands.get("fontFamily");t.ui.componentFactory.add("fontFamily",n=>{const r=Oc(n);return Lc(r,function(t,e){const i=new xi;for(const o of t){const t={type:"button",model:new lh({commandName:"fontFamily",commandParam:o.model,label:o.title,withText:!0})};t.model.bind("isOn").to(e,"value",t=>t===o.model||!(!t||!o.model)&&t.split(",")[0].replace(/'/g,"").toLowerCase()===o.model.toLowerCase()),o.view&&o.view.styles&&t.model.set("labelStyle","font-family: "+o.view.styles["font-family"]),i.add(t)}return i}(i,o)),r.buttonView.set({label:e("Font Family"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(o),this.listenTo(r,"execute",e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()}),r})}_getLocalizedOptions(){const t=this.editor,e=t.t;return ug(t.config.get("fontFamily").options).map(t=>("Default"===t.title&&(t.title=e("Default")),t))}}class pg extends og{constructor(t){super(t,"fontSize")}}function bg(t){return t.map(t=>function(t){if(e=t,"object"==typeof e&&e.title&&e.model&&e.view)return kg(t);var e;const i=function(t){return wg[t]||wg[t.model]}(t);if(i)return kg(i);if("default"===t)return{model:void 0,title:"Default"};if(function(t){let e;if("object"==typeof t){if(!t.model)throw new ui.b("font-size-invalid-definition: Provided font size definition is invalid.",null,t);e=parseFloat(t.model)}else e=parseFloat(t);return isNaN(e)}(t))return;return function(t){"number"!=typeof t&&"string"!=typeof t||(t={title:String(t),model:parseFloat(t)+"px"});return t.view={name:"span",styles:{"font-size":t.model}},kg(t)}(t)}(t)).filter(t=>!!t)}const wg={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function kg(t){return t.view.priority||(t.view.priority=7),t}class _g extends Wc{static get pluginName(){return"FontSizeEditing"}constructor(t){super(t),t.config.define("fontSize",{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"fontSize"}),t.model.schema.setAttributeProperties("fontSize",{isFormatting:!0,copyOnEnter:!0});const e=t.config.get("fontSize.supportAllValues"),i=cg("fontSize",bg(this.editor.config.get("fontSize.options")).filter(t=>t.model));e?this._prepareAnyValueConverters(i):t.conversion.attributeToElement(i),t.commands.add("fontSize",new pg(t))}_prepareAnyValueConverters(t){const e=this.editor,i=t.model.values.filter(t=>!String(t).match(/[\d.]+[\w%]+/));if(i.length)throw new ui.b("font-size-invalid-use-of-named-presets: If config.fontSize.supportAllValues is set to true, you need to use numerical values as font size options.",null,{presets:i});e.conversion.for("downcast").attributeToElement({model:"fontSize",view:(t,e)=>{if(t)return e.createAttributeElement("span",{style:"font-size:"+t},{priority:7})}}),e.conversion.for("upcast").attributeToAttribute({model:{key:"fontSize",value:t=>t.getStyle("font-size")},view:{name:"span"}})}}i(57);class vg extends Wc{init(){const t=this.editor,e=t.t,i=this._getLocalizedOptions(),o=t.commands.get("fontSize");t.ui.componentFactory.add("fontSize",n=>{const r=Oc(n);return Lc(r,function(t,e){const i=new xi;for(const o of t){const t={type:"button",model:new lh({commandName:"fontSize",commandParam:o.model,label:o.title,class:"ck-fontsize-option",withText:!0})};o.view&&o.view.styles&&t.model.set("labelStyle","font-size:"+o.view.styles["font-size"]),o.view&&o.view.classes&&t.model.set("class",`${t.model.class} ${o.view.classes}`),t.model.bind("isOn").to(e,"value",t=>t===o.model),i.add(t)}return i}(i,o)),r.buttonView.set({label:e("Font Size"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(o),this.listenTo(r,"execute",e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()}),r})}_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 bg(t.config.get("fontSize").options).map(t=>{const e=i[t.title];return e&&e!=t.title&&(t=Object.assign({},t,{title:e})),t})}}class yg extends qc{refresh(){const t=this.editor.model,e=$c(t.document.selection.getSelectedBlocks());this.value=!!e&&e.is("paragraph"),this.isEnabled=!!e&&xg(e,t.schema)}execute(t={}){const e=this.editor.model,i=e.document;e.change(o=>{const n=(t.selection||i.selection).getSelectedBlocks();for(const t of n)!t.is("paragraph")&&xg(t,e.schema)&&o.rename(t,"paragraph")})}}function xg(t,e){return e.checkChild(t.parent,"paragraph")&&!e.isObject(t)}class Ag extends qc{execute(t){const e=this.editor.model;e.schema.checkChild(t.position,"paragraph")&&e.change(i=>{const o=i.createElement("paragraph");e.insertContent(o,t.position),i.setSelection(o,"in")})}}class Cg extends Wc{static get pluginName(){return"Paragraph"}init(){const t=this.editor,e=t.model,i=t.data;t.commands.add("paragraph",new yg(t)),t.commands.add("insertParagraph",new Ag(t)),e.schema.register("paragraph",{inheritAllFrom:"$block"}),t.conversion.elementToElement({model:"paragraph",view:"p"}),t.conversion.for("upcast").elementToElement({model:(t,e)=>Cg.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})&&Sg(e.viewItem,e.modelCursor,i.schema)&&Object.assign(e,Tg(e.viewItem,e.modelCursor,i))},{priority:"low"}),i.upcastDispatcher.on("text",(t,e,i)=>{e.modelRange||Sg(e.viewItem,e.modelCursor,i.schema)&&Object.assign(e,Tg(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 o=e.document.getRoot(i);if(o.isEmpty&&"$graveyard"!=o.rootName&&e.schema.checkChild(o,"paragraph"))return t.insertElement("paragraph",o),!0}}}function Tg(t,e,i){const o=i.writer.createElement("paragraph");return i.writer.insert(o,e),i.convertItem(t,i.writer.createPositionAt(o,0))}function Sg(t,e,i){const o=i.createContext(e);return!!i.checkChild(o,"paragraph")&&!!i.checkChild(o.push("paragraph"),t)}Cg.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td"]);class Pg extends qc{constructor(t,e){super(t),this.modelElements=e}refresh(){const t=$c(this.editor.model.document.selection.getSelectedBlocks());this.value=!!t&&this.modelElements.includes(t.name)&&t.name,this.isEnabled=!!t&&this.modelElements.some(e=>Eg(t,e,this.editor.model.schema))}execute(t){const e=this.editor.model,i=e.document,o=t.value;e.change(t=>{const n=Array.from(i.selection.getSelectedBlocks()).filter(t=>Eg(t,o,e.schema));for(const e of n)e.is(o)||t.rename(e,o)})}}function Eg(t,e,i){return i.checkChild(t.parent,e)&&!i.isObject(t)}class Mg extends Wc{static get pluginName(){return"HeadingEditing"}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[Cg]}init(){const t=this.editor,e=t.config.get("heading.options"),i=[];for(const o of e)"paragraph"!==o.model&&(t.model.schema.register(o.model,{inheritAllFrom:"$block"}),t.conversion.elementToElement(o),i.push(o.model));this._addDefaultH1Conversion(t),t.commands.add("heading",new Pg(t,i))}afterInit(){const t=this.editor,e=t.commands.get("enter"),i=t.config.get("heading.options");e&&this.listenTo(e,"afterExecute",(e,o)=>{const n=t.model.document.selection.getFirstPosition().parent;i.some(t=>n.is(t.model))&&!n.is("paragraph")&&0===n.childCount&&o.writer.rename(n,"paragraph")})}_addDefaultH1Conversion(t){t.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:di.get("low")+1})}}i(12);class Ig extends Wc{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),o=e("Choose heading"),n=e("Heading");t.ui.componentFactory.add("heading",e=>{const r={},s=new xi,a=t.commands.get("heading"),l=t.commands.get("paragraph"),c=[a];for(const t of i){const e={type:"button",model:new lh({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})),s.add(e),r[t.model]=t.title}const d=Oc(e);return Lc(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:n}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(c,"isEnabled",(...t)=>t.some(t=>t)),d.buttonView.bind("label").to(a,"value",l,"value",(t,e)=>{const i=t||e&&"paragraph";return r[i]?r[i]:o}),this.listenTo(d,"execute",e=>{t.execute(e.source.commandName,e.source.commandValue?{value:e.source.commandValue}:void 0),t.editing.view.focus()}),d})}}class Ng extends qc{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,o=t.value;e.change(t=>{const n=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,n=e.getLastMatchingPosition(i,{direction:"backward"}),r=e.getLastMatchingPosition(i),s=t.createRange(n,r);o&&this.value!==o?(t.setAttribute("highlight",o,s),t.setSelectionAttribute("highlight",o)):(t.removeAttribute("highlight",s),t.removeSelectionAttribute("highlight"))}else o&&t.setSelectionAttribute("highlight",o)}else for(const e of n)o?t.setAttribute("highlight",o,e):t.removeAttribute("highlight",e)})}}class Rg extends Wc{static get pluginName(){return"HighlightEditing"}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 Ng(t))}}i(60);class Og extends Wc{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"),lg)}_addHighlighterButton(t){const e=this.editor.commands.get("highlight");this._addButton("highlight:"+t.model,t.title,Vg(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,o,n=(()=>{})){const r=this.editor;r.ui.componentFactory.add(t,t=>{const s=new Tc(t),a=this.localizedOptionTitles[e]?this.localizedOptionTitles[e]:e;return s.set({label:a,icon:i,tooltip:!0}),s.on("execute",()=>{r.execute("highlight",{value:o}),r.editing.view.focus()}),n(s),s})}_addDropdown(t){const e=this.editor,i=e.t,o=e.ui.componentFactory,n=t[0],r=t.reduce((t,e)=>(t[e.model]=e,t),{});o.add("highlight",s=>{const a=e.commands.get("highlight"),l=Oc(s,ch),c=l.buttonView;c.set({tooltip:i("Highlight"),lastExecuted:n.model,commandValue:n.model,isToggleable:!0}),c.bind("icon").to(a,"value",t=>Vg(u(t,"type"))),c.bind("color").to(a,"value",t=>u(t,"color")),c.bind("commandValue").to(a,"value",t=>u(t,"model")),c.bind("isOn").to(a,"value",t=>!!t),c.delegate("execute").to(l);const d=t.map(t=>{const e=o.create("highlight:"+t.model);return this.listenTo(e,"execute",()=>l.buttonView.set({lastExecuted:t.model})),e});function u(t,e){const i=t&&t!==c.lastExecuted?t:c.lastExecuted;return r[i][e]}return l.bind("isEnabled").toMany(d,"isEnabled",(...t)=>t.some(t=>t)),d.push(new fc),d.push(o.create("removeHighlight")),Vc(l,d),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 Vg(t){return"marker"===t?'':''}class Lg extends Nr{constructor(t){super(t),this.domEventType="mousedown"}onDomEvent(t){this.fire(t.type,t)}}function zg(t){const e=[];return(!t.previousSibling||function(t){return t.previousSibling&&Nd(t.previousSibling)}(t))&&e.push("before"),(function(t){return!t.nextSibling}(t)||function(t){return t.nextSibling&&Nd(t.nextSibling)}(t))&&e.push("after"),e}i(62);const Dg=["before","after"],Bg=(new DOMParser).parseFromString('\n',"image/svg+xml").firstChild;class jg extends Wc{static get requires(){return[Cg]}static get pluginName(){return"WidgetTypeAround"}constructor(t){super(t),this._widgetsWithTypeAroundUI=new Set}destroy(){this._widgetsWithTypeAroundUI.clear()}init(){this._enableTypeAroundUIInjection(),this._enableDetectionOfTypeAroundWidgets(),this._enableInsertingParagraphsOnButtonClick()}_insertParagraph(t,e){const i=this.editor,o=i.editing.view,n=i.editing.mapper.toModelElement(t);let r;r="before"===e?i.model.createPositionBefore(n):i.model.createPositionAfter(n),i.execute("insertParagraph",{position:r}),o.focus(),o.scrollToTheSelection()}_enableTypeAroundUIInjection(){const t=this.editor,e=t.model.schema,i=t.locale.t,o={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};t.editing.downcastDispatcher.on("insert",(t,i,n)=>{const r=n.mapper.toViewElement(i.item);(function(t,e,i){return t&&Nd(t)&&!i.isInline(e)})(r,i.item,e)&&(!function(t,e,i){const o=t.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(t){const i=this.toDomElement(t);return function(t,e){for(const i of Dg){const o=new Fl({tag:"div",attributes:{class:["ck","ck-widget__type-around__button","ck-widget__type-around__button_"+i],title:e[i]},children:[t.ownerDocument.importNode(Bg,!0)]});t.appendChild(o.render())}}(i,e),i}));t.insert(t.createPositionAt(i,"end"),o)}(n.writer,o,r),this._widgetsWithTypeAroundUI.add(r))},{priority:"low"})}_enableDetectionOfTypeAroundWidgets(){function t(t){return"ck-widget_can-type-around_"+t}this.editor.editing.view.document.registerPostFixer(e=>{for(const i of this._widgetsWithTypeAroundUI)if(i.isAttached()){const o=zg(i);e.removeClass(Dg.map(t),i),e.addClass(o.map(t),i)}else this._widgetsWithTypeAroundUI.delete(i)})}_enableInsertingParagraphsOnButtonClick(){const t=this.editor.editing.view;t.document.on("mousedown",(e,i)=>{const o=i.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const n=function(t){return t.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),r=function(t,e){const i=t.closest(".ck-widget");return e.mapDomToView(i)}(o,t.domConverter);this._insertParagraph(r,n),i.preventDefault(),e.stop()})}}i(64);class Fg extends Wc{static get pluginName(){return"Widget"}static get requires(){return[jg]}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 o=i.writer,n=o.document.selection,r=n.getSelectedElement();let s=null;for(const t of n.getRanges())for(const e of t){const t=e.item;Nd(t)&&!Hg(t,s)&&(o.addClass("ck-widget_selected",t),this._previouslySelected.add(t),s=t,t==r&&o.setSelection(n.getRanges(),{fake:!0,label:Od(r)}))}},{priority:"low"}),t.addObserver(Lg),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,o=i.editing.view,n=o.document;let r=e.target;if(function(t){for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(Nd(t))return!1;t=t.parent}return!1}(r)){if(hn.isSafari&&e.domEvent.detail>=3){const t=i.editing.mapper.toModelElement(r);this.editor.model.change(i=>{e.preventDefault(),i.setSelection(t,"in")})}return}if(!Nd(r)&&(r=r.findAncestor(Nd),!r))return;e.preventDefault(),n.isFocused||o.focus();const s=i.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_onKeydown(t,e){const i=e.keyCode,o="ltr"===this.editor.locale.contentLanguageDirection,n=i==fn.arrowdown||i==fn[o?"arrowright":"arrowleft"];let r=!1;!function(t){return t==fn.arrowright||t==fn.arrowleft||t==fn.arrowup||t==fn.arrowdown}(i)?i===fn.enter&&(r=this._handleEnterKey(e.shiftKey)):r=this._handleArrowKeys(n),r&&(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 o=e.anchor.parent;for(;o.isEmpty;){const e=o;o=e.parent,t.remove(e)}this._setSelectionOverElement(i)}),!0):void 0}_handleArrowKeys(t){const e=this.editor.model,i=e.schema,o=e.document.selection,n=o.getSelectedElement();if(n&&i.isObject(n)){const n=t?o.getLastPosition():o.getFirstPosition(),r=i.getNearestSelectionRange(n,t?"forward":"backward");return r&&e.change(t=>{t.setSelection(r)}),!0}if(!o.isCollapsed)return;const r=this._getObjectElementNextToSelection(t);return r&&i.isObject(r)?(this._setSelectionOverElement(r),!0):void 0}_handleEnterKey(t){const e=this.editor.model,i=e.document.selection.getSelectedElement();if(o=i,n=e.schema,o&&n.isObject(o)&&!n.isInline(o))return e.change(o=>{let n=o.createPositionAt(i,t?"before":"after");const r=o.createElement("paragraph");if(e.schema.isBlock(i.parent)){const t=e.schema.findAllowedParent(n,r);n=o.split(n,t).position}o.insert(r,n),o.setSelection(r,"in")}),!0;var o,n}_setSelectionOverElement(t){this.editor.model.change(e=>{e.setSelection(e.createRangeOn(t))})}_getObjectElementNextToSelection(t){const e=this.editor.model,i=e.schema,o=e.document.selection,n=e.createSelection(o);e.modifySelection(n,{direction:t?"forward":"backward"});const r=t?n.focus.nodeBefore:n.focus.nodeAfter;return r&&i.isObject(r)?r:null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected)t.removeClass("ck-widget_selected",e);this._previouslySelected.clear()}}function Hg(t,e){return!!e&&Array.from(t.getAncestors()).includes(e)}class Wg extends qc{refresh(){const t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=jd(t),jd(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)})}}class Ug extends Wc{static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new Wg(this.editor))}}i(66);class qg extends sc{constructor(t,e){super(t);const i="ck-labeled-field-view-"+ci(),o="ck-labeled-field-view-status-"+ci();this.fieldView=e(this,i,o),this.set("label"),this.set("isEnabled",!0),this.set("errorText",null),this.set("infoText",null),this.set("class"),this.labelView=this._createLabelView(i),this.statusView=this._createStatusView(o),this.bind("_statusText").to(this,"errorText",this,"infoText",(t,e)=>t||e);const n=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",n.to("class"),n.if("isEnabled","ck-disabled",t=>!t)]},children:[this.labelView,this.fieldView,this.statusView]})}_createLabelView(t){const e=new sg(this.locale);return e.for=t,e.bind("text").to(this,"label"),e}_createStatusView(t){const e=new sc(this.locale),i=this.bindTemplate;return e.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",i.if("errorText","ck-labeled-field-view__status_error"),i.if("_statusText","ck-hidden",t=>!t)],id:t,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),e}focus(){this.fieldView.focus()}}i(68);class Yg extends sc{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,o)=>{t(o)})}select(){this.element.select()}focus(){this.element.focus()}}function $g(t,e,i){const o=new Yg(t.locale);return o.set({id:e,ariaDescribedById:i}),o.bind("isReadOnly").to(t,"isEnabled",t=>!t),o.bind("hasError").to(t,"errorText",t=>!!t),o.on("input",()=>{t.errorText=null}),o}function Gg(t,e,i){const o=Oc(t.locale);return o.set({id:e,ariaDescribedById:i}),o.bind("isEnabled").to(t),o}function Kg({view:t}){t.listenTo(t.element,"submit",(e,i)=>{i.preventDefault(),t.fire("submit")},{useCapture:!0})}var Qg='',Jg='';i(70);class Zg extends sc{constructor(t){super(t);const e=this.locale.t;this.focusTracker=new Nl,this.keystrokes=new Al,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(e("Save"),Qg,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(e("Cancel"),Jg,"ck-button-cancel","cancel"),this._focusables=new jl,this._focusCycler=new gc({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),Kg({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach(t=>{this._focusables.add(t),this.focusTracker.add(t.element)})}_createButton(t,e,i,o){const n=new Tc(this.locale);return n.set({label:t,icon:e,tooltip:!0}),n.extendTemplate({attributes:{class:i}}),o&&n.delegate("execute").to(this,o),n}_createLabeledInputView(){const t=this.locale.t,e=new qg(this.locale,$g);return e.label=t("Text alternative"),e.fieldView.placeholder=t("Text alternative"),e}}i(72),i(74);const Xg=Cd("px");class tm extends Wc{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 Pd(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 ui.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 ui.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 ui.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 em(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 o=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return e("%0 of %1",[o,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 im(this.editor.locale,this.view);return t.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",(t,e)=>!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:o=!1}){this.view.class=e,this.view.withArrow=i,this._rotatorView.showView(t),this.visibleView=t,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),o&&(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 em extends sc{constructor(t){super(t);const e=t.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Nl,this.buttonPrevView=this._createButtonView(e("Previous"),''),this.buttonNextView=this._createButtonView(e("Next"),''),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 Tc(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i}}class im extends sc{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",Xg),left:i.to("left",Xg),width:i.to("width",Xg),height:i.to("height",Xg)}},children:this.content}),this.on("change:numberOfPanels",(t,e,i,o)=>{i>o?this._addPanels(i-o):this._removePanels(o-i),this.updatePosition()})}_addPanels(t){for(;t--;){const t=new sc;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:o}=new Zr(this._balloonPanelView.element);Object.assign(this,{top:t,left:e,width:i,height:o})}}}function om(t){const e=t.editing.view,i=Pd.defaultPositions;return{target:e.domConverter.viewToDom(e.document.selection.getSelectedElement()),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast]}}class nm extends Wc{static get requires(){return[tm]}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 o=t.commands.get("imageTextAlternative"),n=new Tc(i);return n.set({label:e("Change image text alternative"),icon:'',tooltip:!0}),n.bind("isEnabled").to(o,"isEnabled"),this.listenTo(n,"execute",()=>{this._showForm()}),n})}_createForm(){const t=this.editor,e=t.editing.view.document;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new Zg(t.locale),this._form.render(),this.listenTo(this._form,"submit",()=>{t.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.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",()=>{Bd(e.selection)?this._isVisible&&function(t){const e=t.plugins.get("ContextualBalloon");if(Bd(t.editing.view.document.selection)){const i=om(t);e.updatePosition(i)}}(t):this._hideForm(!0)}),Rc({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:om(t)}),i.fieldView.value=i.fieldView.element.value=e.value||"",this._form.labeledInput.fieldView.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)}}class rm extends Wc{static get requires(){return[Ug,nm]}static get pluginName(){return"ImageTextAlternative"}}i(76);function sm(t){for(const e of t.getChildren())if(e&&e.is("caption"))return e;return null}function am(t){const e=t.parent;return"figcaption"==t.name&&e&&"figure"==e.name&&e.hasClass("image")?{name:!0}:null}class lm extends Wc{static get pluginName(){return"ImageCaptionEditing"}init(){const t=this.editor,e=t.editing.view,i=t.model.schema,o=t.data,n=t.editing,r=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:am,model:"caption"});o.downcastDispatcher.on("insert:caption",cm(t=>t.createContainerElement("figcaption"),!1));const s=function(t,e){return i=>{const o=i.createEditableElement("figcaption");return i.setCustomProperty("imageCaption",!0,o),Vl({view:t,element:o,text:e}),Vd(o,i)}}(e,r("Enter image caption"));n.downcastDispatcher.on("insert:caption",cm(s)),n.downcastDispatcher.on("insert",this._fixCaptionVisibility(t=>t.item),{priority:"high"}),n.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 o;const n=this.editor.model.document.selection,r=n.getSelectedElement();if(r&&r.is("image")){const t=sm(r);o=e.toViewElement(t)}const s=dm(n.getFirstPosition().parent);if(s&&(o=e.toViewElement(s)),o)return i?(i===o||(um(i,t),this._lastSelectedCaption=o),hm(o,t)):(this._lastSelectedCaption=o,hm(o,t));if(i){const e=um(i,t);return this._lastSelectedCaption=null,e}return!1}_fixCaptionVisibility(t){return(e,i,o)=>{const n=dm(t(i)),r=this.editor.editing.mapper,s=o.writer;if(n){const t=r.toViewElement(n);t&&(n.childCount?s.removeClass("ck-hidden",t):s.addClass("ck-hidden",t))}}}_insertMissingModelCaptionElement(t){const e=this.editor.model,i=e.document.differ.getChanges(),o=[];for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter;if(i.is("image")&&!sm(i)&&o.push(i),!i.is("image")&&i.childCount)for(const t of e.createRangeIn(i).getItems())t.is("image")&&!sm(t)&&o.push(t)}for(const e of o)t.appendElement("caption",e);return!!o.length}}function cm(t,e=!0){return(i,o,n)=>{const r=o.item;if((r.childCount||e)&&jd(r.parent)){if(!n.consumable.consume(o.item,"insert"))return;const e=n.mapper.toViewElement(o.range.start.parent),i=t(n.writer),s=n.writer;r.childCount||s.addClass("ck-hidden",i),function(t,e,i,o){const n=o.writer.createPositionAt(i,"end");o.writer.insert(n,t),o.mapper.bindElements(e,t)}(i,o.item,e,n)}}}function dm(t){const e=t.getAncestors({includeSelf:!0}).find(t=>"caption"==t.name);return e&&e.parent&&"image"==e.parent.name?e:null}function um(t,e){return!t.childCount&&!t.hasClass("ck-hidden")&&(e.addClass("ck-hidden",t),!0)}function hm(t,e){return!!t.hasClass("ck-hidden")&&(e.removeClass("ck-hidden",t),!0)}i(78);class gm{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 o=new Zr(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 Zr(t),o=e.split("-"),n={x:"right"==o[1]?i.right:i.left,y:"bottom"==o[0]?i.bottom:i.top};return n.x+=t.ownerDocument.defaultView.scrollX,n.y+=t.ownerDocument.defaultView.scrollY,n}(e,function(t){const e=t.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[e[0]]}-${i[e[1]]}`}(this.activeHandlePosition)),this.originalWidth=o.width,this.originalHeight=o.height,this.aspectRatio=o.width/o.height;const n=i.style.width;n&&n.match(/^\d+\.?\d*%$/)?this.originalWidthPercents=parseFloat(n):this.originalWidthPercents=function(t,e){const i=t.parentElement,o=parseFloat(i.ownerDocument.defaultView.getComputedStyle(i).width);return e.width/o*100}(i,o)}update(t){this.proposedWidth=t.width,this.proposedHeight=t.height,this.proposedWidthPercents=t.widthPercents,this.proposedHandleHostWidth=t.handleHostWidth,this.proposedHandleHostHeight=t.handleHostHeight}}yi(gm,Ho);class mm{constructor(t){this._options=t,this._domResizerWrapper=null,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",t=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),t.stop())},{priority:"high"})}attach(){const t=this,e=this._options.viewElement;this._options.editor.editing.view.change(i=>{const o=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,o)=>{i.style.display=o?"":"none"}),i.style.display=t.isEnabled?"":"none",i}));i.insert(i.createPositionAt(e,"end"),o),i.addClass("ck-widget_with-resizer",e),this._viewResizerWrapper=o})}begin(t){this.state=new gm(this._options),this._sizeUI.bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(t,this._getHandleHost(),this._getResizeHost())}updateSize(t){const e=this._proposeNewSize(t);this._options.editor.editing.view.change(t=>{const i=this._options.unit||"%",o=("%"===i?e.widthPercents:e.width)+i;t.setStyle("width",o,this._options.viewElement)});const i=this._getHandleHost(),o=new Zr(i);e.handleHostWidth=Math.round(o.width),e.handleHostHeight=Math.round(o.height);const n=new Zr(i);e.width=Math.round(n.width),e.height=Math.round(n.height),this.redraw(o),this.state.update(e)}commit(){const t=this._options.unit||"%",e=("%"===t?this.state.proposedWidthPercents:this.state.proposedWidth)+t;this._options.editor.editing.view.change(()=>{this._cleanup(),this._options.onCommit(e)})}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(t){const e=this._domResizerWrapper;var i;(i=e)&&i.ownerDocument&&i.ownerDocument.contains(i)&&this._options.editor.editing.view.change(i=>{const o=e.parentElement,n=this._getHandleHost(),r=t||new Zr(n);i.setStyle("width",r.width+"px",this._viewResizerWrapper),i.setStyle("height",r.height+"px",this._viewResizerWrapper);const s=n.offsetLeft,a=n.offsetTop,l=n.offsetHeight,c=n.offsetWidth;o.isSameNode(n)||(i.setStyle("left",s+"px",this._viewResizerWrapper),i.setStyle("top",a+"px",this._viewResizerWrapper),i.setStyle("height",l+"px",this._viewResizerWrapper),i.setStyle("width",c+"px",this._viewResizerWrapper))})}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;this._options.editor.editing.view.change(t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)})}_proposeNewSize(t){const e=this.state,i={x:(o=t).pageX,y:o.pageY};var o;const n=!this._options.isCentered||this._options.isCentered(this),r={x:e._referenceCoordinates.x-(i.x+e.originalWidth),y:i.y-e.originalHeight-e._referenceCoordinates.y};n&&e.activeHandlePosition.endsWith("-right")&&(r.x=i.x-(e._referenceCoordinates.x+e.originalWidth)),n&&(r.x*=2);const s={width:Math.abs(e.originalWidth+r.x),height:Math.abs(e.originalHeight+r.y)};s.dominant=s.width/e.aspectRatio>s.height?"width":"height",s.max=s[s.dominant];const a={width:s.width,height:s.height};return"width"==s.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 o of e)t.appendChild(new Fl({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=o,"ck-widget__resizer__handle-"+i)}}).render());var i}_appendSizeUI(t){const e=new fm;e.render(),this._sizeUI=e,t.appendChild(e.element)}}yi(mm,Ho);class fm extends sc{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,o)=>"px"===t.unit?`${e}×${i}`:o+"%"),this.bind("activeHandlePosition").to(e)}dismiss(){this.unbind(),this.isVisible=!1}}var pm=function(t,e,i){var o=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return z(i)&&(o="leading"in i?!!i.leading:o,n="trailing"in i?!!i.trailing:n),Wr(t,e,{leading:o,maxWait:e,trailing:n})};i(80);class bm extends Wc{static get pluginName(){return"WidgetResize"}init(){this.set("_visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map;const t=Xn.window.document;this.editor.model.schema.setAttributeProperties("width",{isFormatting:!0}),this._observer=Object.create(lr),this._observer.listenTo(t,"mousedown",this._mouseDownListener.bind(this)),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this));const e=()=>{this._visibleResizer&&this._visibleResizer.redraw()},i=pm(e,200);this.on("change:_visibleResizer",e),this.editor.ui.on("update",i),this._observer.listenTo(Xn.window,"resize",i);const o=this.editor.editing.view.document.selection;o.on("change",()=>{const t=o.getSelectedElement();this._visibleResizer=this._getResizerByViewElement(t)||null})}destroy(){this._observer.stopListening();for(const t of this._resizers.values())t.destroy()}attachTo(t){const e=new mm(t),i=this.editor.plugins;if(e.attach(),i.has("WidgetToolbarRepository")){const t=i.get("WidgetToolbarRepository");e.on("begin",()=>{t.forceDisabled("resize")},{priority:"lowest"}),e.on("cancel",()=>{t.clearForceDisabled("resize")},{priority:"highest"}),e.on("commit",()=>{t.clearForceDisabled("resize")},{priority:"highest"})}return this._resizers.set(t.viewElement,e),e}_getResizerByHandle(t){for(const e of this._resizers.values())if(e.containsHandle(t))return e}_getResizerByViewElement(t){return this._resizers.get(t)}_mouseDownListener(t,e){if(!mm.isResizeHandle(e.target))return;const i=e.target;this._activeResizer=this._getResizerByHandle(i),this._activeResizer&&this._activeResizer.begin(i)}_mouseMoveListener(t,e){this._activeResizer&&this._activeResizer.updateSize(e)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}yi(bm,Ho);class wm extends qc{refresh(){const t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=jd(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(82);class km extends qc{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=jd(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,o=i.document.selection.getSelectedElement();i.change(t=>{this.styles[e].isDefault?t.removeAttribute("imageStyle",o):t.setAttribute("imageStyle",e,o)})}}function _m(t,e){for(const i of e)if(i.name===t)return i}var vm='',ym='',xm='',Am='';const Cm={full:{name:"full",title:"Full size image",icon:vm,isDefault:!0},side:{name:"side",title:"Side image",icon:Am,className:"image-style-side"},alignLeft:{name:"alignLeft",title:"Left aligned image",icon:ym,className:"image-style-align-left"},alignCenter:{name:"alignCenter",title:"Centered image",icon:xm,className:"image-style-align-center"},alignRight:{name:"alignRight",title:"Right aligned image",icon:Am,className:"image-style-align-right"}},Tm={full:vm,left:ym,right:Am,center:xm};function Sm(t=[]){return t.map(Pm)}function Pm(t){if("string"==typeof t){const e=t;Cm[e]?t=Object.assign({},Cm[e]):(console.warn(Object(ui.a)("image-style-not-found: There is no such image style of given name."),{name:e}),t={name:e})}else if(Cm[t.name]){const e=Cm[t.name],i=Object.assign({},t);for(const o in e)t.hasOwnProperty(o)||(i[o]=e[o]);t=i}return"string"==typeof t.icon&&Tm[t.icon]&&(t.icon=Tm[t.icon]),t}class Em extends Wc{static get pluginName(){return"ImageStyleEditing"}init(){const t=this.editor,e=t.model.schema,i=t.data,o=t.editing;t.config.define("image.styles",["full","side"]);const n=Sm(t.config.get("image.styles"));e.extend("image",{allowAttributes:"imageStyle"});const r=function(t){return(e,i,o)=>{if(!o.consumable.consume(i.item,e.name))return;const n=_m(i.attributeNewValue,t),r=_m(i.attributeOldValue,t),s=o.mapper.toViewElement(i.item),a=o.writer;r&&a.removeClass(r.className,s),n&&a.addClass(n.className,s)}}(n);o.downcastDispatcher.on("attribute:imageStyle:image",r),i.downcastDispatcher.on("attribute:imageStyle:image",r),i.upcastDispatcher.on("element:figure",function(t){const e=t.filter(t=>!t.isDefault);return(t,i,o)=>{if(!i.modelRange)return;const n=i.viewItem,r=$c(i.modelRange.getItems());if(o.schema.checkAttribute(r,"imageStyle"))for(const t of e)o.consumable.consume(n,{classes:t.className})&&o.writer.setAttribute("imageStyle",t.name,r)}}(n),{priority:"low"}),t.commands.add("imageStyle",new km(t,n))}}i(84);class Mm extends Wc{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}(Sm(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 o=e.commands.get("imageStyle"),n=new Tc(i);return n.set({label:t.title,icon:t.icon,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(o,"isEnabled"),n.bind("isOn").to(o,"value",e=>e===t.name),this.listenTo(n,"execute",()=>{e.execute("imageStyle",{value:t.name}),e.editing.view.focus()}),n})}}class Im extends Wc{static get requires(){return[tm]}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||!Nd(e))})(t.editing.view.document.selection)&&e.stop()},{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",()=>{this._updateToolbarsVisibility()}),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:o,balloonClassName:n="ck-toolbar-container"}){const r=this.editor,s=r.t,a=new zc(r.locale);if(a.ariaLabel=e||s("Widget toolbar"),this._toolbarDefinitions.has(t))throw new ui.b("widget-toolbar-duplicated: Toolbar with the given id was already added.",this,{toolbarId:t});a.fillFromConfig(i,r.ui.componentFactory),this._toolbarDefinitions.set(t,{view:a,getRelatedElement:o,balloonClassName:n})}_updateToolbarsVisibility(){let t=0,e=null,i=null;for(const o of this._toolbarDefinitions.values()){const n=o.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&n)if(this.editor.ui.focusTracker.isFocused){const r=n.getAncestors().length;r>t&&(t=r,e=n,i=o)}else this._isToolbarVisible(o)&&this._hideToolbar(o);else this._isToolbarInBalloon(o)&&this._hideToolbar(o)}i&&this._showToolbar(i,e)}_hideToolbar(t){this._balloon.remove(t.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){this._isToolbarVisible(t)?Nm(this.editor,e):this._isToolbarInBalloon(t)||(this._balloon.add({view:t.view,position:Rm(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);Nm(this.editor,e)}}))}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function Nm(t,e){const i=t.plugins.get("ContextualBalloon"),o=Rm(t,e);i.updatePosition(o)}function Rm(t,e){const i=t.editing.view,o=Pd.defaultPositions;return{target:i.domConverter.mapViewToDom(e),positions:[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,zd]}}class Om extends sc{constructor(t){super(t),this.buttonView=new Tc(t),this._fileInputView=new Vm(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 Vm extends sc{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 Lm='';function zm(t){const e=t.map(t=>t.replace("+","\\+"));return new RegExp(`^image\\/(${e.join("|")})$`)}class Dm extends Wc{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add("imageUpload",i=>{const o=new Om(i),n=t.commands.get("imageUpload"),r=t.config.get("image.upload.types"),s=zm(r);return o.set({acceptedType:r.map(t=>"image/"+t).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:e("Insert image"),icon:Lm,tooltip:!0}),o.buttonView.bind("isEnabled").to(n),o.on("done",(e,i)=>{const o=Array.from(i).filter(t=>s.test(t.type));o.length&&t.execute("imageUpload",{file:o})}),o})}}i(86),i(88),i(90);class Bm extends Wc{constructor(t){super(t),this.placeholder="data:image/svg+xml;utf8,"+encodeURIComponent('')}init(){this.editor.editing.downcastDispatcher.on("attribute:uploadStatus:image",(...t)=>this.uploadStatusChange(...t))}uploadStatusChange(t,e,i){const o=this.editor,n=e.item,r=n.getAttribute("uploadId");if(!i.consumable.consume(e.item,t.name))return;const s=o.plugins.get(Lu),a=r?e.attributeNewValue:null,l=this.placeholder,c=o.editing.mapper.toViewElement(n),d=i.writer;if("reading"==a)return jm(c,d),void Fm(l,c,d);if("uploading"==a){const t=s.loaders.get(r);return jm(c,d),void(t?(Hm(c,d),function(t,e,i,o){const n=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"),n),i.on("change:uploadedPercent",(t,e,i)=>{o.change(t=>{t.setStyle("width",i+"%",n)})})}(c,d,t,o.editing.view),function(t,e,i){if(i.data){const o=Wd(t);e.setAttribute("src",i.data,o)}}(c,d,t)):Fm(l,c,d))}"complete"==a&&s.loaders.get(r)&&function(t,e,i){const o=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(t,"end"),o),setTimeout(()=>{i.change(t=>t.remove(t.createRangeOn(o)))},3e3)}(c,d,o.editing.view),function(t,e){Um(t,e,"progressBar")}(c,d),Hm(c,d),function(t,e){e.removeClass("ck-appear",t)}(c,d)}}function jm(t,e){t.hasClass("ck-appear")||e.addClass("ck-appear",t)}function Fm(t,e,i){e.hasClass("ck-image-upload-placeholder")||i.addClass("ck-image-upload-placeholder",e);const o=Wd(e);o.getAttribute("src")!==t&&i.setAttribute("src",t,o),Wm(e,"placeholder")||i.insert(i.createPositionAfter(o),function(t){const e=t.createUIElement("div",{class:"ck-upload-placeholder-loader"});return t.setCustomProperty("placeholder",!0,e),e}(i))}function Hm(t,e){t.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",t),Um(t,e,"placeholder")}function Wm(t,e){for(const i of t.getChildren())if(i.getCustomProperty(e))return i}function Um(t,e,i){const o=Wm(t,i);o&&e.remove(e.createRangeOn(o))}class qm{constructor(t){this.document=t}createDocumentFragment(t){return new xn(this.document,t)}createElement(t,e,i){return new Ro(this.document,t,e,i)}createText(t){return new Ri(this.document,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 o=i.getChildIndex(t);return this.removeChildren(o,1,i),this.insertChild(o,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 Ro(this.document,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){y(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 Zo._createAt(t,e)}createPositionAfter(t){return Zo._createAfter(t)}createPositionBefore(t){return Zo._createBefore(t)}createRange(t,e){return new Xo(t,e)}createRangeOn(t){return Xo._createOn(t)}createRangeIn(t){return Xo._createIn(t)}createSelection(t,e,i){return new on(t,e,i)}}class Ym extends qc{refresh(){this.isEnabled=Hd(this.editor.model)}execute(t){const e=this.editor,i=e.model,o=e.plugins.get(Lu);i.change(e=>{const n=Array.isArray(t.file)?t.file:[t.file];for(const t of n)$m(e,i,o,t)})}}function $m(t,e,i,o){const n=i.createLoader(o);n&&Fd(t,e,{uploadId:n.id})}class Gm extends Wc{static get requires(){return[Lu,Mu,mh]}static get pluginName(){return"ImageUploadEditing"}constructor(t){super(t),t.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}})}init(){const t=this.editor,e=t.model.document,i=t.model.schema,o=t.conversion,n=t.plugins.get(Lu),r=zm(t.config.get("image.upload.types"));i.extend("image",{allowAttributes:["uploadId","uploadStatus"]}),t.commands.add("imageUpload",new Ym(t)),o.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(t.editing.view.document,"clipboardInput",(e,i)=>{if(o=i.dataTransfer,Array.from(o.types).includes("text/html")&&""!==o.getData("text/html"))return;var o;const n=Array.from(i.dataTransfer.files).filter(t=>!!t&&r.test(t.type)),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})}))})}),this.listenTo(t.plugins.get(mh),"inputTransformation",(e,i)=>{const o=Array.from(t.editing.view.createRangeIn(i.content)).filter(t=>{return!(!(e=t.item).is("element","img")||!e.getAttribute("src"))&&(e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||e.getAttribute("src").match(/^blob:/g))&&!t.item.getAttribute("uploadProcessed");var e}).map(t=>{return{promise:(e=t.item,new Promise((t,i)=>{const o=e.getAttribute("src");fetch(o).then(t=>t.blob()).then(e=>{const i=function(t,e){return t.type?t.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}(e,o),n=i.replace("image/",""),r=new File([e],"image."+n,{type:i});t(r)}).catch(i)})),imageElement:t.item};var e});if(!o.length)return;const r=new qm(t.editing.view.document);for(const t of o){r.setAttribute("uploadProcessed",!0,t.imageElement);const e=n.createLoader(t.promise);e&&(r.setAttribute("src","",t.imageElement),r.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,o="$graveyard"==e.position.root.rootName;for(const e of Km(t,i)){const t=e.getAttribute("uploadId");if(!t)continue;const i=n.loaders.get(t);i&&(o?i.abort():"idle"==i.status&&this._readAndUpload(i,e))}}})}_readAndUpload(t,e){const i=this.editor,o=i.model,n=i.locale.t,r=i.plugins.get(Lu),s=i.plugins.get(Mu);return o.enqueueChange("transparent",t=>{t.setAttribute("uploadStatus","reading",e)}),t.read().then(()=>{const n=t.upload();if(hn.isSafari){const t=Wd(i.editing.mapper.toViewElement(e));i.editing.view.once("render",()=>{if(!t.parent)return;const e=i.editing.view.domConverter.mapViewToDom(t.parent);if(!e)return;const o=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=o})}return o.enqueueChange("transparent",t=>{t.setAttribute("uploadStatus","uploading",e)}),n}).then(t=>{o.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&&s.showWarning(i,{title:n("Upload failed"),namespace:"upload"}),a(),o.enqueueChange("transparent",t=>{t.remove(e)})});function a(){o.enqueueChange("transparent",t=>{t.removeAttribute("uploadId",e),t.removeAttribute("uploadStatus",e)}),r.destroyLoader(t)}}_parseAndSetSrcsetAttributeOnImage(t,e,i){let o=0;const n=Object.keys(t).filter(t=>{const e=parseInt(t,10);if(!isNaN(e))return o=Math.max(o,e),!0}).map(e=>`${t[e]} ${e}w`).join(", ");""!=n&&i.setAttribute("srcset",{data:n,width:o},e)}}function Km(t,e){return Array.from(t.model.createRangeOn(e)).filter(t=>t.item.is("image")).map(t=>t.item)}class Qm extends Wc{static get pluginName(){return"ItalicEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"italic"}),t.model.schema.setAttributeProperties("italic",{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:"italic",view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),t.commands.add("italic",new pd(t,"italic")),t.keystrokes.set("CTRL+I","italic")}}class Jm extends Wc{init(){const t=this.editor,e=t.t;t.ui.componentFactory.add("italic",i=>{const o=t.commands.get("italic"),n=new Tc(i);return n.set({label:e("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),n.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(n,"execute",()=>{t.execute("italic"),t.editing.view.focus()}),n})}}class Zm extends Nr{constructor(t){super(t),this.domEventType="click"}onDomEvent(t){this.fire(t.type,t)}}i(92);class Xm extends sc{constructor(t,e){super(t);const i=t.t;this.focusTracker=new Nl,this.keystrokes=new Al,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),Qg,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),Jg,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e),this.children=this._createFormChildren(e.manualDecorators),this._focusables=new jl,this._focusCycler=new gc({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form"];e.manualDecorators.length&&o.push("ck-link-form_layout-vertical"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce((t,e)=>(t[e.name]=e.isOn,t),{})}render(){super.render(),Kg({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 qg(this.locale,$g);return e.label=t("Link URL"),e.fieldView.placeholder="https://example.com",e}_createButton(t,e,i,o){const n=new Tc(this.locale);return n.set({label:t,icon:e,tooltip:!0}),n.extendTemplate({attributes:{class:i}}),o&&n.delegate("execute").to(this,o),n}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const i of t.manualDecorators){const o=new Nc(this.locale);o.set({name:i.id,label:i.label,withText:!0}),o.bind("isOn").toMany([i,t],"value",(t,e)=>void 0===e&&void 0===t?i.defaultValue:t),o.on("execute",()=>{i.set("value",!o.isOn)}),e.add(o)}return e}_createFormChildren(t){const e=this.createCollection();if(e.add(this.urlInputView),t.length){const t=new sc;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}}i(94);class tf extends sc{constructor(t){super(t);const e=t.t;this.focusTracker=new Nl,this.keystrokes=new Al,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(e("Unlink"),'',"unlink"),this.editButtonView=this._createButton(e("Edit link"),'',"edit"),this.set("href"),this._focusables=new jl,this._focusCycler=new gc({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 o=new Tc(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.delegate("execute").to(this,i),o}_createPreviewButton(){const t=new Tc(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&&wu(t)),target:"_blank",rel:"noopener noreferrer"}}),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}}class ef extends Wc{static get requires(){return[tm]}static get pluginName(){return"LinkUI"}init(){const t=this.editor;t.editing.view.addObserver(Zm),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=t.plugins.get(tm),this._createToolbarLinkButton(),this._enableUserBalloonInteractions()}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const t=this.editor,e=new tf(t.locale),i=t.commands.get("link"),o=t.commands.get("unlink");return e.bind("href").to(i,"value"),e.editButtonView.bind("isEnabled").to(i),e.unlinkButtonView.bind("isEnabled").to(o),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("Ctrl+K",(t,e)=>{this._addFormView(),e()}),e}_createFormView(){const t=this.editor,e=t.commands.get("link"),i=new Xm(t.locale,e);return i.urlInputView.fieldView.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.fieldView.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("Ctrl+K",(t,e)=>{e(),this._showUI(!0)}),t.ui.componentFactory.add("link",t=>{const o=new Tc(t);return o.isEnabled=!0,o.label=i("Link"),o.icon='',o.keystroke="Ctrl+K",o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(e,"isEnabled"),o.bind("isOn").to(e,"value",t=>!!t),this.listenTo(o,"execute",()=>this._showUI(!0)),o})}_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())}),Rc({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.fieldView.select(),this.formView.urlInputView.fieldView.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._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(),o=r();const n=()=>{const t=this._getSelectedLinkElement(),e=r();i&&!t||!i&&e!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=t,o=e};function r(){return e.selection.focus.getAncestors().reverse().find(t=>t.is("element"))}this.listenTo(t.ui,"update",n),this.listenTo(this._balloon,"change:visibleView",n)}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 of(e.getFirstPosition());{const i=e.getFirstRange().getTrimmed(),o=of(i.start),n=of(i.end);return o&&o==n&&t.createRangeIn(o).getTrimmed().isEqual(i)?o:null}}}function of(t){return t.getAncestors().find(t=>{return(e=t).is("attributeElement")&&!!e.getCustomProperty("link");var e})}class nf extends qc{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=>sf(e,t.schema)),o=!0===this.value;t.change(t=>{if(o){let e=i[i.length-1].nextSibling,o=Number.POSITIVE_INFINITY,n=[];for(;e&&"listItem"==e.name&&0!==e.getAttribute("listIndent");){const t=e.getAttribute("listIndent");t=i;)r>n.getAttribute("listIndent")&&(r=n.getAttribute("listIndent")),n.getAttribute("listIndent")==r&&t[e?"unshift":"push"](n),n=n[e?"previousSibling":"nextSibling"]}}function sf(t,e){return e.checkChild(t.parent,"listItem")&&!e.isObject(t)}class af extends qc{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 o=e.nextSibling;for(;o&&"listItem"==o.name&&o.getAttribute("listIndent")>e.getAttribute("listIndent");)i.push(o),o=o.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=$c(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 o=t.previousSibling;for(;o&&o.is("listItem")&&o.getAttribute("listIndent")>=e;){if(o.getAttribute("listIndent")==e)return o.getAttribute("listType")==i;o=o.previousSibling}return!1}return!0}}function lf(t,e){const i=e.mapper,o=e.writer,n="numbered"==t.getAttribute("listType")?"ol":"ul",r=function(t){const e=t.createContainerElement("li");return e.getFillerOffset=mf,e}(o),s=o.createContainerElement(n,null);return o.insert(o.createPositionAt(s,0),r),i.bindElements(t,r),r}function cf(t,e,i,o){const n=e.parent,r=i.mapper,s=i.writer;let a=r.toViewPosition(o.createPositionBefore(t));const l=hf(t.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:t.getAttribute("listIndent")}),c=t.previousSibling;if(l&&l.getAttribute("listIndent")==t.getAttribute("listIndent")){const t=r.toViewElement(l);a=s.breakContainer(s.createPositionAfter(t))}else a=c&&"listItem"==c.name?r.toViewPosition(o.createPositionAt(c,"end")):r.toViewPosition(o.createPositionBefore(t));if(a=uf(a),s.insert(a,n),c&&"listItem"==c.name){const t=r.toViewElement(c),i=s.createRange(s.createPositionAt(t,0),a).getWalker({ignoreElementEnd:!0});for(const t of i)if(t.item.is("li")){const o=s.breakContainer(s.createPositionBefore(t.item)),n=t.item.parent,r=s.createPositionAt(e,"end");df(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(n),r),i.position=o}}else{const i=n.nextSibling;if(i&&(i.is("ul")||i.is("ol"))){let o=null;for(const e of i.getChildren()){const i=r.toModelElement(e);if(!(i&&i.getAttribute("listIndent")>t.getAttribute("listIndent")))break;o=e}o&&(s.breakContainer(s.createPositionAfter(o)),s.move(s.createRangeOn(o.parent),s.createPositionAt(e,"end")))}}df(s,n,n.nextSibling),df(s,n.previousSibling,n)}function df(t,e,i){return!e||!i||"ul"!=e.name&&"ol"!=e.name||e.name!=i.name||e.getAttribute("class")!==i.getAttribute("class")?null:t.mergeContainers(t.createPositionAfter(e))}function uf(t){return t.getLastMatchingPosition(t=>t.item.is("uiElement"))}function hf(t,e){const i=!!e.sameIndent,o=!!e.smallerIndent,n=e.listIndent;let r=t;for(;r&&"listItem"==r.name;){const t=r.getAttribute("listIndent");if(i&&n==t||o&&n>t)return r;r=r.previousSibling}return null}function gf(t,e,i,o){t.ui.componentFactory.add(e,n=>{const r=t.commands.get(e),s=new Tc(n);return s.set({label:i,icon:o,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",()=>{t.execute(e),t.editing.view.focus()}),s})}function mf(){const t=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||t?0:Lo.call(this)}function ff(t){return(e,i,o)=>{const n=o.consumable;if(!n.test(i.item,"insert")||!n.test(i.item,"attribute:listType")||!n.test(i.item,"attribute:listIndent"))return;n.consume(i.item,"insert"),n.consume(i.item,"attribute:listType"),n.consume(i.item,"attribute:listIndent");const r=i.item;cf(r,lf(r,o),o,t)}}function pf(t,e,i){if(!i.consumable.consume(e.item,"attribute:listType"))return;const o=i.mapper.toViewElement(e.item),n=i.writer;n.breakContainer(n.createPositionBefore(o)),n.breakContainer(n.createPositionAfter(o));const r=o.parent,s="numbered"==e.attributeNewValue?"ol":"ul";n.rename(s,r)}function bf(t,e,i){const o=i.mapper.toViewElement(e.item).parent,n=i.writer;df(n,o,o.nextSibling),df(n,o.previousSibling,o);for(const t of e.item.getChildren())i.consumable.consume(t,"insert")}function wf(t,e,i){if("listItem"!=e.item.name){let t=i.mapper.toViewPosition(e.range.start);const o=i.writer,n=[];for(;("ul"==t.parent.name||"ol"==t.parent.name)&&(t=o.breakContainer(t),"li"==t.parent.name);){const e=t,i=o.createPositionAt(t.parent,"end");if(!e.isEqual(i)){const t=o.remove(o.createRange(e,i));n.push(t)}t=o.createPositionAfter(t.parent)}if(n.length>0){for(let e=0;e0){const e=df(o,i,i.nextSibling);e&&e.parent==i&&t.offset--}}df(o,t.nodeBefore,t.nodeAfter)}}}function kf(t,e,i){const o=i.mapper.toViewPosition(e.position),n=o.nodeBefore,r=o.nodeAfter;df(i.writer,n,r)}function _f(t,e,i){if(i.consumable.consume(e.viewItem,{name:!0})){const t=i.writer,o=t.createElement("listItem"),n=function(t){let e=0,i=t.parent;for(;i;){if(i.is("li"))e++;else{const t=i.previousSibling;t&&t.is("li")&&e++}i=i.parent}return e}(e.viewItem);t.setAttribute("listIndent",n,o);const r=e.viewItem.parent&&"ol"==e.viewItem.parent.name?"numbered":"bulleted";t.setAttribute("listType",r,o);const s=i.splitToAllowedParent(o,e.modelCursor);if(!s)return;t.insert(o,s.position);const a=function(t,e,i){const{writer:o,schema:n}=i;let r=o.createPositionAfter(t);for(const s of e)if("ul"==s.name||"ol"==s.name)r=i.convertItem(s,r).modelCursor;else{const e=i.convertItem(s,o.createPositionAt(t,"end")),a=e.modelRange.start.nodeAfter;a&&a.is("element")&&!n.checkChild(t,a.name)&&(t=e.modelCursor.parent.is("listItem")?e.modelCursor.parent:Cf(e.modelCursor),r=o.createPositionAfter(t))}return r}(o,e.viewItem.getChildren(),i);e.modelRange=t.createRange(e.modelCursor,a),s.cursorParent?e.modelCursor=t.createPositionAt(s.cursorParent,0):e.modelCursor=e.modelRange.end}}function vf(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")||Sf(e))&&e._remove()}}}function yf(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,o=!0;for(const e of t)i&&!Sf(e)&&e._remove(),e.is("text")?(o&&(e._data=e.data.replace(/^\s+/,"")),e.nextSibling&&!Sf(e.nextSibling)||(e._data=e.data.replace(/\s+$/,""))):Sf(e)&&(i=!0),o=!1}}function xf(t){return(e,i)=>{if(i.isPhantom)return;const o=i.modelPosition.nodeBefore;if(o&&o.is("listItem")){const e=i.mapper.toViewElement(o),n=e.getAncestors().find(Sf),r=t.createPositionAt(e,0).getWalker();for(const t of r){if("elementStart"==t.type&&t.item.is("li")){i.viewPosition=t.previousPosition;break}if("elementEnd"==t.type&&t.item==n){i.viewPosition=t.nextPosition;break}}}}}function Af(t,[e,i]){let o,n=e.is("documentFragment")?e.getChild(0):e;if(o=i?this.createSelection(i):this.document.selection,n&&n.is("listItem")){const t=o.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(;n&&n.is("listItem");)n._setAttribute("listIndent",n.getAttribute("listIndent")+t),n=n.nextSibling}}}function Cf(t){const e=new bs({startPosition:t});let i;do{i=e.next()}while(!i.value.item.is("listItem"));return i.value.item}function Tf(t,e,i,o,n,r){const s=hf(e.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:t,foo:"b"}),a=n.mapper,l=n.writer,c=s?s.getAttribute("listIndent"):null;let d;if(s)if(c==t){const t=a.toViewElement(s).parent;d=l.createPositionAfter(t)}else{const t=r.createPositionAt(s,"end");d=a.toViewPosition(t)}else d=i;d=uf(d);for(const t of[...o.getChildren()])Sf(t)&&(d=l.move(l.createRangeOn(t),d).end,df(l,t,t.nextSibling),df(l,t.previousSibling,t))}function Sf(t){return t.is("ol")||t.is("ul")}class Pf extends Wc{static get pluginName(){return"ListEditing"}static get requires(){return[Cg]}init(){const t=this.editor;t.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const e=t.data,i=t.editing;var o;t.model.document.registerPostFixer(e=>function(t,e){const i=t.document.differ.getChanges(),o=new Map;let n=!1;for(const o of i)if("insert"==o.type&&"listItem"==o.name)r(o.position);else if("insert"==o.type&&"listItem"!=o.name){if("$text"!=o.name){const i=o.position.nodeAfter;i.hasAttribute("listIndent")&&(e.removeAttribute("listIndent",i),n=!0),i.hasAttribute("listType")&&(e.removeAttribute("listType",i),n=!0);for(const e of Array.from(t.createRangeIn(i)).filter(t=>t.item.is("listItem")))r(e.previousPosition)}r(o.position.getShiftedBy(o.length))}else"remove"==o.type&&"listItem"==o.name?r(o.position):("attribute"==o.type&&"listIndent"==o.attributeKey||"attribute"==o.type&&"listType"==o.attributeKey)&&r(o.range.start);for(const t of o.values())s(t),a(t);return n;function r(t){const e=t.nodeBefore;if(e&&e.is("listItem")){let t=e;if(o.has(t))return;for(let e=t.previousSibling;e&&e.is("listItem");e=t.previousSibling)if(t=e,o.has(t))return;o.set(e,t)}else{const e=t.nodeAfter;e&&e.is("listItem")&&o.set(e,e)}}function s(t){let i=0,o=null;for(;t&&t.is("listItem");){const r=t.getAttribute("listIndent");if(r>i){let s;null===o?(o=r-i,s=i):(o>r&&(o=r),s=r-o),e.setAttribute("listIndent",s,t),n=!0}else o=null,i=t.getAttribute("listIndent")+1;t=t.nextSibling}}function a(t){let i=[],o=null;for(;t&&t.is("listItem");){const r=t.getAttribute("listIndent");if(o&&o.getAttribute("listIndent")>r&&(i=i.slice(0,r+1)),0!=r)if(i[r]){const o=i[r];t.getAttribute("listType")!=o&&(e.setAttribute("listType",o,t),n=!0)}else i[r]=t.getAttribute("listType");o=t,t=t.nextSibling}}}(t.model,e)),i.mapper.registerViewToModelLength("li",Ef),e.mapper.registerViewToModelLength("li",Ef),i.mapper.on("modelToViewPosition",xf(i.view)),i.mapper.on("viewToModelPosition",(o=t.model,(t,e)=>{const i=e.viewPosition,n=i.parent,r=e.mapper;if("ul"==n.name||"ol"==n.name){if(i.isAtEnd){const t=r.toModelElement(i.nodeBefore),n=r.getModelLength(i.nodeBefore);e.modelPosition=o.createPositionBefore(t).getShiftedBy(n)}else{const t=r.toModelElement(i.nodeAfter);e.modelPosition=o.createPositionBefore(t)}t.stop()}else if("li"==n.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const s=r.toModelElement(n);let a=1,l=i.nodeBefore;for(;l&&Sf(l);)a+=r.getModelLength(l),l=l.previousSibling;e.modelPosition=o.createPositionBefore(s).getShiftedBy(a),t.stop()}})),e.mapper.on("modelToViewPosition",xf(i.view)),t.conversion.for("editingDowncast").add(e=>{e.on("insert",wf,{priority:"high"}),e.on("insert:listItem",ff(t.model)),e.on("attribute:listType:listItem",pf,{priority:"high"}),e.on("attribute:listType:listItem",bf,{priority:"low"}),e.on("attribute:listIndent:listItem",function(t){return(e,i,o)=>{if(!o.consumable.consume(i.item,"attribute:listIndent"))return;const n=o.mapper.toViewElement(i.item),r=o.writer;r.breakContainer(r.createPositionBefore(n)),r.breakContainer(r.createPositionAfter(n));const s=n.parent,a=s.previousSibling,l=r.createRangeOn(s);r.remove(l),a&&a.nextSibling&&df(r,a,a.nextSibling),Tf(i.attributeOldValue+1,i.range.start,l.start,n,o,t),cf(i.item,n,o,t);for(const t of i.item.getChildren())o.consumable.consume(t,"insert")}}(t.model)),e.on("remove:listItem",function(t){return(e,i,o)=>{const n=o.mapper.toViewPosition(i.position).getLastMatchingPosition(t=>!t.item.is("li")).nodeAfter,r=o.writer;r.breakContainer(r.createPositionBefore(n)),r.breakContainer(r.createPositionAfter(n));const s=n.parent,a=s.previousSibling,l=r.createRangeOn(s),c=r.remove(l);a&&a.nextSibling&&df(r,a,a.nextSibling);Tf(o.mapper.toModelElement(n).getAttribute("listIndent")+1,i.position,l.start,n,o,t);for(const t of r.createRangeIn(c).getItems())o.mapper.unbindViewElement(t);e.stop()}}(t.model)),e.on("remove",kf,{priority:"low"})}),t.conversion.for("dataDowncast").add(e=>{e.on("insert",wf,{priority:"high"}),e.on("insert:listItem",ff(t.model))}),t.conversion.for("upcast").add(t=>{t.on("element:ul",vf,{priority:"high"}),t.on("element:ol",vf,{priority:"high"}),t.on("element:li",yf,{priority:"high"}),t.on("element:li",_f)}),t.model.on("insertContent",Af,{priority:"high"}),t.commands.add("numberedList",new nf(t,"numbered")),t.commands.add("bulletedList",new nf(t,"bulleted")),t.commands.add("indentList",new af(t,"forward")),t.commands.add("outdentList",new af(t,"backward"));const n=i.view.document;this.listenTo(n,"enter",(t,e)=>{const i=this.editor.model.document,o=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==o.name&&o.isEmpty&&(this.editor.execute("outdentList"),e.preventDefault(),t.stop())}),this.listenTo(n,"delete",(t,e)=>{if("backward"!==e.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const o=i.getFirstPosition();if(!o.isAtStart)return;const n=o.parent;if("listItem"!==n.name)return;n.previousSibling&&"listItem"===n.previousSibling.name||(this.editor.execute("outdentList"),e.preventDefault(),t.stop())},{priority:"high"});const r=t=>(e,i)=>{this.editor.commands.get(t).isEnabled&&(this.editor.execute(t),i())};t.keystrokes.set("Tab",r("indentList")),t.keystrokes.set("Shift+Tab",r("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 Ef(t){let e=1;for(const i of t.getChildren())if("ul"==i.name||"ol"==i.name)for(const t of i.getChildren())e+=Ef(t);return e}class Mf extends Wc{init(){const t=this.editor.t;gf(this.editor,"numberedList",t("Numbered List"),''),gf(this.editor,"bulletedList",t("Bulleted List"),'')}}function If(t,e){return t=>{t.on("attribute:url:media",i)};function i(i,o,n){if(!n.consumable.consume(o.item,i.name))return;const r=o.attributeNewValue,s=n.writer,a=n.mapper.toViewElement(o.item),l=[...a.getChildren()].find(t=>t.getCustomProperty("media-content"));s.remove(l);const c=t.getMediaViewElement(s,r,e);s.insert(s.createPositionAt(a,0),c)}}function Nf(t,e,i,o){const n=t.createContainerElement("figure",{class:"media"});return n.getFillerOffset=Vf,t.insert(t.createPositionAt(n,0),e.getMediaViewElement(t,i,o)),n}function Rf(t){const e=t.getSelectedElement();return e&&e.is("media")?e:null}function Of(t,e,i){t.change(o=>{const n=o.createElement("media",{url:e});t.insertContent(n,i),o.setSelection(n,"on")})}function Vf(){return null}class Lf extends qc{refresh(){const t=this.editor.model,e=t.document.selection,i=t.schema,o=e.getFirstPosition(),n=Rf(e);let r=o.parent;r!=r.root&&(r=r.parent),this.value=n?n.getAttribute("url"):null,this.isEnabled=i.checkChild(r,"media")}execute(t){const e=this.editor.model,i=e.document.selection,o=Rf(i);if(o)e.change(e=>{e.setAttribute("url",t,o)});else{const o=Ld(i,e);Of(e,t,o)}}}class zf{constructor(t,e){const i=e.providers,o=e.extraProviders||[],n=new Set(e.removeProviders),r=i.concat(o).filter(t=>{const e=t.name;return e?!n.has(e):(console.warn(Object(ui.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=r}hasMedia(t){return!!this._getMedia(t)}getMediaViewElement(t,e,i){return this._getMedia(e).getViewElement(t,i)}_getMedia(t){if(!t)return new Df(this.locale);t=t.trim();for(const e of this.providerDefinitions){const i=e.html;let o=e.url;Array.isArray(o)||(o=[o]);for(const e of o){const o=this._getUrlMatches(t,e);if(o)return new Df(this.locale,t,o,i)}}return null}_getUrlMatches(t,e){let i=t.match(e);if(i)return i;let o=t.replace(/^https?:\/\//,"");return i=o.match(e),i||(o=o.replace(/^www\./,""),i=o.match(e),i||null)}}class Df{constructor(t,e,i,o){this.url=this._getValidUrl(e),this._t=t.t,this._match=i,this._previewRenderer=o}getViewElement(t,e){const i={};let o;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);o=t.createUIElement("div",i,(function(t){const e=this.toDomElement(t);return e.innerHTML=n,e}))}else this.url&&(i.url=this.url),o=t.createEmptyElement("oembed",i);return t.setCustomProperty("media-content",!0,o),o}_getPreviewHtml(t){return this._previewRenderer?this._previewRenderer(this._match):this.url&&t.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const t=new Cc,e=new Ac;t.text=this._t("Open media in new tab"),e.content='',e.viewBox="0 0 64 42";return new Fl({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(96);class Bf extends Wc{static get pluginName(){return"MediaEmbedEditing"}constructor(t){super(t),t.config.define("mediaEmbed",{providers:[{name:"dailymotion",url:/^dailymotion\.com\/video\/(\w+)/,html:t=>``},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:t=>``},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)/,/^youtube\.com\/embed\/([\w-]+)/,/^youtu\.be\/([\w-]+)/],html:t=>``},{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=>``},{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 zf(t.locale,t.config.get("mediaEmbed"))}init(){const t=this.editor,e=t.model.schema,i=t.t,o=t.conversion,n=t.config.get("mediaEmbed.previewsInData"),r=this.registry;t.commands.add("mediaEmbed",new Lf(t)),e.register("media",{isObject:!0,isBlock:!0,allowWhere:"$block",allowAttributes:["url"]}),o.for("dataDowncast").elementToElement({model:"media",view:(t,e)=>{const i=t.getAttribute("url");return Nf(e,r,i,{renderMediaPreview:i&&n})}}),o.for("dataDowncast").add(If(r,{renderMediaPreview:n})),o.for("editingDowncast").elementToElement({model:"media",view:(t,e)=>{const o=t.getAttribute("url"),n=Nf(e,r,o,{renderForEditingView:!0});return s=n,a=e,l=i("media widget"),a.setCustomProperty("media",!0,s),Rd(s,a,{label:l});var s,a,l}}),o.for("editingDowncast").add(If(r,{renderForEditingView:!0})),o.for("upcast").elementToElement({view:{name:"oembed",attributes:{url:!0}},model:(t,e)=>{const i=t.getAttribute("url");if(r.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(r.hasMedia(i))return e.createElement("media",{url:i})}})}}const jf=/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]+$/;class Ff extends Wc{static get requires(){return[mh,ig]}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(mh),"inputTransformation",()=>{const t=e.selection.getFirstRange(),i=al.fromPosition(t.start);i.stickiness="toPrevious";const o=al.fromPosition(t.end);o.stickiness="toNext",e.once("change:data",()=>{this._embedMediaBetweenPositions(i,o),i.detach(),o.detach()},{priority:"high"})}),t.commands.get("undo").on("execute",()=>{this._timeoutId&&(Xn.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)},{priority:"high"})}_embedMediaBetweenPositions(t,e){const i=this.editor,o=i.plugins.get(Bf).registry,n=new Os(t,e),r=n.getWalker({ignoreElementEnd:!0});let s="";for(const t of r)t.item.is("textProxy")&&(s+=t.item.data);if(s=s.trim(),!s.match(jf))return void n.detach();if(!o.hasMedia(s))return void n.detach();i.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=al.fromPosition(t),this._timeoutId=Xn.window.setTimeout(()=>{i.model.change(t=>{let e;this._timeoutId=null,t.remove(n),n.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(e=this._positionToInsert),Of(i.model,s,e),this._positionToInsert.detach(),this._positionToInsert=null})},100)):n.detach()}}i(98);class Hf extends sc{constructor(t,e){super(e);const i=e.t;this.focusTracker=new Nl,this.keystrokes=new Al,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),Qg,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),Jg,"ck-button-cancel","cancel"),this._focusables=new jl,this._focusCycler=new gc({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(),Kg({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.fieldView.element.value.trim()}set url(t){this.urlInputView.fieldView.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 qg(this.locale,$g),i=e.fieldView;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,o){const n=new Tc(this.locale);return n.set({label:t,icon:e,tooltip:!0}),n.extendTemplate({attributes:{class:i}}),o&&n.delegate("execute").to(this,o),n}}class Wf extends Wc{static get requires(){return[Bf]}static get pluginName(){return"MediaEmbedUI"}init(){const t=this.editor,e=t.commands.get("mediaEmbed"),i=t.plugins.get(Bf).registry;t.ui.componentFactory.add("mediaEmbed",o=>{const n=Oc(o),r=new Hf(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);return this._setUpDropdown(n,r,e,t),this._setUpForm(n,r,e),n})}_setUpDropdown(t,e,i){const o=this.editor,n=o.t,r=t.buttonView;function s(){o.editing.view.focus(),t.isOpen=!1}t.bind("isEnabled").to(i),t.panelView.children.add(e),r.set({label:n("Insert media"),icon:'\n',tooltip:!0}),r.on("open",()=>{e.url=i.value||"",e.urlInputView.fieldView.select(),e.focus()},{priority:"low"}),t.on("submit",()=>{e.isValid()&&(o.execute("mediaEmbed",e.url),s())}),t.on("change:isOpen",()=>e.resetFormStatus()),t.on("cancel",()=>s())}_setUpForm(t,e,i){e.delegate("submit","cancel").to(t),e.urlInputView.bind("value").to(i,"value"),e.urlInputView.bind("isReadOnly").to(i,"isEnabled",t=>!t),e.saveButtonView.bind("isEnabled").to(i)}}i(100);function Uf(t,e){if(!t.childCount)return;const i=new qm(t.document),o=function(t,e){const i=e.createRangeIn(t),o=new Li({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),n=[];for(const t of i)if("elementStart"===t.type&&o.match(t.item)){const e=Yf(t.item);n.push({element:t.item,id:e.id,order:e.order,indent:e.indent})}return n}(t,i);if(!o.length)return;let n=null,r=1;o.forEach((t,s)=>{const a=function(t,e){if(!t)return!0;if(t.id!==e.id)return!0;const i=e.element.previousSibling;if(!i)return!0;return o=i,!(o.is("ol")||o.is("ul"));var o}(o[s-1],t),l=a?null:o[s-1],c=(u=t,(d=l)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(n=null,r=1),!n||0!==c){const o=function(t,e){const i=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),o=/mso-level-number-format:([^;]*);/gi,n=i.exec(e);let r="decimal";if(n&&n[1]){const t=o.exec(n[1]);t&&t[1]&&(r=t[1].trim())}return{type:"bullet"!==r&&"image"!==r?"ol":"ul",style:r}}(t,e);if(n){if(t.indent>r){const t=n.getChild(n.childCount-1),e=t.getChild(t.childCount-1);n=qf(o,e,i),r+=1}else if(t.indent(\s+)<\/span>/g,(t,e)=>1===e.length?" ":Array(e.length+1).join(" ").substr(0,e.length))}function Qf(t,e){const i=new DOMParser,o=function(t){return Kf(Kf(t)).replace(/([\s]*?)[\r\n]+(\s*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>(\s*[\r\n]\s*)<")}(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}(t=t.replace(/
abc
\n\t\t\t//\n\t\t\tif ( isAttribute && this._wrapAttributeElement( wrapElement, child ) ) {\n\t\t\t\twrapPositions.push( new Position( parent, i ) );\n\t\t\t}\n\t\t\t//\n\t\t\t// Wrap the child if it is not an attribute element or if it is an attribute element that should be inside\n\t\t\t// `wrapElement` (due to priority).\n\t\t\t//\n\t\t\t//
abc
-->
abc
\n\t\t\t//
abc
-->
abc
\n\t\t\t//\n\t\t\telse if ( isText || isEmpty || isUI || ( isAttribute && shouldABeOutsideB( wrapElement, child ) ) ) {\n\t\t\t\t// Clone attribute.\n\t\t\t\tconst newAttribute = wrapElement._clone();\n\n\t\t\t\t// Wrap current node with new attribute.\n\t\t\t\tchild._remove();\n\t\t\t\tnewAttribute._appendChild( child );\n\n\t\t\t\tparent._insertChild( i, newAttribute );\n\t\t\t\tthis._addToClonedElementsGroup( newAttribute );\n\n\t\t\t\twrapPositions.push( new Position( parent, i ) );\n\t\t\t}\n\t\t\t//\n\t\t\t// If other nested attribute is found and it wasn't wrapped (see above), continue wrapping inside it.\n\t\t\t//\n\t\t\t//
\n\t\t\t//\n\t\t\telse if ( isAttribute ) {\n\t\t\t\tthis._wrapChildren( child, 0, child.childCount, wrapElement );\n\t\t\t}\n\n\t\t\ti++;\n\t\t}\n\n\t\t// Merge at each wrap.\n\t\tlet offsetChange = 0;\n\n\t\tfor ( const position of wrapPositions ) {\n\t\t\tposition.offset -= offsetChange;\n\n\t\t\t// Do not merge with elements outside selected children.\n\t\t\tif ( position.offset == startOffset ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst newPosition = this.mergeAttributes( position );\n\n\t\t\t// If nodes were merged - other merge offsets will change.\n\t\t\tif ( !newPosition.isEqual( position ) ) {\n\t\t\t\toffsetChange++;\n\t\t\t\tendOffset--;\n\t\t\t}\n\t\t}\n\n\t\treturn Range._createFromParentsAndOffsets( parent, startOffset, parent, endOffset );\n\t}\n\n\t/**\n\t * Unwraps children from provided `unwrapElement`. Only children contained in `parent` element between\n\t * `startOffset` and `endOffset` will be unwrapped.\n\t *\n\t * @private\n\t * @param {module:engine/view/element~Element} parent\n\t * @param {Number} startOffset\n\t * @param {Number} endOffset\n\t * @param {module:engine/view/element~Element} unwrapElement\n\t */\n\t_unwrapChildren( parent, startOffset, endOffset, unwrapElement ) {\n\t\tlet i = startOffset;\n\t\tconst unwrapPositions = [];\n\n\t\t// Iterate over each element between provided offsets inside parent.\n\t\t// We don't use tree walker or range iterator because we will be removing and merging potentially multiple nodes,\n\t\t// so it could get messy. It is safer to it manually in this case.\n\t\twhile ( i < endOffset ) {\n\t\t\tconst child = parent.getChild( i );\n\n\t\t\t// Skip all text nodes. There should be no container element's here either.\n\t\t\tif ( !child.is( 'attributeElement' ) ) {\n\t\t\t\ti++;\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t//\n\t\t\t// (In all examples, assume that `unwrapElement` is `` element.)\n\t\t\t//\n\t\t\t// If the child is similar to the given attribute element, unwrap it - it will be completely removed.\n\t\t\t//\n\t\t\t//
abcxyz
-->
abcxyz
\n\t\t\t//\n\t\t\tif ( child.isSimilar( unwrapElement ) ) {\n\t\t\t\tconst unwrapped = child.getChildren();\n\t\t\t\tconst count = child.childCount;\n\n\t\t\t\t// Replace wrapper element with its children\n\t\t\t\tchild._remove();\n\t\t\t\tparent._insertChild( i, unwrapped );\n\n\t\t\t\tthis._removeFromClonedElementsGroup( child );\n\n\t\t\t\t// Save start and end position of moved items.\n\t\t\t\tunwrapPositions.push(\n\t\t\t\t\tnew Position( parent, i ),\n\t\t\t\t\tnew Position( parent, i + count )\n\t\t\t\t);\n\n\t\t\t\t// Skip elements that were unwrapped. Assuming there won't be another element to unwrap in child elements.\n\t\t\t\ti += count;\n\t\t\t\tendOffset += count - 1;\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t//\n\t\t\t// If the child is not similar but is an attribute element, try partial unwrapping - remove the same attributes/styles/classes.\n\t\t\t// Partial unwrapping will happen only if the elements have the same name.\n\t\t\t//\n\t\t\t//
abcxyz
-->
abcxyz
\n\t\t\t//
abcxyz
-->
abcxyz
\n\t\t\t//\n\t\t\tif ( this._unwrapAttributeElement( unwrapElement, child ) ) {\n\t\t\t\tunwrapPositions.push(\n\t\t\t\t\tnew Position( parent, i ),\n\t\t\t\t\tnew Position( parent, i + 1 )\n\t\t\t\t);\n\n\t\t\t\ti++;\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t//\n\t\t\t// If other nested attribute is found, look through it's children for elements to unwrap.\n\t\t\t//\n\t\t\t//
abc
-->
abc
\n\t\t\t//\n\t\t\tthis._unwrapChildren( child, 0, child.childCount, unwrapElement );\n\n\t\t\ti++;\n\t\t}\n\n\t\t// Merge at each unwrap.\n\t\tlet offsetChange = 0;\n\n\t\tfor ( const position of unwrapPositions ) {\n\t\t\tposition.offset -= offsetChange;\n\n\t\t\t// Do not merge with elements outside selected children.\n\t\t\tif ( position.offset == startOffset || position.offset == endOffset ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst newPosition = this.mergeAttributes( position );\n\n\t\t\t// If nodes were merged - other merge offsets will change.\n\t\t\tif ( !newPosition.isEqual( position ) ) {\n\t\t\t\toffsetChange++;\n\t\t\t\tendOffset--;\n\t\t\t}\n\t\t}\n\n\t\treturn Range._createFromParentsAndOffsets( parent, startOffset, parent, endOffset );\n\t}\n\n\t/**\n\t * Helper function for `view.writer.wrap`. Wraps range with provided attribute element.\n\t * This method will also merge newly added attribute element with its siblings whenever possible.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not\n\t * an instance of {@link module:engine/view/attributeelement~AttributeElement AttributeElement}.\n\t *\n\t * @private\n\t * @param {module:engine/view/range~Range} range\n\t * @param {module:engine/view/attributeelement~AttributeElement} attribute\n\t * @returns {module:engine/view/range~Range} New range after wrapping, spanning over wrapping attribute element.\n\t */\n\t_wrapRange( range, attribute ) {\n\t\t// Break attributes at range start and end.\n\t\tconst { start: breakStart, end: breakEnd } = this._breakAttributesRange( range, true );\n\t\tconst parentContainer = breakStart.parent;\n\n\t\t// Wrap all children with attribute.\n\t\tconst newRange = this._wrapChildren( parentContainer, breakStart.offset, breakEnd.offset, attribute );\n\n\t\t// Merge attributes at the both ends and return a new range.\n\t\tconst start = this.mergeAttributes( newRange.start );\n\n\t\t// If start position was merged - move end position back.\n\t\tif ( !start.isEqual( newRange.start ) ) {\n\t\t\tnewRange.end.offset--;\n\t\t}\n\t\tconst end = this.mergeAttributes( newRange.end );\n\n\t\treturn new Range( start, end );\n\t}\n\n\t/**\n\t * Helper function for {@link #wrap}. Wraps position with provided attribute element.\n\t * This method will also merge newly added attribute element with its siblings whenever possible.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not\n\t * an instance of {@link module:engine/view/attributeelement~AttributeElement AttributeElement}.\n\t *\n\t * @private\n\t * @param {module:engine/view/position~Position} position\n\t * @param {module:engine/view/attributeelement~AttributeElement} attribute\n\t * @returns {module:engine/view/position~Position} New position after wrapping.\n\t */\n\t_wrapPosition( position, attribute ) {\n\t\t// Return same position when trying to wrap with attribute similar to position parent.\n\t\tif ( attribute.isSimilar( position.parent ) ) {\n\t\t\treturn movePositionToTextNode( position.clone() );\n\t\t}\n\n\t\t// When position is inside text node - break it and place new position between two text nodes.\n\t\tif ( position.parent.is( 'text' ) ) {\n\t\t\tposition = breakTextNode( position );\n\t\t}\n\n\t\t// Create fake element that will represent position, and will not be merged with other attributes.\n\t\tconst fakePosition = this.createAttributeElement();\n\t\tfakePosition._priority = Number.POSITIVE_INFINITY;\n\t\tfakePosition.isSimilar = () => false;\n\n\t\t// Insert fake element in position location.\n\t\tposition.parent._insertChild( position.offset, fakePosition );\n\n\t\t// Range around inserted fake attribute element.\n\t\tconst wrapRange = new Range( position, position.getShiftedBy( 1 ) );\n\n\t\t// Wrap fake element with attribute (it will also merge if possible).\n\t\tthis.wrap( wrapRange, attribute );\n\n\t\t// Remove fake element and place new position there.\n\t\tconst newPosition = new Position( fakePosition.parent, fakePosition.index );\n\t\tfakePosition._remove();\n\n\t\t// If position is placed between text nodes - merge them and return position inside.\n\t\tconst nodeBefore = newPosition.nodeBefore;\n\t\tconst nodeAfter = newPosition.nodeAfter;\n\n\t\tif ( nodeBefore instanceof Text && nodeAfter instanceof Text ) {\n\t\t\treturn mergeTextNodes( nodeBefore, nodeAfter );\n\t\t}\n\n\t\t// If position is next to text node - move position inside.\n\t\treturn movePositionToTextNode( newPosition );\n\t}\n\n\t/**\n\t * \tWraps one {@link module:engine/view/attributeelement~AttributeElement AttributeElement} into another by\n\t * \tmerging them if possible. When merging is possible - all attributes, styles and classes are moved from wrapper\n\t * \telement to element being wrapped.\n\t *\n\t * \t@private\n\t * \t@param {module:engine/view/attributeelement~AttributeElement} wrapper Wrapper AttributeElement.\n\t * \t@param {module:engine/view/attributeelement~AttributeElement} toWrap AttributeElement to wrap using wrapper element.\n\t * \t@returns {Boolean} Returns `true` if elements are merged.\n\t */\n\t_wrapAttributeElement( wrapper, toWrap ) {\n\t\tif ( !canBeJoined( wrapper, toWrap ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Can't merge if name or priority differs.\n\t\tif ( wrapper.name !== toWrap.name || wrapper.priority !== toWrap.priority ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check if attributes can be merged.\n\t\tfor ( const key of wrapper.getAttributeKeys() ) {\n\t\t\t// Classes and styles should be checked separately.\n\t\t\tif ( key === 'class' || key === 'style' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// If some attributes are different we cannot wrap.\n\t\t\tif ( toWrap.hasAttribute( key ) && toWrap.getAttribute( key ) !== wrapper.getAttribute( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// Check if styles can be merged.\n\t\tfor ( const key of wrapper.getStyleNames() ) {\n\t\t\tif ( toWrap.hasStyle( key ) && toWrap.getStyle( key ) !== wrapper.getStyle( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// Move all attributes/classes/styles from wrapper to wrapped AttributeElement.\n\t\tfor ( const key of wrapper.getAttributeKeys() ) {\n\t\t\t// Classes and styles should be checked separately.\n\t\t\tif ( key === 'class' || key === 'style' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Move only these attributes that are not present - other are similar.\n\t\t\tif ( !toWrap.hasAttribute( key ) ) {\n\t\t\t\tthis.setAttribute( key, wrapper.getAttribute( key ), toWrap );\n\t\t\t}\n\t\t}\n\n\t\tfor ( const key of wrapper.getStyleNames() ) {\n\t\t\tif ( !toWrap.hasStyle( key ) ) {\n\t\t\t\tthis.setStyle( key, wrapper.getStyle( key ), toWrap );\n\t\t\t}\n\t\t}\n\n\t\tfor ( const key of wrapper.getClassNames() ) {\n\t\t\tif ( !toWrap.hasClass( key ) ) {\n\t\t\t\tthis.addClass( key, toWrap );\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Unwraps {@link module:engine/view/attributeelement~AttributeElement AttributeElement} from another by removing\n\t * corresponding attributes, classes and styles. All attributes, classes and styles from wrapper should be present\n\t * inside element being unwrapped.\n\t *\n\t * @private\n\t * @param {module:engine/view/attributeelement~AttributeElement} wrapper Wrapper AttributeElement.\n\t * @param {module:engine/view/attributeelement~AttributeElement} toUnwrap AttributeElement to unwrap using wrapper element.\n\t * @returns {Boolean} Returns `true` if elements are unwrapped.\n\t **/\n\t_unwrapAttributeElement( wrapper, toUnwrap ) {\n\t\tif ( !canBeJoined( wrapper, toUnwrap ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Can't unwrap if name or priority differs.\n\t\tif ( wrapper.name !== toUnwrap.name || wrapper.priority !== toUnwrap.priority ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check if AttributeElement has all wrapper attributes.\n\t\tfor ( const key of wrapper.getAttributeKeys() ) {\n\t\t\t// Classes and styles should be checked separately.\n\t\t\tif ( key === 'class' || key === 'style' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// If some attributes are missing or different we cannot unwrap.\n\t\t\tif ( !toUnwrap.hasAttribute( key ) || toUnwrap.getAttribute( key ) !== wrapper.getAttribute( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// Check if AttributeElement has all wrapper classes.\n\t\tif ( !toUnwrap.hasClass( ...wrapper.getClassNames() ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check if AttributeElement has all wrapper styles.\n\t\tfor ( const key of wrapper.getStyleNames() ) {\n\t\t\t// If some styles are missing or different we cannot unwrap.\n\t\t\tif ( !toUnwrap.hasStyle( key ) || toUnwrap.getStyle( key ) !== wrapper.getStyle( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// Remove all wrapper's attributes from unwrapped element.\n\t\tfor ( const key of wrapper.getAttributeKeys() ) {\n\t\t\t// Classes and styles should be checked separately.\n\t\t\tif ( key === 'class' || key === 'style' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.removeAttribute( key, toUnwrap );\n\t\t}\n\n\t\t// Remove all wrapper's classes from unwrapped element.\n\t\tthis.removeClass( Array.from( wrapper.getClassNames() ), toUnwrap );\n\n\t\t// Remove all wrapper's styles from unwrapped element.\n\t\tthis.removeStyle( Array.from( wrapper.getStyleNames() ), toUnwrap );\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Helper function used by other `DowncastWriter` methods. Breaks attribute elements at the boundaries of given range.\n\t *\n\t * @private\n\t * @param {module:engine/view/range~Range} range Range which `start` and `end` positions will be used to break attributes.\n\t * @param {Boolean} [forceSplitText=false] If set to `true`, will break text nodes even if they are directly in container element.\n\t * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.\n\t * @returns {module:engine/view/range~Range} New range with located at break positions.\n\t */\n\t_breakAttributesRange( range, forceSplitText = false ) {\n\t\tconst rangeStart = range.start;\n\t\tconst rangeEnd = range.end;\n\n\t\tvalidateRangeContainer( range, this.document );\n\n\t\t// Break at the collapsed position. Return new collapsed range.\n\t\tif ( range.isCollapsed ) {\n\t\t\tconst position = this._breakAttributes( range.start, forceSplitText );\n\n\t\t\treturn new Range( position, position );\n\t\t}\n\n\t\tconst breakEnd = this._breakAttributes( rangeEnd, forceSplitText );\n\t\tconst count = breakEnd.parent.childCount;\n\t\tconst breakStart = this._breakAttributes( rangeStart, forceSplitText );\n\n\t\t// Calculate new break end offset.\n\t\tbreakEnd.offset += breakEnd.parent.childCount - count;\n\n\t\treturn new Range( breakStart, breakEnd );\n\t}\n\n\t/**\n\t * Helper function used by other `DowncastWriter` methods. Breaks attribute elements at given position.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-empty-element` when break position\n\t * is placed inside {@link module:engine/view/emptyelement~EmptyElement EmptyElement}.\n\t *\n\t * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-ui-element` when break position\n\t * is placed inside {@link module:engine/view/uielement~UIElement UIElement}.\n\t *\n\t * @private\n\t * @param {module:engine/view/position~Position} position Position where to break attributes.\n\t * @param {Boolean} [forceSplitText=false] If set to `true`, will break text nodes even if they are directly in container element.\n\t * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.\n\t * @returns {module:engine/view/position~Position} New position after breaking the attributes.\n\t */\n\t_breakAttributes( position, forceSplitText = false ) {\n\t\tconst positionOffset = position.offset;\n\t\tconst positionParent = position.parent;\n\n\t\t// If position is placed inside EmptyElement - throw an exception as we cannot break inside.\n\t\tif ( position.parent.is( 'emptyElement' ) ) {\n\t\t\t/**\n\t\t\t * Cannot break inside EmptyElement instance.\n\t\t\t *\n\t\t\t * @error view-writer-cannot-break-empty-element\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-writer-cannot-break-empty-element', this.document );\n\t\t}\n\n\t\t// If position is placed inside UIElement - throw an exception as we cannot break inside.\n\t\tif ( position.parent.is( 'uiElement' ) ) {\n\t\t\t/**\n\t\t\t * Cannot break inside UIElement instance.\n\t\t\t *\n\t\t\t * @error view-writer-cannot-break-ui-element\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-writer-cannot-break-ui-element', this.document );\n\t\t}\n\n\t\t// There are no attributes to break and text nodes breaking is not forced.\n\t\tif ( !forceSplitText && positionParent.is( 'text' ) && isContainerOrFragment( positionParent.parent ) ) {\n\t\t\treturn position.clone();\n\t\t}\n\n\t\t// Position's parent is container, so no attributes to break.\n\t\tif ( isContainerOrFragment( positionParent ) ) {\n\t\t\treturn position.clone();\n\t\t}\n\n\t\t// Break text and start again in new position.\n\t\tif ( positionParent.is( 'text' ) ) {\n\t\t\treturn this._breakAttributes( breakTextNode( position ), forceSplitText );\n\t\t}\n\n\t\tconst length = positionParent.childCount;\n\n\t\t//
\n\t\t\telse {\n\t\t\t\tconst offsetAfter = positionParent.index + 1;\n\n\t\t\t\t// Break element.\n\t\t\t\tconst clonedNode = positionParent._clone();\n\n\t\t\t\t// Insert cloned node to position's parent node.\n\t\t\t\tpositionParent.parent._insertChild( offsetAfter, clonedNode );\n\t\t\t\tthis._addToClonedElementsGroup( clonedNode );\n\n\t\t\t\t// Get nodes to move.\n\t\t\t\tconst count = positionParent.childCount - positionOffset;\n\t\t\t\tconst nodesToMove = positionParent._removeChildren( positionOffset, count );\n\n\t\t\t\t// Move nodes to cloned node.\n\t\t\t\tclonedNode._appendChild( nodesToMove );\n\n\t\t\t\t// Create new position to work on.\n\t\t\t\tconst newPosition = new Position( positionParent.parent, offsetAfter );\n\n\t\t\t\treturn this._breakAttributes( newPosition, forceSplitText );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Stores the information that an {@link module:engine/view/attributeelement~AttributeElement attribute element} was\n\t * added to the tree. Saves the reference to the group in the given element and updates the group, so other elements\n\t * from the group now keep a reference to the given attribute element.\n\t *\n\t * The clones group can be obtained using {@link module:engine/view/attributeelement~AttributeElement#getElementsWithSameId}.\n\t *\n\t * Does nothing if added element has no {@link module:engine/view/attributeelement~AttributeElement#id id}.\n\t *\n\t * @private\n\t * @param {module:engine/view/attributeelement~AttributeElement} element Attribute element to save.\n\t */\n\t_addToClonedElementsGroup( element ) {\n\t\t// Add only if the element is in document tree.\n\t\tif ( !element.root.is( 'rootElement' ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Traverse the element's children recursively to find other attribute elements that also might got inserted.\n\t\t// The loop is at the beginning so we can make fast returns later in the code.\n\t\tif ( element.is( 'element' ) ) {\n\t\t\tfor ( const child of element.getChildren() ) {\n\t\t\t\tthis._addToClonedElementsGroup( child );\n\t\t\t}\n\t\t}\n\n\t\tconst id = element.id;\n\n\t\tif ( !id ) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet group = this._cloneGroups.get( id );\n\n\t\tif ( !group ) {\n\t\t\tgroup = new Set();\n\t\t\tthis._cloneGroups.set( id, group );\n\t\t}\n\n\t\tgroup.add( element );\n\t\telement._clonesGroup = group;\n\t}\n\n\t/**\n\t * Removes all the information about the given {@link module:engine/view/attributeelement~AttributeElement attribute element}\n\t * from its clones group.\n\t *\n\t * Keep in mind, that the element will still keep a reference to the group (but the group will not keep a reference to it).\n\t * This allows to reference the whole group even if the element was already removed from the tree.\n\t *\n\t * Does nothing if the element has no {@link module:engine/view/attributeelement~AttributeElement#id id}.\n\t *\n\t * @private\n\t * @param {module:engine/view/attributeelement~AttributeElement} element Attribute element to remove.\n\t */\n\t_removeFromClonedElementsGroup( element ) {\n\t\t// Traverse the element's children recursively to find other attribute elements that also got removed.\n\t\t// The loop is at the beginning so we can make fast returns later in the code.\n\t\tif ( element.is( 'element' ) ) {\n\t\t\tfor ( const child of element.getChildren() ) {\n\t\t\t\tthis._removeFromClonedElementsGroup( child );\n\t\t\t}\n\t\t}\n\n\t\tconst id = element.id;\n\n\t\tif ( !id ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst group = this._cloneGroups.get( id );\n\n\t\tif ( !group ) {\n\t\t\treturn;\n\t\t}\n\n\t\tgroup.delete( element );\n\t\t// Not removing group from element on purpose!\n\t\t// If other parts of code have reference to this element, they will be able to get references to other elements from the group.\n\t}\n}\n\n// Helper function for `view.writer.wrap`. Checks if given element has any children that are not ui elements.\nfunction _hasNonUiChildren( parent ) {\n\treturn Array.from( parent.getChildren() ).some( child => !child.is( 'uiElement' ) );\n}\n\n/**\n * Attribute element need to be instance of attribute element.\n *\n * @error view-writer-wrap-invalid-attribute\n */\n\n// Returns first parent container of specified {@link module:engine/view/position~Position Position}.\n// Position's parent node is checked as first, then next parents are checked.\n// Note that {@link module:engine/view/documentfragment~DocumentFragment DocumentFragment} is treated like a container.\n//\n// @param {module:engine/view/position~Position} position Position used as a start point to locate parent container.\n// @returns {module:engine/view/containerelement~ContainerElement|module:engine/view/documentfragment~DocumentFragment|undefined}\n// Parent container element or `undefined` if container is not found.\nfunction getParentContainer( position ) {\n\tlet parent = position.parent;\n\n\twhile ( !isContainerOrFragment( parent ) ) {\n\t\tif ( !parent ) {\n\t\t\treturn undefined;\n\t\t}\n\t\tparent = parent.parent;\n\t}\n\n\treturn parent;\n}\n\n// Checks if first {@link module:engine/view/attributeelement~AttributeElement AttributeElement} provided to the function\n// can be wrapped otuside second element. It is done by comparing elements'\n// {@link module:engine/view/attributeelement~AttributeElement#priority priorities}, if both have same priority\n// {@link module:engine/view/element~Element#getIdentity identities} are compared.\n//\n// @param {module:engine/view/attributeelement~AttributeElement} a\n// @param {module:engine/view/attributeelement~AttributeElement} b\n// @returns {Boolean}\nfunction shouldABeOutsideB( a, b ) {\n\tif ( a.priority < b.priority ) {\n\t\treturn true;\n\t} else if ( a.priority > b.priority ) {\n\t\treturn false;\n\t}\n\n\t// When priorities are equal and names are different - use identities.\n\treturn a.getIdentity() < b.getIdentity();\n}\n\n// Returns new position that is moved to near text node. Returns same position if there is no text node before of after\n// specified position.\n//\n//\t\t
foo[]
->
foo{}
\n//\t\t
[]foo
->
{}foo
\n//\n// @param {module:engine/view/position~Position} position\n// @returns {module:engine/view/position~Position} Position located inside text node or same position if there is no text nodes\n// before or after position location.\nfunction movePositionToTextNode( position ) {\n\tconst nodeBefore = position.nodeBefore;\n\n\tif ( nodeBefore && nodeBefore.is( 'text' ) ) {\n\t\treturn new Position( nodeBefore, nodeBefore.data.length );\n\t}\n\n\tconst nodeAfter = position.nodeAfter;\n\n\tif ( nodeAfter && nodeAfter.is( 'text' ) ) {\n\t\treturn new Position( nodeAfter, 0 );\n\t}\n\n\treturn position;\n}\n\n// Breaks text node into two text nodes when possible.\n//\n//\t\t
foo{}bar
->
foo[]bar
\n//\t\t
{}foobar
->
[]foobar
\n//\t\t
foobar{}
->
foobar[]
\n//\n// @param {module:engine/view/position~Position} position Position that need to be placed inside text node.\n// @returns {module:engine/view/position~Position} New position after breaking text node.\nfunction breakTextNode( position ) {\n\tif ( position.offset == position.parent.data.length ) {\n\t\treturn new Position( position.parent.parent, position.parent.index + 1 );\n\t}\n\n\tif ( position.offset === 0 ) {\n\t\treturn new Position( position.parent.parent, position.parent.index );\n\t}\n\n\t// Get part of the text that need to be moved.\n\tconst textToMove = position.parent.data.slice( position.offset );\n\n\t// Leave rest of the text in position's parent.\n\tposition.parent._data = position.parent.data.slice( 0, position.offset );\n\n\t// Insert new text node after position's parent text node.\n\tposition.parent.parent._insertChild( position.parent.index + 1, new Text( position.root.document, textToMove ) );\n\n\t// Return new position between two newly created text nodes.\n\treturn new Position( position.parent.parent, position.parent.index + 1 );\n}\n\n// Merges two text nodes into first node. Removes second node and returns merge position.\n//\n// @param {module:engine/view/text~Text} t1 First text node to merge. Data from second text node will be moved at the end of\n// this text node.\n// @param {module:engine/view/text~Text} t2 Second text node to merge. This node will be removed after merging.\n// @returns {module:engine/view/position~Position} Position after merging text nodes.\nfunction mergeTextNodes( t1, t2 ) {\n\t// Merge text data into first text node and remove second one.\n\tconst nodeBeforeLength = t1.data.length;\n\tt1._data += t2.data;\n\tt2._remove();\n\n\treturn new Position( t1, nodeBeforeLength );\n}\n\n// Checks if provided nodes are valid to insert. Checks if each node is an instance of\n// {@link module:engine/view/text~Text Text} or {@link module:engine/view/attributeelement~AttributeElement AttributeElement},\n// {@link module:engine/view/containerelement~ContainerElement ContainerElement},\n// {@link module:engine/view/emptyelement~EmptyElement EmptyElement} or\n// {@link module:engine/view/uielement~UIElement UIElement}.\n//\n// Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-insert-invalid-node` when nodes to insert\n// contains instances that are not {@link module:engine/view/text~Text Texts},\n// {@link module:engine/view/emptyelement~EmptyElement EmptyElements},\n// {@link module:engine/view/uielement~UIElement UIElements},\n// {@link module:engine/view/attributeelement~AttributeElement AttributeElements} or\n// {@link module:engine/view/containerelement~ContainerElement ContainerElements}.\n//\n// @param Iterable. nodes\n// @param {Object} errorContext\nfunction validateNodesToInsert( nodes, errorContext ) {\n\tfor ( const node of nodes ) {\n\t\tif ( !validNodesToInsert.some( ( validNode => node instanceof validNode ) ) ) { // eslint-disable-line no-use-before-define\n\t\t\t/**\n\t\t\t * Inserted nodes should be valid to insert. of {@link module:engine/view/attributeelement~AttributeElement AttributeElement},\n\t\t\t * {@link module:engine/view/containerelement~ContainerElement ContainerElement},\n\t\t\t * {@link module:engine/view/emptyelement~EmptyElement EmptyElement},\n\t\t\t * {@link module:engine/view/uielement~UIElement UIElement}, {@link module:engine/view/text~Text Text}.\n\t\t\t *\n\t\t\t * @error view-writer-insert-invalid-node\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-writer-insert-invalid-node', errorContext );\n\t\t}\n\n\t\tif ( !node.is( 'text' ) ) {\n\t\t\tvalidateNodesToInsert( node.getChildren(), errorContext );\n\t\t}\n\t}\n}\n\nconst validNodesToInsert = [ Text, AttributeElement, ContainerElement, EmptyElement, UIElement ];\n\n// Checks if node is ContainerElement or DocumentFragment, because in most cases they should be treated the same way.\n//\n// @param {module:engine/view/node~Node} node\n// @returns {Boolean} Returns `true` if node is instance of ContainerElement or DocumentFragment.\nfunction isContainerOrFragment( node ) {\n\treturn node && ( node.is( 'containerElement' ) || node.is( 'documentFragment' ) );\n}\n\n// Checks if {@link module:engine/view/range~Range#start range start} and {@link module:engine/view/range~Range#end range end} are placed\n// inside same {@link module:engine/view/containerelement~ContainerElement container element}.\n// Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-invalid-range-container` when validation fails.\n//\n// @param {module:engine/view/range~Range} range\n// @param {Object} errorContext\nfunction validateRangeContainer( range, errorContext ) {\n\tconst startContainer = getParentContainer( range.start );\n\tconst endContainer = getParentContainer( range.end );\n\n\tif ( !startContainer || !endContainer || startContainer !== endContainer ) {\n\t\t/**\n\t\t * Range container is invalid. This can happen if {@link module:engine/view/range~Range#start range start} and\n\t\t * {@link module:engine/view/range~Range#end range end} positions are not placed inside same container or\n\t\t * parent container for these positions cannot be found.\n\t\t *\n\t\t * @error view-writer-invalid-range-container\n\t\t */\n\n\t\tthrow new CKEditorError( 'view-writer-invalid-range-container', errorContext );\n\t}\n}\n\n// Checks if two attribute elements can be joined together. Elements can be joined together if, and only if\n// they do not have ids specified.\n//\n// @private\n// @param {module:engine/view/element~Element} a\n// @param {module:engine/view/element~Element} b\n// @returns {Boolean}\nfunction canBeJoined( a, b ) {\n\treturn a.id === null && b.id === null;\n}\n","/**\n * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module utils/dom/istext\n */\n\n/**\n * Checks if the object is a native DOM Text node.\n *\n * @param {*} obj\n * @returns {Boolean}\n */\nexport default function isText( obj ) {\n\treturn Object.prototype.toString.call( obj ) == '[object Text]';\n}\n","/**\n * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\nimport { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';\nimport isText from '@ckeditor/ckeditor5-utils/src/dom/istext';\n\n/**\n * Set of utils related to block and inline fillers handling.\n *\n * Browsers do not allow to put caret in elements which does not have height. Because of it, we need to fill all\n * empty elements which should be selectable with elements or characters called \"fillers\". Unfortunately there is no one\n * universal filler, this is why two types are uses:\n *\n * * Block filler is an element which fill block elements, like `
`. CKEditor uses ` ` as a block filler during the editing,\n * as browsers do natively. So instead of an empty `
` there will be `
`. The advantage of block filler is that\n * it is transparent for the selection, so when the caret is before the ` ` and user presses right arrow he will be\n * moved to the next paragraph, not after the ` `. The disadvantage is that it breaks a block, so it can not be used\n * in the middle of a line of text. The {@link module:engine/view/filler~BR_FILLER ` ` filler} can be replaced with any other\n * character in the data output, for instance {@link module:engine/view/filler~NBSP_FILLER non-breaking space}.\n *\n * * Inline filler is a filler which does not break a line of text, so it can be used inside the text, for instance in the empty\n * `` surrendered by text: `foobar`, if we want to put the caret there. CKEditor uses a sequence of the zero-width\n * spaces as an {@link module:engine/view/filler~INLINE_FILLER inline filler} having the predetermined\n * {@link module:engine/view/filler~INLINE_FILLER_LENGTH length}. A sequence is used, instead of a single character to\n * avoid treating random zero-width spaces as the inline filler. Disadvantage of the inline filler is that it is not\n * transparent for the selection. The arrow key moves the caret between zero-width spaces characters, so the additional\n * code is needed to handle the caret.\n *\n * Both inline and block fillers are handled by the {@link module:engine/view/renderer~Renderer renderer} and are not present in the\n * view.\n *\n * @module engine/view/filler\n */\n\n/**\n * Non-breaking space filler creator. This is a function which creates ` ` text node.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~BR_FILLER\n * @function\n */\nexport const NBSP_FILLER = domDocument => domDocument.createTextNode( '\\u00A0' );\n\n/**\n * ` ` filler creator. This is a function which creates ` ` element.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~NBSP_FILLER\n * @function\n */\nexport const BR_FILLER = domDocument => {\n\tconst fillerBr = domDocument.createElement( 'br' );\n\tfillerBr.dataset.ckeFiller = true;\n\n\treturn fillerBr;\n};\n\n/**\n * Length of the {@link module:engine/view/filler~INLINE_FILLER INLINE_FILLER}.\n */\nexport const INLINE_FILLER_LENGTH = 7;\n\n/**\n * Inline filler which is a sequence of the zero width spaces.\n */\nexport const INLINE_FILLER = ( () => {\n\tlet inlineFiller = '';\n\n\tfor ( let i = 0; i < INLINE_FILLER_LENGTH; i++ ) {\n\t\tinlineFiller += '\\u200b';\n\t}\n\n\treturn inlineFiller;\n} )(); // Usu IIF so the INLINE_FILLER appears as a constant in the docs.\n\n/**\n * Checks if the node is a text node which starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n *\n *\t\tstartsWithFiller( document.createTextNode( INLINE_FILLER ) ); // true\n *\t\tstartsWithFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // true\n *\t\tstartsWithFiller( document.createTextNode( 'foo' ) ); // false\n *\t\tstartsWithFiller( document.createElement( 'p' ) ); // false\n *\n * @param {Node} domNode DOM node.\n * @returns {Boolean} True if the text node starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n */\nexport function startsWithFiller( domNode ) {\n\treturn isText( domNode ) && ( domNode.data.substr( 0, INLINE_FILLER_LENGTH ) === INLINE_FILLER );\n}\n\n/**\n * Checks if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n *\n *\t\tisInlineFiller( document.createTextNode( INLINE_FILLER ) ); // true\n *\t\tisInlineFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // false\n *\n * @param {Text} domText DOM text node.\n * @returns {Boolean} True if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n */\nexport function isInlineFiller( domText ) {\n\treturn domText.data.length == INLINE_FILLER_LENGTH && startsWithFiller( domText );\n}\n\n/**\n * Get string data from the text node, removing an {@link module:engine/view/filler~INLINE_FILLER inline filler} from it,\n * if text node contains it.\n *\n *\t\tgetDataWithoutFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ) == 'foo' // true\n *\t\tgetDataWithoutFiller( document.createTextNode( 'foo' ) ) == 'foo' // true\n *\n * @param {Text} domText DOM text node, possible with inline filler.\n * @returns {String} Data without filler.\n */\nexport function getDataWithoutFiller( domText ) {\n\tif ( startsWithFiller( domText ) ) {\n\t\treturn domText.data.slice( INLINE_FILLER_LENGTH );\n\t} else {\n\t\treturn domText.data;\n\t}\n}\n\n/**\n * Assign key observer which move cursor from the end of the inline filler to the beginning of it when\n * the left arrow is pressed, so the filler does not break navigation.\n *\n * @param {module:engine/view/view~View} view View controller instance we should inject quirks handling on.\n */\nexport function injectQuirksHandling( view ) {\n\tview.document.on( 'keydown', jumpOverInlineFiller );\n}\n\n// Move cursor from the end of the inline filler to the beginning of it when, so the filler does not break navigation.\nfunction jumpOverInlineFiller( evt, data ) {\n\tif ( data.keyCode == keyCodes.arrowleft ) {\n\t\tconst domSelection = data.domTarget.ownerDocument.defaultView.getSelection();\n\n\t\tif ( domSelection.rangeCount == 1 && domSelection.getRangeAt( 0 ).collapsed ) {\n\t\t\tconst domParent = domSelection.getRangeAt( 0 ).startContainer;\n\t\t\tconst domOffset = domSelection.getRangeAt( 0 ).startOffset;\n\n\t\t\tif ( startsWithFiller( domParent ) && domOffset <= INLINE_FILLER_LENGTH ) {\n\t\t\t\tdomSelection.collapse( domParent, 0 );\n\t\t\t}\n\t\t}\n\t}\n}\n","/**\n * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module utils/fastdiff\n */\n\n/**\n * Finds positions of the first and last change in the given string/array and generates a set of changes:\n *\n *\t\tfastDiff( '12a', '12xyza' );\n *\t\t// [ { index: 2, type: 'insert', values: [ 'x', 'y', 'z' ] } ]\n *\n *\t\tfastDiff( '12a', '12aa' );\n *\t\t// [ { index: 3, type: 'insert', values: [ 'a' ] } ]\n *\n *\t\tfastDiff( '12xyza', '12a' );\n *\t\t// [ { index: 2, type: 'delete', howMany: 3 } ]\n *\n *\t\tfastDiff( [ '1', '2', 'a', 'a' ], [ '1', '2', 'a' ] );\n *\t\t// [ { index: 3, type: 'delete', howMany: 1 } ]\n *\n *\t\tfastDiff( [ '1', '2', 'a', 'b', 'c', '3' ], [ '2', 'a', 'b' ] );\n *\t\t// [ { index: 0, type: 'insert', values: [ '2', 'a', 'b' ] }, { index: 3, type: 'delete', howMany: 6 } ]\n *\n * Passed arrays can contain any type of data, however to compare them correctly custom comparator function\n * should be passed as a third parameter:\n *\n *\t\tfastDiff( [ { value: 1 }, { value: 2 } ], [ { value: 1 }, { value: 3 } ], ( a, b ) => {\n *\t\t\treturn a.value === b.value;\n *\t\t} );\n *\t\t// [ { index: 1, type: 'insert', values: [ { value: 3 } ] }, { index: 2, type: 'delete', howMany: 1 } ]\n *\n * The resulted set of changes can be applied to the input in order to transform it into the output, for example:\n *\n *\t\tlet input = '12abc3';\n *\t\tconst output = '2ab';\n *\t\tconst changes = fastDiff( input, output );\n *\n *\t\tchanges.forEach( change => {\n *\t\t\tif ( change.type == 'insert' ) {\n *\t\t\t\tinput = input.substring( 0, change.index ) + change.values.join( '' ) + input.substring( change.index );\n *\t\t\t} else if ( change.type == 'delete' ) {\n *\t\t\t\tinput = input.substring( 0, change.index ) + input.substring( change.index + change.howMany );\n *\t\t\t}\n *\t\t} );\n *\n *\t\t// input equals output now\n *\n * or in case of arrays:\n *\n *\t\tlet input = [ '1', '2', 'a', 'b', 'c', '3' ];\n *\t\tconst output = [ '2', 'a', 'b' ];\n *\t\tconst changes = fastDiff( input, output );\n *\n *\t\tchanges.forEach( change => {\n *\t\t\tif ( change.type == 'insert' ) {\n *\t\t\t\tinput = input.slice( 0, change.index ).concat( change.values, input.slice( change.index ) );\n *\t\t\t} else if ( change.type == 'delete' ) {\n *\t\t\t\tinput = input.slice( 0, change.index ).concat( input.slice( change.index + change.howMany ) );\n *\t\t\t}\n *\t\t} );\n *\n *\t\t// input equals output now\n *\n * By passing `true` as the fourth parameter (`atomicChanges`) the output of this function will become compatible with\n * the {@link module:utils/diff~diff `diff()`} function:\n *\n *\t\tfastDiff( '12a', '12xyza' );\n *\t\t// [ 'equal', 'equal', 'insert', 'insert', 'insert', 'equal' ]\n *\n * The default output format of this function is compatible with the output format of\n * {@link module:utils/difftochanges~diffToChanges `diffToChanges()`}. The `diffToChanges()` input format is, in turn,\n * compatible with the output of {@link module:utils/diff~diff `diff()`}:\n *\n *\t\tconst a = '1234';\n *\t\tconst b = '12xyz34';\n *\n *\t\t// Both calls will return the same results (grouped changes format).\n *\t\tfastDiff( a, b );\n *\t\tdiffToChanges( diff( a, b ) );\n *\n *\t\t// Again, both calls will return the same results (atomic changes format).\n *\t\tfastDiff( a, b, null, true );\n *\t\tdiff( a, b );\n *\n *\n * @param {Array|String} a Input array or string.\n * @param {Array|String} b Input array or string.\n * @param {Function} [cmp] Optional function used to compare array values, by default `===` (strict equal operator) is used.\n * @param {Boolean} [atomicChanges=false] Whether an array of `inset|delete|equal` operations should\n * be returned instead of changes set. This makes this function compatible with {@link module:utils/diff~diff `diff()`}.\n * @returns {Array} Array of changes.\n */\nexport default function fastDiff( a, b, cmp, atomicChanges = false ) {\n\t// Set the comparator function.\n\tcmp = cmp || function( a, b ) {\n\t\treturn a === b;\n\t};\n\n\t// Convert the string (or any array-like object - eg. NodeList) to an array by using the slice() method because,\n\t// unlike Array.from(), it returns array of UTF-16 code units instead of the code points of a string.\n\t// One code point might be a surrogate pair of two code units. All text offsets are expected to be in code units.\n\t// See ckeditor/ckeditor5#3147.\n\t//\n\t// We need to make sure here that fastDiff() works identical to diff().\n\tif ( !Array.isArray( a ) ) {\n\t\ta = Array.prototype.slice.call( a );\n\t}\n\n\tif ( !Array.isArray( b ) ) {\n\t\tb = Array.prototype.slice.call( b );\n\t}\n\n\t// Find first and last change.\n\tconst changeIndexes = findChangeBoundaryIndexes( a, b, cmp );\n\n\t// Transform into changes array.\n\treturn atomicChanges ? changeIndexesToAtomicChanges( changeIndexes, b.length ) : changeIndexesToChanges( b, changeIndexes );\n}\n\n// Finds position of the first and last change in the given arrays. For example:\n//\n//\t\tconst indexes = findChangeBoundaryIndexes( [ '1', '2', '3', '4' ], [ '1', '3', '4', '2', '4' ] );\n//\t\tconsole.log( indexes ); // { firstIndex: 1, lastIndexOld: 3, lastIndexNew: 4 }\n//\n// The above indexes means that in the first array the modified part is `1[23]4` and in the second array it is `1[342]4`.\n// Based on such indexes, array with `insert`/`delete` operations which allows transforming first value into the second one\n// can be generated.\n//\n// @param {Array} arr1\n// @param {Array} arr2\n// @param {Function} cmp Comparator function.\n// @returns {Object}\n// @returns {Number} return.firstIndex Index of the first change in both values (always the same for both).\n// @returns {Number} result.lastIndexOld Index of the last common value in `arr1`.\n// @returns {Number} result.lastIndexNew Index of the last common value in `arr2`.\nfunction findChangeBoundaryIndexes( arr1, arr2, cmp ) {\n\t// Find the first difference between passed values.\n\tconst firstIndex = findFirstDifferenceIndex( arr1, arr2, cmp );\n\n\t// If arrays are equal return -1 indexes object.\n\tif ( firstIndex === -1 ) {\n\t\treturn { firstIndex: -1, lastIndexOld: -1, lastIndexNew: -1 };\n\t}\n\n\t// Remove the common part of each value and reverse them to make it simpler to find the last difference between them.\n\tconst oldArrayReversed = cutAndReverse( arr1, firstIndex );\n\tconst newArrayReversed = cutAndReverse( arr2, firstIndex );\n\n\t// Find the first difference between reversed values.\n\t// It should be treated as \"how many elements from the end the last difference occurred\".\n\t//\n\t// For example:\n\t//\n\t// \t\t\t\tinitial\t->\tafter cut\t-> reversed:\n\t// oldValue:\t'321ba'\t->\t'21ba'\t\t-> 'ab12'\n\t// newValue:\t'31xba'\t->\t'1xba'\t\t-> 'abx1'\n\t// lastIndex:\t\t\t\t\t\t\t-> 2\n\t//\n\t// So the last change occurred two characters from the end of the arrays.\n\tconst lastIndex = findFirstDifferenceIndex( oldArrayReversed, newArrayReversed, cmp );\n\n\t// Use `lastIndex` to calculate proper offset, starting from the beginning (`lastIndex` kind of starts from the end).\n\tconst lastIndexOld = arr1.length - lastIndex;\n\tconst lastIndexNew = arr2.length - lastIndex;\n\n\treturn { firstIndex, lastIndexOld, lastIndexNew };\n}\n\n// Returns a first index on which given arrays differ. If both arrays are the same, -1 is returned.\n//\n// @param {Array} arr1\n// @param {Array} arr2\n// @param {Function} cmp Comparator function.\n// @returns {Number}\nfunction findFirstDifferenceIndex( arr1, arr2, cmp ) {\n\tfor ( let i = 0; i < Math.max( arr1.length, arr2.length ); i++ ) {\n\t\tif ( arr1[ i ] === undefined || arr2[ i ] === undefined || !cmp( arr1[ i ], arr2[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\treturn -1; // Return -1 if arrays are equal.\n}\n\n// Returns a copy of the given array with `howMany` elements removed starting from the beginning and in reversed order.\n//\n// @param {Array} arr Array to be processed.\n// @param {Number} howMany How many elements from array beginning to remove.\n// @returns {Array} Shortened and reversed array.\nfunction cutAndReverse( arr, howMany ) {\n\treturn arr.slice( howMany ).reverse();\n}\n\n// Generates changes array based on change indexes from `findChangeBoundaryIndexes` function. This function will\n// generate array with 0 (no changes), 1 (deletion or insertion) or 2 records (insertion and deletion).\n//\n// @param {Array} newArray New array for which change indexes were calculated.\n// @param {Object} changeIndexes Change indexes object from `findChangeBoundaryIndexes` function.\n// @returns {Array.